mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 10:57:58 +01:00
Formatting fixes.
This commit is contained in:
@@ -42,7 +42,7 @@ function Buffer() //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// FIXME: This doesn't belong here.
|
// FIXME: This doesn't belong here.
|
||||||
let mainWindowID = config.mainWindowID || "mainplayer";
|
let mainWindowID = config.mainWindowID || "mainplayer";
|
||||||
|
|
||||||
let fontSize = util.computedStyle(document.getElementById(mainWindowID)).fontSize;
|
let fontSize = util.computedStyle(document.getElementById(mainWindowID)).fontSize;
|
||||||
@@ -215,12 +215,12 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, ["<C-c>"],
|
mappings.add(myModes, ["<C-c>"],
|
||||||
"Stop loading",
|
"Stop loading",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if(config.name == "Xulmus")
|
if(config.name == "Xulmus")
|
||||||
getBrowser().mCurrentBrowser.stop();
|
getBrowser().mCurrentBrowser.stop();
|
||||||
else
|
else
|
||||||
window.BrowserStop();
|
window.BrowserStop();
|
||||||
});
|
});
|
||||||
|
|
||||||
// scrolling
|
// scrolling
|
||||||
@@ -603,12 +603,12 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["st[op]"],
|
commands.add(["st[op]"],
|
||||||
"Stop loading",
|
"Stop loading",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if(config.name == "Xulmus")
|
if (config.name == "Xulmus")
|
||||||
getBrowser().mCurrentBrowser.stop();
|
getBrowser().mCurrentBrowser.stop();
|
||||||
else
|
else
|
||||||
window.BrowserStop();
|
window.BrowserStop();
|
||||||
},
|
},
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
|
|||||||
@@ -1381,7 +1381,7 @@ function Completion() //{{{
|
|||||||
completion.urls(context, tags);
|
completion.urls(context, tags);
|
||||||
},
|
},
|
||||||
|
|
||||||
songCompletion: function songCompletion(context, args)
|
songCompletion: function songCompletion(context, args)
|
||||||
{
|
{
|
||||||
if (args.completeArg == 0)
|
if (args.completeArg == 0)
|
||||||
context.completions = getArtists();
|
context.completions = getArtists();
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ function Events() //{{{
|
|||||||
// return true when load successful, or false otherwise
|
// return true when load successful, or false otherwise
|
||||||
function waitForPageLoaded() events.waitForPageLoad();
|
function waitForPageLoaded() events.waitForPageLoad();
|
||||||
|
|
||||||
// load all macros inside ~/.xulmus/macros/
|
// load all macros
|
||||||
// setTimeout needed since io. is loaded after events.
|
// setTimeout needed since io. is loaded after events.
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
try
|
try
|
||||||
@@ -1037,8 +1037,8 @@ function Events() //{{{
|
|||||||
// (i.e., cntrl codes 27--31)
|
// (i.e., cntrl codes 27--31)
|
||||||
// ---
|
// ---
|
||||||
// For more information, see:
|
// For more information, see:
|
||||||
// [*] Vimp FAQ: http://xulmus.org/trac/wiki/Xulmus/FAQ#WhydoesntC-workforEscMacOSX
|
// [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
|
||||||
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/xulmus/2008-May/001548.html
|
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
|
||||||
// [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
|
// [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
|
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
|
||||||
// [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
|
// [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
|
||||||
@@ -1226,10 +1226,10 @@ function Events() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.name == "Xulmus")
|
if (config.name == "Xulmus")
|
||||||
{
|
{
|
||||||
// Switch to -- PLAYER -- mode for Songbird Media Player.
|
// Switch to -- PLAYER -- mode for Songbird Media Player.
|
||||||
if(config.isPlayerWindow)
|
if (config.isPlayerWindow)
|
||||||
{
|
{
|
||||||
liberator.mode = modes.PLAYER;
|
liberator.mode = modes.PLAYER;
|
||||||
}
|
}
|
||||||
@@ -1437,7 +1437,6 @@ function Events() //{{{
|
|||||||
// also fixes key navigation in combo boxes, submitting forms, etc.
|
// also fixes key navigation in combo boxes, submitting forms, etc.
|
||||||
// FIXME: breaks iabbr for now --mst
|
// FIXME: breaks iabbr for now --mst
|
||||||
if (((config.name == "Xulmus" || config.name == "Vimperator") && liberator.mode == modes.NORMAL || liberator.mode == modes.INSERT))
|
if (((config.name == "Xulmus" || config.name == "Vimperator") && liberator.mode == modes.NORMAL || liberator.mode == modes.INSERT))
|
||||||
|
|
||||||
{
|
{
|
||||||
if (key == "<Return>")
|
if (key == "<Return>")
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ const liberator = (function () //{{{
|
|||||||
let nError = 0;
|
let nError = 0;
|
||||||
function loadModule(name, func)
|
function loadModule(name, func)
|
||||||
{
|
{
|
||||||
let message = "Loading module " + name + "...";
|
let message = "Loading module " + name + "...";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
liberator.log(message, 0);
|
liberator.log(message, 0);
|
||||||
@@ -82,10 +82,10 @@ const liberator = (function () //{{{
|
|||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
if (nError++ == 0)
|
if (nError++ == 0)
|
||||||
liberator.dump("Error loading module - "+ name + "..");
|
window.toJavaScriptConsole();
|
||||||
liberator.dump(e);
|
liberator.dump("Error loading module - "+ name + "..");
|
||||||
liberator.dump(e.stack);
|
liberator.dump(e);
|
||||||
window.toJavaScriptConsole();
|
liberator.dump(e.stack);
|
||||||
liberator.reportError(e);
|
liberator.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1219,6 +1219,8 @@ const liberator = (function () //{{{
|
|||||||
startup: function ()
|
startup: function ()
|
||||||
{
|
{
|
||||||
let start = Date.now();
|
let start = Date.now();
|
||||||
|
liberator.log("Initializing liberator object...", 0);
|
||||||
|
|
||||||
config.features = config.features || [];
|
config.features = config.features || [];
|
||||||
config.features.push(getPlatformFeature());
|
config.features.push(getPlatformFeature());
|
||||||
config.defaults = config.defaults || {};
|
config.defaults = config.defaults || {};
|
||||||
@@ -1227,7 +1229,7 @@ const liberator = (function () //{{{
|
|||||||
config.mailModes = config.mailModes || [modes.NORMAL];
|
config.mailModes = config.mailModes || [modes.NORMAL];
|
||||||
// TODO: suitable defaults?
|
// TODO: suitable defaults?
|
||||||
//config.mainWidget
|
//config.mainWidget
|
||||||
//config.mainWindowID
|
//config.mainWindowID
|
||||||
//config.visualbellWindow
|
//config.visualbellWindow
|
||||||
//config.styleableChrome
|
//config.styleableChrome
|
||||||
config.autocommands = config.autocommands || [];
|
config.autocommands = config.autocommands || [];
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function Services()
|
|||||||
self.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
self.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
||||||
self.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
self.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
||||||
self.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", Ci.nsINavBookmarksService);
|
self.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", Ci.nsINavBookmarksService);
|
||||||
|
|
||||||
self.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
self.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
||||||
self.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
self.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
||||||
self.addClass("process", "@mozilla.org/process/util;1", Ci.nsIProcess);
|
self.addClass("process", "@mozilla.org/process/util;1", Ci.nsIProcess);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ function Tabs() //{{{
|
|||||||
/*
|
/*
|
||||||
if (config.name == "Xulmus")
|
if (config.name == "Xulmus")
|
||||||
getBrowser()._strip.getElementsByClassName(
|
getBrowser()._strip.getElementsByClassName(
|
||||||
*/
|
*/
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
var startHints = false; // whether we're waiting to start hints mode
|
var startHints = false; // whether we're waiting to start hints mode
|
||||||
var lastSubstring = "";
|
var lastSubstring = "";
|
||||||
|
|
||||||
// the containing box for the promptWidget and commandWidget
|
// the containing box for the promptWidget and commandWidget
|
||||||
const commandlineWidget = document.getElementById("liberator-commandline");
|
const commandlineWidget = document.getElementById("liberator-commandline");
|
||||||
// the prompt for the current command, for example : or /. Can be blank
|
// the prompt for the current command, for example : or /. Can be blank
|
||||||
@@ -577,7 +577,7 @@ function CommandLine() //{{{
|
|||||||
const commandWidget = document.getElementById("liberator-commandline-command");
|
const commandWidget = document.getElementById("liberator-commandline-command");
|
||||||
|
|
||||||
const messageBox = document.getElementById("liberator-message");
|
const messageBox = document.getElementById("liberator-message");
|
||||||
|
|
||||||
commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||||
messageBox.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
messageBox.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ const util = { //{{{
|
|||||||
*/
|
*/
|
||||||
computedStyle: function computedStyle(node)
|
computedStyle: function computedStyle(node)
|
||||||
{
|
{
|
||||||
while (node instanceof Text && node.parentNode)
|
while (node instanceof Text && node.parentNode)
|
||||||
node = node.parentNode;
|
node = node.parentNode;
|
||||||
return node.ownerDocument.defaultView.getComputedStyle(node, null);
|
return node.ownerDocument.defaultView.getComputedStyle(node, null);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/bin/dash
|
#!/bin/dash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
||||||
top=$(pwd)
|
top=$(pwd)
|
||||||
jar=$1
|
jar=$1
|
||||||
bases=$2
|
bases=$2
|
||||||
@@ -15,7 +14,7 @@ stage="$top/${jar%.*}"
|
|||||||
mkdir -p $stage
|
mkdir -p $stage
|
||||||
|
|
||||||
getfiles () {
|
getfiles () {
|
||||||
filter="\.($(echo $1 | tr ' ' '|'))$"; shift
|
filter="\.($(echo $1 | tr ' ' '|'))$"; shift
|
||||||
find "$@" -not -path '*CVS*' 2>/dev/null | grep -E "$filter" || true
|
find "$@" -not -path '*CVS*' 2>/dev/null | grep -E "$filter" || true
|
||||||
}
|
}
|
||||||
copytext () {
|
copytext () {
|
||||||
@@ -31,12 +30,12 @@ do
|
|||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
cd $base
|
cd $base
|
||||||
[ ${jar##*.} = jar ] && stage="$stage/${base##*/}"
|
[ ${jar##*.} = jar ] && stage="$stage/${base##*/}"
|
||||||
for dir in $dirs
|
for dir in $dirs
|
||||||
do
|
do
|
||||||
for f in $(getfiles "$bin" "$dir")
|
for f in $(getfiles "$bin" "$dir")
|
||||||
do
|
do
|
||||||
mkdir -p "$stage/${f%/*}"
|
mkdir -p "$stage/${f%/*}"
|
||||||
cp $f "$stage/$f"
|
cp $f "$stage/$f"
|
||||||
done
|
done
|
||||||
for f in $(getfiles "$text" "$dir")
|
for f in $(getfiles "$text" "$dir")
|
||||||
@@ -52,7 +51,7 @@ do
|
|||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
cd $stage
|
cd $stage
|
||||||
zip -r "$top/$jar" *
|
zip -r "$top/$jar" *
|
||||||
cd -
|
cd -
|
||||||
rm -rf "$stage"
|
rm -rf "$stage"
|
||||||
|
|||||||
@@ -2,218 +2,210 @@
|
|||||||
|
|
||||||
var artists = getArtistsArray();
|
var artists = getArtistsArray();
|
||||||
|
|
||||||
function Player()
|
function Player() // {{{
|
||||||
{
|
{
|
||||||
|
// Get the focus to the visible playlist first
|
||||||
// Get the focus to the visible playlist first
|
//window._SBShowMainLibrary();
|
||||||
//window._SBShowMainLibrary();
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
|
||||||
["x"], "Play Track",
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
gMM.sequencer.play();
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
|
||||||
["z"], "Previous Track",
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
gSongbirdWindowController.doCommand("cmd_control_previous");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["c"], "Pause/Unpause Track",
|
["x"], "Play Track",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
gMM.sequencer.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
|
||||||
["b"], "Next Track",
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
gSongbirdWindowController.doCommand("cmd_control_next");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
|
||||||
["v"], "Stop Track",
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
gMM.sequencer.stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["z"], "Previous Track",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
gSongbirdWindowController.doCommand("cmd_control_previous");
|
||||||
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["l"], "Play Media",
|
["c"], "Pause/Unpause Track",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
commandline.open(":","playmedia ", modes.EX);
|
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["s"], "Toggle Shuffle",
|
["b"], "Next Track",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
|
gSongbirdWindowController.doCommand("cmd_control_next");
|
||||||
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
|
});
|
||||||
else
|
|
||||||
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["r"], "Toggle Repeat",
|
["v"], "Stop Track",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
switch(gMM.sequencer.repeatMode)
|
gMM.sequencer.stop();
|
||||||
{
|
});
|
||||||
case gMM.sequencer.MODE_REPEAT_NONE:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
|
|
||||||
break;
|
|
||||||
case gMM.sequencer.MODE_REPEAT_ONE:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
|
|
||||||
break;
|
|
||||||
case gMM.sequencer.MODE_REPEAT_ALL:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
commands.add(["playmedia"],
|
mappings.add([modes.PLAYER],
|
||||||
"PLay Media",
|
["l"], "Play Media",
|
||||||
function(args)
|
function ()
|
||||||
{
|
{
|
||||||
//Store the old view
|
commandline.open(":","playmedia ", modes.EX);
|
||||||
//var prev_view = gMM.status.view;
|
});
|
||||||
var library = LibraryUtils.mainLibrary;
|
|
||||||
var mainView = library.createView();
|
|
||||||
var sqncr = gMM.sequencer;
|
|
||||||
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
|
||||||
|
|
||||||
//args
|
|
||||||
|
|
||||||
if (args.length == 1){
|
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
|
||||||
}
|
|
||||||
else if (args.length == 2){
|
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
|
||||||
}
|
|
||||||
else if (args.length == 3){
|
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
|
||||||
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0,Ci.sbIMediaItem)));
|
mappings.add([modes.PLAYER],
|
||||||
|
["s"], "Toggle Shuffle",
|
||||||
|
function ()
|
||||||
},
|
{
|
||||||
{
|
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
|
||||||
completer: function(context, args) completion.songCompletion(context, args)
|
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
|
||||||
});
|
else
|
||||||
|
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
mappings.add([modes.PLAYER],
|
||||||
|
["r"], "Toggle Repeat",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
switch (gMM.sequencer.repeatMode)
|
||||||
|
{
|
||||||
|
case gMM.sequencer.MODE_REPEAT_NONE:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
|
||||||
|
break;
|
||||||
|
case gMM.sequencer.MODE_REPEAT_ONE:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
|
||||||
|
break;
|
||||||
|
case gMM.sequencer.MODE_REPEAT_ALL:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.add(["playmedia"],
|
||||||
|
"Play Media",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
//Store the old view
|
||||||
|
//var prev_view = gMM.status.view;
|
||||||
|
var library = LibraryUtils.mainLibrary;
|
||||||
|
var mainView = library.createView();
|
||||||
|
var sqncr = gMM.sequencer;
|
||||||
|
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||||
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
|
|
||||||
|
//args
|
||||||
|
if (args.length == 1){
|
||||||
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
|
}
|
||||||
|
else if (args.length == 2){
|
||||||
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
|
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||||
|
}
|
||||||
|
else if (args.length == 3){
|
||||||
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
|
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||||
|
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0,Ci.sbIMediaItem)));
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (context, args) completion.songCompletion(context, args)
|
||||||
|
});
|
||||||
|
} // }}}
|
||||||
|
|
||||||
function getArtists()
|
function getArtists()
|
||||||
{
|
{
|
||||||
return this.artists;
|
return this.artists;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArtistsArray()
|
function getArtistsArray()
|
||||||
{
|
{
|
||||||
|
var list = LibraryUtils.mainLibrary;
|
||||||
var list = LibraryUtils.mainLibrary;
|
|
||||||
|
// Create an enumeration listener to count each item
|
||||||
// Create an enumeration listener to count each item
|
var listener = {
|
||||||
var listener = {
|
count: 0,
|
||||||
count: 0,
|
onEnumerationBegin: function (aMediaList) {
|
||||||
onEnumerationBegin: function(aMediaList) {
|
this.count = 0;
|
||||||
this.count = 0;
|
},
|
||||||
},
|
onEnumeratedItem: function (aMediaList, aMediaItem) {
|
||||||
onEnumeratedItem: function(aMediaList, aMediaItem) {
|
this.count++;
|
||||||
this.count++;
|
},
|
||||||
},
|
onEnumerationEnd: function (aMediaList, aStatusCode) {}
|
||||||
onEnumerationEnd: function(aMediaList, aStatusCode) {}
|
};
|
||||||
};
|
|
||||||
|
var artistCounts = {};
|
||||||
var artistCounts = {};
|
var artists = list.getDistinctValuesForProperty(SBProperties.artistName);
|
||||||
var artists = list.getDistinctValuesForProperty(SBProperties.artistName);
|
var artist;
|
||||||
var artist;
|
var artistArray = [];
|
||||||
var artistArray = [];
|
var i = 0;
|
||||||
var i=0;
|
// Count the number of media items for each distinct artist
|
||||||
// Count the number of media items for each distinct artist
|
while (artists.hasMore()) {
|
||||||
while (artists.hasMore()) {
|
artist = artists.getNext();
|
||||||
artist = artists.getNext();
|
artistArray[i] = [artist,artist];
|
||||||
artistArray[i] = [artist,artist];
|
list.enumerateItemsByProperty(SBProperties.artistName,
|
||||||
list.enumerateItemsByProperty(SBProperties.artistName,
|
artist,
|
||||||
artist,
|
listener,
|
||||||
listener,
|
Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
|
||||||
Ci.sbIMediaList.ENUMERATIONTYPE_LOCKING);
|
artistCounts[artist] = listener.count;
|
||||||
artistCounts[artist] = listener.count;
|
i++;
|
||||||
i++;
|
}
|
||||||
}
|
|
||||||
|
//liberator.dump("Count : "+artistCounts.toSource());
|
||||||
//liberator.dump("Count : "+artistCounts.toSource());
|
return artistArray;
|
||||||
return artistArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlbums(artist)
|
function getAlbums(artist)
|
||||||
{
|
{
|
||||||
var list = LibraryUtils.mainLibrary;
|
var list = LibraryUtils.mainLibrary;
|
||||||
var albumArray = [];
|
var albumArray = [];
|
||||||
var items = list.getItemsByProperty(SBProperties.artistName, artist).enumerate();
|
var items = list.getItemsByProperty(SBProperties.artistName, artist).enumerate();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
while(items.hasMoreElements()) {
|
while (items.hasMoreElements()) {
|
||||||
album = items.getNext().getProperty(SBProperties.albumName);
|
album = items.getNext().getProperty(SBProperties.albumName);
|
||||||
albumArray[i] = [album, album];
|
albumArray[i] = [album, album];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeDuplicateElement(albumArray);
|
return removeDuplicateElement(albumArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTracks(artist,album)
|
function getTracks(artist,album)
|
||||||
{
|
{
|
||||||
var list = LibraryUtils.mainLibrary;
|
var list = LibraryUtils.mainLibrary;
|
||||||
var tracksArray = [];
|
var tracksArray = [];
|
||||||
var pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
var pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
pa.appendProperty(SBProperties.artistName,artist.toString());
|
|
||||||
pa.appendProperty(SBProperties.albumName,album.toString());
|
|
||||||
var items = list.getItemsByProperties(pa).enumerate();
|
|
||||||
|
|
||||||
while(items.hasMoreElements()) {
|
pa.appendProperty(SBProperties.artistName,artist.toString());
|
||||||
track = items.getNext().getProperty(SBProperties.trackName);
|
pa.appendProperty(SBProperties.albumName,album.toString());
|
||||||
tracksArray[i] = [track, track];
|
var items = list.getItemsByProperties(pa).enumerate();
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tracksArray;
|
while (items.hasMoreElements()) {
|
||||||
|
track = items.getNext().getProperty(SBProperties.trackName);
|
||||||
|
tracksArray[i] = [track, track];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tracksArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function removeDuplicateElement(arrayName)
|
function removeDuplicateElement(arrayName)
|
||||||
{
|
{
|
||||||
var newArray=new Array();
|
var newArray = new Array();
|
||||||
label:for(var i=0; i<arrayName.length;i++ )
|
label:for (var i = 0; i < arrayName.length; i++)
|
||||||
{
|
{
|
||||||
for(var j=0; j<newArray.length;j++ )
|
for (var j = 0; j < newArray.length; j++)
|
||||||
{
|
{
|
||||||
if(newArray[j].toString()==arrayName[i].toString())
|
if (newArray[j].toString() == arrayName[i].toString())
|
||||||
continue label;
|
continue label;
|
||||||
}
|
}
|
||||||
newArray[newArray.length] = arrayName[i];
|
newArray[newArray.length] = arrayName[i];
|
||||||
}
|
}
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user