efront 3.33.3 → 3.34.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/apps/kugou/icons/kugo.ico +0 -0
  2. package/apps/kugou/icons/kuwo.png +0 -0
  3. package/apps/kugou/icons/qqjt.ico +0 -0
  4. package/apps/kugou/icons/yyyy.ico +0 -0
  5. package/apps/kugou/index.html +2 -1
  6. package/apps/kugou/main.js +4 -0
  7. package/apps/kugou/search/search.html +3 -4
  8. package/apps/kugou/search/search.js +55 -5
  9. package/apps/kugou/search/search.less +3 -0
  10. package/coms/basic/cross_.js +13 -1
  11. package/coms/basic/parseURL.js +2 -2
  12. package/coms/basic/parseURL_test.js +1 -0
  13. package/coms/basic/seek.js +42 -4
  14. package/coms/kugou/api.js +30 -2
  15. package/coms/kugou/buildList.html +1 -1
  16. package/coms/kugou/buildList.js +2 -2
  17. package/coms/kugou/buildScroll.js +1 -1
  18. package/coms/kugou/getSandbox.js +1 -1
  19. package/coms/kugou/krc.js +80 -34
  20. package/coms/kugou/musicList.js +37 -2
  21. package/coms/kugou/page.js +6 -6
  22. package/coms/kugou/playList.html +1 -1
  23. package/coms/kugou/playList.js +0 -1
  24. package/coms/kugou/playList.less +9 -2
  25. package/coms/kugou/player.html +3 -3
  26. package/coms/kugou/player.js +76 -30
  27. package/coms/kugou/qqjc.js +172 -0
  28. package/coms/kugou/song.html +8 -3
  29. package/coms/kugou/song.js +29 -7
  30. package/coms/kugou/song.less +78 -16
  31. package/coms/kugou/yyyc.js +535 -0
  32. package/coms/reptile/colored_console.js +1 -1
  33. package/coms/third-party/crypto.js +6166 -0
  34. package/coms/third-party//344/273/243/347/240/201/346/235/245/346/272/220.txt +1 -0
  35. package/coms/zimoli/Canvas.js +7 -7
  36. package/coms/zimoli/anchor.js +2 -2
  37. package/coms/zimoli/anniu.js +6 -6
  38. package/coms/zimoli/button.js +9 -6
  39. package/coms/zimoli/cloneVisible.js +2 -3
  40. package/coms/zimoli/createElement.js +1 -1
  41. package/coms/zimoli/data.js +8 -5
  42. package/coms/zimoli/dateslider.js +8 -8
  43. package/coms/zimoli/download.js +1 -1
  44. package/coms/zimoli/editor.js +2 -2
  45. package/coms/zimoli/gallery.js +2 -2
  46. package/coms/zimoli/gallery.less +1 -1
  47. package/coms/zimoli/getGenerator.js +1 -6
  48. package/coms/zimoli/group.js +2 -2
  49. package/coms/zimoli/hline.js +1 -1
  50. package/coms/zimoli/icon.js +3 -3
  51. package/coms/zimoli/input.js +2 -2
  52. package/coms/zimoli/label.js +3 -3
  53. package/coms/zimoli/list.js +17 -28
  54. package/coms/zimoli/mask.js +2 -2
  55. package/coms/zimoli/option.js +7 -7
  56. package/coms/zimoli/render.js +1 -0
  57. package/coms/zimoli/selectDate.js +2 -2
  58. package/coms/zimoli/space.js +1 -1
  59. package/coms/zimoli/swap.js +1 -1
  60. package/coms/zimoli/titlebar.js +4 -4
  61. package/coms/zimoli/vbox.js +1 -1
  62. package/coms/zimoli/video.js +1 -1
  63. package/coms/zimoli/zimoli.js +1 -1
  64. package/package.json +1 -1
  65. package/public/efront.js +1 -1
Binary file
Binary file
Binary file
Binary file
@@ -10,7 +10,7 @@
10
10
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
11
  <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
12
12
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
13
- <title>酷狗尊享版</title>
13
+ <title>酷狗酷你尊享版</title><!-- 这个名字怎么听怎么像骂狗的,你和狗怎么可以放在相同的位置,真是太抬举你了 -->
14
14
  <script deleteoncompile efrontloader>
15
15
  // 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
16
16
  </script>
@@ -20,6 +20,7 @@
20
20
  <script deleteoncompile>
21
21
  cross_host = '';
22
22
  </script>
23
+ <script type="deleteoncompile" src="crypto/*"></script>
23
24
  <style>
24
25
  *,
25
26
  ::before,
@@ -1,4 +1,8 @@
1
1
  data.setConfig(api);
2
+ data.getApi("kuwo-token").then(function (api) {
3
+ var token = cookie.getCookies(api.base);
4
+ if (!token) cross("get", api.base);
5
+ });
2
6
  zimoli.switch("", null, "/home");
3
7
  css("body", "background-color:#323336;");
4
8
  zimoli();
@@ -1,7 +1,6 @@
1
1
  <titlebar>
2
2
  <back></back>
3
- <input placeholder="请输入关键字搜索" ng-model=keyword
4
- ng-keyup="event.which===13?confirm():search(this.value)" />
3
+ <input placeholder="请输入关键字搜索" ng-model=keyword ng-keyup="event.which===13?confirm():search(this.value)" />
5
4
  <icon class="loading" ng-if="result?.loading"></icon>
6
5
  <btn ng-click="keyword='';search()">清空</btn>
7
6
  </titlebar>
@@ -13,8 +12,8 @@
13
12
  <btn ng-click="search(s,0)"><span ng-bind="s"></span></btn>
14
13
  </padding>
15
14
  </div>
16
- <list ng-if="keyword" ng-src="s in result">
15
+ <list -else ng-src="s in result" min-width=260 >
17
16
  <padding>
18
- <song _mark=keyword ng-click="play(s.hash)" ng-src=s></song>
17
+ <song _mark=keyword @play="play(event.value)" ng-src=s></song>
19
18
  </padding>
20
19
  </list>
@@ -19,8 +19,9 @@ function main(params, from) {
19
19
  searchHistory,
20
20
  player: kugou$player,
21
21
  padding,
22
- play(hash) {
23
- this.player.play(hash);
22
+ list: gallery,
23
+ play(info) {
24
+ this.player.play(info);
24
25
  var words = searchHistory.slice(0);
25
26
  var { keyword } = this;
26
27
  for (var cx = words.length - 1; cx >= 0; cx--) {
@@ -30,10 +31,59 @@ function main(params, from) {
30
31
  words = words.slice(0, 20);
31
32
  data.setInstance("searchHistory", words, true);
32
33
  },
33
- search(keyword = this.keyword, timeout = 600) {
34
- if ($scope.keyword !== keyword) $scope.keyword = keyword;
35
- $scope.result = data.lazyInstance('search', { keyword }, timeout);
34
+ resultMap: null,
35
+ addResult(info) {
36
+ var resultMap = this.resultMap;
37
+ var singerName = sortname(String(info.singername || '').split(/[\&\,,、]/)).join('、');
38
+ var songName = info.songname;
39
+ var id = `${singerName}:${info.songname}`;
40
+ if (!resultMap[id]) resultMap[id] = Object.assign([], { singer: singerName, song: songName });
41
+ resultMap[id].push(info);
42
+ },
43
+ async requestSearch(type, id, params, mp, timeout, parse) {
44
+ var res = await data.lazyInstance(id, params, timeout, parse);
45
+ if (mp !== this.resultMap) return;
46
+ res.forEach(a => a.type = type);
47
+ res.forEach(this.addResult, this);
48
+ this.result = Object.keys(this.resultMap).map(k => this.resultMap[k]).sort((a, b) => b.length - a.length);
49
+ for (var r of this.result) r.sort((a, b) => a.priced - b.priced);
50
+ return res;
51
+ },
52
+ searched: null,
53
+ async search(keyword = this.keyword, timeout = 600) {
54
+ if (keyword === this.searched) return;
55
+ this.keyword = keyword;
56
+ this.searched = keyword;
57
+ this.resultMap = Object.create(null);
58
+ this.result = [];
59
+ if (!keyword) return;
60
+ var s1 = this.requestSearch("kugo", 'search', { keyword }, this.resultMap, timeout, function (s1) {
61
+ s1.forEach(a => {
62
+ a.priced = a.privilege === 10 && (a.price_sq > 0);
63
+ });
64
+ return s1;
65
+ });
66
+ var s2 = this.requestSearch("kuwo", "search-kuwo", { key: keyword }, this.resultMap, timeout);
67
+ var s3 = this.requestSearch("yyyy", "search-yyyy", yyyc.encode({ hlposttag: "</span>", hlposttag: `<span class="s-fc7">`, limit: 30, offset: 0, s: keyword, total: true, type: 1 }), this.resultMap, timeout, function (s3) {
68
+ s3.forEach(a => {
69
+ a.priced = a.fee === 1;
70
+ a.singername = a.ar.map(a => {
71
+ if (a.name === "." || isEmpty(a.name)) return a.alia.join("、");
72
+ return a.name;
73
+ }).join("、");
74
+ });
75
+ return s3;
76
+ });
77
+ var p4 = {
78
+ word: keyword,
79
+ type: 1,
80
+ // pageSize: 20,
81
+ };
82
+ qqjc(p4);
83
+ var s4 = this.requestSearch("qqjt", "search-qqjt", p4, this.resultMap, timeout);
36
84
  state({ keyword });
85
+ await Promise.all([s1, s2, s3, s4]);
86
+
37
87
  },
38
88
  confirm() {
39
89
  this.search(void 0, 0);
@@ -87,4 +87,7 @@
87
87
  background: #5769;
88
88
  padding: 0 16px;
89
89
  }
90
+ }
91
+ list padding{
92
+ display: block;
90
93
  }
@@ -371,7 +371,19 @@ function cross_(jsonp, digest = noop, method, url, headers) {
371
371
  if (_cookies) {
372
372
  _headers.Cookie = _cookies;
373
373
  }
374
- extend(_headers, headers);
374
+ var cookobj = null;
375
+ for (var k in headers) {
376
+ if (/^\$/.test(headers[k])) {
377
+ var k2 = headers[k].slice(1);
378
+ if (!cookobj) cookobj = _cookies ? parseKV(_cookies, ';') : {};
379
+ if (k2 in cookobj) {
380
+ _headers[k] = cookobj[k2];
381
+ }
382
+ }
383
+ else {
384
+ _headers[k] = headers[k];
385
+ }
386
+ }
375
387
  if (/^[mc]/i.test(method)) {
376
388
  _headers["User-Agent"] = /^m/i.test(method)
377
389
  ? "efront/3.25 (iPhone) Safari/602.1"
@@ -17,8 +17,8 @@
17
17
  // │ href │
18
18
  // └────────────────────────────────────────────────────────────────────────────────────────────────┘
19
19
 
20
- // -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6-----------------------------------------------------------------------------------//////////////-7--5///8-------9----------//10--11---10/8/--12----////
21
- var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]+|(?:\.[^\/\\@\:\?\#\.]+)+))?(?:(?:\:|^)(\d+))?)(((?:\/|\\|^)[^\?#]*)?(\?([^#]*))?)(#[\s\S]*)?$/;
20
+ // -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6------------------------------------------------------------------------------------//////////////-7--5///8-------9----------//10--11---10/8/--12----////
21
+ var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[^\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]+|(?:\.[^\/\\@\:\?\#\.]+)+))?(?:(?:\:|^)(\d+))?)(((?:\/|\\|^)[^\?#]*)?(\?([^#]*))?)(#[\s\S]*)?$/;
22
22
  var hrefDescriptor = {
23
23
  get() {
24
24
  var href = '';
@@ -50,6 +50,7 @@ test("./cluster-opt.html", "pathname", "./cluster-opt.html")
50
50
  test(":cluster-opt.html", "pathname", ":cluster-opt.html")
51
51
  test("d:/cluster-opt.html", "pathname", "d:/cluster-opt.html")
52
52
  test("d:\\cluster-opt.html", "pathname", "d:\\cluster-opt.html")
53
+ test("d:\\work\\cluster-opt.html", "pathname", "d:\\work\\cluster-opt.html")
53
54
  test("ftp:\\\\cluster-opt.html", "host", "cluster-opt.html")
54
55
  test("\\\\cluster-opt.html", "host", "cluster-opt.html")
55
56
  test("https://a:b@測試?abc#foo", "host", "測試")
@@ -1,3 +1,8 @@
1
+ class join {
2
+ constructor(t) {
3
+ this.text = t;
4
+ }
5
+ }
1
6
  var seek = function (object, seeker) {
2
7
  if (seeker === null || seeker === undefined || isEmpty(object)) return;
3
8
  if (seeker instanceof Function) {
@@ -6,15 +11,48 @@ var seek = function (object, seeker) {
6
11
  if (typeof seeker === "string") {
7
12
  if (/^(['"`])[\s\S]*$/i.test(seeker)) return seeker.replace(/^(['"`])([\s\S*])\1?$/, "$2");
8
13
  if (seeker === '' || seeker === ".") return object;
9
- seeker = seeker.split(".");
14
+ var s = [];
15
+ s.unshift(seeker.replace(/[\.]([^\.\[]*)|\[([^\]]*)\]|\<([^\>]*)\>/g, (a, b, c, d) => {
16
+ if (b) s.push(b);
17
+ else if (d) {
18
+ s.push(new join(c));
19
+ }
20
+ else if (c) {
21
+ s.push(c || '0');
22
+ }
23
+ return '';
24
+ }));
25
+ seeker = s;
10
26
  }
11
27
  if (seeker instanceof Array) {
12
28
  if (!seeker.length) return;
13
- for (var cx = 0, dx = seeker.length; cx < dx; cx++) {
29
+ loop: for (var cx = 0, dx = seeker.length; cx < dx; cx++) {
14
30
  var key = seeker[cx];
15
31
  if (typeof key === "string") {
16
- object = object[key];
17
- } else {
32
+ if (/[\^]/.test(key)) {
33
+ key = key.split(/[\^]/);
34
+ for (var k of key) {
35
+ if (k in object) {
36
+ object = object[k];
37
+ continue loop;
38
+ }
39
+ }
40
+ object = undefined;
41
+ } else {
42
+ object = object[key];
43
+ }
44
+ }
45
+ else if (key instanceof join) {
46
+ if (object instanceof Array) {
47
+ var restk = seeker.slice(cx + 1, dx);
48
+ object = object.map(a => seek(a, restk)).join(key.text);
49
+ }
50
+ else {
51
+ object = '';
52
+ }
53
+ break;
54
+ }
55
+ else {
18
56
  object = seek(object, key);
19
57
  }
20
58
  if (object === undefined || object === null) return;
package/coms/kugou/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  ({
2
2
  "https://m.kugou.com/": {
3
- "song-info": "get app/i/getSongInfo.php?cmd=playInfo&from=mkugou&hash",
3
+ "song-info;hash": "get app/i/getSongInfo.php?cmd=playInfo&from=mkugou",
4
4
  "slider-src": "get:[].mod-slider>.swipe-wrap>div .#src=img!src&href=a!href",
5
5
  "songs-list": "get:[].panel-songslist%20li .#hash=!id&.panel-songs-item-name>span!innerText",
6
6
  "songs-list": "get:[].m_cm_item1warp:nth-child(2)>div .#=a!href\\song-mix&a:nth-child(2)>p:first-child!innerText&singer=a:nth-child(2)>p:nth-child(2)!innerText&imgurl=img!_src",
@@ -20,5 +20,33 @@
20
20
  },
21
21
  "http://mobilecdn.kugou.com/": {
22
22
  "search?keyword": "get:data.info api/v3/search/song?format=json&page=1&pagesize=30&showtype=1"
23
+ },
24
+ "http://www.kuwo.cn/": {
25
+ "kuwo-token"/*主要用于初始化kw_token*/: "get",
26
+ },
27
+ "http://www.kuwo.cn/api/www/ csrf=$kw_token": {
28
+ "search-kuwo;key": "get:data.list search/searchMusicBykeyWord?&pn=1&rn=30#singername=artist&songname=name&priced=isListenFee",
29
+ "music-info;mid": "get:data music/musicInfo",
30
+ },
31
+ "http://www.kuwo.cn/api/v1/www/": {
32
+ "play-url;mid=rid": "get:data music/playUrl?type=music",
33
+ },
34
+
35
+ "http://m.kuwo.cn/newh5/": {
36
+ "kuwo-lrc;musicId=rid": "get:data.lrclist singles/songinfoandlrc",
37
+ },
38
+ "https://music.163.com/weapi/": {
39
+ "search-yyyy": "form:result.songs cloudsearch/get/web#songname=name&avatar=al.picUrl",
40
+ "yyyy-url": "form:data[0] song/enhance/player/url/v1#encode=type",
41
+ "yyyy-lrc": "form:lrc.lyric song/lyric",
42
+ "yyyy-info": "form:lrc.lyric v3/song/detail",
43
+ },
44
+ "http://lyrics.kugou.com/": {
45
+ "search-krc;keyword=songName&duration=time&hash": "get:candidates[0] search?ver=1&man=yes&client=pc",
46
+ "download-krc;accesskey&id": "get:content download?ver=1&client=pc&fmt=krc&charset=utf8"
47
+ },
48
+ "https://music.91q.com/": {// 千千静听/百度音乐
49
+ "search-qqjt;word": "get:data.typeTrack v1/search#songname=title&singername=artist<、>.name&avatar=pic&priced=isVip",
50
+ "qqjt-url?TSID": "get:data v1/song/tracklink#url=path"
23
51
  }
24
- })
52
+ })
@@ -1,6 +1,6 @@
1
1
  <list ng-src="s in datas" min-width:=datas[0]?.name?320:120>
2
2
  <padding>
3
- <song ng-click="run(s)" ng-class="{activate:s.hash===musicList.active_hash,imgonly:!datas[0]?.name}" ng-src="s"></song>
3
+ <song ng-click="run(s)" ng-class="{activate:musicList.isActived(s),imgonly:!datas[0]?.name}" ng-src="s"></song>
4
4
  </padding>
5
5
  </list>
6
6
  <loading ng-if="datas.is_loading"></loading>
@@ -6,7 +6,7 @@ function main(dataid, datapath) {
6
6
  padding,
7
7
  song,
8
8
  loading,
9
- musicList,
9
+ musicList:kugou$musicList,
10
10
  async run(s) {
11
11
  if (!s.hash && s.hashid) {
12
12
  await data.from("song-mix", s, function (a) {
@@ -15,7 +15,7 @@ function main(dataid, datapath) {
15
15
  });
16
16
  }
17
17
  if (s.hash) {
18
- kugou$player.play(s.hash);
18
+ kugou$player.play(s);
19
19
  } else {
20
20
  go(datapath, s);
21
21
  }
@@ -11,7 +11,7 @@ function Main(dataid, datapath, titleid) {
11
11
  datapath,
12
12
  run(s) {
13
13
  if (s.hash) {
14
- this.player.play(s.hash);
14
+ this.player.play(s);
15
15
  } else {
16
16
  go(datapath, s);
17
17
  }
@@ -1,6 +1,6 @@
1
1
  var getSandbox = function (xhr) {
2
2
  var bodyHTML = String(xhr.responseText || xhr.response || "").replace(RegBodyExp, "$1").replace(RegScriptExp, "").replace(/\son/ig, " no").replace(/\s(src|href)/g, " s$1");
3
- var sandbox = createElement(div);
3
+ var sandbox = document.createElement("div");
4
4
  sandbox.innerHTML = bodyHTML;
5
5
  return sandbox;
6
6
  }
package/coms/kugou/krc.js CHANGED
@@ -2,30 +2,87 @@ var secret = [64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 1
2
2
  var isTrident = /Trident/i.test(navigator.userAgent);
3
3
  function krc(list = div()) {
4
4
  care(list, function (info) {
5
-
6
- cross("get", `http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=${info.songName}&duration=${info.time}&hash=${info.hash}`).done(function (response) {
7
- if (!response.response) return;
8
- var liric = JSON.parse(response.response);
9
- var info = liric.candidates[0];
10
- if (!info) return;
11
- var url = `http://lyrics.kugou.com/download?ver=1&client=pc&id=${info.id}&accesskey=${info.accesskey}&fmt=krc&charset=utf8`;
12
- info && cross("get", url).done(function (response) {
13
- if (!response.response) return;
14
- var krc = JSON.parse(response.responseText || response.response);
15
- var content = fromBase64(krc.content);
16
- content = content.slice(4).map((a, i) => a ^ secret[i % 16]);
17
- var bufff = thirdParty$inflate(content.slice(2));
18
- var krc = decodeUTF8(bufff);
19
- remove(list.children);
20
- var children = createKRC(krc);
5
+ if (info.type !== "kugo") {
6
+ remove(list.children);
7
+ if (info.lrc) {
8
+ var children = createLRC(info.lrc);
21
9
  appendChild(list, children);
22
10
  list.process = children.process;
23
- });
24
- });
25
-
11
+ }
12
+ return;
13
+ }
14
+ var content = info.krc.slice(4).map((a, i) => a ^ secret[i % 16]);
15
+ var bufff = thirdParty$inflate(content.slice(2));
16
+ var krc = decodeUTF8(bufff);
17
+ remove(list.children);
18
+ var children = createKRC(krc);
19
+ appendChild(list, children);
20
+ list.process = children.process;
26
21
  })
27
22
  return list;
28
23
  }
24
+ function createLRC(lrc) {
25
+ var saved_rows = [];
26
+ for (var row of lrc.split(/[\r\n]+/)) {
27
+ var data = /^\s*\[(.*?)\](.*?)$/.exec(row);
28
+ if (!data) {
29
+ if (!isProduction) console.info("%c未解析%c", "color:#c28", "color:#333", row, data);
30
+ continue;
31
+ }
32
+ var [, time, words] = data;
33
+ var startTime = 0;
34
+ var times = time.split(":");
35
+ while (times.length) {
36
+ startTime = startTime * 60 + +times.shift();
37
+ }
38
+ saveToOrderedArray(saved_rows, {
39
+ value: startTime,
40
+ startTime,
41
+ text: words
42
+ });
43
+ }
44
+ var krcList = saved_rows.map(a => {
45
+ var r = document.createElement('div');
46
+ text(r, a.text);
47
+ return r;
48
+ });
49
+ var savedIndex = 0;
50
+ krcList.process = function (offset, length) {
51
+ var index = getIndexFromOrderedArray(saved_rows, offset);
52
+ var current_row = saved_rows[index];
53
+ if (current_row) {
54
+ var ele = krcList[index];
55
+ var firstChild = krcList[0];
56
+ if (index > 0) {
57
+ if (index !== savedIndex) {
58
+ savedIndex = index;
59
+ setClass(krcList, index);
60
+ }
61
+ }
62
+ if (ele && firstChild && firstChild.isMounted) {
63
+ var marginTop = (firstChild.parentNode.offsetHeight - ele.offsetHeight >> 1) - ele.offsetTop + firstChild.offsetTop;
64
+ css(firstChild, `margin-top:${marginTop | 0}px;`);
65
+ }
66
+ }
67
+ };
68
+ return krcList;
69
+ }
70
+
71
+ function setClass(krcList, index) {
72
+ var ele = krcList[index];
73
+ krcList.slice(0, index).map(function (a, cx, arr) {
74
+ removeClass(a, "active after after-active before-active");
75
+ addClass(a, "before");
76
+ });
77
+ removeClass(ele, "after before after-active before-active");
78
+ addClass(krcList[index - 1], 'before-active');
79
+ addClass(ele, "active");
80
+ krcList.slice(index + 1).map(function (a) {
81
+ removeClass(a, "before active after-active before-active");
82
+ addClass(a, "after");
83
+ });
84
+ if (index + 2 < krcList.length) addClass(krcList[index + 1], 'after-active');
85
+ }
29
86
  function createKRC(krc) {
30
87
  var saved_rows = [];
31
88
  krc.split(/[\r\n]+/).map(function (row) {
@@ -73,18 +130,7 @@ function createKRC(krc) {
73
130
  var marginTop = (firstChild.parentNode.offsetHeight - ele.offsetHeight >> 1) - ele.offsetTop + firstChild.offsetTop;
74
131
  if (index > 0) {
75
132
  if (markerLabel.parentNode !== ele) {
76
- krcList.slice(0, index).map(function (a, cx, arr) {
77
- removeClass(a, "active after after-active before-active");
78
- addClass(a, "before");
79
- });
80
- removeClass(ele, "after before after-active before-active");
81
- addClass(krcList[index - 1], 'before-active');
82
- addClass(ele, "active");
83
- krcList.slice(index + 1).map(function (a) {
84
- removeClass(a, "before active after-active before-active");
85
- addClass(a, "after");
86
- });
87
- if (index + 2 < krcList.length) addClass(krcList[index + 1], 'after-active');
133
+ setClass(krcList, index);
88
134
  ele.insertBefore(markerLabel, ele.firstChild);
89
135
  }
90
136
  var word_ele = ele.children[current_row_index + 1];
@@ -109,17 +155,17 @@ function createKRC(krc) {
109
155
  }
110
156
  }
111
157
  };
112
- var markerLabel = createElement(div);
158
+ var markerLabel = document.createElement("div");
113
159
  return krcList;
114
160
  }
115
161
  function createCell(word) {
116
162
  var label = word.label;
117
- var cell = createElement("span");
163
+ var cell = document.createElement("span");
118
164
  text(cell, label);
119
165
  return cell;
120
166
  }
121
167
  function createRow(data) {
122
- var row = createElement(div);
168
+ var row = document.createElement("div");
123
169
  var cells = data.words.map(createCell);
124
170
  appendChild(row, cells);
125
171
  return row;
@@ -1,6 +1,41 @@
1
1
  var musicList = data.getInstance("musicList");
2
+ var actived = null;
2
3
  musicList.forEach(function (music) {
3
- if (music.activate) {
4
- musicList.active_hash = music.hash;
4
+ if (music.activate) actived = music;
5
+ });
6
+
7
+ var isSameSong = function (m1, m2) {
8
+ return m1 === m2 || m1.mid && m1.mid === m2.mid || m1.hash && m1.hash === m2.hash || m1.id && m1.id === m2.id;
9
+ };
10
+
11
+ function addMethod(name, func) {
12
+ Object.defineProperty(musicList, name, {
13
+ value: func,
14
+ enumerable: false
15
+ });
16
+ }
17
+ addMethod("setActive", function (m) {
18
+ if (actived !== m) {
19
+ if (actived && actived !== m) {
20
+ actived.activate = false;
21
+ }
22
+ actived = m;
5
23
  }
24
+ });
25
+ addMethod("remove", function (music) {
26
+ for (var cx = this.length - 1; cx >= 0; cx--) {
27
+ if (isSameSong(this[cx], music)) musicList.splice(cx, 1);
28
+ }
29
+ });
30
+
31
+ addMethod('indexOf', function (music, i) {
32
+ for (var cx = i || 0, dx = this.length; cx < dx; cx++) {
33
+ if (isSameSong(this[cx], music)) return cx;
34
+ }
35
+ });
36
+ addMethod('getActived', function () {
37
+ return actived;
38
+ });
39
+ addMethod('isActived', function (m) {
40
+ return actived && m && isSameSong(m, actived);
6
41
  });
@@ -4,14 +4,14 @@
4
4
  // var document=this.document;
5
5
  // document["body"].appendChild(this.document.createElement("input"));
6
6
  var createBottomBar = function (buttonsConfig) {
7
- var bar = createElement(div);
7
+ var bar = document.createElement("div");
8
8
  addClass(bar, "bottom-bar");
9
9
  var button_count = 0;
10
10
  for (var k in buttonsConfig) button_count++;
11
- var btnArea = createElement(div);
11
+ var btnArea = document.createElement("div");
12
12
  css(btnArea, "width:" + (100 / button_count) + "%;");
13
13
  maxWidth(btnArea, 100);
14
- var line = createElement(btnArea);
14
+ var line = btnArea.cloneNode();
15
15
  inlineBlock(btnArea);
16
16
  var active = function (ratio) {
17
17
  if (ratio >= .6) {
@@ -29,11 +29,11 @@ var createBottomBar = function (buttonsConfig) {
29
29
  var index = 0;
30
30
  for (var k in buttonsConfig) {
31
31
  var [url, info] = buttonsConfig[k].split(":");
32
- var btn = createElement(btnArea);
32
+ var btn = btnArea.cloneNode();
33
33
  btn.url = url;
34
34
  btn.searchInfo = info;
35
35
  btn.active = active;
36
- btn.container = createElement(div);
36
+ btn.container = document.createElement("div");
37
37
  btn.index = index++;
38
38
  btn.innerHTML = k;
39
39
  onclick(btn, function () {
@@ -83,7 +83,7 @@ onappend(pages, function () {
83
83
  if (!isFinite(index)) index = 1;
84
84
  pages.go(index);
85
85
  });
86
- var page = createElement(div);
86
+ var page = document.createElement("div");
87
87
  appendChild(page, pages, bar);
88
88
  ontouchstart(page, kugou$dragview);
89
89
  onmousedown(page, kugou$dragview);
@@ -4,7 +4,7 @@
4
4
  </div>
5
5
  <list class="body" ng-src="(p,i) in musicList" min-width=480>
6
6
  <padding ng-delete="remove(i)">
7
- <song ng-click="play(i)" ng-class="{activate:p.hash===musicList.active_hash}" ng-src=p></song>
7
+ <song ng-click="play(i)" ng-class="{activate:musicList.isActived(p)}" ng-src=p></song>
8
8
  </padding>
9
9
  </list>
10
10
  <div foot>
@@ -24,7 +24,6 @@ var $scope = {
24
24
  },
25
25
  remove(i) {
26
26
  var list = kugou$musicList.slice(0);
27
- list.active_hash = kugou$musicList.active_hash;
28
27
  list.splice(i, 1);
29
28
  data.setInstance("musicList", list, true);
30
29
  },
@@ -12,13 +12,20 @@
12
12
  margin-top: 0;
13
13
  transition: margin .2s ease-out;
14
14
  color: #fff;
15
+ border: 1px solid;
15
16
  }
16
- >.head{
17
+
18
+ >.head {
17
19
  background: inherit;
20
+ border-bottom: 1px solid;
18
21
  }
19
- >.foot{
22
+
23
+ >[foot] {
20
24
  background: inherit;
25
+ border-top: 1px solid;
26
+ padding-bottom: 6px;
21
27
  }
28
+
22
29
  >list.body {
23
30
  overflow-x: hidden;
24
31
  overflow-y: scroll;
@@ -11,9 +11,9 @@
11
11
  <span ng-bind="totalTime"></span>
12
12
  </div>
13
13
  <div class="song">
14
- <span class="name" ng-bind=info.songName></span>
15
- <span class="spliter" ng-if="info.songName&&info.singerName">&nbsp;-&nbsp;</span>
16
- <span class="singer" ng-bind=info.singerName></span>
14
+ <span class="name" ng-bind=songName></span>
15
+ <span class="spliter" ng-if="songName&&singerName">&nbsp;-&nbsp;</span>
16
+ <span class="singer" ng-bind=singerName></span>
17
17
  </div>
18
18
  </div>
19
19
  <btn class="prev" ng-click=play(index-1)></btn>