mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-03 10:45:48 +01:00
Replace removeDuplicateElement with use of util.Array.uniq.
This commit is contained in:
@@ -4,9 +4,17 @@ var artists = getArtistsArray();
|
|||||||
|
|
||||||
function Player() // {{{
|
function Player() // {{{
|
||||||
{
|
{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// Get the focus to the visible playlist first
|
// Get the focus to the visible playlist first
|
||||||
//window._SBShowMainLibrary();
|
//window._SBShowMainLibrary();
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["x"], "Play Track",
|
["x"], "Play Track",
|
||||||
function ()
|
function ()
|
||||||
@@ -46,7 +54,7 @@ function Player() // {{{
|
|||||||
["l"], "Play Media",
|
["l"], "Play Media",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
commandline.open(":","playmedia ", modes.EX);
|
commandline.open(":", "playmedia ", modes.EX);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
@@ -80,6 +88,10 @@ function Player() // {{{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
commands.add(["playmedia"],
|
commands.add(["playmedia"],
|
||||||
"Play Media",
|
"Play Media",
|
||||||
function (args)
|
function (args)
|
||||||
@@ -90,17 +102,20 @@ function Player() // {{{
|
|||||||
var mainView = library.createView();
|
var mainView = library.createView();
|
||||||
var sqncr = gMM.sequencer;
|
var sqncr = gMM.sequencer;
|
||||||
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
|
|
||||||
//args
|
//args
|
||||||
if (args.length == 1){
|
if (args.length == 1)
|
||||||
|
{
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
}
|
}
|
||||||
else if (args.length == 2){
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||||
}
|
}
|
||||||
else if (args.length == 3){
|
else if (args.length == 3)
|
||||||
|
{
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||||
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
||||||
@@ -111,6 +126,12 @@ function Player() // {{{
|
|||||||
{
|
{
|
||||||
completer: function (context, args) completion.song(context, args)
|
completer: function (context, args) completion.song(context, args)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
//}}}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
function getArtists()
|
function getArtists()
|
||||||
@@ -168,7 +189,7 @@ function getAlbums(artist)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeDuplicateElement(albumArray);
|
return util.Array.uniq(albumArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTracks(artist,album)
|
function getTracks(artist,album)
|
||||||
@@ -176,7 +197,7 @@ 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.artistName,artist.toString());
|
||||||
@@ -192,20 +213,4 @@ function getTracks(artist,album)
|
|||||||
return tracksArray;
|
return tracksArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function removeDuplicateElement(arrayName)
|
|
||||||
{
|
|
||||||
var newArray = new Array();
|
|
||||||
label:for (var i = 0; i < arrayName.length; i++)
|
|
||||||
{
|
|
||||||
for (var j = 0; j < newArray.length; j++)
|
|
||||||
{
|
|
||||||
if (newArray[j].toString() == arrayName[i].toString())
|
|
||||||
continue label;
|
|
||||||
}
|
|
||||||
newArray[newArray.length] = arrayName[i];
|
|
||||||
}
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user