mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-05 02:55:44 +01:00
Employ dactyl.assert where appropriate in Melodactyl.
This commit is contained in:
@@ -215,10 +215,8 @@ const AutoCommands = Module("autocommands", {
|
|||||||
// TODO: Perhaps this should take -args to pass to the command?
|
// TODO: Perhaps this should take -args to pass to the command?
|
||||||
function (args) {
|
function (args) {
|
||||||
// Vim compatible
|
// Vim compatible
|
||||||
if (args.length == 0) {
|
if (args.length == 0)
|
||||||
dactyl.echomsg("No matching autocommands");
|
return void dactyl.echomsg("No matching autocommands");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [event, url] = args;
|
let [event, url] = args;
|
||||||
let defaultURL = url || buffer.URL;
|
let defaultURL = url || buffer.URL;
|
||||||
|
|||||||
@@ -211,12 +211,8 @@ const Config = Module("config", ConfigBase, {
|
|||||||
"Close a display pane",
|
"Close a display pane",
|
||||||
function (args) {
|
function (args) {
|
||||||
let arg = args.literalArg;
|
let arg = args.literalArg;
|
||||||
|
dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
|
||||||
if (arg in Config.displayPanes)
|
Config.closeDisplayPane(Config.displayPanes[arg]);
|
||||||
Config.closeDisplayPane(Config.displayPanes[arg]);
|
|
||||||
else
|
|
||||||
dactyl.echoerr("E475: Invalid argument: " + arg);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
@@ -229,12 +225,9 @@ const Config = Module("config", ConfigBase, {
|
|||||||
"Open a display pane",
|
"Open a display pane",
|
||||||
function (args) {
|
function (args) {
|
||||||
let arg = args.literalArg;
|
let arg = args.literalArg;
|
||||||
|
dactyl.assert(arg in Config.displayPanes, "E475: Invalid argument: " + arg);
|
||||||
if (arg in Config.displayPanes)
|
// TODO: focus when we have better key handling of these extended modes
|
||||||
Config.openDisplayPane(Config.displayPanes[arg]);
|
Config.openDisplayPane(Config.displayPanes[arg]);
|
||||||
// TODO: focus when we have better key handling of these extended modes
|
|
||||||
else
|
|
||||||
dactyl.echoerr("E475: Invalid argument: " + arg);
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
|
|||||||
@@ -444,17 +444,14 @@ const Player = Module("player", {
|
|||||||
commands.add(["f[ilter]"],
|
commands.add(["f[ilter]"],
|
||||||
"Filter tracks based on keywords {genre/artist/album/track}",
|
"Filter tracks based on keywords {genre/artist/album/track}",
|
||||||
function (args) {
|
function (args) {
|
||||||
let library = LibraryUtils.mainLibrary;
|
|
||||||
let view = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.literalArg);
|
let view = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.literalArg);
|
||||||
|
|
||||||
if (view.length == 0)
|
dactyl.assert(view.length, "No matching tracks");
|
||||||
dactyl.echoerr("No Tracks matching the keywords");
|
|
||||||
else {
|
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
|
||||||
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
|
"chrome://songbird/content/mediapages/filtersPage.xul");
|
||||||
"chrome://songbird/content/mediapages/filtersPage.xul");
|
// TODO: make this this.focusTrack work ?
|
||||||
// TODO: make this this.focusTrack work ?
|
this.focusTrack(view.getItemByIndex(0));
|
||||||
this.focusTrack(view.getItemByIndex(0));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
@@ -469,16 +466,13 @@ const Player = Module("player", {
|
|||||||
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
// load the selected playlist/smart playlist
|
// load the selected playlist/smart playlist
|
||||||
let playlists = player.getPlaylists();
|
for ([, playlist] in Iterator(player.getPlaylists())) {
|
||||||
|
if (util.compareIgnoreCase(arg, playlist.name) == 0) {
|
||||||
for ([i, list] in Iterator(playlists)) {
|
SBGetBrowser().loadMediaList(playlist);
|
||||||
if (util.compareIgnoreCase(arg, list.name) == 0) {
|
|
||||||
SBGetBrowser().loadMediaList(playlists[i]);
|
|
||||||
this.focusTrack(this._currentView.getItemByIndex(0));
|
this.focusTrack(this._currentView.getItemByIndex(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dactyl.echoerr("E475: Invalid argument: " + arg);
|
dactyl.echoerr("E475: Invalid argument: " + arg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -519,8 +513,8 @@ const Player = Module("player", {
|
|||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
|
|
||||||
// intentionally supports 999:99:99
|
// intentionally supports 999:99:99
|
||||||
if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
|
dactyl.assert(/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg),
|
||||||
return void dactyl.echoerr("E475: Invalid argument: " + arg);
|
"E475: Invalid argument: " + arg);
|
||||||
|
|
||||||
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
|
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",
|
"Change the current media view",
|
||||||
function (args) {
|
function (args) {
|
||||||
// FIXME: is this a SB restriction? --djk
|
// FIXME: is this a SB restriction? --djk
|
||||||
if (!SBGetBrowser().currentMediaPage)
|
dactyl.assert(SBGetBrowser().currentMediaPage,
|
||||||
return void dactyl.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
|
"Exxx: Can only set the media view from the media tab"); // XXX
|
||||||
|
|
||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
let pages = player.getMediaPages();
|
for ([, page] in Iterator(player.getMediaPages())) {
|
||||||
|
|
||||||
for ([, page] in Iterator(pages)) {
|
|
||||||
if (util.compareIgnoreCase(arg, page.contentTitle) == 0) {
|
if (util.compareIgnoreCase(arg, page.contentTitle) == 0) {
|
||||||
player.loadMediaPage(page, SBGetBrowser().currentMediaListView.mediaList,
|
player.loadMediaPage(page, SBGetBrowser().currentMediaListView.mediaList,
|
||||||
SBGetBrowser().currentMediaListView);
|
SBGetBrowser().currentMediaListView);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dactyl.echoerr("E475: Invalid argument: " + arg);
|
dactyl.echoerr("E475: Invalid argument: " + arg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -628,8 +619,7 @@ const Player = Module("player", {
|
|||||||
function (args) {
|
function (args) {
|
||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
|
|
||||||
if (!/^[+-]?\d+$/.test(arg))
|
dactyl.assert(/^[+-]?\d+$/.test(arg), "E488: Trailing characters");
|
||||||
return void dactyl.echoerr("E488: Trailing characters");
|
|
||||||
|
|
||||||
let level = parseInt(arg, 10) / 100;
|
let level = parseInt(arg, 10) / 100;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user