Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* *************************************** Helper functions *****************************************
- * Author : r0k and T.P Wang (for functions copied from the documentation file "helpers").
- * Those functions are used by my WSH scripts, feel free to use them in your scripts but don't change
- * them nor rename this file.
- * Please note that if you use those functions, they might be changed in the future to adress bugs
- * or add features. There is no guarantee updates will be backward compatibles. If possible they will
- * be but if you use one of those functions for one of your script it might be a good idea to keep a
- * copy of this file somewhere.
- */
- function RGB(r, g, b) { // (T.P Wang)
- return (0xff000000 | (r << 16) | (g << 8) | (b));
- }
- function RGBA(r, g, b, a) { // (T.P Wang)
- return ((a << 24) | (r << 16) | (g << 8) | (b));
- }
- function setAlpha(color, a) { // (T.P Wang)
- return ((color & 0x00ffffff) | (a << 24));
- }
- function getFont(type) {
- // Retreives font used by other panels (CUI or DUI). Font type is either "item" or "label".
- switch (type) {
- case "item" :
- __DUIflag = 3;
- __CUIflag = 0;
- break;
- case "label" :
- __DUIflag = 1;
- __CUIflag = 1;
- break;
- }
- if (window.InstanceType) { // DUI
- __font = window.GetFontDUI(__DUIflag);
- } else { // CUI
- __font = window.GetFontCUI(__CUIflag);
- }
- return __font;
- }
- function getColor(type) {
- // Retreives color used by other panels (CUI or DUI).
- switch (type) {
- case "text" :
- __DUIflag = 0;
- __CUIflag = 0;
- break;
- case "background" :
- __DUIflag = 1;
- __CUIflag = 3;
- break;
- case "highlight" :
- __DUIflag = 2;
- __CUIflag = 5;
- break;
- case "select" :
- __DUIflag = 3;
- __CUIflag = 4;
- break;
- }
- if(window.InstanceType) { // DUI
- __color = window.GetColorDUI(__DUIflag);
- } else { // CUI
- __color = window.GetColorCUI(__CUIflag);
- }
- return __color;
- }
- function doSplitTitleFormatString(titleFormat) {
- // This function will process a title-format string and split it to return an array of sub-strings.
- // The string is split at typical boudaries between parts of a title format (such as two "%" signs).
- // Usefull for grouping tracks.
- var _titleFormat = titleFormat.toString();
- doPrint("Split TF : "+_titleFormat,"doSplitTitleFormatString");
- doPrint(_titleFormat.length,"doSplitTitleFormatString");
- __tfArray = [];
- do {
- __split1 = (_titleFormat.indexOf("%%")>0) ? _titleFormat.indexOf("%%")+1 : _titleFormat.length;
- __split2 = (_titleFormat.indexOf("%$")>0) ? _titleFormat.indexOf("%$")+1 : _titleFormat.length;
- __split3 = (_titleFormat.indexOf(")%")>0) ? _titleFormat.indexOf(")%")+1: _titleFormat.length;
- __split4 = (_titleFormat.indexOf(")$")>0) ? _titleFormat.indexOf(")$")+1 : _titleFormat.length;
- __split5 = (_titleFormat.indexOf("[")>0) ? _titleFormat.indexOf("[") +1 : _titleFormat.length;
- __splitAt = Math.min(__split1,__split2,__split3,__split4,__split5);
- __extract = _titleFormat.slice(0,__splitAt);
- __tfArray.push(__extract);
- doPrint(__extract,"doSplitTitleFormatString");
- _titleFormat = _titleFormat.slice(__splitAt);
- doPrint(_titleFormat.length,"doSplitTitleFormatString");
- } while (_titleFormat.length>0);
- doPrint(__tfArray.join("|"),"doSplitTitleFormatString");
- return __tfArray;
- }
- function doPrint(message,callerId) {
- // Simple console output. Not very useful. Will probably be removed.
- var __string = $system.scriptName || "Unnamed Script"; __string += " | ";
- __string += callerId || ""; __string += " | ";
- __string += message;
- fb.trace(__string);
- }
- function is_resizing(_callback) {
- // This function should be called from on_size() callback function in main script. It will call
- // a function passed as argument when resizing is done, enabling you to redraw the window after
- // resizing for instance.
- // Note that a delay is required and so the result won't be immediate. If you need to use some
- // output from this function at the start of the script you need some delay in your init process.
- __w1 = window.Width; __h1 = window.Height;
- function check_resizing(_callback) {
- __w2 = window.Width; __h2 = window.Height;
- if (__h2 == __h1 && __w2 == __w1) {
- _callback();
- } else {
- window.SetTimeout(function () {is_resizing(_callback);}, 100);
- }
- }
- window.SetTimeout(function () {check_resizing(_callback);}, 300);
- }
- /* **************************************** Common values *******************************************
- * Stored for conveniance.
- */
- $buttonStates = {normal: 1, hover: 2, down: 3};
- var $default = { // needed in case those values are not passed to object constructors.
- sort : "%album artist%[%date%]%album%[%discnumber%]%tracknumber%",
- query : ".",
- group : "%album artist%%album%"
- };
- Colors = {
- AliceBlue : 0xFFF0F8FF,
- AntiqueWhite : 0xFFFAEBD7,
- Aqua : 0xFF00FFFF,
- Aquamarine : 0xFF7FFFD4,
- Azure : 0xFFF0FFFF,
- Beige : 0xFFF5F5DC,
- Bisque : 0xFFFFE4C4,
- Black : 0xFF000000,
- BlanchedAlmond : 0xFFFFEBCD,
- Blue : 0xFF0000FF,
- BlueViolet : 0xFF8A2BE2,
- Brown : 0xFFA52A2A,
- BurlyWood : 0xFFDEB887,
- CadetBlue : 0xFF5F9EA0,
- Chartreuse : 0xFF7FFF00,
- Chocolate : 0xFFD2691E,
- Coral : 0xFFFF7F50,
- CornflowerBlue : 0xFF6495ED,
- Cornsilk : 0xFFFFF8DC,
- Crimson : 0xFFDC143C,
- Cyan : 0xFF00FFFF,
- DarkBlue : 0xFF00008B,
- DarkCyan : 0xFF008B8B,
- DarkGoldenrod : 0xFFB8860B,
- DarkGray : 0xFFA9A9A9,
- DarkGreen : 0xFF006400,
- DarkKhaki : 0xFFBDB76B,
- DarkMagenta : 0xFF8B008B,
- DarkOliveGreen : 0xFF556B2F,
- DarkOrange : 0xFFFF8C00,
- DarkOrchid : 0xFF9932CC,
- DarkRed : 0xFF8B0000,
- DarkSalmon : 0xFFE9967A,
- DarkSeaGreen : 0xFF8FBC8B,
- DarkSlateBlue : 0xFF483D8B,
- DarkSlateGray : 0xFF2F4F4F,
- DarkTurquoise : 0xFF00CED1,
- DarkViolet : 0xFF9400D3,
- DeepPink : 0xFFFF1493,
- DeepSkyBlue : 0xFF00BFFF,
- DimGray : 0xFF696969,
- DodgerBlue : 0xFF1E90FF,
- Firebrick : 0xFFB22222,
- FloralWhite : 0xFFFFFAF0,
- ForestGreen : 0xFF228B22,
- Fuchsia : 0xFFFF00FF,
- Gainsboro : 0xFFDCDCDC,
- GhostWhite : 0xFFF8F8FF,
- Gold : 0xFFFFD700,
- Goldenrod : 0xFFDAA520,
- Gray : 0xFF808080,
- Green : 0xFF008000,
- GreenYellow : 0xFFADFF2F,
- Honeydew : 0xFFF0FFF0,
- HotPink : 0xFFFF69B4,
- IndianRed : 0xFFCD5C5C,
- Indigo : 0xFF4B0082,
- Ivory : 0xFFFFFFF0,
- Khaki : 0xFFF0E68C,
- Lavender : 0xFFE6E6FA,
- LavenderBlush : 0xFFFFF0F5,
- LawnGreen : 0xFF7CFC00,
- LemonChiffon : 0xFFFFFACD,
- LightBlue : 0xFFADD8E6,
- LightCoral : 0xFFF08080,
- LightCyan : 0xFFE0FFFF,
- LightGoldenrodYellow : 0xFFFAFAD2,
- LightGray : 0xFFD3D3D3,
- LightGreen : 0xFF90EE90,
- LightPink : 0xFFFFB6C1,
- LightSalmon : 0xFFFFA07A,
- LightSeaGreen : 0xFF20B2AA,
- LightSkyBlue : 0xFF87CEFA,
- LightSlateGray : 0xFF778899,
- LightSteelBlue : 0xFFB0C4DE,
- LightYellow : 0xFFFFFFE0,
- Lime : 0xFF00FF00,
- LimeGreen : 0xFF32CD32,
- Linen : 0xFFFAF0E6,
- Magenta : 0xFFFF00FF,
- Maroon : 0xFF800000,
- MediumAquamarine : 0xFF66CDAA,
- MediumBlue : 0xFF0000CD,
- MediumOrchid : 0xFFBA55D3,
- MediumPurple : 0xFF9370DB,
- MediumSeaGreen : 0xFF3CB371,
- MediumSlateBlue : 0xFF7B68EE,
- MediumSpringGreen : 0xFF00FA9A,
- MediumTurquoise : 0xFF48D1CC,
- MediumVioletRed : 0xFFC71585,
- MidnightBlue : 0xFF191970,
- MintCream : 0xFFF5FFFA,
- MistyRose : 0xFFFFE4E1,
- Moccasin : 0xFFFFE4B5,
- NavajoWhite : 0xFFFFDEAD,
- Navy : 0xFF000080,
- OldLace : 0xFFFDF5E6,
- Olive : 0xFF808000,
- OliveDrab : 0xFF6B8E23,
- Orange : 0xFFFFA500,
- OrangeRed : 0xFFFF4500,
- Orchid : 0xFFDA70D6,
- PaleGoldenrod : 0xFFEEE8AA,
- PaleGreen : 0xFF98FB98,
- PaleTurquoise : 0xFFAFEEEE,
- PaleVioletRed : 0xFFDB7093,
- PapayaWhip : 0xFFFFEFD5,
- PeachPuff : 0xFFFFDAB9,
- Peru : 0xFFCD853F,
- Pink : 0xFFFFC0CB,
- Plum : 0xFFDDA0DD,
- PowderBlue : 0xFFB0E0E6,
- Purple : 0xFF800080,
- Red : 0xFFFF0000,
- RosyBrown : 0xFFBC8F8F,
- RoyalBlue : 0xFF4169E1,
- SaddleBrown : 0xFF8B4513,
- Salmon : 0xFFFA8072,
- SandyBrown : 0xFFF4A460,
- SeaGreen : 0xFF2E8B57,
- SeaShell : 0xFFFFF5EE,
- Sienna : 0xFFA0522D,
- Silver : 0xFFC0C0C0,
- SkyBlue : 0xFF87CEEB,
- SlateBlue : 0xFF6A5ACD,
- SlateGray : 0xFF708090,
- Snow : 0xFFFFFAFA,
- SpringGreen : 0xFF00FF7F,
- SteelBlue : 0xFF4682B4,
- Tan : 0xFFD2B48C,
- Teal : 0xFF008080,
- Thistle : 0xFFD8BFD8,
- Tomato : 0xFFFF6347,
- Transparent : 0x00FFFFFF,
- Turquoise : 0xFF40E0D0,
- Violet : 0xFFEE82EE,
- Wheat : 0xFFF5DEB3,
- White : 0xFFFFFFFF,
- WhiteSmoke : 0xFFF5F5F5,
- Yellow : 0xFFFFFF00,
- YellowGreen : 0xFF9ACD32
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement