mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-17 18:23:33 +01:00
Change multiline error message guard clauses to single line formatting.
Also apply similar formattng fixes to conditional blocks as per standard.
This commit is contained in:
@@ -465,9 +465,7 @@ function Bookmarks() //{{{
|
||||
|
||||
let count = this.remove(url);
|
||||
if (count > 0)
|
||||
{
|
||||
commandline.echo("Removed bookmark: " + url, commandline.HL_NORMAL, commandline.FORCE_SINGLELINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
let title = buffer.title || url;
|
||||
@@ -622,9 +620,7 @@ function Bookmarks() //{{{
|
||||
param = aURL.substr(offset + 1);
|
||||
}
|
||||
if (!aPostDataRef)
|
||||
{
|
||||
aPostDataRef = {};
|
||||
}
|
||||
var engine = searchService.getEngineByAlias(keyword);
|
||||
if (engine)
|
||||
{
|
||||
@@ -634,23 +630,17 @@ function Bookmarks() //{{{
|
||||
}
|
||||
[shortcutURL, aPostDataRef.value] = PlacesUtils.getURLAndPostDataForKeyword(keyword);
|
||||
if (!shortcutURL)
|
||||
{
|
||||
return aURL;
|
||||
}
|
||||
var postData = "";
|
||||
if (aPostDataRef.value)
|
||||
{
|
||||
postData = unescape(aPostDataRef.value);
|
||||
}
|
||||
if (/%s/i.test(shortcutURL) || /%s/i.test(postData))
|
||||
{
|
||||
var charset = "";
|
||||
const re = /^(.*)\&mozcharset=([a-zA-Z][_\-a-zA-Z0-9]+)\s*$/;
|
||||
var matches = shortcutURL.match(re);
|
||||
if (matches)
|
||||
{
|
||||
[, shortcutURL, charset] = matches;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
@@ -660,21 +650,19 @@ function Bookmarks() //{{{
|
||||
}
|
||||
var encodedParam = "";
|
||||
if (charset)
|
||||
{
|
||||
encodedParam = escape(convertFromUnicode(charset, param));
|
||||
} else {
|
||||
else
|
||||
encodedParam = encodeURIComponent(param);
|
||||
}
|
||||
shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
|
||||
if (/%s/i.test(postData))
|
||||
{
|
||||
aPostDataRef.value = getPostDataStream(postData, param, encodedParam, "application/x-www-form-urlencoded");
|
||||
}
|
||||
} else if (param) {
|
||||
}
|
||||
else if (param)
|
||||
{
|
||||
aPostDataRef.value = null;
|
||||
return aURL;
|
||||
}
|
||||
return shortcutURL;
|
||||
return shortcutURL;
|
||||
}
|
||||
|
||||
url = getShortcutOrURI(searchString, postData);
|
||||
@@ -762,9 +750,7 @@ function History() //{{{
|
||||
let url = args.literalArg;
|
||||
|
||||
if (args.bang)
|
||||
{
|
||||
history.goToStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (url)
|
||||
@@ -781,9 +767,7 @@ function History() //{{{
|
||||
liberator.echoerr("Exxx: URL not found in history");
|
||||
}
|
||||
else
|
||||
{
|
||||
history.stepTo(-Math.max(args.count, 1));
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -808,9 +792,7 @@ function History() //{{{
|
||||
let url = args.literalArg;
|
||||
|
||||
if (args.bang)
|
||||
{
|
||||
history.goToEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (url)
|
||||
@@ -827,9 +809,7 @@ function History() //{{{
|
||||
liberator.echoerr("Exxx: URL not found in history");
|
||||
}
|
||||
else
|
||||
{
|
||||
history.stepTo(Math.max(args.count, 1));
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1006,16 +986,10 @@ function QuickMarks() //{{{
|
||||
{
|
||||
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
||||
if (!args.bang && !args.string)
|
||||
{
|
||||
liberator.echoerr("E471: Argument required");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E471: Argument required");
|
||||
|
||||
if (args.bang && args.string)
|
||||
{
|
||||
liberator.echoerr("E474: Invalid argument");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E474: Invalid argument");
|
||||
|
||||
if (args.bang)
|
||||
quickmarks.removeAll();
|
||||
@@ -1053,10 +1027,7 @@ function QuickMarks() //{{{
|
||||
|
||||
// ignore invalid qmark characters unless there are no valid qmark chars
|
||||
if (args && !/[a-zA-Z0-9]/.test(args))
|
||||
{
|
||||
liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
|
||||
|
||||
let filter = args.replace(/[^a-zA-Z0-9]/g, "");
|
||||
quickmarks.list(filter);
|
||||
@@ -1110,19 +1081,13 @@ function QuickMarks() //{{{
|
||||
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
|
||||
|
||||
if (marks.length == 0)
|
||||
{
|
||||
liberator.echoerr("No QuickMarks set");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("No QuickMarks set");
|
||||
|
||||
if (filter.length > 0)
|
||||
{
|
||||
marks = marks.filter(function (qmark) filter.indexOf(qmark) >= 0);
|
||||
if (marks.length == 0)
|
||||
{
|
||||
liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
|
||||
}
|
||||
|
||||
let items = [[mark, qmarks.get(mark)] for ([k, mark] in Iterator(marks))];
|
||||
|
||||
@@ -426,9 +426,7 @@ const config = { //{{{
|
||||
function (args)
|
||||
{
|
||||
if (args.string)
|
||||
{
|
||||
liberator.open(args.string);
|
||||
}
|
||||
else if (args.bang)
|
||||
BrowserReloadSkipCache();
|
||||
else
|
||||
@@ -451,9 +449,7 @@ const config = { //{{{
|
||||
? liberator.NEW_TAB : liberator.CURRENT_TAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.openPreferences();
|
||||
}
|
||||
},
|
||||
{
|
||||
argCount: "0",
|
||||
|
||||
@@ -13,7 +13,7 @@ function Player() // {{{
|
||||
|
||||
services.add("mediaPageManager", "@songbirdnest.com/Songbird/MediaPageManager;1", Ci.sbIMediaPageManager);
|
||||
services.add("propertyManager","@songbirdnest.com/Songbird/Properties/PropertyManager;1", Ci.sbIPropertyManager);
|
||||
|
||||
|
||||
// Register Callbacks for searching.
|
||||
liberator.registerCallback("change", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchKeyPress(str); });
|
||||
liberator.registerCallback("submit", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchSubmit(str); });
|
||||
@@ -287,10 +287,7 @@ function Player() // {{{
|
||||
|
||||
// intentionally supports 999:99:99
|
||||
if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
|
||||
{
|
||||
liberator.echoerr("E475: Invalid argument: " + arg);
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E475: Invalid argument: " + arg);
|
||||
|
||||
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
|
||||
|
||||
@@ -322,10 +319,7 @@ function Player() // {{{
|
||||
{
|
||||
// FIXME: is this a SB restriction? --djk
|
||||
if (!gBrowser.currentMediaPage)
|
||||
{
|
||||
liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
|
||||
|
||||
let arg = args[0];
|
||||
|
||||
@@ -401,10 +395,7 @@ function Player() // {{{
|
||||
let arg = args[0];
|
||||
|
||||
if (!/^[+-]?\d+$/.test(arg))
|
||||
{
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
return;
|
||||
}
|
||||
return void liberator.echoerr("E488: Trailing characters");
|
||||
|
||||
let level = parseInt(arg, 10) / 100;
|
||||
|
||||
@@ -602,9 +593,7 @@ function Player() // {{{
|
||||
focusTrack(mySearchView.getItemByIndex(lastSearchIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
|
||||
}
|
||||
},
|
||||
|
||||
searchViewAgain: function searchViewAgain(reverse)
|
||||
@@ -683,9 +672,7 @@ function Player() // {{{
|
||||
{
|
||||
// FIXME: why are there null items and duplicates?
|
||||
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
|
||||
{
|
||||
playlists.push(item);
|
||||
}
|
||||
return Ci.sbIMediaListEnumerationListener.CONTINUE;
|
||||
}
|
||||
};
|
||||
@@ -735,34 +722,34 @@ function Player() // {{{
|
||||
liberator.dump("PropertyID - "+propManager.getPropertyInfo(propertyID).id);
|
||||
properties.push(propManager.getPropertyInfo(propertyID).displayName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return properties;
|
||||
},
|
||||
|
||||
sortBy: function sortBy(property, order)
|
||||
{
|
||||
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
|
||||
liberator.dump("Property: "+property);
|
||||
|
||||
liberator.dump("Property: " + property);
|
||||
|
||||
switch (property.string)
|
||||
{
|
||||
case "#":
|
||||
case "Title":
|
||||
pa.appendProperty(SBProperties.trackName, 'a');
|
||||
pa.appendProperty(SBProperties.trackName, "a");
|
||||
break;
|
||||
case "Rating":
|
||||
pa.appendProperty(SBProperties.rating, 1);
|
||||
break;
|
||||
case "Album":
|
||||
pa.appendProperty(SBProperties.albumName, 'a');
|
||||
pa.appendProperty(SBProperties.albumName, "a");
|
||||
break;
|
||||
default:
|
||||
pa.appendProperty(SBProperties.trackName, 'a');
|
||||
pa.appendProperty(SBProperties.trackName, "a");
|
||||
break;
|
||||
}
|
||||
|
||||
_SBGetCurrentView().setSort(pa);
|
||||
|
||||
_SBGetCurrentView().setSort(pa);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user