summaryrefslogtreecommitdiff
path: root/melodactyl/content
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2010-10-21 15:25:54 +1100
committerDoug Kearns <dougkearns@gmail.com>2010-10-21 15:25:54 +1100
commit48dd94773e5634d0e4d3ae9073b16cb3f7e2a09b (patch)
treee970d9520b5b0628b29246cc7b963d2f3a5326e6 /melodactyl/content
parentd196061b16bdab42fac16be863b55f3a683ada78 (diff)
downloadpentadactyl-48dd94773e5634d0e4d3ae9073b16cb3f7e2a09b.tar.gz
Employ dactyl.assert where appropriate in Melodactyl.
Diffstat (limited to 'melodactyl/content')
-rw-r--r--melodactyl/content/config.js17
-rw-r--r--melodactyl/content/player.js40
2 files changed, 20 insertions, 37 deletions
diff --git a/melodactyl/content/config.js b/melodactyl/content/config.js
index 15a6fab6..976a2b18 100644
--- a/melodactyl/content/config.js
+++ b/melodactyl/content/config.js
@@ -211,12 +211,8 @@ const Config = Module("config", ConfigBase, {
"Close a display pane",
function (args) {
let arg = args.literalArg;
-
- if (arg in Config.displayPanes)
- Config.closeDisplayPane(Config.displayPanes[arg]);
- else
- dactyl.echoerr("E475: Invalid argument: " + arg);
-
+ dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
+ Config.closeDisplayPane(Config.displayPanes[arg]);
},
{
argCount: "1",
@@ -229,12 +225,9 @@ const Config = Module("config", ConfigBase, {
"Open a display pane",
function (args) {
let arg = args.literalArg;
-
- if (arg in Config.displayPanes)
- Config.openDisplayPane(Config.displayPanes[arg]);
- // TODO: focus when we have better key handling of these extended modes
- else
- dactyl.echoerr("E475: Invalid argument: " + arg);
+ dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
+ // TODO: focus when we have better key handling of these extended modes
+ Config.openDisplayPane(Config.displayPanes[arg]);
},
{
argCount: "1",
diff --git a/melodactyl/content/player.js b/melodactyl/content/player.js
index 6349ebd6..84bbd876 100644
--- a/melodactyl/content/player.js
+++ b/melodactyl/content/player.js
@@ -444,17 +444,14 @@ const Player = Module("player", {
commands.add(["f[ilter]"],
"Filter tracks based on keywords {genre/artist/album/track}",
function (args) {
- let library = LibraryUtils.mainLibrary;
let view = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.literalArg);
- if (view.length == 0)
- dactyl.echoerr("No Tracks matching the keywords");
- else {
- SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
- "chrome://songbird/content/mediapages/filtersPage.xul");
- // TODO: make this this.focusTrack work ?
- this.focusTrack(view.getItemByIndex(0));
- }
+ dactyl.assert(view.length, "No matching tracks");
+
+ SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
+ "chrome://songbird/content/mediapages/filtersPage.xul");
+ // TODO: make this this.focusTrack work ?
+ this.focusTrack(view.getItemByIndex(0));
},
{
argCount: "1",
@@ -469,16 +466,13 @@ const Player = Module("player", {
if (arg) {
// load the selected playlist/smart playlist
- let playlists = player.getPlaylists();
-
- for ([i, list] in Iterator(playlists)) {
- if (util.compareIgnoreCase(arg, list.name) == 0) {
- SBGetBrowser().loadMediaList(playlists[i]);
+ for ([, playlist] in Iterator(player.getPlaylists())) {
+ if (util.compareIgnoreCase(arg, playlist.name) == 0) {
+ SBGetBrowser().loadMediaList(playlist);
this.focusTrack(this._currentView.getItemByIndex(0));
return;
}
}
-
dactyl.echoerr("E475: Invalid argument: " + arg);
}
else {
@@ -519,8 +513,8 @@ const Player = Module("player", {
let arg = args[0];
// intentionally supports 999:99:99
- if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
- return void dactyl.echoerr("E475: Invalid argument: " + arg);
+ dactyl.assert(/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg),
+ "E475: Invalid argument: " + arg);
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
@@ -548,22 +542,19 @@ const Player = Module("player", {
"Change the current media view",
function (args) {
// FIXME: is this a SB restriction? --djk
- if (!SBGetBrowser().currentMediaPage)
- return void dactyl.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
+ dactyl.assert(SBGetBrowser().currentMediaPage,
+ "Exxx: Can only set the media view from the media tab"); // XXX
let arg = args[0];
if (arg) {
- let pages = player.getMediaPages();
-
- for ([, page] in Iterator(pages)) {
+ for ([, page] in Iterator(player.getMediaPages())) {
if (util.compareIgnoreCase(arg, page.contentTitle) == 0) {
player.loadMediaPage(page, SBGetBrowser().currentMediaListView.mediaList,
SBGetBrowser().currentMediaListView);
return;
}
}
-
dactyl.echoerr("E475: Invalid argument: " + arg);
}
},
@@ -628,8 +619,7 @@ const Player = Module("player", {
function (args) {
let arg = args[0];
- if (!/^[+-]?\d+$/.test(arg))
- return void dactyl.echoerr("E488: Trailing characters");
+ dactyl.assert(/^[+-]?\d+$/.test(arg), "E488: Trailing characters");
let level = parseInt(arg, 10) / 100;