Guest User

Untitled

a guest
Jul 6th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 82.21 KB | None | 0 0
  1. // ====================================== //
  2. // @name "List Panel (01.06.2013)"
  3. // @author "eXtremeHunter"
  4. // ====================================== //
  5. //window.DlgCode = DLGC_WANTALLKEYS;//uncomment for DUI
  6. var rowsInGroup = window.GetProperty("user.Rows In Group", 4);
  7. if (rowsInGroup < 0) {
  8. rowsInGroup = 0;
  9. window.SetProperty("user.Rows In Group", 0);
  10. }
  11. var rowH = window.GetProperty("user.Row Height", 20);
  12. //--->
  13. var minRowH = 10;
  14. if (rowH < minRowH) {
  15. rowH = minRowH;
  16. window.SetProperty("user.Row Height", minRowH);
  17. }
  18. //--->
  19. var scrollStep = window.GetProperty("user.Scroll Step", 3);
  20. if (scrollStep < 1) {
  21. scrollStep = 1;
  22. window.SetProperty("user.Scroll Step", 1);
  23. }
  24. //--->
  25. var listLeft = window.GetProperty("user.List Left", 15);
  26. var listTop = window.GetProperty("user.List Top", 15);
  27. var listRight = window.GetProperty("user.List Right", 15);
  28. var listBottom = window.GetProperty("user.List Bottom", 15);
  29. var scrollbarRight = window.GetProperty("user.Scrollbar Right", 15);
  30. var showPlayCount = window.GetProperty("user.Show Play Count", componentPlayCount ? true : false);
  31. var showRating = window.GetProperty("user.Show Rating", componentPlayCount ? true : false);
  32. var showAlbumArt = window.GetProperty("user.Show Album Art", true);
  33. var showGroupInfo = window.GetProperty("user.Show Group Info", true);
  34. var showFocusItem = window.GetProperty("user.Show Focus Item", false);
  35. var showQueueItem = window.GetProperty("user.Show Queue Item", true);
  36. var groupFormat = window.GetProperty("user.Format Group", "%album artist%%album%%discnumber%");
  37. var autoExpandCollapseGroups = window.GetProperty("user.Auto Expand/Collapse Groups", false);
  38. var alternateRowColor = window.GetProperty("user.Alternate Row Color", false);
  39. var skipLessThan = window.GetProperty("user.Skip Less Than", 2);
  40. var enableSkip = window.GetProperty("user.Skip Enable", false);
  41. var componentPlayCount = utils.CheckComponent("foo_playcount", true);
  42. //--->
  43. var listLength = maxRows = wh = ww = listX = listY = listW = listH = 0;
  44. var listStep = [];
  45. var rowDrag = fileDrag = makeSelectionDrag = linkToLastItem = false;
  46. var panelFocus;
  47. var nowPlayingGroupNr = -1;
  48. var focusGroupNr = -1;
  49. var keyPressed = false;
  50. var guiInstanceType = window.InstanceType;
  51. var tempFocusItemIndex;
  52. //--->
  53. AlbumArtId = {
  54. front: 0,
  55. back: 1,
  56. disc: 2,
  57. icon: 3,
  58. artist: 4
  59. };
  60. // =================================================== //
  61. //--->
  62. var thisPanelName = "Playlist"; //Don't change!! needed on Scrollbar.txt.
  63. //---> Fonts
  64. var titleFontNormal = gdi.font("Segoe Ui", 12, 0);
  65. var titleFontSelected = gdi.font("Segoe Ui Semibold", 12, 0);
  66. var titleFontPlaying = gdi.font("Segoe Ui Semibold", 12, 0);
  67. var artistFontNormal = gdi.font("Segoe Ui Semibold", 18, 0);
  68. var artistFontPlaying = gdi.font("Segoe Ui Semibold", 18, 0 | 4);
  69. var playCountFont = gdi.font("Segoe Ui", 9, 0);
  70. var albumFont = gdi.font("Segoe Ui", 15, 0);
  71. var dateFont = gdi.font("Segoe UI Semibold", 16, 1);
  72. var infoFont = gdi.font("Segoe Ui", 11, 0);
  73. var coverFont = gdi.font("Segoe Ui", 12, 0);
  74. var ratingFontNotRated = gdi.font("Segoe Ui Symbol", 14);
  75. var ratingFontRated = gdi.font("Segoe Ui Symbol", 16);
  76. //---> Group Colors
  77. var groupTitleColor = RGB(180, 182, 184);
  78. var artistColorNormal = groupTitleColor;
  79. var albumColorNormal = groupTitleColor;
  80. var infoColorNormal = RGB(130, 132, 134);
  81. var dateColorNormal = groupTitleColor;
  82. var lineColorNormal = panelsLineColor;
  83. var lineColorSelected = panelsLineColorSelected;
  84. var groupTitleColorSelected = groupTitleColor;
  85. var artAlpha = 220;
  86. //---> Item Colors
  87. var titleColorSelected = groupTitleColorSelected;
  88. var titleColorPlaying = RGB(255, 165, 0);
  89. var titleColorNormal = panelsNormalTextColor;
  90. var ratingColorRated = titleColorNormal;
  91. var countColorNormal = RGB(120, 122, 124);
  92. var countColorSelected = titleColorSelected;
  93. var countColorPlaying = titleColorPlaying;
  94. //---> Row Colors
  95. var rowColorSelected = RGB(40, 40, 40);
  96. var rowColorAlternate = RGB(40, 40, 40);
  97. var rowColorFocusSelected = RGB(70, 70, 70);
  98. var rowColorFocusNormal = RGB(80, 80, 80);
  99. var rowColorQueued = RGBA(150, 150, 150, 0);
  100. //--->
  101. var backgroundColor = panelsBackColor;
  102. var dropped = false;
  103. //========================================================================================================//
  104.  
  105. function on_paint(gr) {
  106.  
  107. gr.FillSolidRect(0, 0, ww, wh, backgroundColor);
  108.  
  109. var playingID;
  110. var selectedID;
  111. var focusID;
  112. var queueIndexes = [];
  113. var queueIndexCount = [];
  114. var isPlaylistItemQueued = [];
  115. var groupItemCounter = 0;
  116.  
  117. gr.SetTextRenderingHint(5);
  118.  
  119. if (plman.PlayingPlaylist == activeList) {
  120. playingID = plman.GetPlayingItemLocation().PlaylistItemIndex;
  121.  
  122. }
  123.  
  124. focusID = plman.GetPlaylistFocusItemIndex(activeList);
  125.  
  126. if (listLength) {
  127.  
  128. //---> Get visible group row count
  129.  
  130. var visibleGroupRows = [];
  131. var tempGroupNr = 0;
  132. var groupRowCount = 0;
  133.  
  134. for (var i = 0; i != maxRows; i++) {
  135.  
  136. var ID = list[i + listStep[activeList]];
  137.  
  138. if (ID.isGroupHeader) {
  139. var groupNr = ID.groupNr;
  140. (groupNr == tempGroupNr) ? groupRowCount++ : groupRowCount = 1;
  141. visibleGroupRows[groupNr] = groupRowCount;
  142.  
  143. }
  144.  
  145. tempGroupNr = groupNr;
  146.  
  147. }
  148.  
  149. //--->
  150.  
  151. var tempGroupNr = -1;
  152.  
  153. for (var i = 0; i != maxRows; i++) {
  154.  
  155. var ID = list[i + listStep[activeList]];
  156.  
  157.  
  158. if (plman.IsPlaylistItemSelected(activeList, ID.nr)) {
  159. selectedID = ID.nr;
  160. }
  161.  
  162. var metadb = ID.metadb;
  163.  
  164. var x = listX,
  165. y = r[i].y,
  166. w = listW,
  167. h = rowH;
  168.  
  169. if (ID.isGroupHeader) {
  170.  
  171. var groupNr = ID.groupNr;
  172. var selectedGroup = isGroupSelected(groupNr, playingID);
  173. groupItemCounter = 1;
  174. //--->
  175.  
  176. if (selectedGroup) {
  177.  
  178. lineColor = lineColorSelected;
  179. artistColor = albumColor = dateColor = infoColor = groupTitleColorSelected;
  180. rowColorFocus = rowColorFocusSelected;
  181.  
  182. } else {
  183.  
  184. artistColor = artistColorNormal;
  185. albumColor = albumColorNormal;
  186. infoColor = infoColorNormal;
  187. dateColor = dateColorNormal;
  188. lineColor = lineColorNormal;
  189. rowColorFocus = rowColorFocusNormal;
  190.  
  191. }
  192.  
  193. //--->
  194.  
  195. (nowPlayingGroupNr == groupNr) ? artistFont = artistFontPlaying : artistFont = artistFontNormal;
  196.  
  197. //--->
  198.  
  199. if (groupNr != tempGroupNr) {
  200.  
  201. var clipY = r[i].y + 1;
  202. var clipH = visibleGroupRows[groupNr] * rowH - 1;
  203. var clipImg = gdi.CreateImage(listW, clipH);
  204. var g = clipImg.GetGraphics();
  205.  
  206. var groupY;
  207. (i == 0 && ID.rowNr > 1) ? groupY = -((ID.rowNr - 1) * rowH) : groupY = -1;
  208. var groupH = rowsInGroup * rowH;
  209.  
  210. var p = 6,
  211. artX = showAlbumArt ? p : 0,
  212. artY = groupY + p,
  213. artW = showAlbumArt ? groupH - p * 2 : 0,
  214. artH = groupH - p * 2;
  215.  
  216. //--->
  217. g.FillSolidRect(0, groupY, w, groupH, backgroundColor); // Solid background for ClearTypeGridFit text rendering
  218. if (selectedGroup) g.FillSolidRect(0, groupY, w, groupH, rowColorSelected);
  219.  
  220. //g.DrawRect(0, groupY, w-1, groupH-1, 1, RGB(0, 0, 255)); // Test
  221. //g.DrawRect(artX, artY, artW, artH, 1, rowColorFocus); // Test
  222.  
  223. g.SetTextRenderingHint(TextRenderingHint.ClearTypeGridFit);
  224.  
  225. //g.DrawRect(artX, artY, artW, artH, 1, rowColorFocus);
  226.  
  227. if (isCollapsed[groupNr] && focusGroupNr == groupNr) {
  228.  
  229. g.DrawRect(2, groupY + 2, w - 4, groupH - 4, 1, lineColor);
  230.  
  231. }
  232.  
  233. //************************************************************//
  234.  
  235. if (showAlbumArt) {
  236.  
  237. var art = artArray[ID.groupNr];
  238.  
  239. if (art) {
  240.  
  241. g.DrawImage(art, artX + 2, artY + 2, artW - 4, artH - 4, 0, 0, art.Width, art.Height, 0, artAlpha);
  242.  
  243. } else if (art === null) {
  244.  
  245. g.DrawString("NO COVER", coverFont, lineColor, artX, artY, artW, artH, StringFormat(1, 1));
  246.  
  247. } else {
  248.  
  249. g.DrawString("LOADING", coverFont, lineColor, artX, artY, artW, artH, StringFormat(1, 1));
  250.  
  251. }
  252.  
  253. g.DrawRect(artX, artY, artW - 1, artH - 1, 1, lineColor);
  254.  
  255. }
  256.  
  257. //************************************************************//
  258.  
  259. (!showGroupInfo) ? divGroupH = groupH / 2 : divGroupH = groupH / 3;
  260.  
  261. var leftPad = artX + artW + 10;
  262. var path = $("%path%", metadb).slice(0, 4);
  263.  
  264. var radio = (path == "http") ? true : false;
  265.  
  266. //---> DATE
  267. var date = $("%date%", metadb);
  268. if (date == "?" && radio) date = "";
  269. var dateW = Math.ceil(gr.MeasureString(date, dateFont, 0, 0, 0, 0).Width + 5);
  270. var dateX = w - dateW - 5;
  271. var dateY = groupY;
  272. var dateH = groupH;
  273.  
  274.  
  275. (dateX > leftPad) && g.DrawString(date, dateFont, dateColor, dateX, dateY, dateW, dateH, StringFormat(0, 1));
  276.  
  277. //---> ARTIST
  278. var artistX = leftPad;
  279. if (showGroupInfo) {
  280. artistW = 0 + w - artistX - 0;
  281. artistH = divGroupH;
  282. } else {
  283. artistW = dateX - leftPad - 5;
  284. artistH = divGroupH - 5;
  285. }
  286. var artist = $("%album artist%", metadb);
  287. if (artist == "?" && radio) artist = "Radio Stream";
  288.  
  289. g.DrawString(artist, artistFont, artistColor, artistX, groupY, artistW, artistH, StringFormat(0, 2, 3, 0x1000));
  290.  
  291. //---> ALBUM
  292. var albumX = leftPad;
  293. var albumW = dateX - leftPad - 5;
  294. var albumH = divGroupH;
  295.  
  296. showGroupInfo ? albumY = groupY + divGroupH : albumY = groupY + divGroupH + 5;
  297.  
  298. var album = $("%album%", metadb);
  299. if (album == "?" && radio) album = "";
  300.  
  301. g.DrawString(album, albumFont, albumColor, albumX, albumY, albumW, albumH, StringFormat(0, showGroupInfo ? 1 : 0, 3, 0x1000));
  302.  
  303. var albumStringW = gr.MeasureString(album, albumFont, 0, 0, 0, 0).Width;
  304.  
  305. var lineX1 = leftPad + albumStringW + 10;
  306. var lineY = albumY + albumH / 2 + 1;
  307.  
  308. if (!showGroupInfo) {
  309. lineX1 = leftPad;
  310. lineY = groupY + groupH / 2 + 1;
  311. }
  312. var lineX2 = dateX - 10;
  313.  
  314. (lineX2 - lineX1 > 0) && g.DrawLine(lineX1, lineY, lineX2, lineY, 1, lineColor);
  315.  
  316. //---> INFO
  317. if (showGroupInfo) {
  318.  
  319. var infoX = leftPad;
  320. var infoY = groupY + artistH + albumH;
  321. var infoH = h;
  322. var infoW = w - x - infoX;
  323.  
  324. var codec = $("$ext(%path%)", metadb);
  325. if (codec == "cue") codec = $("$ext($Info(referenced_file))", metadb);
  326. else if (codec == "mpc") codec = codec + "-" + $("$Info(codec_profile)", metadb).replace("quality ", "q");
  327. else if ($("$Info(encoding)", metadb) == "lossy") {
  328. if ($("$Info(codec_profile)", metadb) == "CBR") codec = codec + "-" + $("%bitrate%", metadb) + " kbps";
  329. else codec = codec + "-" + $("$Info(codec_profile)", metadb);
  330. }
  331.  
  332. if (!codec) codec = path;
  333. var iCount = itemCount[ID.groupNr];
  334. var genre = radio ? "" : "%genre% | ";
  335. var info = $(genre + codec + "[ | Disc: %discnumber%/%totaldiscs%][ | %replaygain_album_gain%]", metadb) + (radio ? "" : " | " + iCount + (iCount == 1 ? " Track" : " Tracks") + " | Time: " + calculateGroupLength(firstItem[groupNr], lastItem[groupNr]));
  336. var w = w - x - 10;
  337. g.DrawString(info, infoFont, infoColor, infoX, infoY, infoW, infoH, StringFormat(0, 0, 3, 0x1000));
  338.  
  339. var infoStringH = Math.ceil(gr.MeasureString(info, infoFont, 0, 0, 0, 0).Height + 5);
  340. var lineX1 = infoX,
  341. lineX2 = 20 + w,
  342. lineY = infoY + infoStringH;
  343. (lineX2 - lineX1 > 0) && g.DrawLine(lineX1, lineY, lineX2, lineY, 1, lineColor);
  344.  
  345. }
  346.  
  347. //************************************************************//
  348.  
  349. clipImg.ReleaseGraphics(g);
  350. gr.DrawImage(clipImg, listX, clipY, listW, clipH, 0, 0, listW, clipH, 0, 255);
  351. clipImg.Dispose();
  352.  
  353. }
  354.  
  355. tempGroupNr = groupNr;
  356.  
  357. //--->
  358.  
  359. } else {
  360.  
  361. if (ID.isOdd && alternateRowColor) {
  362.  
  363. gr.FillSolidRect(x, y + 1, w, h - 1, rowColorAlternate);
  364.  
  365. }
  366.  
  367. if (selectedID == ID.nr) {
  368.  
  369. if (alternateRowColor) gr.DrawRect(x, y, w - 1, h, 1, rowColorFocusSelected);
  370. else gr.FillSolidRect(x, y, w, h, rowColorSelected);
  371.  
  372. titleColor = titleColorSelected;
  373. countColor = countColorSelected;
  374. if (playingID == ID.nr) {
  375. titleColor = titleColorPlaying;
  376. countColor = titleColor;
  377. }
  378. rowColorFocus = rowColorFocusSelected;
  379.  
  380. (playingID == ID.nr) ? titleFont = titleFontPlaying : titleFont = titleFontSelected;
  381.  
  382. } else if (playingID == ID.nr) {
  383.  
  384. titleColor = titleColorPlaying;
  385. titleFont = titleFontPlaying;
  386. countColor = countColorPlaying;
  387.  
  388. } else {
  389.  
  390. titleFont = titleFontNormal;
  391. titleColor = titleColorNormal;
  392. countColor = countColorNormal;
  393. rowColorFocus = rowColorFocusNormal;
  394.  
  395. }
  396.  
  397. //--->
  398. if (showFocusItem && panelFocus && focusID == ID.nr) {
  399. gr.DrawRect(x + 1, y + 1, w - 3, h - 2, 1, rowColorFocus);
  400. }
  401.  
  402. if ((rowDrag || fileDrag) && r[i].state == 1) {
  403. gr.DrawLine(x, y, x + w, y, 2, RGB(140, 142, 144));
  404. }
  405.  
  406. if (!dropped && linkToLastItem && !makeSelectionDrag && i == (maxRows - 1)) {
  407. gr.DrawLine(x, y + h - 1, x + w, y + h - 1, 2, RGB(255, 165, 0));
  408. }
  409. //--->
  410.  
  411. var testRect = 0;
  412.  
  413. var playCount = (radio ? "" : $("%play_count%", metadb));
  414. var length = $("[%length%]", metadb);
  415. var lengthWidth = length ? 50 : 0;
  416. var playCountWidth = 0;
  417. if (playCount != 0 && showPlayCount) {
  418. playCount = playCount + " |";
  419. playCountWidth = gr.MeasureString(playCount, playCountFont, 0, 0, 0, 0).Width;
  420. }
  421. var ratingW = 0;
  422. if (componentPlayCount && showRating) ratingW = listW - ratingBtnX + 16;
  423.  
  424. //---> QUEUE
  425. var queueContents = plman.GetPlaybackQueueContents().toArray();
  426.  
  427. if (showQueueItem && queueContents.length) {
  428.  
  429. var queueIndex = plman.FindPlaybackQueueItemIndex(metadb, activeList, ID.nr);
  430.  
  431. for (var q = 0; q != queueContents.length; q++) {
  432.  
  433. var handle = queueContents[q].Handle;
  434.  
  435. var indexCount = 0;
  436.  
  437. if (metadb.Compare(handle)) {
  438.  
  439. queueIndexes.push(queueIndex);
  440.  
  441. isPlaylistItemQueued[i] = true;
  442.  
  443. for (var qi = 0, l = queueIndexes.length; qi < l; qi++) {
  444.  
  445. if (queueIndex == queueIndexes[qi]) queueIndexCount[queueIndex] = ++indexCount;
  446.  
  447. }
  448.  
  449. }
  450.  
  451. }
  452.  
  453. }
  454. if (isPlaylistItemQueued[i]) gr.FillSolidRect(x, y, w, h, rowColorQueued);
  455.  
  456. var queue = ((showQueueItem && queueContents.length && queueIndex != -1) ? (' [' + (queueIndex + 1) + ']' + (queueIndexCount[queueIndex] > 1 ? '*' + queueIndexCount[queueIndex] : '')) : '');
  457.  
  458. //---> TITLE
  459. W = w - lengthWidth - playCountWidth - ratingW;
  460. var gic = groupItemCounter++;
  461. var itemNr = (((gic) < 10) ? ("0" + (gic)) : (gic));
  462. gr.DrawString($("$if(%tracknumber%,%tracknumber%.," + itemNr + ".) %title%[ \u25AA $if($greater($len(%track artist%),1),%track artist%)]", metadb) + queue, titleFont, titleColor, x + 10, y, W - 20, h, StringFormat(0, 1, 3, 0x1000));
  463.  
  464. testRect && gr.DrawRect(x, y - 1, W, h, 1, RGBA(155, 155, 255, 250));
  465.  
  466. //---> LENGTH
  467. X = x + w - lengthWidth - ratingW;
  468. W = lengthWidth;
  469. gr.DrawString(length, titleFont, titleColor, X, y, W, h, StringFormat(1, 1));
  470. testRect && gr.DrawRect(X, y - 1, W, h, 1, RGBA(155, 155, 255, 250));
  471.  
  472. //---> COUNT
  473. if (componentPlayCount && playCount != 0 && showPlayCount) {
  474. X = x + w - lengthWidth - playCountWidth - ratingW;
  475. W = playCountWidth;
  476. gr.DrawString(playCount, playCountFont, countColor, X, y, W, h, StringFormat(1, 1));
  477. testRect && gr.DrawRect(X, y - 1, W, h, 1, RGBA(155, 155, 255, 250));
  478.  
  479. }
  480.  
  481. //---> RATING
  482. if (componentPlayCount && showRating) {
  483.  
  484. for (var j = 0; j < 5; j++) {
  485.  
  486. var x = ratingBtnX + j * ratingBtnW - ratingBtnRightPad;
  487. var w = ratingBtnW;
  488.  
  489. var rating = $("%rating%", metadb);
  490.  
  491. if (j < rating) {
  492.  
  493. if (selectedID == ID.nr) {
  494.  
  495. var color = titleColor;
  496.  
  497. } else color = titleColor;
  498.  
  499. gr.DrawString("\u2605", ratingFontRated, color, x, y - 1, w, h, StringFormat(1, 1));
  500.  
  501. } else gr.DrawString("\u2219", ratingFontNotRated, titleColor, x, y - 1, w, h, StringFormat(1, 1));
  502.  
  503. } //eol
  504.  
  505. }
  506.  
  507. }
  508.  
  509. } // eo_row_loop
  510.  
  511. needsScrollbar && drawScrollbar(gr);
  512.  
  513. } else { //eo ifListLength
  514.  
  515. var text = "Drag some tracks here";
  516.  
  517. if (fb.PlaylistCount) {
  518. text = "Playlist: " + plman.GetPlaylistName(activeList) + "\n<--- Empty --->";
  519. }
  520.  
  521. gr.DrawString(text, gdi.font("Segoe Ui", 16, 0), RGB(80, 80, 80), 0, 0, ww, wh, StringFormat(1, 1));
  522.  
  523. }
  524.  
  525. //gr.DrawRect(listX, listY, listW-1, listH-1, 1, RGB(220, 220, 220)); // Test
  526.  
  527. }
  528. // =================================================== //
  529.  
  530. function on_mouse_move(x, y, m) {
  531.  
  532. if (uiHacks) {
  533. try {
  534. if (m && UIHacks && UIHacks.FrameStyle == 3 && !UIHacks.DisableSizing) {
  535. UIHacks.DisableSizing = true;
  536. }
  537. } catch (e) {
  538. fb.trace(e)
  539. };
  540. }
  541. if (!listLength) return;
  542. rowMouseEventHandler(x, y, m);
  543. scrollbarMouseEventHandler(x, y);
  544. }
  545. // =================================================== //
  546. var onMouseLbtnDown = false;
  547.  
  548. function on_mouse_lbtn_down(x, y, m) {
  549.  
  550. onMouseLbtnDown = true;
  551. if (!listLength) return;
  552. rowMouseEventHandler(x, y, m);
  553. scrollbarMouseEventHandler(x, y);
  554.  
  555. }
  556. // =================================================== //
  557.  
  558. function on_mouse_rbtn_down(x, y, m) {
  559.  
  560. if (!listLength) return;
  561. rowMouseEventHandler(x, y, m);
  562.  
  563. }
  564. // =================================================== //
  565.  
  566. function on_mouse_lbtn_dblclk(x, y, m) {
  567.  
  568. if (!listLength && !safeMode) {
  569. try {
  570. WshShell.Run("explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}");
  571. } catch (e) {
  572. fb.trace(e)
  573. };
  574. }
  575.  
  576. if (!listLength) return;
  577. rowMouseEventHandler(x, y, m);
  578. scrollbarMouseEventHandler(x, y);
  579.  
  580. }
  581. // =================================================== //
  582.  
  583. function on_mouse_lbtn_up(x, y, m) {
  584.  
  585. onMouseLbtnDown = false;
  586. if (uiHacks) {
  587. try {
  588. if (UIHacks && UIHacks.FrameStyle == 3 && UIHacks.DisableSizing) {
  589. UIHacks.DisableSizing = false;
  590. }
  591. } catch (e) {
  592. fb.trace(e)
  593. };
  594. }
  595.  
  596. if (!listLength) return;
  597.  
  598. rowMouseEventHandler(x, y, m);
  599. scrollbarMouseEventHandler(x, y);
  600.  
  601. }
  602. // =================================================== //
  603.  
  604. function on_mouse_wheel(delta) {
  605.  
  606. if (!listLength) return;
  607. scrollbarMouseEventHandler(delta);
  608.  
  609. }
  610. // =================================================== //
  611.  
  612. function on_mouse_leave() {
  613.  
  614. rowMouseEventHandler(0, 0);
  615. scrollbarMouseEventHandler(0, 0);
  616.  
  617. }
  618. // =================================================== //
  619.  
  620. function on_playlist_switch() {
  621.  
  622. initList();
  623.  
  624. }
  625. // =================================================== //
  626.  
  627. function on_playlists_changed() {
  628.  
  629. if (fb.ActivePlaylist > fb.PlaylistCount - 1) {
  630. fb.ActivePlaylist = fb.PlaylistCount - 1;
  631. initList();
  632. }
  633.  
  634. }
  635. // =================================================== //
  636.  
  637. function on_playlist_items_reordered(playlist) {
  638.  
  639. if (playlist != activeList) return;
  640. initList();
  641.  
  642. }
  643. // =================================================== //
  644.  
  645. function on_playlist_items_removed(playlist) {
  646.  
  647. if (playlist != activeList) return;
  648. initList();
  649.  
  650. }
  651. // =================================================== //
  652.  
  653. function on_playlist_items_added(playlist) {
  654.  
  655. if (playlist != activeList) return;
  656.  
  657. if (dragOverID && !linkToLastItem) {
  658.  
  659. if (dragOverID.isGroupHeader) {
  660.  
  661. plman.MovePlaylistSelection(playlist, -(playlistItemCount - firstItem[dragOverID.groupNr]));
  662.  
  663. } else {
  664.  
  665. plman.MovePlaylistSelection(playlist, -(playlistItemCount - dragOverID.nr));
  666.  
  667. }
  668.  
  669. }
  670.  
  671. dragOverID = undefined;
  672. fileDrag = false;
  673. initList();
  674.  
  675. if (linkToLastItem) {
  676. onScrollStep("scrollToEnd");
  677. linkToLastItem = false;
  678. refreshScrollbar();
  679. }
  680. }
  681.  
  682. // =================================================== //
  683.  
  684. function on_playlist_items_selection_change() {
  685.  
  686. repaintList();
  687.  
  688. if (!mouseOverList) { //this code executes only if selection is made from external panel.
  689. if (plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count <= 1) {
  690. selectedIndexes = [];
  691. window.Repaint();
  692. }
  693. }
  694.  
  695. }
  696. // =================================================== //
  697.  
  698. function on_metadb_changed(handles, fromhook) {
  699.  
  700. repaintList();
  701.  
  702. }
  703. // =================================================== //
  704.  
  705. function on_item_focus_change(playlist, from, to) {
  706.  
  707. var CtrlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
  708. var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
  709.  
  710. //-----------------------------------------------------//
  711.  
  712. if (!mouseOverList) { //this code executes only if selection is made from external panel.
  713.  
  714. if (!selectedIndexes.length && !ShiftKeyPressed && !CtrlKeyPressed) {
  715.  
  716. selectedIndexes = [];
  717. selectedIndexes[0] = to;
  718.  
  719. }
  720.  
  721. if (CtrlKeyPressed) {
  722.  
  723. if (!selectedIndexes.length) {
  724. selectedIndexes[0] = from;
  725.  
  726. }
  727.  
  728. for (var i = 0; i < selectedIndexes.length; i++) {
  729.  
  730. if (selectedIndexes[i] == to) {
  731.  
  732. selectedIndexes.splice(i, 1);
  733.  
  734. }
  735.  
  736. } //eol
  737.  
  738. if (plman.IsPlaylistItemSelected(fb.ActivePlaylist, to)) {
  739.  
  740. selectedIndexes.push(to);
  741. selectedIndexes.sort(numericAscending);
  742.  
  743. }
  744.  
  745. } //Ctrl end
  746.  
  747. if (ShiftKeyPressed) {
  748.  
  749. var a = new Date();
  750. time = 0;
  751.  
  752. var fromTo = [from, to].sort(numericAscending);
  753.  
  754. for (i = fromTo[0], l = fromTo[1]; i <= l; i++) {
  755.  
  756. selectedIndexes.push(i);
  757.  
  758. } //eol i
  759.  
  760. //find and remove duplicates.
  761. var tempSelectedIndexes = [];
  762. var obj = {};
  763.  
  764.  
  765. for (i = 0, l = selectedIndexes.length; i < l; i++) {
  766.  
  767. obj[selectedIndexes[i]] = 0;
  768.  
  769. }
  770.  
  771. for (i in obj) {
  772.  
  773. tempSelectedIndexes.push(i);
  774.  
  775. }
  776.  
  777. selectedIndexes = tempSelectedIndexes;
  778. // cleanup selectedIndexes
  779. tempSelectedIndexes = [];
  780.  
  781. for (i = 0, l = selectedIndexes.length; i < l; i++) {
  782.  
  783. if (plman.IsPlaylistItemSelected(fb.ActivePlaylist, selectedIndexes[i])) {
  784.  
  785. tempSelectedIndexes.push(selectedIndexes[i]);
  786.  
  787. }
  788. }
  789.  
  790. selectedIndexes = tempSelectedIndexes.sort(numericAscending);
  791.  
  792. var b = new Date();
  793. time = "Initialized: " + (b - a) + " ms";
  794.  
  795. } //if shift
  796. }
  797.  
  798. //------------------------------------------------------------//
  799.  
  800. if (CtrlKeyPressed || ShiftKeyPressed) repaintList();
  801. if (!ShiftKeyPressed) tempFocusItemIndex = undefined;
  802.  
  803. if (!CtrlKeyPressed && !ShiftKeyPressed && plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count > 1) repaintList();
  804.  
  805. focusGroupNr = -1;
  806.  
  807. if (!onMouseLbtnDown) displayFocusItem(to);
  808.  
  809. for (var i = 0; i != maxRows; i++) {
  810.  
  811. var ID = list[i + listStep[activeList]];
  812. var groupNr = ID.groupNr;
  813.  
  814. if (isCollapsed[groupNr] && ID.isGroupHeader) {
  815.  
  816. for (var item = firstItem[groupNr]; item <= lastItem[groupNr]; item++) {
  817.  
  818. if (to == item) {
  819. focusGroupNr = groupNr;
  820. window.Repaint();
  821. return;
  822. }
  823.  
  824. }
  825.  
  826. }
  827.  
  828. }
  829.  
  830. }
  831. // =================================================== //
  832.  
  833. function on_playback_pause(state) {
  834. repaintList();
  835. }
  836. // =================================================== //
  837.  
  838. function on_playback_starting(cmd, is_paused) {
  839. repaintList();
  840. }
  841. // =================================================== //
  842.  
  843. function on_playback_edited(metadb) {
  844.  
  845. repaintList();
  846.  
  847. }
  848. // =================================================== //
  849.  
  850. function on_playback_queue_changed() {
  851.  
  852. repaintList();
  853.  
  854. }
  855. // =================================================== //
  856. var oldPlayingID;
  857.  
  858. function on_playback_new_track(metadb) {
  859.  
  860. var playingID = plman.GetPlayingItemLocation().PlaylistItemIndex;
  861. var rating = $("[%rating%]", metadb);
  862.  
  863. repaintList();
  864.  
  865. if (newTrackByClick) {
  866.  
  867. newTrackByClick = false;
  868.  
  869. } else {
  870.  
  871. //----------------------->
  872. if (enableSkip && rating && rating < skipLessThan) {
  873. if (oldPlayingID < playingID) fb.Next();
  874. else if (oldPlayingID == undefined || oldPlayingID > playingID) fb.Prev();
  875. }
  876. //----------------------->
  877.  
  878. var album = $("%artist%%album%%discnumber%", metadb);
  879.  
  880. if (album != tempAlbumOnPlaybackNewTrack || fb.ActivePlaylist == plman.PlayingPlaylist) {
  881.  
  882. tempAlbumOnPlaybackNewTrack = album;
  883.  
  884. if (autoExpandCollapseGroups) getPlayingGroupCollapseExpand();
  885.  
  886. }
  887.  
  888. }
  889.  
  890. oldPlayingID = playingID;
  891.  
  892. }
  893. // =================================================== //
  894.  
  895. function on_playback_stop(reason) {
  896.  
  897. if (reason != 2) {
  898. repaintList();
  899. }
  900. }
  901. // =================================================== //
  902.  
  903. function on_focus(is_focused) {
  904.  
  905. panelFocus = is_focused;
  906. repaintList();
  907.  
  908. }
  909.  
  910. // =================================================== //
  911.  
  912. function on_key_down(vkey) {
  913.  
  914. var CtrlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
  915. var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
  916.  
  917. if (vkey == VK_UP || vkey == VK_DOWN || vkey == VK_RETURN) {
  918.  
  919. var focusItemIndex = plman.GetPlaylistFocusItemIndex(activeList);
  920.  
  921. }
  922.  
  923. if (!ShiftKeyPressed || tempFocusItemIndex == undefined) tempFocusItemIndex = focusItemIndex;
  924.  
  925. keyPressed = true;
  926.  
  927. switch (vkey) {
  928.  
  929.  
  930. case VK_UP:
  931.  
  932. if (focusItemIndex == 0 && !listIsScrolledUp) displayFocusItem(0);
  933. if (focusItemIndex == 0) return;
  934.  
  935. if (ShiftKeyPressed) {
  936.  
  937. if (tempFocusItemIndex == focusItemIndex) {
  938. plman.ClearPlaylistSelection(activeList);
  939. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex, true);
  940. }
  941.  
  942. if (tempFocusItemIndex < focusItemIndex) {
  943. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex, false);
  944. }
  945.  
  946. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex - 1, true);
  947.  
  948. }
  949.  
  950. if (!CtrlKeyPressed && !ShiftKeyPressed) {
  951. plman.ClearPlaylistSelection(activeList);
  952. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex - 1, true);
  953. }
  954.  
  955. plman.SetPlaylistFocusItem(activeList, focusItemIndex - 1);
  956.  
  957. break;
  958. case VK_DOWN:
  959.  
  960. if (focusItemIndex == (playlistItemCount - 1) && !listIsScrolledDown) displayFocusItem(focusItemIndex);
  961. if (focusItemIndex == (playlistItemCount - 1)) return;
  962.  
  963. if (ShiftKeyPressed) {
  964.  
  965. if (tempFocusItemIndex == focusItemIndex) {
  966. plman.ClearPlaylistSelection(activeList);
  967. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex, true);
  968. }
  969.  
  970. if (tempFocusItemIndex > focusItemIndex) {
  971. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex, false);
  972. }
  973.  
  974. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex + 1, true);
  975.  
  976. }
  977.  
  978. if (!CtrlKeyPressed && !ShiftKeyPressed) {
  979. plman.ClearPlaylistSelection(activeList);
  980. plman.SetPlaylistSelectionSingle(activeList, focusItemIndex + 1, true);
  981. }
  982. plman.SetPlaylistFocusItem(activeList, focusItemIndex + 1);
  983.  
  984. break;
  985. case VK_PRIOR:
  986.  
  987. var IDnr = 0;
  988.  
  989. if (needsScrollbar) {
  990. fastScrollActive = true;
  991. onScrollStep(1, maxRows); // PAGE UP
  992. var ID = list[Math.floor(maxRows / 2) + listStep[activeList]];
  993. ID.isGroupHeader ? IDnr = firstItem[ID.groupNr] : IDnr = ID.nr;
  994. }
  995.  
  996. plman.ClearPlaylistSelection(activeList);
  997. plman.SetPlaylistSelectionSingle(activeList, IDnr, true);
  998. plman.SetPlaylistFocusItem(activeList, IDnr);
  999.  
  1000. break
  1001. case VK_NEXT:
  1002.  
  1003. var IDnr = (playlistItemCount - 1);
  1004.  
  1005. if (needsScrollbar) {
  1006. fastScrollActive = true;
  1007. onScrollStep(-1, maxRows); // PAGE DOWN
  1008. var ID = list[Math.floor(maxRows / 2) + listStep[activeList]];
  1009. ID.isGroupHeader ? IDnr = firstItem[ID.groupNr] : IDnr = ID.nr;
  1010. }
  1011.  
  1012. plman.ClearPlaylistSelection(activeList);
  1013. plman.SetPlaylistSelectionSingle(activeList, IDnr, true);
  1014. plman.SetPlaylistFocusItem(activeList, IDnr);
  1015.  
  1016. break;
  1017. case VK_DELETE:
  1018.  
  1019. plman.RemovePlaylistSelection(activeList, crop = false);
  1020.  
  1021. break;
  1022. case VK_KEY_A:
  1023.  
  1024. CtrlKeyPressed && selectAll();
  1025.  
  1026. break;
  1027. case VK_KEY_F:
  1028.  
  1029. CtrlKeyPressed && fb.RunMainMenuCommand("Edit/Search");
  1030. ShiftKeyPressed && fb.RunMainMenuCommand("Library/Search");
  1031.  
  1032. break;
  1033. case VK_RETURN:
  1034.  
  1035. plman.ExecutePlaylistDefaultAction(activeList, focusItemIndex);
  1036. newTrackByClick = true;
  1037.  
  1038. break;
  1039.  
  1040. case VK_HOME:
  1041.  
  1042. plman.ClearPlaylistSelection(activeList);
  1043. plman.SetPlaylistSelectionSingle(activeList, 0, true);
  1044. plman.SetPlaylistFocusItem(activeList, 0);
  1045.  
  1046. break;
  1047. case VK_END:
  1048.  
  1049. plman.ClearPlaylistSelection(activeList);
  1050. plman.SetPlaylistSelectionSingle(activeList, (playlistItemCount - 1), true);
  1051. plman.SetPlaylistFocusItem(activeList, (playlistItemCount - 1));
  1052.  
  1053. break;
  1054. case VK_KEY_N:
  1055. if (CtrlKeyPressed) {
  1056.  
  1057. fb.CreatePlaylist(fb.PlaylistCount, "");
  1058. fb.ActivePlaylist = fb.PlaylistCount - 1;
  1059.  
  1060. }
  1061. break;
  1062. case VK_KEY_O:
  1063. if (ShiftKeyPressed) {
  1064. fb.RunContextCommandWithMetadb("Open Containing Folder", fb.GetFocusItem());
  1065. }
  1066. break;
  1067. case VK_KEY_P:
  1068. if (CtrlKeyPressed) {
  1069. fb.RunMainMenuCommand("File/Preferences");
  1070. }
  1071. break;
  1072.  
  1073. }
  1074.  
  1075. }
  1076. // =================================================== //
  1077.  
  1078. function on_key_up(vkey) {
  1079.  
  1080. if (vkey == VK_PRIOR || vkey == VK_NEXT) {
  1081.  
  1082. fastScrollActive = false;
  1083. getAlbumArt();
  1084.  
  1085. }
  1086.  
  1087. }
  1088. //=============================================================//
  1089.  
  1090. function on_size() {
  1091.  
  1092. ww = window.Width;
  1093. wh = window.Height;
  1094.  
  1095. if (ww <= 0 || wh <= 0) return;
  1096.  
  1097. listOnSize();
  1098.  
  1099. }
  1100. // =================================================== //
  1101.  
  1102. function on_drag_enter(action, x, y, mask) {
  1103.  
  1104. dropped = false;
  1105.  
  1106. if (listLength && (y > (r[maxRows - 1].y + rowH)) && !linkToLastItem && ((needsScrollbar && listIsScrolledDown) || !needsScrollbar)) {
  1107.  
  1108. linkToLastItem = true;
  1109. r[maxRows - 1].repaint();
  1110.  
  1111. } else linkToLastItem = false;
  1112.  
  1113.  
  1114. }
  1115. // =================================================== //
  1116.  
  1117. function on_drag_drop(action, x, y, mask) {
  1118.  
  1119. var idx;
  1120.  
  1121. if (!fb.PlaylistCount) {
  1122.  
  1123. idx = fb.CreatePlaylist(0, "Default");
  1124. fb.ActivePlaylist = 0;
  1125.  
  1126. } else {
  1127.  
  1128. plman.ClearPlaylistSelection(activeList);
  1129. idx = activeList;
  1130.  
  1131. }
  1132.  
  1133. if (idx !== undefined) {
  1134.  
  1135. action.ToPlaylist();
  1136. action.Playlist = idx;
  1137. action.ToSelect = true;
  1138.  
  1139. }
  1140.  
  1141. dropped = true;
  1142. fileDrag = false;
  1143. repaintList();
  1144.  
  1145. }
  1146. // =================================================== //
  1147.  
  1148. function on_drag_over(action, x, y, mask) {
  1149.  
  1150. rowMouseEventHandler(x, y);
  1151.  
  1152. }
  1153. // =================================================== //
  1154.  
  1155. function on_drag_leave() {
  1156.  
  1157. dragOverID = undefined;
  1158. fileDrag = linkToLastItem = dropped = false;
  1159.  
  1160. repaintList();
  1161.  
  1162. }
  1163. // =================================================== //
  1164.  
  1165. function getAlbumArt() {
  1166.  
  1167. if (!showAlbumArt) return;
  1168.  
  1169. if (fastScrollActive) return;
  1170.  
  1171. for (var i = 0; i != maxRows; i++) {
  1172.  
  1173. var ID = list[i + listStep[activeList]];
  1174.  
  1175. var groupNr = ID.groupNr;
  1176.  
  1177. if (ID.isGroupHeader) {
  1178.  
  1179. if (groupNr != tempGroupNrOnGetAlbumArt) {
  1180.  
  1181. if (!artArray[groupNr] && artArray[groupNr] !== null) {
  1182.  
  1183. utils.GetAlbumArtAsync(window.ID, ID.metadb, AlbumArtId.front);
  1184.  
  1185. }
  1186.  
  1187. }
  1188.  
  1189. tempGroupNrOnGetAlbumArt = groupNr;
  1190.  
  1191. }
  1192.  
  1193. }
  1194.  
  1195. }
  1196. // =================================================== //
  1197. var artSize = rowsInGroup * rowH;
  1198.  
  1199. function on_get_album_art_done(metadb, art_id, image, image_path) {
  1200.  
  1201. if (image && image.Height > artSize) {
  1202. image = image.Resize(artSize, artSize, 0);
  1203. }
  1204. if (image) {
  1205. image = image;
  1206. } else {
  1207. image = null;
  1208. }
  1209.  
  1210. var tempGroupNr = -1;
  1211.  
  1212. for (var i = 0; i != maxRows; i++) {
  1213.  
  1214. var ID = list[i + listStep[activeList]];
  1215. var groupNr = ID.groupNr;
  1216.  
  1217. if (ID.isGroupHeader && (artArray[groupNr] !== null) && groupNr != tempGroupNr && ID.metadb.Compare(metadb)) {
  1218.  
  1219. artArray[groupNr] = image;
  1220.  
  1221. tempGroupNr = groupNr;
  1222.  
  1223. repaintList();
  1224.  
  1225. }
  1226.  
  1227. }
  1228.  
  1229. }
  1230. // =================================================== //
  1231.  
  1232. function selectAll() {
  1233.  
  1234. for (var i = 0; i != playlistItemCount; i++) {
  1235. selectedIndexes[i] = i;
  1236. }
  1237.  
  1238. plman.SetPlaylistSelection(fb.ActivePlaylist, selectedIndexes, true);
  1239.  
  1240. }
  1241. // =================================================== //
  1242.  
  1243. function resizeDone() {
  1244.  
  1245. if (listLength) {
  1246. getAlbumArt();
  1247. }
  1248. }
  1249. // =================================================== //
  1250.  
  1251. function calculateGroupLength(a, b) {
  1252.  
  1253. var groupLengthInSeconds = 0;
  1254.  
  1255. for (var item = a; item <= b; item++) {
  1256.  
  1257. groupLengthInSeconds += parseFloat(fb.TitleFormat("%length_seconds_fp%").EvalWithMetadb(getPlaylistItems.Item(item)));
  1258.  
  1259. }
  1260.  
  1261. return timeFormat(groupLengthInSeconds);
  1262.  
  1263. }
  1264. // =================================================== //
  1265.  
  1266. function repaintList() {
  1267.  
  1268. var ex = 10;
  1269. listW && window.RepaintRect(listX - ex, listY - ex, listW + ex * 2, listH + ex * 2);
  1270.  
  1271. }
  1272. // =================================================== //
  1273.  
  1274. function collapseExpand(arg, nowPlaying) {
  1275.  
  1276. if (fb.ActivePlaylist != fb.PlayingPlaylist) return;
  1277.  
  1278. var playingID = plman.GetPlayingItemLocation().PlaylistItemIndex;
  1279.  
  1280. if (typeof (arg) == "number") {
  1281.  
  1282. var thisGroupNr = arg;
  1283.  
  1284. if (isCollapsed[thisGroupNr]) {
  1285.  
  1286. for (var j = lastItemID[thisGroupNr]; j >= firstItemID[thisGroupNr]; j--) {
  1287.  
  1288. list.splice(_firstItemID[thisGroupNr], 0, $list[j]);
  1289.  
  1290. }
  1291.  
  1292. isCollapsed[thisGroupNr] = false;
  1293.  
  1294. } else {
  1295.  
  1296. list.splice(_firstItemID[thisGroupNr], itemCount[thisGroupNr]);
  1297. isCollapsed[thisGroupNr] = true;
  1298.  
  1299. }
  1300.  
  1301. } else {
  1302.  
  1303. for (var i = groupNr; i >= 0; i--) {
  1304.  
  1305. if (arg == "collapse") {
  1306.  
  1307. if (isCollapsed[i] && i == nowPlaying) {
  1308.  
  1309. var thisGroupNr = nowPlaying;
  1310.  
  1311. for (var j = lastItemID[thisGroupNr]; j >= firstItemID[thisGroupNr]; j--) {
  1312.  
  1313. list.splice(_firstItemID[thisGroupNr], 0, $list[j]);
  1314.  
  1315. }
  1316.  
  1317. isCollapsed[thisGroupNr] = false;
  1318.  
  1319. }
  1320.  
  1321. if (i == nowPlaying) continue;
  1322.  
  1323. if (!isCollapsed[i]) {
  1324. list.splice(_firstItemID[i], itemCount[i]);
  1325. isCollapsed[i] = true;
  1326. }
  1327.  
  1328. } else if (arg == "expand") {
  1329.  
  1330. list = $list.slice(0);
  1331. for (var i = groupNr; i >= 0; i--) {
  1332. isCollapsed = [];
  1333. }
  1334.  
  1335. }
  1336.  
  1337. } //eol
  1338.  
  1339. }
  1340.  
  1341. //---> update _firstItemID
  1342. for (var i = 0; list[i]; i++) {
  1343.  
  1344. var ID = list[i];
  1345.  
  1346. if (ID.isGroupHeader && ID.rowNr == rowsInGroup) {
  1347.  
  1348. _firstItemID[ID.groupNr] = i + 1;
  1349.  
  1350. }
  1351.  
  1352. } //eol
  1353.  
  1354. listLength = list.length;
  1355. listOnSize();
  1356. window.Repaint();
  1357.  
  1358. if (nowPlaying != undefined) {
  1359.  
  1360. //when outo or collapse all but now playing is selected scrolls now playing album to the top
  1361.  
  1362. for (var j = 0; j < listLength; j++) {
  1363.  
  1364. var ID = list[j];
  1365.  
  1366. if (ID.isGroupHeader && ID.groupNr == nowPlaying) {
  1367.  
  1368. var step = j;
  1369. if (step < 0) step = 0;
  1370. listStep[activeList] = Math.min(listLength - maxRows, step);
  1371. window.SetProperty("system.List Step", listStep.toString());
  1372. break;
  1373.  
  1374. }
  1375.  
  1376. } // eol
  1377.  
  1378. }
  1379.  
  1380. listOnSize();
  1381. onScrollStep(0); //check and fix false scrolled up or down var if needed
  1382. window.Repaint();
  1383.  
  1384. }
  1385. // =================================================== //
  1386.  
  1387. function getPlayingGroupCollapseExpand() {
  1388.  
  1389. if (!fb.IsPlaying || fb.ActivePlaylist != fb.PlayingPlaylist) return;
  1390.  
  1391. var playingItemLocation = plman.GetPlayingItemLocation();
  1392. var isValid;
  1393.  
  1394. if (playingItemLocation.IsValid) {
  1395. collapseExpand("collapse", getPlayingGroupNr());
  1396. }
  1397.  
  1398. var counter = 0;
  1399.  
  1400. if (!playingItemLocation.IsValid) {
  1401. var timer = window.SetInterval(function () { // timer for getting delayed item location info when skip track selected
  1402.  
  1403. isValid = plman.GetPlayingItemLocation().IsValid;
  1404.  
  1405. counter++;
  1406.  
  1407. if (isValid || counter == 100 || !fb.IsPlaying) {
  1408.  
  1409. window.ClearInterval(timer);
  1410.  
  1411. if (fb.IsPlaying) {
  1412. collapseExpand("collapse", getPlayingGroupNr());
  1413. }
  1414.  
  1415. }
  1416.  
  1417. }, 100);
  1418.  
  1419. }
  1420.  
  1421. function getPlayingGroupNr() {
  1422.  
  1423. var playingIndex = -1;
  1424.  
  1425. if (plman.PlayingPlaylist == activeList) {
  1426. playingIndex = plman.GetPlayingItemLocation().PlaylistItemIndex;
  1427. }
  1428.  
  1429. for (var g = 0; g <= groupNr; g++) {
  1430. for (var i = firstItem[g]; i <= lastItem[g]; i++) {
  1431. if (playingIndex == i) {
  1432. return g;
  1433. }
  1434. }
  1435. }
  1436. }
  1437.  
  1438. }
  1439. // =================================================== //
  1440.  
  1441. function isGroupSelected(groupNr, playingID) {
  1442.  
  1443. // searches only currently visible groups
  1444. var selectedCount = 0;
  1445. nowPlayingGroupNr = -1;
  1446.  
  1447. for (var item = firstItem[groupNr]; item <= lastItem[groupNr]; item++) {
  1448. if (plman.IsPlaylistItemSelected(activeList, item)) selectedCount++;
  1449. if (playingID == item) nowPlayingGroupNr = groupNr;
  1450. }
  1451.  
  1452. if (selectedCount == (lastItem[groupNr] + 1 - firstItem[groupNr])) return true;
  1453. else return false;
  1454.  
  1455. }
  1456. // =================================================== //
  1457.  
  1458. function displayFocusItem(focusID) {
  1459.  
  1460. if (listLength <= maxRows) return;
  1461.  
  1462. var visibleGroupRows = [];
  1463. var tempGroupNr = 0;
  1464. var groupRowCount = 0;
  1465.  
  1466. for (var i = 0; i != maxRows; i++) {
  1467.  
  1468. var ID = list[i + listStep[activeList]];
  1469.  
  1470. if (isCollapsed.length && ID.isGroupHeader) {
  1471.  
  1472. var groupNr = ID.groupNr;
  1473.  
  1474. (groupNr == tempGroupNr) ? groupRowCount++ : groupRowCount = 1;
  1475. visibleGroupRows[groupNr] = groupRowCount;
  1476.  
  1477. }
  1478.  
  1479. tempGroupNr = groupNr;
  1480.  
  1481. }
  1482.  
  1483. for (var i = 0; i != maxRows; i++) {
  1484.  
  1485. var ID = list[i + listStep[activeList]];
  1486. var groupNr = ID.groupNr;
  1487.  
  1488. if (isCollapsed[groupNr] && ID.isGroupHeader) {
  1489.  
  1490. for (var item = firstItem[groupNr]; item <= lastItem[groupNr]; item++) {
  1491.  
  1492. if (focusID == item && visibleGroupRows[groupNr] == rowsInGroup) {
  1493.  
  1494. return;
  1495.  
  1496. }
  1497. }
  1498.  
  1499. } else if (ID && focusID == ID.nr) return;
  1500.  
  1501. }
  1502.  
  1503. var IDnr;
  1504. for (var i = 0; i < listLength; i++) {
  1505.  
  1506. var ID = list[i];
  1507.  
  1508. var groupNr = ID.groupNr;
  1509.  
  1510. if (isCollapsed.length && ID.isGroupHeader && ID.rowNr == rowsInGroup) {
  1511.  
  1512. for (var item = firstItem[groupNr]; item <= lastItem[groupNr]; item++) {
  1513.  
  1514. if (focusID == item && isCollapsed[groupNr]) {
  1515. IDnr = firstItem[groupNr];
  1516.  
  1517. }
  1518.  
  1519. }
  1520.  
  1521. }
  1522.  
  1523. if (IDnr != undefined || ID.nr == focusID) {
  1524.  
  1525. var step = i - Math.floor(maxRows / 2);
  1526. if (step < 0) step = 0;
  1527.  
  1528. listStep[activeList] = step;
  1529.  
  1530. window.SetProperty("system.List Step", listStep.toString());
  1531. listOnSize();
  1532.  
  1533. window.Repaint();
  1534.  
  1535. listIsScrolledUp = (listStep[activeList] == 0);
  1536. listIsScrolledDown = ((list[maxRows - 1 + listStep[activeList]]) == list[listLength - 1]);
  1537.  
  1538. return;
  1539.  
  1540. }
  1541.  
  1542. } // eol
  1543.  
  1544. }
  1545. // =================================================== //
  1546.  
  1547. function showNowPlaying() {
  1548.  
  1549. if (!fb.Isplaying) return;
  1550. var getPlayingItemLocation = plman.GetPlayingItemLocation()
  1551. if (!getPlayingItemLocation.IsValid) return;
  1552.  
  1553. if (fb.ActivePlaylist != plman.PlayingPlaylist) {
  1554. fb.ActivePlaylist = plman.PlayingPlaylist;
  1555. initList();
  1556. }
  1557.  
  1558. var playingID = getPlayingItemLocation.PlaylistItemIndex;
  1559. plman.ClearPlaylistSelection(activeList);
  1560. plman.SetPlaylistSelectionSingle(activeList, playingID, true);
  1561. plman.SetPlaylistFocusItem(activeList, playingID);
  1562.  
  1563. for (var i = 0; i < listLength; i++) {
  1564.  
  1565. var ID = list[i];
  1566. var groupNr = ID.groupNr;
  1567.  
  1568. if (isCollapsed.length && ID.isGroupHeader && ID.rowNr == rowsInGroup) {
  1569.  
  1570. for (var item = firstItem[groupNr]; item <= lastItem[groupNr]; item++) {
  1571.  
  1572. if (playingID == item && isCollapsed[groupNr]) collapseExpand(groupNr);
  1573.  
  1574. }
  1575.  
  1576. }
  1577.  
  1578. if (ID.nr == playingID) {
  1579.  
  1580. var step = i - Math.floor(maxRows / 2);
  1581. if (step < 0) step = 0;
  1582.  
  1583. listStep[activeList] = step;
  1584.  
  1585. window.SetProperty("system.List Step", listStep.toString());
  1586.  
  1587. on_size();
  1588. window.Repaint();
  1589.  
  1590. break;
  1591.  
  1592. }
  1593.  
  1594. } // eol
  1595.  
  1596. }
  1597. // =================================================== //
  1598. (function initList() {
  1599. //print(caller());
  1600. tempAlbumOnPlaybackNewTrack = undefined;
  1601. tempGroupNrOnGetAlbumArt = -1;
  1602.  
  1603. activeList = plman.ActivePlaylist;
  1604. playlistCount = plman.PlaylistCount;
  1605. playlistItemCount = plman.PlaylistItemCount(activeList);
  1606. getPlaylistItems = plman.GetPlaylistItems(activeList);
  1607. selectedItemCount = plman.GetPlaylistSelectedItems(activeList).Count;
  1608.  
  1609. listIsScrolledUp = listIsScrolledDown = false;
  1610. list = [];
  1611. $list = [];
  1612. firstItem = [];
  1613. firstItemID = [];
  1614. _firstItemID = [];
  1615. lastItem = [];
  1616. lastItemID = [];
  1617. itemCount = [];
  1618. isCollapsed = [];
  1619. selectedIndexes = [];
  1620. queueIndexes = [];
  1621. artArray = [];
  1622. groupNr = 0;
  1623. totalGroups = 0;
  1624. var a, b, metadb;
  1625. var id = 0;
  1626. var from = to = 0;
  1627.  
  1628. var initTest = 0;
  1629. if (initTest) from = new Date();
  1630.  
  1631. for (var i = 0; i != playlistItemCount; i++) {
  1632.  
  1633. metadb = getPlaylistItems.Item(i);
  1634.  
  1635. a = fb.TitleFormat(groupFormat).EvalWithMetadb(metadb);
  1636.  
  1637. if (a != b) {
  1638.  
  1639. for (var groupHeaderRow = 1; groupHeaderRow <= rowsInGroup; groupHeaderRow++) {
  1640.  
  1641. group = {
  1642.  
  1643. groupNr: groupNr, // first group nr = 0
  1644. metadb: metadb,
  1645. isGroupHeader: true,
  1646. rowNr: groupHeaderRow
  1647.  
  1648. };
  1649.  
  1650. firstItem[groupNr] = i;
  1651. $list[id] = group;
  1652.  
  1653. id++
  1654.  
  1655. if (groupHeaderRow == rowsInGroup) {
  1656. firstItemID[groupNr] = id;
  1657. }
  1658.  
  1659. }
  1660.  
  1661. if (groupNr > 0) {
  1662. var gNr = groupNr - 1;
  1663. lastItem[gNr] = i - 1;
  1664. lastItemID[gNr] = id - rowsInGroup - 1;
  1665. itemCount[gNr] = lastItem[groupNr - 1] - firstItem[groupNr - 1] + 1;
  1666. }
  1667.  
  1668. groupNr++;
  1669.  
  1670. b = a;
  1671.  
  1672. if (i % 2 == 0) oddItem = 0;
  1673. if (i % 2 == 1) oddItem = 1;
  1674.  
  1675. }
  1676.  
  1677. var item = {
  1678.  
  1679. metadb: metadb,
  1680. nr: i,
  1681. isOdd: i % 2 == oddItem
  1682.  
  1683. };
  1684.  
  1685. $list[id] = item;
  1686.  
  1687. id++;
  1688.  
  1689.  
  1690. if (selectedItemCount && plman.IsPlaylistItemSelected(activeList, i)) {
  1691. selectedIndexes.push(i);
  1692. }
  1693.  
  1694. } //eol
  1695.  
  1696. if (initTest) {
  1697. to = new Date();
  1698. print("Initialized: " + (to - from) + " ms");
  1699. }
  1700.  
  1701. groupNr--;
  1702. totalGroups = groupNr;
  1703.  
  1704. gNr = groupNr;
  1705. lastItem[gNr] = playlistItemCount - 1;
  1706. lastItemID[gNr] = id - 1;
  1707. itemCount[gNr] = lastItem[gNr] - firstItem[gNr] + 1;
  1708.  
  1709. list = $list.slice(0);
  1710. _firstItemID = firstItemID.slice(0);
  1711. listLength = list.length;
  1712.  
  1713. (listOnSize = function () {
  1714.  
  1715. if (ww <= 0 || wh <= 0) return;
  1716.  
  1717. isResizingDone(ww, wh);
  1718.  
  1719. listX = listLeft;
  1720. listY = listTop;
  1721. listH = Math.max(0, window.Height - listY - listBottom);
  1722. listW = Math.max(100, window.Width - listX - listRight);
  1723.  
  1724. maxRows = Math.max(0, Math.min(listLength, Math.floor(listH / rowH)));
  1725.  
  1726. if (listStep[activeList] + maxRows > listLength && listLength >= maxRows) {
  1727. listStep[activeList] += listLength - (listStep[activeList] + maxRows);
  1728. window.SetProperty("system.List Step", listStep.toString());
  1729. }
  1730.  
  1731. needsScrollbar = listLength > maxRows;
  1732.  
  1733. if (needsScrollbar && showScrollbar) {
  1734. listW = listW - scrollbarWidth - scrollbarRight;
  1735. }
  1736.  
  1737. //---> Row Object
  1738.  
  1739. r = [];
  1740. b = [];
  1741.  
  1742. ratingBtnW = 14;
  1743. ratingBtnX = listX + listW - ratingBtnW * 5;
  1744.  
  1745. if (listLength) {
  1746. for (var i = 0; i != maxRows; i++) {
  1747.  
  1748. var rowY = listY + i * rowH;
  1749. r[i] = new Row(listX, rowY, listW, rowH);
  1750.  
  1751. }
  1752.  
  1753. (initRowButton = function () {
  1754.  
  1755. ratingBtnRightPad = 5;
  1756. for (var i = 0; i != maxRows; i++) {
  1757.  
  1758. r[i].b = [];
  1759.  
  1760. for (var j = 0; j < 5; j++) {
  1761.  
  1762. var x = ratingBtnX + j * ratingBtnW - ratingBtnRightPad;
  1763. var y = r[i].y + rowH / 2 - ratingBtnW / 2 - 1;
  1764.  
  1765. r[i].b[j] = new RowButton(x, y, ratingBtnW, ratingBtnW);
  1766.  
  1767. }
  1768. }
  1769.  
  1770. })();
  1771.  
  1772. }
  1773.  
  1774. //---> Scrollbar
  1775.  
  1776. scrollbarX = window.Width - scrollbarWidth - scrollbarRight;
  1777. scrollbarY = listTop;
  1778. scrollbarBottom = listBottom;
  1779. scrollbarHeight = window.Height - scrollbarY - scrollbarBottom;
  1780.  
  1781. refreshScrollbar();
  1782.  
  1783. //--->
  1784.  
  1785. if (needsScrollbar) {
  1786. createScrollbarThumbImages();
  1787. }
  1788.  
  1789. })();
  1790.  
  1791. //---> init list step
  1792. listStep = [];
  1793.  
  1794. var step = [];
  1795. var s = window.GetProperty("system.List Step", "");
  1796. s.indexOf(",") != -1 ? step = s.split(",") : step[0] = Math.max(0, s);
  1797.  
  1798. for (var i = 0; i < playlistCount; i++) {
  1799.  
  1800. listStep[i] = (step[i] == undefined ? 0 : (isNaN(step[i]) ? 0 : Math.max(0, step[i])));
  1801.  
  1802. }
  1803. window.SetProperty("system.List Step", listStep.toString());
  1804. //--->
  1805.  
  1806. window.Repaint();
  1807. if (needsScrollbar) {
  1808. repaintScrollbar();
  1809. }
  1810.  
  1811. plman.SetActivePlaylistContext();
  1812.  
  1813. })(); //eoInitList
  1814.  
  1815. // =================================================== //
  1816. var rowDrag = fileDrag = linkToLastItem = doubleClicked = mouseOverList = newTrackByClick = actionNotAllowed = clickedOnSelectedItem = selectWithDrag = false;
  1817. var oldRowBtn, oldRowNr, oldRow, oldID, selectedIndex, dragOverID;
  1818.  
  1819. function rowMouseEventHandler(x, y, m) {
  1820.  
  1821. var CtrlKeyPressed = utils.IsKeyPressed(VK_CONTROL);
  1822. var ShiftKeyPressed = utils.IsKeyPressed(VK_SHIFT);
  1823.  
  1824. if (thumbDown || !listLength) return;
  1825.  
  1826. var c = caller();
  1827.  
  1828. var thisID, thisRow, thisRowNr, thisRowBtn;
  1829. var thisRowBtnNr = 0;
  1830.  
  1831. mouseOverList = false;
  1832. mouseInRatingBtn = false;
  1833.  
  1834. for (var i = 0; r[i]; i++) {
  1835.  
  1836. if (r[i].mouseInThisRow(x, y)) {
  1837. mouseOverList = true;
  1838. thisRow = r[i];
  1839. thisID = list[i + listStep[activeList]];
  1840. thisRowNr = i;
  1841. //->
  1842. if (showRating && !thisID.isGroupHeader) {
  1843.  
  1844. var b = r[i].b;
  1845.  
  1846. for (var j = 0; j < 5; j++) {
  1847.  
  1848. if (b[j].mouseInThisRowButton(x, y)) {
  1849.  
  1850. thisRowBtn = b[j];
  1851. thisRowBtnNr = j;
  1852. mouseInRatingBtn = true;
  1853.  
  1854. }
  1855.  
  1856. }
  1857.  
  1858. }
  1859.  
  1860. }
  1861.  
  1862. }
  1863.  
  1864. if (c == "on_drag_over") {
  1865.  
  1866. fileDrag = true;
  1867.  
  1868. if (thisID) {
  1869.  
  1870. dragOverID = thisID;
  1871.  
  1872. }
  1873.  
  1874. c = "on_mouse_move";
  1875.  
  1876. }
  1877.  
  1878. switch (c) {
  1879.  
  1880. case "on_mouse_move":
  1881.  
  1882. if (thisRow !== undefined) {
  1883.  
  1884. mouseOverList = true;
  1885. linkToLastItem = false;
  1886.  
  1887. }
  1888.  
  1889. if (selectedIndexes.length && !doubleClicked && m == 1 && (oldRow && thisRow != oldRow)) {
  1890.  
  1891. if (fb.IsAutoPlaylist(activeList) && !actionNotAllowed) {
  1892.  
  1893. window.SetCursor(IDC_NO);
  1894. actionNotAllowed = true;
  1895.  
  1896. }
  1897. dropped = false;
  1898. if (!actionNotAllowed && clickedOnSelectedItem) rowDrag = true;
  1899. if (!clickedOnSelectedItem) selectWithDrag = true;
  1900. }
  1901.  
  1902.  
  1903. if ((fileDrag || rowDrag || makeSelectionDrag) && thisID && thisID.isGroupHeader && isCollapsed[thisID.groupNr]) {
  1904. collapseExpand(thisID.groupNr);
  1905. }
  1906.  
  1907. //->
  1908. if (oldRow && oldRow != thisRow) {
  1909.  
  1910. if (!clickedOnSelectedItem && m == 1 && thisID && thisID.isGroupHeader) {
  1911.  
  1912. var firstIDnr = firstItem[thisID.groupNr];
  1913.  
  1914. if ((oldID.nr < firstIDnr && selectedIndex > oldID.nr) || (oldID.nr == firstIDnr && selectedIndex < oldID.nr)) {
  1915.  
  1916. plman.SetPlaylistSelectionSingle(activeList, oldID.nr, false);
  1917.  
  1918. }
  1919.  
  1920. }
  1921.  
  1922. oldRow.changeState(0);
  1923.  
  1924. }
  1925.  
  1926. if (thisRow && thisRow != oldRow) {
  1927. thisRow.changeState(1);
  1928.  
  1929. if (rowDrag || fileDrag || makeSelectionDrag) {
  1930.  
  1931. if (thisRowNr == 0 && !listIsScrolledUp) {
  1932.  
  1933. startScrollRepeat("dragUp");
  1934.  
  1935. }
  1936.  
  1937. if ((thisRowNr == (maxRows - 1)) && !listIsScrolledDown) {
  1938.  
  1939. startScrollRepeat("dragDown");
  1940.  
  1941. }
  1942.  
  1943. }
  1944.  
  1945. if (!clickedOnSelectedItem && m == 1) {
  1946.  
  1947. makeSelectionDrag = true;
  1948.  
  1949. selectedIndexes = [];
  1950.  
  1951. if (thisID) {
  1952.  
  1953. for (var i = selectedIndex; i <= thisID.nr; i++) {
  1954. selectedIndexes.push(i);
  1955. }
  1956. for (var i = selectedIndex; i >= thisID.nr; i--) {
  1957. selectedIndexes.push(i);
  1958. }
  1959.  
  1960. if (!thisID.isGroupHeader) {
  1961. plman.ClearPlaylistSelection(activeList);
  1962. plman.SetPlaylistSelection(fb.ActivePlaylist, selectedIndexes, true);
  1963. }
  1964.  
  1965. }
  1966. }
  1967.  
  1968. }
  1969.  
  1970. //->
  1971.  
  1972. if ((rowDrag || fileDrag) && listLength && (y > (r[maxRows - 1].y + rowH)) && !linkToLastItem && ((needsScrollbar && listIsScrolledDown) || !needsScrollbar)) {
  1973.  
  1974. linkToLastItem = true;
  1975. r[maxRows - 1].repaint();
  1976.  
  1977. }
  1978.  
  1979. if ((rowDrag || fileDrag || makeSelectionDrag) && thisID && (thisRowNr != 0 && thisRowNr != (maxRows - 1))) {
  1980.  
  1981. stopScrollRepeat();
  1982.  
  1983. }
  1984.  
  1985. oldID = thisID;
  1986. oldRow = thisRow;
  1987. //->
  1988.  
  1989. break;
  1990.  
  1991. case ("on_mouse_lbtn_down"):
  1992.  
  1993. if (doubleClicked) return;
  1994.  
  1995. if (!thisID) {
  1996. if (!mouseInScrollbar) {
  1997. selectedIndexes = [];
  1998. plman.ClearPlaylistSelection(activeList);
  1999. }
  2000. return;
  2001. }
  2002.  
  2003. var thisIndex = thisID.nr;
  2004.  
  2005. if (thisID.isGroupHeader) {
  2006.  
  2007. if (!CtrlKeyPressed) selectedIndexes = [];
  2008.  
  2009. var thisGroupNr = thisID.groupNr;
  2010.  
  2011. for (var id = firstItem[thisGroupNr]; id <= lastItem[thisGroupNr]; id++) {
  2012.  
  2013. selectedIndexes.push(id);
  2014.  
  2015. }
  2016.  
  2017. plman.ClearPlaylistSelection(activeList);
  2018. plman.SetPlaylistSelection(fb.ActivePlaylist, selectedIndexes, true);
  2019. plman.SetPlaylistFocusItem(activeList, firstItem[thisID.groupNr]);
  2020.  
  2021. } else {
  2022.  
  2023. IDIsSelected = plman.IsPlaylistItemSelected(activeList, thisIndex);
  2024.  
  2025. IDIsSelected ? clickedOnSelectedItem = true : clickedOnSelectedItem = false;
  2026.  
  2027. if (!CtrlKeyPressed && !ShiftKeyPressed && !IDIsSelected) {
  2028.  
  2029. selectedIndexes = [];
  2030. plman.ClearPlaylistSelection(activeList);
  2031.  
  2032. }
  2033.  
  2034. if (ShiftKeyPressed) {
  2035.  
  2036. selectedIndexes = [];
  2037.  
  2038. var a = b = 0;
  2039.  
  2040. if (selectedIndex == undefined) selectedIndex = plman.GetPlaylistFocusItemIndex(activeList);
  2041.  
  2042. if (selectedIndex < thisIndex) {
  2043. a = selectedIndex;
  2044. b = thisIndex;
  2045. } else {
  2046. a = thisIndex;
  2047. b = selectedIndex;
  2048. }
  2049.  
  2050. for (var id = a; id <= b; id++) {
  2051.  
  2052. selectedIndexes.push(id);
  2053.  
  2054. }
  2055.  
  2056. plman.ClearPlaylistSelection(activeList);
  2057. plman.SetPlaylistSelection(activeList, selectedIndexes, true);
  2058.  
  2059. } else {
  2060.  
  2061. plman.SetPlaylistSelectionSingle(activeList, thisIndex, true);
  2062.  
  2063. if (utils.IsKeyPressed(VK_KEY_Q))
  2064. plman.AddPlaylistItemToPlaybackQueue(activeList, thisIndex);
  2065. else if (utils.IsKeyPressed(VK_KEY_Z)) {
  2066. var index = plman.FindPlaybackQueueItemIndex(thisID.metadb, activeList, thisIndex)
  2067. plman.RemoveItemFromPlaybackQueue(index);
  2068. }
  2069.  
  2070. }
  2071.  
  2072. if (!IDIsSelected && !CtrlKeyPressed && !ShiftKeyPressed) {
  2073.  
  2074. selectedIndexes = [];
  2075.  
  2076. selectedIndexes[0] = thisIndex;
  2077.  
  2078. }
  2079.  
  2080. if (CtrlKeyPressed) {
  2081.  
  2082. if (!IDIsSelected) selectedIndexes.push(thisIndex);
  2083.  
  2084. plman.SetPlaylistSelectionSingle(activeList, thisIndex, IDIsSelected ? false : true);
  2085.  
  2086. if (IDIsSelected) {
  2087.  
  2088. for (var i = 0; i < selectedIndexes.length; i++) {
  2089.  
  2090. if (selectedIndexes[i] == thisIndex) selectedIndexes.splice(i, 1);
  2091.  
  2092. }
  2093.  
  2094. }
  2095.  
  2096. }
  2097.  
  2098. plman.SetPlaylistFocusItem(activeList, thisIndex);
  2099.  
  2100. if (selectedIndex == undefined) selectedIndex = thisIndex;
  2101.  
  2102. if (selectedIndexes.length > 1) selectedIndexes.sort(numericAscending);
  2103.  
  2104. } //eof isGroup else
  2105.  
  2106. break;
  2107.  
  2108. case ("on_mouse_rbtn_down"):
  2109.  
  2110. if (!thisID) {
  2111. if (!mouseInScrollbar) {
  2112. selectedIndexes = [];
  2113. plman.ClearPlaylistSelection(activeList);
  2114. }
  2115. return;
  2116. }
  2117.  
  2118. var thisIndex = thisID.nr;
  2119.  
  2120. if (thisID.isGroupHeader) {
  2121.  
  2122. if (isGroupSelected(thisID.groupNr)) return;
  2123.  
  2124. selectedIndexes = [];
  2125.  
  2126. var thisGroupNr = thisID.groupNr;
  2127.  
  2128. for (var id = firstItem[thisGroupNr]; id <= lastItem[thisGroupNr]; id++) {
  2129.  
  2130. selectedIndexes.push(id);
  2131.  
  2132. }
  2133.  
  2134. plman.ClearPlaylistSelection(activeList);
  2135. plman.SetPlaylistSelection(fb.ActivePlaylist, selectedIndexes, true);
  2136. plman.SetPlaylistFocusItem(activeList, firstItem[thisID.groupNr]);
  2137.  
  2138. } else {
  2139.  
  2140. var IDIsSelected = plman.IsPlaylistItemSelected(activeList, thisIndex);
  2141.  
  2142. if (IDIsSelected) {
  2143.  
  2144. plman.SetPlaylistFocusItem(activeList, thisIndex);
  2145. repaintList();
  2146.  
  2147. } else {
  2148.  
  2149. selectedIndexes = [];
  2150. plman.ClearPlaylistSelection(activeList);
  2151. selectedIndexes[0] = thisIndex;
  2152. plman.SetPlaylistFocusItem(activeList, thisIndex);
  2153. plman.SetPlaylistSelectionSingle(activeList, thisIndex, true);
  2154.  
  2155. }
  2156.  
  2157. }
  2158.  
  2159. break;
  2160.  
  2161. case ("on_mouse_lbtn_dblclk"):
  2162.  
  2163. if (!thisID) return;
  2164. doubleClicked = true;
  2165.  
  2166. //---> Set rating
  2167. if (mouseInRatingBtn) {
  2168.  
  2169. var metadb = thisID.metadb;
  2170.  
  2171. var currentRating = $("%rating%", metadb);
  2172.  
  2173. var rate = thisRowBtnNr + 1;
  2174.  
  2175. (currentRating == 1 && rate == 1) ? fb.RunContextCommandWithMetadb("<not set>", metadb) : fb.RunContextCommandWithMetadb("Rating/" + rate, metadb);
  2176.  
  2177. return;
  2178.  
  2179. }
  2180.  
  2181. if (thisID.isGroupHeader) {
  2182.  
  2183. collapseExpand(thisID.groupNr);
  2184.  
  2185. } else if (!utils.IsKeyPressed(VK_KEY_Q) && !utils.IsKeyPressed(VK_KEY_Z)) {
  2186.  
  2187. plman.ExecutePlaylistDefaultAction(activeList, thisID.nr);
  2188. newTrackByClick = true;
  2189.  
  2190. }
  2191.  
  2192. break;
  2193.  
  2194. case "on_mouse_lbtn_up":
  2195.  
  2196. if (doubleClicked) {
  2197. doubleClicked = false;
  2198. return;
  2199. }
  2200.  
  2201. if (thisRow) {
  2202. thisRow.changeState(0);
  2203. }
  2204.  
  2205. if (thisID && thisID.nr !== undefined) {
  2206.  
  2207. if (rowDrag && thisID) {
  2208.  
  2209. var selectedItems = plman.GetPlaylistSelectedItems(activeList);
  2210. var selectedItemCount = selectedItems.Count;
  2211. var focusIndex = plman.GetPlaylistFocusItemIndex(activeList);
  2212. var focusHandle = plman.GetPlaylistFocusItemHandle(false);
  2213. var thisIndex = thisID.nr;
  2214. var add = 0;
  2215.  
  2216. if (selectedItemCount > 1) {
  2217.  
  2218. //--->
  2219. var temp;
  2220. var odd = false;
  2221. for (var i = 0; i < playlistItemCount; i++) {
  2222. if (plman.IsPlaylistItemSelected(activeList, i)) {
  2223. if (temp != undefined && ((i - 1) != temp)) {
  2224. odd = true;
  2225. break;
  2226. }
  2227. temp = i;
  2228. }
  2229. }
  2230. //--->
  2231.  
  2232. if (odd) {
  2233.  
  2234. for (var i = 0; i < selectedIndexes.length; i++) {
  2235.  
  2236. if (selectedIndexes[i] < thisIndex) {
  2237. add = i + 1;
  2238.  
  2239. }
  2240.  
  2241. }
  2242.  
  2243. plman.MovePlaylistSelection(activeList, -listLength);
  2244.  
  2245. } else {
  2246.  
  2247. for (var i = 0; i < selectedIndexes.length; i++) {
  2248.  
  2249. if (selectedIndexes[i] == focusIndex) {
  2250. add = i;
  2251. break;
  2252. }
  2253.  
  2254. }
  2255.  
  2256. }
  2257.  
  2258. }
  2259.  
  2260. if (focusIndex > thisIndex) {
  2261.  
  2262. (selectedItemCount > 1) ? (odd ? delta = thisIndex - add : delta = -(focusIndex - thisIndex - add)) : delta = -(focusIndex - thisIndex);
  2263.  
  2264. } else {
  2265.  
  2266. (selectedItemCount > 1) ? (odd ? delta = thisIndex - add : delta = (thisIndex - focusIndex - (selectedItemCount - add))) : delta = (thisIndex - 1 - focusIndex);
  2267.  
  2268. }
  2269.  
  2270. if (!odd && plman.IsPlaylistItemSelected(plman.ActivePlaylist, thisIndex)) delta = 0;
  2271.  
  2272. plman.MovePlaylistSelection(activeList, delta);
  2273.  
  2274. } //row drag end
  2275.  
  2276.  
  2277. if (!CtrlKeyPressed && !ShiftKeyPressed && !rowDrag && !selectWithDrag) {
  2278.  
  2279. if (plman.GetPlaylistSelectedItems(activeList).Count > 1) {
  2280.  
  2281. selectedIndexes = [];
  2282. selectedIndexes[0] = thisID.nr;
  2283. plman.ClearPlaylistSelection(activeList);
  2284. plman.SetPlaylistSelectionSingle(activeList, thisID.nr, true);
  2285.  
  2286. }
  2287.  
  2288. }
  2289.  
  2290. }
  2291.  
  2292. if (linkToLastItem) {
  2293.  
  2294. plman.MovePlaylistSelection(activeList, listLength - plman.GetPlaylistSelectedItems(activeList).Count);
  2295.  
  2296. r[maxRows - 1].repaint();
  2297.  
  2298. }
  2299.  
  2300. if (!ShiftKeyPressed) selectedIndex = undefined;
  2301.  
  2302. rowDrag = fileDrag = makeSelectionDrag = linkToLastItem = selectWithDrag = false;
  2303.  
  2304. //--->
  2305.  
  2306. plman.SetActivePlaylistContext();
  2307.  
  2308. if (actionNotAllowed) {
  2309. window.SetCursor(IDC_ARROW);
  2310. actionNotAllowed = false;
  2311. }
  2312.  
  2313. break;
  2314.  
  2315. case ("on_mouse_leave"):
  2316.  
  2317. for (var i = 0; r[i]; i++) {
  2318.  
  2319. if (r[i].state != 0) {
  2320.  
  2321. if (r[i].b) {
  2322. for (var j = 0; r[i].b[j]; j++) {
  2323.  
  2324. r[i].b[j].changeState(0);
  2325.  
  2326. }
  2327. }
  2328.  
  2329. r[i].changeState(0);
  2330.  
  2331. }
  2332.  
  2333. }
  2334.  
  2335. selectedIndex = oldRow = thisRow = undefined;
  2336.  
  2337. break;
  2338.  
  2339. }
  2340.  
  2341. }
  2342. // =================================================== //
  2343.  
  2344. function Row(x, y, w, h, b) {
  2345.  
  2346. this.x = x;
  2347. this.y = y;
  2348. this.w = w;
  2349. this.h = h;
  2350. this.b = b;
  2351. this.state = 0;
  2352.  
  2353. }
  2354. // =================================================== //
  2355. Row.prototype.mouseInThisRow = function (x, y) {
  2356.  
  2357. return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
  2358.  
  2359. }
  2360. // =================================================== //
  2361. Row.prototype.repaint = function () {
  2362.  
  2363. window.RepaintRect(this.x - 5, this.y - 5, this.w + 10, this.h + 10);
  2364.  
  2365. }
  2366. // =================================================== //
  2367. Row.prototype.changeState = function (state) {
  2368.  
  2369. this.state = state;
  2370. if (rowDrag || fileDrag) {
  2371. this.repaint();
  2372. }
  2373. //this.state == 0 ? window.SetCursor(IDC_ARROW) : window.SetCursor(IDC_HAND);
  2374.  
  2375. }
  2376. // =================================================== //
  2377.  
  2378. function RowButton(x, y, w, h) {
  2379.  
  2380. this.x = x;
  2381. this.y = y;
  2382. this.w = w;
  2383. this.h = h;
  2384. this.state = 0;
  2385.  
  2386. }
  2387. // =================================================== //
  2388. RowButton.prototype.mouseInThisRowButton = function (x, y) {
  2389.  
  2390. return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
  2391.  
  2392. }
  2393. // =================================================== //
  2394. RowButton.prototype.repaint = function () {
  2395.  
  2396. window.RepaintRect(this.x, this.y, this.w, this.h);
  2397.  
  2398. }
  2399. // =================================================== //
  2400. RowButton.prototype.changeState = function (state) {
  2401.  
  2402. this.state = state;
  2403. this.repaint();
  2404.  
  2405. //this.state == 0 ? window.SetCursor(IDC_ARROW) : window.SetCursor(IDC_HAND);
  2406.  
  2407. }
  2408. // =============================================== //
  2409.  
  2410. function on_mouse_rbtn_up(x, y) {
  2411.  
  2412. if (mouseInScrollbar) {
  2413. scrollbarMouseEventHandler(x, y);
  2414. return true;
  2415. }
  2416.  
  2417. var metadb = utils.IsKeyPressed(VK_CONTROL) ? (fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem()) : fb.GetFocusItem();
  2418.  
  2419. var windowsVisualStyleEnabled = window.CreateThemeManager("WINDOW");
  2420. var selected = plman.GetPlaylistSelectedItems(plman.ActivePlaylist).Count;
  2421. var selection = (selected > 1);
  2422. var queueActive = plman.IsPlaybackQueueActive();
  2423. var isAutoPlaylist = fb.IsAutoPlaylist(activeList);
  2424. var playlistCount = fb.PlaylistCount;
  2425.  
  2426. var cpm = window.CreatePopupMenu();
  2427. var web = window.CreatePopupMenu();
  2428. var ce = window.CreatePopupMenu();
  2429. var ccmm = fb.CreateContextMenuManager();
  2430. var appear = window.CreatePopupMenu();
  2431. var sort = window.CreatePopupMenu();
  2432. var lists = window.CreatePopupMenu();
  2433. var send = window.CreatePopupMenu();
  2434. var skip = window.CreatePopupMenu();
  2435.  
  2436. if (utils.IsKeyPressed(VK_SHIFT)) {
  2437.  
  2438. cpm.AppendMenuItem(MF_STRING, 1, "Restart");
  2439. cpm.AppendMenuSeparator();
  2440. cpm.AppendMenuItem(safeMode ? MF_GRAYED : MF_STRING, 2, "Configure script...");
  2441. cpm.AppendMenuItem(MF_STRING, 3, "Configure...");
  2442. cpm.AppendMenuItem(MF_STRING, 4, "Properties...");
  2443. cpm.AppendMenuSeparator();
  2444. }
  2445.  
  2446. plman.SetActivePlaylistContext();
  2447.  
  2448. fb.Isplaying && cpm.AppendMenuItem(MF_STRING, 5, "Show Now Playing");
  2449.  
  2450. if (plman.PlaylistItemCount(plman.ActivePlaylist)) {
  2451.  
  2452. cpm.AppendMenuItem(MF_STRING, 6, "Refresh all");
  2453. cpm.AppendMenuItem(MF_STRING, 7, "Select all (Ctrl+A)");
  2454. if (selected) cpm.AppendMenuItem(isAutoPlaylist ? MF_GRAYED : MF_STRING, 8, "Remove from list (Delete)");
  2455. if (queueActive) cpm.AppendMenuItem(MF_STRING, 9, "Flush playback queue");
  2456. cpm.AppendMenuSeparator();
  2457. // -------------------------------------------------------------- //
  2458. //---> Collapse/Expand
  2459. if (rowsInGroup) {
  2460. ce.AppendMenuItem(MF_STRING, 20, "Collapse all");
  2461. if (fb.ActivePlaylist == plman.PlayingPlaylist) ce.AppendMenuItem(MF_STRING, 21, "Collapse all but now playing");
  2462. ce.AppendMenuItem(MF_STRING, 22, "Expand all");
  2463. ce.AppendMenuSeparator();
  2464. ce.AppendMenuItem(MF_STRING, 23, "Auto");
  2465. ce.CheckMenuItem(23, autoExpandCollapseGroups);
  2466. ce.AppendTo(cpm, MF_STRING | MF_POPUP, "Collapse/Expand");
  2467. }
  2468. // -------------------------------------------------------------- //
  2469. //---> Skip trak
  2470. skip.AppendMenuItem(MF_STRING, 24, "Enable");
  2471. skip.CheckMenuItem(24, enableSkip);
  2472. skip.AppendMenuSeparator();
  2473. skip.AppendMenuItem(enableSkip ? MF_STRING : MF_GRAYED, 25, "Rated less than 2");
  2474. skip.AppendMenuItem(enableSkip ? MF_STRING : MF_GRAYED, 26, "Rated less than 3");
  2475. skip.AppendMenuItem(enableSkip ? MF_STRING : MF_GRAYED, 27, "Rated less than 4");
  2476. skip.AppendMenuItem(enableSkip ? MF_STRING : MF_GRAYED, 28, "Rated less than 5");
  2477. skip.AppendTo(cpm, MF_STRING | MF_POPUP, "Skip");
  2478. skip.CheckMenuRadioItem(25, 28, 23 + skipLessThan);
  2479. // -------------------------------------------------------------- //
  2480. //---> Appearance
  2481. appear.AppendMenuItem(MF_STRING, 30, "Show album art");
  2482. appear.CheckMenuItem(30, showAlbumArt);
  2483. appear.AppendMenuItem(MF_STRING, 31, "Show group info");
  2484. appear.CheckMenuItem(31, showGroupInfo);
  2485. appear.AppendMenuItem(componentPlayCount ? MF_STRING : MF_GRAYED, 32, "Show play count");
  2486. appear.CheckMenuItem(32, showPlayCount);
  2487. appear.AppendMenuItem(componentPlayCount ? MF_STRING : MF_GRAYED, 33, "Show rating");
  2488. appear.CheckMenuItem(33, showRating);
  2489. appear.AppendMenuItem(MF_STRING, 34, "Show focus item");
  2490. appear.CheckMenuItem(34, showFocusItem);
  2491. appear.AppendMenuItem(MF_STRING, 35, "Show queue item");
  2492. appear.CheckMenuItem(35, showQueueItem);
  2493. appear.AppendMenuItem(MF_STRING, 36, "Alternate row color");
  2494. appear.CheckMenuItem(36, alternateRowColor);
  2495. appear.AppendMenuItem(MF_STRING, 37, "Show scrollbar");
  2496. appear.CheckMenuItem(37, showScrollbar);
  2497. if (showScrollbar && windowsVisualStyleEnabled) {
  2498. appear.AppendMenuItem(MF_STRING, 38, "Scrollbar use windows style");
  2499. appear.CheckMenuItem(38, scrollbarUseWindowsVisualStyle);
  2500. }
  2501. appear.AppendTo(cpm, MF_STRING | MF_POPUP, "Appearance");
  2502. // -------------------------------------------------------------- //
  2503. //---> Sort
  2504. sort.AppendMenuItem(MF_STRING, 40, "Sort by...");
  2505. sort.AppendMenuItem(MF_STRING, 41, "Randomize");
  2506. sort.AppendMenuItem(MF_STRING, 42, "Reverse");
  2507. sort.AppendMenuItem(MF_STRING, 43, "Sort by album");
  2508. sort.AppendMenuItem(MF_STRING, 44, "Sort by artist");
  2509. sort.AppendMenuItem(MF_STRING, 45, "Sort by file path");
  2510. sort.AppendMenuItem(MF_STRING, 46, "Sort by title");
  2511. sort.AppendMenuItem(MF_STRING, 47, "Sort by track number");
  2512. sort.AppendTo(cpm, isAutoPlaylist ? MF_GRAYED : MF_STRING | MF_POPUP, selection ? "Sort selection" : "Sort");
  2513. // -------------------------------------------------------------- //
  2514. //---> Weblinks
  2515. web.AppendMenuItem(MF_STRING, 50, "Google");
  2516. web.AppendMenuItem(MF_STRING, 51, "Google Images");
  2517. web.AppendMenuItem(MF_STRING, 52, "eCover");
  2518. web.AppendMenuItem(MF_STRING, 53, "Wikipedia");
  2519. web.AppendMenuItem(MF_STRING, 54, "YouTube");
  2520. web.AppendMenuItem(MF_STRING, 55, "Last FM");
  2521. web.AppendMenuItem(MF_STRING, 56, "Discogs");
  2522. web.AppendTo(cpm, safeMode ? MF_GRAYED : MF_STRING | MF_POPUP, "Weblinks");
  2523.  
  2524. }
  2525. // -------------------------------------------------------------- //
  2526. //---> Playlists
  2527. var playlistId = 102;
  2528. lists.AppendMenuItem(MF_STRING, 100, "Playlist manager...");
  2529. lists.AppendMenuSeparator();
  2530. lists.AppendMenuItem(MF_STRING, 101, "Create New Playlist");
  2531. lists.AppendMenuSeparator();
  2532. for (var i = 0; i != playlistCount; i++) {
  2533. lists.AppendMenuItem(MF_STRING, playlistId + i, fb.GetPlaylistName(i) + " [" + fb.PlaylistItemCount(i) + "]" + (fb.IsAutoPlaylist(i) ? " (Auto)" : "") + (i == plman.PlayingPlaylist ? " (Now Playing)" : ""));
  2534. }
  2535. lists.AppendTo(cpm, MF_STRING | MF_POPUP, "Playlists");
  2536. // -------------------------------------------------------------- //
  2537. if (selected) {
  2538. var sendToPlaylistId = playlistId + playlistCount + 1;
  2539. send.AppendMenuItem(MF_STRING, sendToPlaylistId - 1, "Create New Playlist");
  2540. send.AppendMenuSeparator();
  2541. for (var i = 0; i != playlistCount; i++) {
  2542. send.AppendMenuItem((fb.IsAutoPlaylist(i) || i == activeList) ? MF_GRAYED : MF_STRING, sendToPlaylistId + i, fb.GetPlaylistName(i) + " [" + fb.PlaylistItemCount(i) + "]" + (fb.IsAutoPlaylist(i) ? " (Auto)" : "") + (i == plman.PlayingPlaylist ? " (Now Playing)" : ""));
  2543. }
  2544. send.AppendTo(cpm, MF_STRING | MF_POPUP, "Send selection");
  2545. }
  2546. // -------------------------------------------------------------- //
  2547. //---> Context Menu Manager
  2548. var contextId = playlistId + sendToPlaylistId + playlistCount;
  2549. if (selected) {
  2550. cpm.AppendMenuSeparator();
  2551. ccmm.InitContext(plman.GetPlaylistSelectedItems(activeList));
  2552. ccmm.BuildMenu(cpm, contextId, -1);
  2553. }
  2554.  
  2555. id = cpm.TrackPopupMenu(x, y);
  2556.  
  2557. if (selected) ccmm.ExecuteByID(id - contextId);
  2558. // -------------------------------------------------------------- //
  2559. switch (id) {
  2560.  
  2561. case 1:
  2562. fb.RunMainMenuCommand("File/Restart");
  2563. break;
  2564. case 2:
  2565. try {
  2566.  
  2567. WshShell.Run("notepad.exe themes\\" + themeName + "\\Scripts\\Panel_List.js");
  2568.  
  2569. } catch (e) {
  2570. fb.trace(e)
  2571. };
  2572. break;
  2573. case 3:
  2574. window.ShowConfigure();
  2575. break;
  2576. case 4:
  2577. window.ShowProperties();
  2578. break;
  2579. case 5:
  2580. showNowPlaying();
  2581. break;
  2582. case 6:
  2583. initList();
  2584. break;
  2585. case 7:
  2586. selectAll();
  2587. break;
  2588. case 8:
  2589. plman.RemovePlaylistSelection(activeList);
  2590. break;
  2591. case 9:
  2592. plman.FlushPlaybackQueue();
  2593. break;
  2594. case 10:
  2595.  
  2596. break;
  2597. // -------------------------------------------------------------- //
  2598. case 20:
  2599. //---> Collapse/Expand
  2600. collapseExpand("collapse");
  2601. displayFocusItem(plman.GetPlaylistFocusItemIndex(activeList));
  2602. break;
  2603. case 21:
  2604. getPlayingGroupCollapseExpand();
  2605. break;
  2606. case 22:
  2607. collapseExpand("expand");
  2608. displayFocusItem(plman.GetPlaylistFocusItemIndex(activeList));
  2609. break;
  2610. case 23:
  2611. autoExpandCollapseGroups = !autoExpandCollapseGroups;
  2612. window.SetProperty("user.Auto Expand/Collapse Groups", autoExpandCollapseGroups);
  2613. autoExpandCollapseGroups && getPlayingGroupCollapseExpand();
  2614. break;
  2615. // -------------------------------------------------------------- //
  2616. case 24:
  2617. enableSkip = !enableSkip;
  2618. window.SetProperty("user.Skip Enable", enableSkip);
  2619. break;
  2620. case 25:
  2621. skipLessThan = 2;
  2622. window.SetProperty("user.Skip Less Than", skipLessThan);
  2623. break;
  2624. case 26:
  2625. skipLessThan = 3;
  2626. window.SetProperty("user.Skip Less Than", skipLessThan);
  2627. break;
  2628. case 27:
  2629. skipLessThan = 4;
  2630. window.SetProperty("user.Skip Less Than", skipLessThan);
  2631. break;
  2632. case 28:
  2633. skipLessThan = 5;
  2634. window.SetProperty("user.Skip Less Than", skipLessThan);
  2635. break;
  2636. // -------------------------------------------------------------- //
  2637. case 30:
  2638. //---> Appearance
  2639. showAlbumArt = !showAlbumArt;
  2640. window.SetProperty("user.Show Album Art", showAlbumArt);
  2641. showAlbumArt && getAlbumArt();
  2642. repaintList();
  2643. break;
  2644. case 31:
  2645. showGroupInfo = !showGroupInfo;
  2646. window.SetProperty("user.Show Group Info", showGroupInfo);
  2647. repaintList();
  2648. break;
  2649. case 32:
  2650. showPlayCount = !showPlayCount;
  2651. window.SetProperty("user.Show Play Count", showPlayCount);
  2652. repaintList();
  2653. break;
  2654. case 33:
  2655. showRating = !showRating;
  2656. window.SetProperty("user.Show Rating", showRating);
  2657. repaintList();
  2658. break;
  2659. case 34:
  2660. showFocusItem = !showFocusItem;
  2661. window.SetProperty("user.Show Focus Item", showFocusItem);
  2662. repaintList();
  2663. break;
  2664. case 35:
  2665. showQueueItem = !showQueueItem;
  2666. window.SetProperty("user.Show Queue Item", showQueueItem);
  2667. repaintList();
  2668. break;
  2669. case 36:
  2670. alternateRowColor = !alternateRowColor;
  2671. window.SetProperty("user.Alternate Row Color", alternateRowColor);
  2672. repaintList();
  2673. break;
  2674. case 37:
  2675. showScrollbar = !showScrollbar;
  2676. window.SetProperty("user.Show Scrollbar", showScrollbar);
  2677. on_size();
  2678. window.Repaint();
  2679. break;
  2680. case 38:
  2681. scrollbarUseWindowsVisualStyle = !scrollbarUseWindowsVisualStyle;
  2682. window.SetProperty("user.Scrollbar Use Windows Visual Style", scrollbarUseWindowsVisualStyle);
  2683. refreshScrollbarStyle();
  2684. break;
  2685. // -------------------------------------------------------------- //
  2686. case 40:
  2687. //---> Sort
  2688. selection ? fb.RunMainMenuCommand("Edit/Selection/Sort/Sort by...") : fb.RunMainMenuCommand("Edit/Sort/Sort by...");
  2689. break;
  2690. case 41:
  2691. plman.SortByFormat(activeList, "", selection ? true : false);
  2692. break;
  2693. case 42:
  2694. selection ? fb.RunMainMenuCommand("Edit/Selection/Sort/Reverse") : fb.RunMainMenuCommand("Edit/Sort/Reverse");
  2695. break;
  2696. case 43:
  2697. plman.SortByFormat(activeList, "%album%", selection ? true : false);
  2698. break;
  2699. case 44:
  2700. plman.SortByFormat(activeList, "%artist%", selection ? true : false);
  2701. break;
  2702. case 45:
  2703. plman.SortByFormat(activeList, "%path%%subsong%", selection ? true : false);
  2704. break;
  2705. case 46:
  2706. plman.SortByFormat(activeList, "%title%", selection ? true : false);
  2707. break;
  2708. case 47:
  2709. plman.SortByFormat(activeList, "%tracknumber%", selection ? true : false);
  2710. break;
  2711. // -------------------------------------------------------------- //
  2712. case 50:
  2713. link("google", metadb);
  2714. break;
  2715. case 51:
  2716. link("googleImages", metadb);
  2717. break;
  2718. case 52:
  2719. link("eCover", metadb);
  2720. break;
  2721. case 53:
  2722. link("wikipedia", metadb);
  2723. break;
  2724. case 54:
  2725. link("youTube", metadb);
  2726. break;
  2727. case 55:
  2728. link("lastFM", metadb);
  2729. break;
  2730. case 56:
  2731. link("discogs", metadb);
  2732. break;
  2733. // -------------------------------------------------------------- //
  2734. case 100:
  2735. fb.RunMainMenuCommand("View/Playlist Manager");
  2736. break;
  2737. case 101:
  2738. fb.CreatePlaylist(playlistCount, "");
  2739. fb.ActivePlaylist = fb.PlaylistCount;
  2740. break;
  2741. case (sendToPlaylistId - 1):
  2742. fb.CreatePlaylist(playlistCount, "");
  2743. plman.InsertPlaylistItems(playlistCount, 0, plman.GetPlaylistSelectedItems(activeList), select = true);
  2744. break;
  2745.  
  2746. }
  2747.  
  2748. for (var i = 0; i != playlistCount; i++) {
  2749. if (id == (playlistId + i)) fb.ActivePlaylist = i; // playlist switch
  2750. }
  2751.  
  2752. for (var i = 0; i < plman.PlaylistCount; i++) {
  2753. if (id == (sendToPlaylistId + i)) {
  2754. plman.ClearPlaylistSelection(i);
  2755. plman.InsertPlaylistItems(i, plman.PlaylistItemCount(i), plman.GetPlaylistSelectedItems(activeList), select = true);
  2756. }
  2757. }
  2758.  
  2759. cpm.Dispose();
  2760. ccmm.Dispose();
  2761. web.Dispose();
  2762. ce.Dispose();
  2763. appear.Dispose();
  2764. sort.Dispose();
  2765. lists.Dispose();
  2766. send.Dispose();
  2767.  
  2768. return true;
  2769. }
Add Comment
Please, Sign In to add comment