1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 05:07:59 +01:00

Finish the Great Opening Brace Correction.

This commit is contained in:
Doug Kearns
2009-11-09 16:03:00 +11:00
parent 8ef1674c6e
commit a7925705d7
22 changed files with 334 additions and 656 deletions

View File

@@ -29,10 +29,8 @@ const systemPrincipal = channel.owner;
channel.cancel(NS_BINDING_ABORTED);
delete channel;
function dataURL(type, data)
"data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data);
function makeChannel(url, orig)
{
function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data);
function makeChannel(url, orig) {
if (typeof url == "function")
url = dataURL.apply(null, url());
let uri = ioService.newURI(url, null, null);
@@ -41,10 +39,8 @@ function makeChannel(url, orig)
channel.originalURI = orig;
return channel;
}
function fakeChannel(orig)
makeChannel("chrome://liberator/content/does/not/exist", orig);
function redirect(to, orig)
{
function fakeChannel(orig) makeChannel("chrome://liberator/content/does/not/exist", orig);
function redirect(to, orig) {
let html = <html><head><meta http-equiv="Refresh" content={"0;" + to}/></head></html>.toXMLString();
return makeChannel(dataURL('text/html', html), ioServices.newURI(to, null, null));
}
@@ -56,8 +52,7 @@ ChromeData.prototype = {
classDescription: "Data URIs with chrome privileges",
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIProtocolHandler]),
_xpcom_factory: {
createInstance: function (outer, iid)
{
createInstance: function (outer, iid) {
if (!ChromeData.instance)
ChromeData.instance = new ChromeData();
if (outer != null)
@@ -73,8 +68,7 @@ ChromeData.prototype = {
| nsIProtocolHandler.URI_NOAUTH
| nsIProtocolHandler.URI_IS_UI_RESOURCE,
newURI: function (spec, charset, baseURI)
{
newURI: function (spec, charset, baseURI) {
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIStandardURL)
.QueryInterface(Components.interfaces.nsIURI);
@@ -82,10 +76,8 @@ ChromeData.prototype = {
return uri;
},
newChannel: function (uri)
{
try
{
newChannel: function (uri) {
try {
if (uri.scheme == this.scheme)
return makeChannel(uri.spec.replace(/^.*?:\/*(.*)(?:#.*)?/, "data:$1"), uri);
}
@@ -94,8 +86,7 @@ ChromeData.prototype = {
}
};
function Liberator()
{
function Liberator() {
this.wrappedJSObject = this;
const self = this;
@@ -109,8 +100,7 @@ Liberator.prototype = {
classDescription: "Liberator utility protocol",
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIProtocolHandler]),
_xpcom_factory: {
createInstance: function (outer, iid)
{
createInstance: function (outer, iid) {
if (!Liberator.instance)
Liberator.instance = new Liberator();
if (outer != null)
@@ -119,10 +109,8 @@ Liberator.prototype = {
}
},
init: function (obj)
{
for each (let prop in ["HELP_TAGS", "FILE_MAP", "OVERLAY_MAP"])
{
init: function (obj) {
for each (let prop in ["HELP_TAGS", "FILE_MAP", "OVERLAY_MAP"]) {
this[prop] = this[prop].constructor();
for (let [k, v] in Iterator(obj[prop] || {}))
this[prop][k] = v
@@ -136,8 +124,7 @@ Liberator.prototype = {
| nsIProtocolHandler.URI_IS_UI_RESOURCE
| nsIProtocolHandler.URI_IS_LOCAL_RESOURCE,
newURI: function (spec, charset, baseURI)
{
newURI: function (spec, charset, baseURI) {
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIStandardURL)
.QueryInterface(Components.interfaces.nsIURI);
@@ -145,12 +132,9 @@ Liberator.prototype = {
return uri;
},
newChannel: function (uri)
{
try
{
switch(uri.host)
{
newChannel: function (uri) {
try {
switch(uri.host) {
case "help":
let url = this.FILE_MAP[uri.path.replace(/^\/|#.*/g, "")];
return makeChannel(url, uri);
@@ -170,9 +154,6 @@ Liberator.prototype = {
var components = [ChromeData, Liberator];
function NSGetModule(compMgr, fileSpec)
{
return XPCOMUtils.generateModule(components);
}
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule(components)
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -355,10 +355,8 @@ const Buffer = Module("buffer", {
for (let [, regex] in Iterator(regexes)) {
for (let i in util.range(res.snapshotLength, 0, -1)) {
let elem = res.snapshotItem(i);
if (regex.test(elem.textContent) ||
regex.test(elem.title) ||
Array.some(elem.childNodes, function (child) regex.test(child.alt)))
{
if (regex.test(elem.textContent) || regex.test(elem.title) ||
Array.some(elem.childNodes, function (child) regex.test(child.alt))) {
buffer.followLink(elem, liberator.CURRENT_TAB);
return true;
}

View File

@@ -321,8 +321,7 @@ function Highlights(name, store) {
this.loadCSS = function (css) {
css.replace(/^(\s*\S*\s+)\{((?:.|\n)*?)\}\s*$/gm, function (_, _1, _2) _1 + " " + _2.replace(/\n\s*/g, " "))
.split("\n").filter(function (s) /\S/.test(s))
.forEach(function (style)
{
.forEach(function (style) {
style = Highlight.apply(Highlight, Array.slice(style.match(/^\s*((?:[^,\s]|\s\S)+)(?:,((?:[^,\s]|\s\S)+)?)?(?:,((?:[^,\s]|\s\S)+))?\s*(.*)$/), 1));
if (/^[>+ ]/.test(style.selector))
style.selector = self.selector(style.class) + style.selector;

View File

@@ -227,9 +227,7 @@ const Tabs = Module("tabs", {
if (getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab);
else {
if (buffer.URL != "about:blank" ||
window.getWebNavigation().sessionHistory.count > 0)
{
if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
getBrowser().removeTab(tab);
}

View File

@@ -9,8 +9,7 @@ var CommandLineHandler;
function initCommandLineHandler(Name) {
var name = Name.toLowerCase();
CommandLineHandler = function CommandLineHandler()
{
CommandLineHandler = function CommandLineHandler() {
this.wrappedJSObject = this;
}
CommandLineHandler.prototype = {
@@ -28,21 +27,18 @@ function initCommandLineHandler(Name) {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
handle: function (commandLine)
{
handle: function (commandLine) {
// TODO: handle remote launches differently?
try
{
try {
this.optionValue = commandLine.handleFlagWithParam(name, false);
}
catch (e)
{
catch (e) {
//"vimperator: option -vimperator requires an argument"
}
}
};
}
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler])
// vim: set ft=javascript fdm=marker sw=4 ts=4 et:

View File

@@ -27,29 +27,24 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
// XXX: does not belong here
function Timer(minInterval, maxInterval, callback)
{
function Timer(minInterval, maxInterval, callback) {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.doneAt = 0;
this.latest = 0;
this.notify = function (aTimer)
{
this.notify = function (aTimer) {
timer.cancel();
this.latest = 0;
// minInterval is the time between the completion of the command and the next firing
this.doneAt = Date.now() + minInterval;
try
{
try {
callback(this.arg);
}
finally
{
finally {
this.doneAt = Date.now() + minInterval;
}
};
this.tell = function (arg)
{
this.tell = function (arg) {
if (arguments.length > 0)
this.arg = arg;
@@ -68,32 +63,27 @@ function Timer(minInterval, maxInterval, callback)
timer.initWithCallback(this, Math.max(timeout, 0), timer.TYPE_ONE_SHOT);
this.doneAt = -1;
};
this.reset = function ()
{
this.reset = function () {
timer.cancel();
this.doneAt = 0;
};
this.flush = function ()
{
this.flush = function () {
if (this.doneAt == -1)
this.notify();
};
}
function getFile(name)
{
function getFile(name) {
let file = storage.infoPath.clone();
file.append(name);
return file;
}
function readFile(file)
{
function readFile(file) {
let fileStream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
let stream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
try
{
try {
fileStream.init(file, -1, 0, 0);
stream.init(fileStream, "UTF-8", 4096, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); // 4096 bytes buffering
@@ -110,8 +100,7 @@ function readFile(file)
catch (e) {}
}
function writeFile(file, data)
{
function writeFile(file, data) {
if (!file.exists())
file.create(file.NORMAL_FILE_TYPE, 0600);
@@ -132,34 +121,28 @@ var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPref
.getBranch("extensions.liberator.datastore.");
var json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
function getCharPref(name)
{
try
{
function getCharPref(name) {
try {
return prefService.getComplexValue(name, Ci.nsISupportsString).data;
}
catch (e) {}
}
function setCharPref(name, value)
{
function setCharPref(name, value) {
var str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
str.data = value;
return prefService.setComplexValue(name, Ci.nsISupportsString, str);
}
function loadPref(name, store, type)
{
try
{
function loadPref(name, store, type) {
try {
if (store)
var pref = getCharPref(name);
if (!pref && storage.infoPath)
var file = readFile(getFile(name));
if (pref || file)
var result = json.decode(pref || file);
if (pref)
{
if (pref) {
prefService.clearUserPref(name);
savePref({ name: name, store: true, serial: pref });
}
@@ -169,8 +152,7 @@ function loadPref(name, store, type)
catch (e) {}
}
function savePref(obj)
{
function savePref(obj) {
if (obj.privateData && storage.privateMode)
return;
if (obj.store && storage.infoPath)
@@ -181,8 +163,7 @@ var prototype = {
OPTIONS: ["privateData"],
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
save: function () { savePref(this); },
init: function (name, store, data, options)
{
init: function (name, store, data, options) {
this.__defineGetter__("store", function () store);
this.__defineGetter__("name", function () name);
for (let [k, v] in Iterator(options))
@@ -192,12 +173,10 @@ var prototype = {
}
};
function ObjectStore(name, store, load, options)
{
function ObjectStore(name, store, load, options) {
var object = {};
this.reload = function reload()
{
this.reload = function reload() {
object = load() || {};
this.fireEvent("change", null);
};
@@ -205,8 +184,7 @@ function ObjectStore(name, store, load, options)
this.init.apply(this, arguments);
this.__defineGetter__("serial", function () json.encode(object));
this.set = function set(key, val)
{
this.set = function set(key, val) {
var defined = key in object;
var orig = object[key];
object[key] = val;
@@ -216,8 +194,7 @@ function ObjectStore(name, store, load, options)
this.fireEvent("change", key);
};
this.remove = function remove(key)
{
this.remove = function remove(key) {
var ret = object[key];
delete object[key];
this.fireEvent("remove", key);
@@ -226,8 +203,7 @@ function ObjectStore(name, store, load, options)
this.get = function get(val) object[val];
this.clear = function ()
{
this.clear = function () {
object = {};
};
@@ -235,12 +211,10 @@ function ObjectStore(name, store, load, options)
}
ObjectStore.prototype = prototype;
function ArrayStore(name, store, load, options)
{
function ArrayStore(name, store, load, options) {
var array = [];
this.reload = function reload()
{
this.reload = function reload() {
array = load() || [];
this.fireEvent("change", null);
};
@@ -249,31 +223,26 @@ function ArrayStore(name, store, load, options)
this.__defineGetter__("serial", function () json.encode(array));
this.__defineGetter__("length", function () array.length);
this.set = function set(index, value)
{
this.set = function set(index, value) {
var orig = array[index];
array[index] = value;
this.fireEvent("change", index);
};
this.push = function push(value)
{
this.push = function push(value) {
array.push(value);
this.fireEvent("push", array.length);
};
this.pop = function pop(value)
{
this.pop = function pop(value) {
var ret = array.pop();
this.fireEvent("pop", array.length);
return ret;
};
this.truncate = function truncate(length, fromEnd)
{
this.truncate = function truncate(length, fromEnd) {
var ret = array.length;
if (array.length > length)
{
if (array.length > length) {
if (fromEnd)
array.splice(0, array.length - length);
array.length = length;
@@ -283,16 +252,14 @@ function ArrayStore(name, store, load, options)
};
// XXX: Awkward.
this.mutate = function mutate(aFuncName)
{
this.mutate = function mutate(aFuncName) {
var funcName = aFuncName;
arguments[0] = array;
array = Array[funcName].apply(Array, arguments);
this.fireEvent("change", null);
};
this.get = function get(index)
{
this.get = function get(index) {
return index >= 0 ? array[index] : array[array.length + index];
};
@@ -306,10 +273,8 @@ var timers = {};
var storage = {
alwaysReload: {},
newObject: function newObject(key, constructor, params)
{
if (!(key in keys) || params.reload || this.alwaysReload[key])
{
newObject: function newObject(key, constructor, params) {
if (!(key in keys) || params.reload || this.alwaysReload[key]) {
if (key in this && !(params.reload || this.alwaysReload[key]))
throw Error();
let load = function () loadPref(key, params.store, params.type || Object);
@@ -320,27 +285,22 @@ var storage = {
return keys[key];
},
newMap: function newMap(key, options)
{
newMap: function newMap(key, options) {
return this.newObject(key, ObjectStore, options);
},
newArray: function newArray(key, options)
{
newArray: function newArray(key, options) {
return this.newObject(key, ArrayStore, { type: Array, __proto__: options });
},
addObserver: function addObserver(key, callback, ref)
{
if (ref)
{
addObserver: function addObserver(key, callback, ref) {
if (ref) {
if (!ref.liberatorStorageRefs)
ref.liberatorStorageRefs = [];
ref.liberatorStorageRefs.push(callback);
var callbackRef = Cu.getWeakReference(callback);
}
else
{
else {
callbackRef = { get: function () callback };
}
this.removeDeadObservers();
@@ -350,8 +310,7 @@ var storage = {
observers[key].push({ ref: ref && Cu.getWeakReference(ref), callback: callbackRef });
},
removeObserver: function (key, callback)
{
removeObserver: function (key, callback) {
this.removeDeadObservers();
if (!(key in observers))
return;
@@ -360,10 +319,8 @@ var storage = {
delete obsevers[key];
},
removeDeadObservers: function ()
{
for (let [key, ary] in Iterator(observers))
{
removeDeadObservers: function () {
for (let [key, ary] in Iterator(observers)) {
observers[key] = ary = ary.filter(function (o) o.callback.get() && (!o.ref || o.ref.get() && o.ref.get().liberatorStorageRefs));
if (!ary.length)
delete observers[key];
@@ -372,8 +329,7 @@ var storage = {
get observers() observers,
fireEvent: function fireEvent(key, event, arg)
{
fireEvent: function fireEvent(key, event, arg) {
if (!(key in this))
return;
this.removeDeadObservers();
@@ -383,27 +339,23 @@ var storage = {
timers[key].tell();
},
load: function load(key)
{
load: function load(key) {
if (this[key].store && this[key].reload)
this[key].reload();
},
save: function save(key)
{
save: function save(key) {
savePref(keys[key]);
},
saveAll: function storeAll()
{
saveAll: function storeAll() {
for each (let obj in keys)
savePref(obj);
},
_privateMode: false,
get privateMode() this._privateMode,
set privateMode(val)
{
set privateMode(val) {
if (!val && this._privateMode)
for (let key in keys)
this.load(key);

View File

@@ -25,19 +25,16 @@ AboutHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function (uri)
{
newChannel: function (uri) {
let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
.newChannel("chrome://" + name + "/content/about.html", null, null);
channel.originalURI = uri;
return channel;
},
getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT,
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler])
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -11,8 +11,7 @@ const Name = "Muttator";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const name = Name.toLowerCase();
function CommandLineHandler()
{
function CommandLineHandler() {
this.wrappedJSObject = this;
}
CommandLineHandler.prototype = {
@@ -30,20 +29,17 @@ CommandLineHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
handle: function (commandLine)
{
handle: function (commandLine) {
// TODO: handle remote launches differently?
try
{
try {
this.optionValue = commandLine.handleFlagWithParam(name, false);
}
catch (e)
{
catch (e) {
//"vimperator: option -vimperator requires an argument"
}
}
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler])
// vim: set ft=javascript fdm=marker sw=4 ts=4 et:

View File

@@ -3,8 +3,7 @@
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
function Addressbook() //{{{
{
function Addressbook() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -14,8 +13,7 @@ function Addressbook() //{{{
// TODO: add option for a format specifier, like:
// :set displayname=%l, %f
function generateDisplayName(firstName, lastName)
{
function generateDisplayName(firstName, lastName) {
if (firstName && lastName)
return lastName + ", " + firstName;
else if (firstName)
@@ -40,14 +38,11 @@ function Addressbook() //{{{
mappings.add(myModes, ["a"],
"Open a prompt to save a new addressbook entry for the sender of the selected message",
function ()
{
try
{
function () {
try {
var to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
}
catch (e)
{
catch (e) {
liberator.beep();
}
@@ -57,8 +52,7 @@ function Addressbook() //{{{
let address = to.substring(to.indexOf("<") + 1, to.indexOf(">"));
let displayName = to.substr(0, to.indexOf("<") - 1);
if (/^\S+\s+\S+\s*$/.test(displayName))
{
if (/^\S+\s+\S+\s*$/.test(displayName)) {
let names = displayName.split(/\s+/);
displayName = "-firstname=" + names[0].replace(/"/g, "")
+ " -lastname=" + names[1].replace(/"/g, "");
@@ -75,8 +69,7 @@ function Addressbook() //{{{
commands.add(["con[tact]"],
"Add an address book entry",
function (args)
{
function (args) {
let mailAddr = args[0]; // TODO: support more than one email address
let firstName = args["-firstname"] || null;
let lastName = args["-lastname"] || null;
@@ -108,8 +101,7 @@ function Addressbook() //{{{
return {
add: function (address, firstName, lastName, displayName)
{
add: function (address, firstName, lastName, displayName) {
const personalAddressbookURI = "moz-abmdbdirectory://abook.mab";
let directory = getDirectoryFromURI(personalAddressbookURI);
let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(Ci.nsIAbCard);
@@ -126,18 +118,15 @@ function Addressbook() //{{{
},
// TODO: add telephone number support
list: function (filter, newMail)
{
list: function (filter, newMail) {
let addresses = [];
let dirs = abManager.directories;
let lowerFilter = filter.toLowerCase();
while (dirs.hasMoreElements())
{
while (dirs.hasMoreElements()) {
let addrbook = dirs.getNext().QueryInterface(Ci.nsIAbDirectory);
let cards = addrbook.childCards;
while (cards.hasMoreElements())
{
while (cards.hasMoreElements()) {
let card = cards.getNext().QueryInterface(Ci.nsIAbCard);
//var mail = card.primaryEmail || ""; //XXX
let displayName = card.displayName;
@@ -150,8 +139,7 @@ function Addressbook() //{{{
}
}
if (addresses.length < 1)
{
if (addresses.length < 1) {
if (!filter)
liberator.echoerr("Exxx: No contacts", commandline.FORCE_SINGLELINE);
else
@@ -159,8 +147,7 @@ function Addressbook() //{{{
return false;
}
if (newMail)
{
if (newMail) {
// Now we have to create a new message
let args = {};
args.to = addresses.map(
@@ -169,8 +156,7 @@ function Addressbook() //{{{
mail.composeNewMail(args);
}
else
{
else {
let list = template.tabular(["Name", "Address"], [],
[[util.clip(address[0], 50), address[1]] for ([, address] in Iterator(addresses))]
);

View File

@@ -3,8 +3,7 @@
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
function Compose() //{{{
{
function Compose() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -12,19 +11,16 @@ function Compose() //{{{
config.features = ["addressbook"]; // the composer has no special features
var stateListener = {
QueryInterface: function (id)
{
QueryInterface: function (id) {
if (id.equals(Ci.nsIDocumentStateListener))
return this;
throw Cr.NS_NOINTERFACE;
},
// this is (also) fired once the new compose window loaded the message for the first time
NotifyDocumentStateChanged: function (nowDirty)
{
NotifyDocumentStateChanged: function (nowDirty) {
// only edit with external editor if this window was not cached!
if (options["autoexternal"] && !window.messageWasEditedExternally/* && !gMsgCompose.recycledWindow*/)
{
if (options["autoexternal"] && !window.messageWasEditedExternally/* && !gMsgCompose.recycledWindow*/) {
window.messageWasEditedExternally = true;
editor.editFieldExternally();
}
@@ -36,8 +32,7 @@ function Compose() //{{{
// XXX: Hack!
window.document.addEventListener("load", function () {
if (window.messageWasEditedExternally === undefined)
{
if (window.messageWasEditedExternally === undefined) {
window.messageWasEditedExternally = false;
GetCurrentEditor().addDocumentStateListener(stateListener);
}

View File

@@ -3,8 +3,7 @@
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
const config = (function () //{{{
{
const config = (function () { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -101,11 +100,9 @@ const config = (function () //{{{
function () { buffer.viewSelectionSource(); }]*/
],
focusChange: function (win)
{
focusChange: function (win) {
// we switch to -- MESSAGE -- mode for Muttator, when the main HTML widget gets focus
if (win && win.document instanceof HTMLDocument || liberator.focus instanceof HTMLAnchorElement)
{
if (win && win.document instanceof HTMLDocument || liberator.focus instanceof HTMLAnchorElement) {
if (config.isComposeWindow)
modes.set(modes.INSERT, modes.TEXTAREA);
else if (liberator.mode != modes.MESSAGE)
@@ -114,8 +111,7 @@ const config = (function () //{{{
},
getBrowser: function () {
if (!tabmail)
{
if (!tabmail) {
tabmail = { __proto__: document.getElementById("tabmail") };
tabmail.__defineGetter__("mTabContainer", function () this.tabContainer);
tabmail.__defineGetter__("mTabs", function () this.tabContainer.childNodes);
@@ -145,10 +141,8 @@ const config = (function () //{{{
],
// NOTE: as I don't use TB I have no idea how robust this is. --djk
get outputHeight()
{
if (!this.isComposeWindow)
{
get outputHeight() {
if (!this.isComposeWindow) {
let container = document.getElementById("tabpanelcontainer").boxObject;
let deck = document.getElementById("displayDeck");
let box = document.getElementById("messagepanebox");
@@ -173,8 +167,7 @@ const config = (function () //{{{
// to allow Vim to :set ft=mail automatically
tempFile: "mutt-ator-mail",
init: function ()
{
init: function () {
// don't wait too long when selecting new messages
// GetThreadTree()._selectDelay = 300; // TODO: make configurable
@@ -182,8 +175,7 @@ const config = (function () //{{{
if (this.isComposeWindow)
// TODO: this should probably be "composer"
liberator.loadModule("compose", Compose);
else
{
else {
liberator.loadModule("mail", Mail);
liberator.loadModule("addressbook", Addressbook);
liberator.loadModule("tabs", Tabs);
@@ -208,8 +200,7 @@ const config = (function () //{{{
"Set the 'work offline' option",
"boolean", true,
{
setter: function (value)
{
setter: function (value) {
if (MailOfflineMgr.isOnline() != value)
MailOfflineMgr.toggleOfflineStatus();
return value;

View File

@@ -3,8 +3,7 @@
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
function Mail() //{{{
{
function Mail() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -25,20 +24,16 @@ function Mail() //{{{
OnItemUnicharPropertyChanged: function (item, property, oldValue, newValue) {},
OnItemPropertyFlagChanged: function (item, property, oldFlag, newFlag) {},
OnItemEvent: function (folder, event)
{
OnItemEvent: function (folder, event) {
let eventType = event.toString();
if (eventType == "FolderLoaded")
{
if (folder)
{
if (eventType == "FolderLoaded") {
if (folder) {
let msgFolder = folder.QueryInterface(Ci.nsIMsgFolder);
autocommands.trigger("FolderLoaded", { url: msgFolder });
// Jump to a message when requested
let indices = [];
if (selectMessageKeys.length > 0)
{
if (selectMessageKeys.length > 0) {
for (let j = 0; j < selectMessageKeys.length; j++)
indices.push([gDBView.findIndexFromKey(selectMessageKeys[j], true), selectMessageKeys[j]]);
@@ -67,19 +62,16 @@ function Mail() //{{{
var notifyFlags = nsIFolderListener.intPropertyChanged | nsIFolderListener.event;
mailSession.AddFolderListener(folderListener, notifyFlags);
function getCurrentFolderIndex()
{
function getCurrentFolderIndex() {
// for some reason, the index is interpreted as a string, therefore the parseInt
return parseInt(gFolderTreeView.getIndexOfFolder(gFolderTreeView.getSelectedFolders()[0]));
}
function getRSSUrl()
{
function getRSSUrl() {
return gDBView.hdrForFirstSelectedMessage.messageId.replace(/(#.*)?@.*$/, "");
}
function moveOrCopy(copy, destinationFolder, operateOnThread)
{
function moveOrCopy(copy, destinationFolder, operateOnThread) {
let folders = mail.getFolders(destinationFolder);
if (folders.length == 0)
return void liberator.echoerr("Exxx: No matching folder for " + destinationFolder);
@@ -96,13 +88,11 @@ function Mail() //{{{
}, 100);
}
function parentIndex(index)
{
function parentIndex(index) {
let parent = index;
let tree = GetThreadTree();
while (true)
{
while (true) {
let tmp = tree.view.getParentIndex(parent);
if (tmp >= 0)
parent = tmp;
@@ -113,18 +103,15 @@ function Mail() //{{{
}
// does not wrap yet, intentional?
function selectUnreadFolder(backwards, count)
{
function selectUnreadFolder(backwards, count) {
count = Math.max(1, count);
let direction = backwards ? -1 : 1;
let c = getCurrentFolderIndex();
let i = direction;
let folder;
while (count > 0 && (c + i) < gFolderTreeView.rowCount && (c + i) >= 0)
{
while (count > 0 && (c + i) < gFolderTreeView.rowCount && (c + i) >= 0) {
let resource = gFolderTreeView._rowMap[c+i]._folder;
if (!resource.isServer && resource.getNumUnread(false))
{
if (!resource.isServer && resource.getNumUnread(false)) {
count -= 1;
folder = i;
}
@@ -136,8 +123,7 @@ function Mail() //{{{
gFolderTreeView.selection.timedSelect(c + folder, 500);
}
function escapeRecipient(recipient)
{
function escapeRecipient(recipient) {
// strip all ":
recipient = recipient.replace(/"/g, "");
return "\"" + recipient + "\"";
@@ -162,10 +148,8 @@ function Mail() //{{{
"Set the layout of the mail window",
"string", "inherit",
{
setter: function (value)
{
switch (value)
{
setter: function (value) {
switch (value) {
case "classic": ChangeMailLayout(0); break;
case "wide": ChangeMailLayout(1); break;
case "vertical": ChangeMailLayout(2); break;
@@ -188,8 +172,7 @@ function Mail() //{{{
"string", services.get("smtpService").defaultServer.key, // TODO: how should we handle these persistent external defaults - "inherit" or null?
{
getter: function () services.get("smtpService").defaultServer.key,
setter: function (value)
{
setter: function (value) {
let server = mail.smtpServers.filter(function (s) s.key == value)[0];
services.get("smtpService").defaultServer = server;
return value;
@@ -202,8 +185,7 @@ function Mail() //{{{
"Use threading to group messages",
"boolean", true,
{
setter: function (value)
{
setter: function (value) {
if (value)
MsgSortThreaded();
else
@@ -225,8 +207,7 @@ function Mail() //{{{
mappings.add(myModes, ["I"],
"Open the message in new tab",
function ()
{
function () {
if (gDBView && gDBView.selection.count < 1)
return void liberator.beep();
@@ -282,10 +263,8 @@ function Mail() //{{{
mappings.add(myModes, ["*"],
"Select next message from the same sender",
function (count)
{
try
{
function (count) {
try {
let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase();
mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, count);
}
@@ -295,10 +274,8 @@ function Mail() //{{{
mappings.add(myModes, ["#"],
"Select previous message from the same sender",
function (count)
{
try
{
function (count) {
try {
let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase();
mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, count);
}
@@ -313,15 +290,12 @@ function Mail() //{{{
mappings.add(myModes, ["M"],
"Compose a new message to the sender of selected mail",
function ()
{
try
{
function () {
try {
let to = escapeRecipient(gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor);
commandline.open(":", "mail " + to + " -subject=", modes.EX);
}
catch (e)
{
catch (e) {
liberator.beep();
}
});
@@ -366,8 +340,7 @@ function Mail() //{{{
// UNDO/REDO
mappings.add(myModes, ["u"],
"Undo",
function ()
{
function () {
if (messenger.canUndo())
messenger.undo(msgWindow);
else
@@ -375,8 +348,7 @@ function Mail() //{{{
});
mappings.add(myModes, ["<C-r>"],
"Redo",
function ()
{
function () {
if (messenger.canRedo())
messenger.redo(msgWindow);
else
@@ -432,8 +404,7 @@ function Mail() //{{{
// FOLDER SWITCHING
mappings.add(myModes, ["gi"],
"Go to inbox",
function (count)
{
function (count) {
let folder = mail.getFolders("Inbox", false, true)[(count > 0) ? (count - 1) : 0];
if (folder)
SelectFolder(folder.URI);
@@ -444,12 +415,10 @@ function Mail() //{{{
mappings.add(myModes, ["<C-n>"],
"Select next folder",
function (count)
{
function (count) {
count = Math.max(1, count);
let newPos = getCurrentFolderIndex() + count;
if (newPos >= gFolderTreeView.rowCount)
{
if (newPos >= gFolderTreeView.rowCount) {
newPos = newPos % gFolderTreeView.rowCount;
commandline.echo("search hit BOTTOM, continuing at TOP", commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
}
@@ -459,20 +428,17 @@ function Mail() //{{{
mappings.add(myModes, ["<C-N>"],
"Go to next mailbox with unread messages",
function (count)
{
function (count) {
selectUnreadFolder(false, count);
},
{ count: true });
mappings.add(myModes, ["<C-p>"],
"Select previous folder",
function (count)
{
function (count) {
count = Math.max(1, count);
let newPos = getCurrentFolderIndex() - count;
if (newPos < 0)
{
if (newPos < 0) {
newPos = (newPos % gFolderTreeView.rowCount) + gFolderTreeView.rowCount;
commandline.echo("search hit TOP, continuing at BOTTOM", commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES);
}
@@ -482,8 +448,7 @@ function Mail() //{{{
mappings.add(myModes, ["<C-P>"],
"Go to previous mailbox with unread messages",
function (count)
{
function (count) {
selectUnreadFolder(true, count);
},
{ count: true });
@@ -532,13 +497,11 @@ function Mail() //{{{
// tagging messages
mappings.add(myModes, ["l"],
"Label message",
function (arg)
{
function (arg) {
if (!GetSelectedMessages())
return void liberator.beep();
switch (arg)
{
switch (arg) {
case "r": MsgMarkMsgAsRead(); break;
case "s": MsgMarkAsFlagged(); break;
case "i": ToggleMessageTagKey(1); break; // Important
@@ -556,8 +519,7 @@ function Mail() //{{{
// TODO: change binding?
mappings.add(myModes, ["T"],
"Mark current folder as read",
function ()
{
function () {
if (mail.currentFolder.isServer)
return liberator.beep();
@@ -566,16 +528,14 @@ function Mail() //{{{
mappings.add(myModes, ["<C-t>"],
"Mark all messages as read",
function ()
{
function () {
mail.getFolders("", false).forEach(function (folder) { folder.markAllMessagesRead(msgWindow); });
});
// DISPLAY OPTIONS
mappings.add(myModes, ["h"],
"Toggle displayed headers",
function ()
{
function () {
let value = gPrefBranch.getIntPref("mail.show_headers", 2);
gPrefBranch.setIntPref("mail.show_headers", value == 2 ? 1 : 2);
ReloadMessage();
@@ -583,8 +543,7 @@ function Mail() //{{{
mappings.add(myModes, ["x"],
"Toggle HTML message display",
function ()
{
function () {
let wantHtml = (gPrefBranch.getIntPref("mailnews.display.html_as", 1) == 1);
mail.setHTML(wantHtml ? 1 : 0);
});
@@ -592,10 +551,8 @@ function Mail() //{{{
// YANKING TEXT
mappings.add(myModes, ["Y"],
"Yank subject",
function ()
{
try
{
function () {
try {
let subject = gDBView.hdrForFirstSelectedMessage.mime2DecodedSubject;
util.copyToClipboard(subject, true);
}
@@ -604,10 +561,8 @@ function Mail() //{{{
mappings.add(myModes, ["y"],
"Yank sender or feed URL",
function ()
{
try
{
function () {
try {
if (mail.currentAccount.server.type == "rss")
util.copyToClipboard(getRSSUrl(), true);
else
@@ -619,16 +574,13 @@ function Mail() //{{{
// RSS specific mappings
mappings.add(myModes, ["p"],
"Open RSS message in browser",
function ()
{
try
{
function () {
try {
if (mail.currentAccount.server.type == "rss")
messenger.launchExternalURL(getRSSUrl());
// TODO: what to do for non-rss message?
}
catch (e)
{
catch (e) {
liberator.beep();
}
});
@@ -639,8 +591,7 @@ function Mail() //{{{
commands.add(["go[to]"],
"Select a folder",
function (args)
{
function (args) {
let count = Math.max(0, args.count - 1);
let arg = args.literalArg || "Inbox";
@@ -661,8 +612,7 @@ function Mail() //{{{
commands.add(["m[ail]"],
"Write a new message",
function (args)
{
function (args) {
let mailargs = {};
mailargs.to = args.join(", ");
mailargs.subject = args["-subject"];
@@ -746,13 +696,11 @@ function Mail() //{{{
get currentFolder() gFolderTreeView.getSelectedFolders()[0],
/** @property {nsISmtpServer[]} The list of configured SMTP servers. */
get smtpServers()
{
get smtpServers() {
let servers = services.get("smtpService").smtpServers;
let ret = [];
while (servers.hasMoreElements())
{
while (servers.hasMoreElements()) {
let server = servers.getNext();
if (server instanceof Ci.nsISmtpServer)
ret.push(server);
@@ -761,13 +709,11 @@ function Mail() //{{{
return ret;
},
composeNewMail: function (args)
{
composeNewMail: function (args) {
let params = Cc["@mozilla.org/messengercompose/composeparams;1"].createInstance(Ci.nsIMsgComposeParams);
params.composeFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(Ci.nsIMsgCompFields);
if (args)
{
if (args) {
if (args.originalMsg)
params.originalMsgURI = args.originalMsg;
if (args.to)
@@ -783,10 +729,8 @@ function Mail() //{{{
if (args.body)
params.composeFields.body = args.body;
if (args.attachments)
{
while (args.attachments.length > 0)
{
if (args.attachments) {
while (args.attachments.length > 0) {
let url = args.attachments.pop();
let file = io.getFile(url);
if (!file.exists())
@@ -807,8 +751,7 @@ function Mail() //{{{
},
// returns an array of nsIMsgFolder objects
getFolders: function (filter, includeServers, includeMsgFolders)
{
getFolders: function (filter, includeServers, includeMsgFolders) {
let folders = [];
if (!filter)
filter = "";
@@ -820,8 +763,7 @@ function Mail() //{{{
if (includeMsgFolders === undefined)
includeMsgFolders = true;
for (let i = 0; i < gFolderTreeView.rowCount; i++)
{
for (let i = 0; i < gFolderTreeView.rowCount; i++) {
let resource = gFolderTreeView._rowMap[i]._folder;
if ((resource.isServer && !includeServers) || (!resource.isServer && !includeMsgFolders))
continue;
@@ -836,22 +778,19 @@ function Mail() //{{{
return folders;
},
getNewMessages: function (currentAccountOnly)
{
getNewMessages: function (currentAccountOnly) {
if (currentAccountOnly)
MsgGetMessagesForAccount();
else
GetMessagesForAllAuthenticatedAccounts();
},
getStatistics: function (currentAccountOnly)
{
getStatistics: function (currentAccountOnly) {
let accounts = currentAccountOnly ? [this.currentAccount]
: this.getFolders("", true, false);
let unreadCount = 0, totalCount = 0, newCount = 0;
for (let i = 0; i < accounts.length; i++)
{
for (let i = 0; i < accounts.length; i++) {
let account = accounts[i];
unreadCount += account.getNumUnread(true); // true == deep (includes subfolders)
totalCount += account.getTotalMessages(true);
@@ -861,14 +800,11 @@ function Mail() //{{{
return { numUnread: unreadCount, numTotal: totalCount, numNew: newCount };
},
collapseThread: function ()
{
collapseThread: function () {
let tree = GetThreadTree();
if (tree)
{
if (tree) {
let parent = parentIndex(tree.currentIndex);
if (tree.changeOpenState(parent, false))
{
if (tree.changeOpenState(parent, false)) {
tree.view.selection.select(parent);
tree.treeBoxObject.ensureRowIsVisible(parent);
return true;
@@ -877,11 +813,9 @@ function Mail() //{{{
return false;
},
expandThread: function ()
{
expandThread: function () {
let tree = GetThreadTree();
if (tree)
{
if (tree) {
let row = tree.currentIndex;
if (row >= 0 && tree.changeOpenState(row, true))
return true;
@@ -898,18 +832,15 @@ function Mail() //{{{
* @param {boolean} openThreads Should we open closed threads?
* @param {boolean} reverse Change direction of searching.
*/
selectMessage: function (validatorFunc, canWrap, openThreads, reverse, count)
{
function currentIndex()
{
selectMessage: function (validatorFunc, canWrap, openThreads, reverse, count) {
function currentIndex() {
let index = gDBView.selection.currentIndex;
if (index < 0)
index = 0;
return index;
}
function closedThread(index)
{
function closedThread(index) {
if (!(gDBView.viewFlags & nsMsgViewFlagsType.kThreadedDisplay))
return false;
@@ -924,34 +855,28 @@ function Mail() //{{{
count = 1;
// first try to find in current folder
if (gDBView)
{
if (gDBView) {
for (let i = currentIndex() + (reverse ? -1 : (openThreads && closedThread() ? 0 : 1));
reverse ? (i >= 0) : (i < gDBView.rowCount);
reverse ? i-- : i++)
{
reverse ? i-- : i++) {
let key = gDBView.getKeyAt(i);
let msg = gDBView.db.GetMsgHdrForKey(key);
// a closed thread
if (openThreads && closedThread(i))
{
if (openThreads && closedThread(i)) {
let thread = gDBView.db.GetThreadContainingMsgHdr(msg);
let originalCount = count;
for (let j = (i == currentIndex() && !reverse) ? 1 : (reverse ? thread.numChildren - 1 : 0);
reverse ? (j >= 0) : (j < thread.numChildren);
reverse ? j-- : j++)
{
reverse ? j-- : j++) {
msg = thread.getChildAt(j);
if (validatorFunc(msg) && --count == 0)
{
if (validatorFunc(msg) && --count == 0) {
// this hack is needed to get the correct message, because getChildAt() does not
// necessarily return the messages in the order they are displayed
gDBView.selection.timedSelect(i, GetThreadTree()._selectDelay || 500);
GetThreadTree().treeBoxObject.ensureRowIsVisible(i);
if (j > 0)
{
if (j > 0) {
GetThreadTree().changeOpenState(i, true);
this.selectMessage(validatorFunc, false, false, false, originalCount);
}
@@ -959,10 +884,8 @@ function Mail() //{{{
}
}
}
else // simple non-threaded message
{
if (validatorFunc(msg) && --count == 0)
{
else { // simple non-threaded message
if (validatorFunc(msg) && --count == 0) {
gDBView.selection.timedSelect(i, GetThreadTree()._selectDelay || 500);
GetThreadTree().treeBoxObject.ensureRowIsVisible(i);
return;
@@ -972,14 +895,12 @@ function Mail() //{{{
}
// then in other folders
if (canWrap)
{
if (canWrap) {
selectMessageReverse = reverse;
let folders = this.getFolders("", true, true);
let ci = getCurrentFolderIndex();
for (let i = 1; i < folders.length; i++)
{
for (let i = 1; i < folders.length; i++) {
let index = (i + ci) % folders.length;
if (reverse)
index = folders.length - 1 - index;
@@ -993,29 +914,24 @@ function Mail() //{{{
// sometimes folder.getMessages can fail with an exception
// TODO: find out why, and solve the problem
try
{
try {
var msgs = folder.messages;
}
catch (e)
{
catch (e) {
msgs = folder.getMessages(msgWindow); // for older thunderbirds
liberator.dump("WARNING: " + folder.prettyName + " failed to getMessages, trying old API");
//continue;
}
while (msgs.hasMoreElements())
{
while (msgs.hasMoreElements()) {
let msg = msgs.getNext().QueryInterface(Ci.nsIMsgDBHdr);
if (validatorFunc(msg))
{
if (validatorFunc(msg)) {
count--;
selectMessageKeys.push(msg.messageKey);
}
}
if (count <= 0)
{
if (count <= 0) {
// SelectFolder is asynchronous, message is selected in folderListener
SelectFolder(folder.URI);
return;
@@ -1028,8 +944,7 @@ function Mail() //{{{
liberator.beep();
},
setHTML: function (value)
{
setHTML: function (value) {
let values = [[true, 1, gDisallow_classes_no_html], // plaintext
[false, 0, 0], // HTML
[false, 3, gDisallow_classes_no_html]]; // sanitized/simple HTML

View File

@@ -25,8 +25,7 @@ AboutHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function (uri)
{
newChannel: function (uri) {
let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
.newChannel("chrome://" + name + "/content/about.html", null, null);
@@ -38,6 +37,6 @@ AboutHandler.prototype = {
getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT,
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler])
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -11,8 +11,7 @@ const Name = "Vimperator";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const name = Name.toLowerCase();
function CommandLineHandler()
{
function CommandLineHandler() {
this.wrappedJSObject = this;
}
CommandLineHandler.prototype = {
@@ -30,20 +29,17 @@ CommandLineHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
handle: function (commandLine)
{
handle: function (commandLine) {
// TODO: handle remote launches differently?
try
{
try {
this.optionValue = commandLine.handleFlagWithParam(name, false);
}
catch (e)
{
catch (e) {
//"vimperator: option -vimperator requires an argument"
}
}
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler])
// vim: set ft=javascript fdm=marker sw=4 ts=4 et:

View File

@@ -119,8 +119,7 @@ const config = { //{{{
get tempFile() {
let prefix = this.name.toLowerCase();
try
{
try {
prefix += "-" + window.content.document.location.hostname;
}
catch (e) {}
@@ -128,12 +127,10 @@ const config = { //{{{
return prefix + ".tmp";
},
init: function ()
{
init: function () {
commands.add(["winon[ly]"],
"Close all other windows",
function ()
{
function () {
liberator.windows.forEach(function (win) {
if (win != window)
win.close();
@@ -143,10 +140,8 @@ const config = { //{{{
commands.add(["pref[erences]", "prefs"],
"Show " + config.hostApplication + " preferences",
function (args)
{
if (args.bang) // open Firefox settings GUI dialog
{
function (args) {
if (args.bang) { // open Firefox settings GUI dialog
liberator.open("about:config",
(options["newtab"] && options.get("newtab").has("all", "prefs"))
? liberator.NEW_TAB : liberator.CURRENT_TAB);
@@ -161,8 +156,7 @@ const config = { //{{{
commands.add(["sbcl[ose]"],
"Close the sidebar window",
function ()
{
function () {
if (!document.getElementById("sidebar-box").hidden)
window.toggleSidebar();
},
@@ -170,24 +164,20 @@ const config = { //{{{
commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
"Open the sidebar window",
function (args)
{
function (args) {
let arg = args.literalArg;
function compare(a, b) util.compareIgnoreCase(a, b) == 0
// focus if the requested sidebar is already open
if (compare(document.getElementById("sidebar-title").value, arg))
{
if (compare(document.getElementById("sidebar-title").value, arg)) {
document.getElementById("sidebar-box").focus();
return;
}
let menu = document.getElementById("viewSidebarMenu");
for (let [, panel] in Iterator(menu.childNodes))
{
if (compare(panel.label, arg))
{
for (let [, panel] in Iterator(menu.childNodes)) {
if (compare(panel.label, arg)) {
panel.doCommand();
return;
}
@@ -197,8 +187,7 @@ const config = { //{{{
},
{
argCount: "1",
completer: function (context)
{
completer: function (context) {
context.ignoreCase = true;
return completion.sidebar(context);
},
@@ -207,8 +196,7 @@ const config = { //{{{
commands.add(["wind[ow]"],
"Execute a command and tell it to output in a new window",
function (args)
{
function (args) {
liberator.forceNewWindow = true;
liberator.execute(args.string, null, true);
liberator.forceNewWindow = false;
@@ -226,8 +214,7 @@ const config = { //{{{
commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
"Open one or more URLs in a new window",
function (args)
{
function (args) {
args = args.string;
if (args)
@@ -249,8 +236,7 @@ const config = { //{{{
"Set the 'work offline' option",
"boolean", true,
{
setter: function (value)
{
setter: function (value) {
const ioService = services.get("io");
if (ioService.offline == value)
BrowserOffline.toggleOfflineStatus();
@@ -289,8 +275,7 @@ const config = { //{{{
services.get("autoCompleteSearch").startSearch(context.filter, "", context.result, {
onSearchResult: function onSearchResult(search, result) {
timer.tell(result);
if (result.searchResult <= result.RESULT_SUCCESS)
{
if (result.searchResult <= result.RESULT_SUCCESS) {
searchRunning = false;
timer.flush();
}

View File

@@ -4,8 +4,7 @@
// given in the LICENSE.txt file included with this file.
function checkFragment()
{
function checkFragment() {
let frag = document.location.hash.substr(1);
if (!frag || document.getElementById(frag))
return;

View File

@@ -76,8 +76,7 @@ let functions = [
// even after doing major Vimperator refactoring
/////////////////////////////////////////////////////////////////////////////////////////
function resetEnvironment()
{
function resetEnvironment() {
multilineOutput.contentDocument.body.innerHTML = "";
singlelineOutput.value = "";
commandline.close();
@@ -91,8 +90,7 @@ function getSinglelineOutput() singlelineOutput.value;
function getTabIndex() getBrowser().mTabContainer.selectedIndex;
function getTabCount() getBrowser().mTabs.length;
function getBufferPosition()
{
function getBufferPosition() {
let win = window.content;
return { x: win.scrollMaxX ? win.pageXOffset / win.scrollMaxX : 0,
y: win.scrollMaxY ? win.pageYOffset / win.scrollMaxY : 0 }
@@ -100,8 +98,7 @@ function getBufferPosition()
function getLocation() window.content.document.location.href;
function echoLine(str, group)
{
function echoLine(str, group) {
if (!doc)
return;
@@ -109,8 +106,7 @@ function echoLine(str, group)
<div highlight={group} style="border: 1px solid gray; white-space: pre; height: 1.5em; line-height: 1.5em;">{str}</div>,
doc));
}
function echoMulti(str, group)
{
function echoMulti(str, group) {
if (!doc)
return;
@@ -122,8 +118,7 @@ function echoMulti(str, group)
commands.addUserCommand(["regr[essions]"],
"Run regression tests",
function (args)
{
function (args) {
// TODO: might need to increase the 'messages' option temporarily
// TODO: count (better even range) support to just run test 34 of 102
// TODO: bang support to either: a) run commands like deleting bookmarks which
@@ -131,8 +126,7 @@ commands.addUserCommand(["regr[essions]"],
// just Ex command tests; Yet to be decided
let updateOutputHeight = null;
function init()
{
function init() {
liberator.registerObserver("echoLine", echoLine);
liberator.registerObserver("echoMultiline", echoMulti);
liberator.open("chrome://liberator/content/buffer.xhtml", liberator.NEW_TAB);
@@ -141,23 +135,20 @@ commands.addUserCommand(["regr[essions]"],
doc.body.setAttributeNS(NS.uri, "highlight", "CmdLine");
updateOutputHeight = commandline.updateOutputHeight;
commandline.updateOutputHeight = function (open)
{
commandline.updateOutputHeight = function (open) {
let elem = document.getElementById("liberator-multiline-output");
if (open)
elem.collapsed = false;
elem.height = 0;
};
}
function cleanup()
{
function cleanup() {
liberator.unregisterObserver("echoLine", echoLine);
liberator.unregisterObserver("echoMultiline", echoMulti);
commandline.updateOutputHeight = updateOutputHeight;
}
function run()
{
function run() {
let now = Date.now();
let totalTests = tests.length + functions.length;
let successfulTests = 0;
@@ -169,17 +160,14 @@ commands.addUserCommand(["regr[essions]"],
// TODO: might want to unify 'tests' and 'functions' handling
// 1.) run commands and mappings tests
outer:
for (let [, test] in Iterator(tests))
{
for (let [, test] in Iterator(tests)) {
currentTest++;
if (args.count >= 1 && currentTest != args.count)
continue;
let testDescription = util.clip(test.cmds.join(" -> "), 80);
for (let [, cmd] in Iterator(test.cmds))
{
if (skipTests.indexOf(cmd) != -1)
{
for (let [, cmd] in Iterator(test.cmds)) {
if (skipTests.indexOf(cmd) != -1) {
skippedTests++;
liberator.echomsg("Skipping test " + currentTest + " of " + totalTests + ": " + testDescription, 0);
continue outer;
@@ -205,8 +193,7 @@ commands.addUserCommand(["regr[essions]"],
}
// 2.) Run function tests
for (let [, func] in Iterator(functions))
{
for (let [, func] in Iterator(functions)) {
currentTest++;
if (args.count >= 1 && currentTest != args.count)
continue;
@@ -232,8 +219,7 @@ commands.addUserCommand(["regr[essions]"],
liberator.execute(":messages");
}
if (!args.bang)
{
if (!args.bang) {
liberator.echo(<e4x>
<span style="font-weight: bold">Running tests should always be done in a new profile.</span><br/>

View File

@@ -25,19 +25,16 @@ AboutHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function (uri)
{
newChannel: function (uri) {
let channel = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
.newChannel("chrome://" + name + "/content/about.html", null, null);
channel.originalURI = uri;
return channel;
},
getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT,
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([AboutHandler])
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -11,8 +11,7 @@ const Name = "Xulmus";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const name = Name.toLowerCase();
function CommandLineHandler()
{
function CommandLineHandler() {
this.wrappedJSObject = this;
}
CommandLineHandler.prototype = {
@@ -30,20 +29,17 @@ CommandLineHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]),
handle: function (commandLine)
{
handle: function (commandLine) {
// TODO: handle remote launches differently?
try
{
try {
this.optionValue = commandLine.handleFlagWithParam(name, false);
}
catch (e)
{
catch (e) {
//"vimperator: option -vimperator requires an argument"
}
}
};
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler]);
function NSGetModule(compMgr, fileSpec) XPCOMUtils.generateModule([CommandLineHandler])
// vim: set ft=javascript fdm=marker sw=4 ts=4 et:

View File

@@ -124,8 +124,7 @@ const config = { //{{{
function () { SBSubscribe(); }]
],
focusChange: function ()
{
focusChange: function () {
// Switch to -- PLAYER -- mode for Songbird Media Player.
if (config.isPlayerWindow)
liberator.mode = modes.PLAYER;
@@ -156,19 +155,16 @@ const config = { //{{{
],
// FIXME: tab arg and media tab exception?
stop: function (tab)
{
stop: function (tab) {
SBGetBrowser().mCurrentBrowser.stop();
},
init: function ()
{
init: function () {
// Adding a mode for Player
//modes.addMode("PLAYER"); // Player mode for songbird
// TODO: support 'nrformats'? -> probably not worth it --mst
function incrementURL(count)
{
function incrementURL(count) {
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
if (!matches)
return void liberator.beep();
@@ -176,8 +172,7 @@ const config = { //{{{
let [, pre, number, post] = matches;
let newNumber = parseInt(number, 10) + count;
let newNumberStr = String(newNumber > 0 ? newNumber : 0);
if (number.match(/^0/)) // add 0009<C-a> should become 0010
{
if (number.match(/^0/)) { // add 0009<C-a> should become 0010
while (newNumberStr.length < number.length)
newNumberStr = "0" + newNumberStr;
}
@@ -185,19 +180,16 @@ const config = { //{{{
liberator.open(pre + newNumberStr + post);
}
function showServicePane(value)
{
function showServicePane(value) {
const key = "splitter.servicepane_splitter.was_collapsed";
gServicePane.open = value;
SBDataSetBoolValue(key, gServicePane.open);
}
function openDisplayPane(id)
{
function openDisplayPane(id) {
if (id == "servicepane")
showServicePane(true);
else
{
else {
let pane = document.getElementById(id);
let manager = Cc['@songbirdnest.com/Songbird/DisplayPane/Manager;1'].getService(Ci.sbIDisplayPaneManager);
let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue);
@@ -209,8 +201,7 @@ const config = { //{{{
}
}
function closeDisplayPane(id)
{
function closeDisplayPane(id) {
if (id == "servicepane")
showServicePane(false);
else
@@ -270,8 +261,7 @@ const config = { //{{{
commands.add(["dpcl[ose]"],
"Close a display pane",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg in displayPanes)
@@ -289,8 +279,7 @@ const config = { //{{{
// TODO: this should accept a second arg to specify content
commands.add(["displayp[ane]", "dp[ane]", "dpope[n]"],
"Open a display pane",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg in displayPanes)
@@ -307,10 +296,8 @@ const config = { //{{{
commands.add(["pref[erences]", "prefs"],
"Show " + config.hostApplication + " preferences",
function (args)
{
if (args.bang) // open Songbird settings GUI dialog
{
function (args) {
if (args.bang) { // open Songbird settings GUI dialog
liberator.open("about:config",
(options["newtab"] && options.get("newtab").has("all", "prefs"))
? liberator.NEW_TAB : liberator.CURRENT_TAB);
@@ -332,8 +319,7 @@ const config = { //{{{
"Set the 'work offline' option",
"boolean", true,
{
setter: function (value)
{
setter: function (value) {
const ioService = services.get("io");
ioService.offline = !value;
options.setPref("browser.offline", ioService.offline);

View File

@@ -4,8 +4,8 @@
// given in the LICENSE.txt file included with this file.
function Library() //{{{
{
function Library() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -14,8 +14,7 @@ function Library() //{{{
function toJSArray(enum) ArrayConverter.JSArray(enum)
function getArtistsArray()
{
function getArtistsArray() {
return toJSArray(MAIN_LIBRARY.getDistinctValuesForProperty(SBProperties.artistName));
}
@@ -44,8 +43,7 @@ function Library() //{{{
* @param {param} artist The artist name.
* @returns {string[]}
*/
getAlbums: function getAlbums(artist)
{
getAlbums: function getAlbums(artist) {
let albums = toJSArray(MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
.map(function (track) track.getProperty(SBProperties.albumName));
return util.Array.uniq(albums);
@@ -59,8 +57,7 @@ function Library() //{{{
* @param {param} album The album name.
* @returns {string[]}
*/
getTracks: function getTracks(artist, album)
{
getTracks: function getTracks(artist, album) {
const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
.createInstance(Ci.sbIMutablePropertyArray);

View File

@@ -4,8 +4,8 @@
// given in the LICENSE.txt file included with this file.
function Player() //{{{
{
function Player() { //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -26,22 +26,18 @@ function Player() //{{{
commandline.registerCallback("cancel", modes.SEARCH_VIEW_FORWARD, function () { player.onSearchCancel(); });
// interval (milliseconds)
function seek(interval, direction)
{
function seek(interval, direction) {
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
player.seekTo(position + (direction ? interval : -interval));
}
function focusTrack(mediaItem)
{
function focusTrack(mediaItem) {
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
}
var mediaCoreListener = {
onMediacoreEvent: function (event)
{
switch (event.type)
{
onMediacoreEvent: function (event) {
switch (event.type) {
case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
liberator.log("Before track changed: " + event.data);
autocommands.trigger("TrackChangePre", { track: event.data });
@@ -193,8 +189,7 @@ function Player() //{{{
["N"], "Find the previous track",
function () { player.searchViewAgain(true);});
for (let i in util.range(0, 6))
{
for (let i in util.range(0, 6)) {
let (rating = i) {
mappings.add([modes.PLAYER],
["<C-" + rating + ">"], "Rate the current media item " + rating,
@@ -208,15 +203,13 @@ function Player() //{{{
commands.add(["f[ilter]"],
"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);
if (view.length == 0)
liberator.echoerr("No Tracks matching the keywords");
else
{
else {
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
"chrome://songbird/content/mediapages/filtersPage.xul");
// TODO: make this focusTrack work ?
@@ -231,19 +224,15 @@ function Player() //{{{
commands.add(["load"],
"Load a playlist",
function (args)
{
function (args) {
let arg = args.literalArg;
if (arg)
{
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)
{
for ([i, list] in Iterator(playlists)) {
if (util.compareIgnoreCase(arg, list.name) == 0) {
SBGetBrowser().loadMediaList(playlists[i]);
focusTrack(_SBGetCurrentView().getItemByIndex(0));
return;
@@ -252,8 +241,7 @@ function Player() //{{{
liberator.echoerr("E475: Invalid argument: " + arg);
}
else
{
else {
// load main library if there are no args
_SBShowMainLibrary();
}
@@ -287,8 +275,7 @@ function Player() //{{{
commands.add(["see[k]"],
"Seek to a track position",
function (args)
{
function (args) {
let arg = args[0];
// intentionally supports 999:99:99
@@ -297,14 +284,12 @@ function Player() //{{{
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
if (/:/.test(arg))
{
if (/:/.test(arg)) {
let [seconds, minutes, hours] = arg.split(":").reverse();
hours = hours || 0;
var value = ms(seconds, "s") + ms(minutes, "m") + ms(hours, "h");
}
else
{
else {
if (!/[smh]/.test(arg.substr(-1)))
arg += "s"; // default to seconds
@@ -321,22 +306,18 @@ function Player() //{{{
commands.add(["mediav[iew]"],
"Change the current media view",
function (args)
{
function (args) {
// FIXME: is this a SB restriction? --djk
if (!gBrowser.currentMediaPage)
return void liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
let arg = args[0];
if (arg)
{
if (arg) {
let pages = player.getMediaPages();
for ([, page] in Iterator(pages))
{
if (util.compareIgnoreCase(arg, page.contentTitle) == 0)
{
for ([, page] in Iterator(pages)) {
if (util.compareIgnoreCase(arg, page.contentTitle) == 0) {
player.loadMediaPage(page, gBrowser.currentMediaListView.mediaList, gBrowser.currentMediaListView);
return;
}
@@ -353,8 +334,7 @@ function Player() //{{{
commands.add(["sort[view]"],
"Sort the current media view",
function (args)
{
function (args) {
player.sortBy(args, true);
});
@@ -362,8 +342,7 @@ function Player() //{{{
// FIXME: use :add -q like cmus? (not very vim-like are it's multi-option commands) --djk
commands.add(["qu[eue]"],
"Queue tracks by artist/album/track",
function (args)
{
function (args) {
// Store the old view
// let prev_view = gMM.status.view;
let library = LibraryUtils.mainLibrary;
@@ -372,8 +351,7 @@ function Player() //{{{
.createInstance(Ci.sbIMutablePropertyArray);
// args
switch (args.length)
{
switch (args.length) {
case 3:
customProps.appendProperty(SBProperties.trackName, args[2]);
case 2:
@@ -396,8 +374,7 @@ function Player() //{{{
// TODO: maybe :vol! could toggle mute on/off? --djk
commands.add(["vol[ume]"],
"Set the volume",
function (args)
{
function (args) {
let arg = args[0];
if (!/^[+-]?\d+$/.test(arg))
@@ -421,18 +398,15 @@ function Player() //{{{
function map(list) list.map(function (i) [i, ""]);
let [artist, album] = [args[0], args[1]];
if (args.completeArg == 0)
{
if (args.completeArg == 0) {
context.title = ["Artists"];
context.completions = map(library.getArtists());
}
else if (args.completeArg == 1)
{
else if (args.completeArg == 1) {
context.title = ["Albums by " + artist];
context.completions = map(library.getAlbums(artist));
}
else if (args.completeArg == 2)
{
else if (args.completeArg == 2) {
context.title = ["Tracks from " + album + " by " + artist];
context.completions = map(library.getTracks(artist, album));
}
@@ -462,53 +436,44 @@ function Player() //{{{
* @property {string} The player volume as a percentage.
*/
get volume() gMM.volumeControl.volume,
set volume(value)
{
set volume(value) {
gMM.volumeControl.volume = value;
},
// FIXME: can't be called from non-media tabs since 840e78
play: function play()
{
play: function play() {
// Check if there is any selection in place, else play first item of the visible view.
if (_SBGetCurrentView().selection.count != 0)
{
if (_SBGetCurrentView().selection.count != 0) {
// Play the selection.
gMM.sequencer.playView(_SBGetCurrentView(), _SBGetCurrentView().getIndexForItem(_SBGetCurrentView().selection.currentMediaItem));
focusTrack(gMM.sequencer.currentItem);
}
else
{
else {
gMM.sequencer.playView(SBGetBrowser().currentMediaListView, 0);
focusTrack(gMM.sequencer.currentItem);
}
},
stop: function stop()
{
stop: function stop() {
gMM.sequencer.stop();
},
next: function next()
{
next: function next() {
gSongbirdWindowController.doCommand("cmd_control_next");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
previous: function previous()
{
previous: function previous() {
gSongbirdWindowController.doCommand("cmd_control_previous");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
togglePlayPause: function togglePlayPause()
{
togglePlayPause: function togglePlayPause() {
gSongbirdWindowController.doCommand("cmd_control_playpause");
focusTrack(gMM.sequencer.currentItem);
},
toggleShuffle: function toggleShuffle()
{
toggleShuffle: function toggleShuffle() {
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
else
@@ -516,10 +481,8 @@ function Player() //{{{
},
// FIXME: not really toggling - good enough for now.
toggleRepeat: function toggleRepeat()
{
switch (gMM.sequencer.repeatMode)
{
toggleRepeat: function toggleRepeat() {
switch (gMM.sequencer.repeatMode) {
case gMM.sequencer.MODE_REPEAT_NONE:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
break;
@@ -542,8 +505,7 @@ function Player() //{{{
* @param {number} interval The time interval (ms) to advance the
* current track.
*/
seekForward: function seekForward(interval)
{
seekForward: function seekForward(interval) {
seek(interval, true);
},
@@ -554,8 +516,7 @@ function Player() //{{{
* @param {number} interval The time interval (ms) to rewind the
* current track.
*/
seekBackward: function seekBackward(interval)
{
seekBackward: function seekBackward(interval) {
seek(interval, false);
},
@@ -564,8 +525,7 @@ function Player() //{{{
*
* @param {number} The new position (ms) in the track.
*/
seekTo: function seekTo(position)
{
seekTo: function seekTo(position) {
// FIXME: if not playing
if (!gMM.playbackControl)
this.play();
@@ -578,32 +538,27 @@ function Player() //{{{
// FIXME: 10% ?
// I think just general increments of say 0.05 might be better --djk
increaseVolume: function increaseVolume()
{
increaseVolume: function increaseVolume() {
gMM.volumeControl.volume = gMM.volumeControl.volume * 1.1;
},
decreaseVolume: function decreaseVolume()
{
decreaseVolume: function decreaseVolume() {
if (gMM.volumeControl.volume == 0)
gMM.volumeControl.volume = 0.1;
else
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
},
focusPlayingTrack :function focusPlayingTrack()
{
focusPlayingTrack :function focusPlayingTrack() {
focusTrack(gMM.sequencer.currentItem);
},
listTracks: function listTracks(view)
{
listTracks: function listTracks(view) {
//let myView = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args);
let length = view.length;
let tracksList = [];
for (let i = 0; i < length; i++)
{
for (let i = 0; i < length; i++) {
let mediaItem = view.getItemByIndex(i);
let trackName = mediaItem.getProperty(SBProperties.trackName);
let albumName = mediaItem.getProperty(SBProperties.albumName);
@@ -615,8 +570,7 @@ function Player() //{{{
return tracksList;
},
searchView: function searchView(args)
{
searchView: function searchView(args) {
let currentView = _SBGetCurrentView();
let mediaItemList = currentView.mediaList;
let search = _getSearchString(currentView);
@@ -631,8 +585,7 @@ function Player() //{{{
let mySearchView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
if (mySearchView.length)
{
if (mySearchView.length) {
lastSearchView = mySearchView;
lastSearchIndex = 0;
focusTrack(mySearchView.getItemByIndex(lastSearchIndex));
@@ -641,29 +594,23 @@ function Player() //{{{
liberator.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
},
searchViewAgain: function searchViewAgain(reverse)
{
function echo(str)
{
searchViewAgain: function searchViewAgain(reverse) {
function echo(str) {
setTimeout(function () {
commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
}, 0);
}
if (reverse)
{
if (lastSearchIndex == 0)
{
if (reverse) {
if (lastSearchIndex == 0) {
lastSearchIndex = lastSearchView.length - 1;
echo("Search hit TOP, continuing at BOTTOM");
}
else
lastSearchIndex = lastSearchIndex - 1;
}
else
{
if (lastSearchIndex == (lastSearchView.length - 1))
{
else {
if (lastSearchIndex == (lastSearchView.length - 1)) {
lastSearchIndex = 0;
echo("Search hit BOTTOM, continuing at TOP");
}
@@ -682,8 +629,7 @@ function Player() //{{{
*
* @param {string} str The contents of the search dialog.
*/
onSearchKeyPress: function (str)
{
onSearchKeyPress: function (str) {
if (options["incsearch"])
this.searchView(str);
},
@@ -693,28 +639,24 @@ function Player() //{{{
*
* @param {string} str The contents of the search dialog.
*/
onSearchSubmit: function (str)
{
onSearchSubmit: function (str) {
this.searchView(str);
},
/**
* The search dialog cancel callback.
*/
onSearchCancel: function ()
{
onSearchCancel: function () {
// TODO: restore the view state if altered by an 'incsearch' search
},
getPlaylists: function getPlaylists()
{
getPlaylists: function getPlaylists() {
let mainLibrary = LibraryUtils.mainLibrary;
let playlists = [mainLibrary];
let listener = {
onEnumerationBegin: function () { },
onEnumerationEnd: function () { },
onEnumeratedItem: function (list, item)
{
onEnumeratedItem: function (list, item) {
// FIXME: why are there null items and duplicates?
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
playlists.push(item);
@@ -728,42 +670,35 @@ function Player() //{{{
},
// Play track at 'row' in 'playlist'
playPlaylist: function playPlaylist(playlist, row)
{
playPlaylist: function playPlaylist(playlist, row) {
gMM.sequencer.playView(playlist.createView(), row);
},
getMediaPages: function getMediaPages()
{
getMediaPages: function getMediaPages() {
let list = gBrowser.currentMediaPage.mediaListView.mediaList;
let pages = services.get("mediaPageManager").getAvailablePages(list);
return ArrayConverter.JSArray(pages).map(function (page) page.QueryInterface(Ci.sbIMediaPageInfo));
},
loadMediaPage: function loadMediaList(page, list, view)
{
loadMediaPage: function loadMediaList(page, list, view) {
services.get("mediaPageManager").setPage(list, page);
gBrowser.loadMediaList(list, null, null, view, null);
},
rateMediaItem: function rateMediaItem(rating)
{
rateMediaItem: function rateMediaItem(rating) {
if (gMM.sequencer.currentItem)
gMM.sequencer.currentItem.setProperty(SBProperties.rating, rating);
},
getUserViewable: function getUserViewable()
{
getUserViewable: function getUserViewable() {
let propManager = services.get("propertyManager");
let propEnumerator = propManager.propertyIDs;
let properties = [];
while (propEnumerator.hasMore())
{
while (propEnumerator.hasMore()) {
let propertyId = propEnumerator.getNext();
if (propManager.getPropertyInfo(propertyId).userViewable)
{
if (propManager.getPropertyInfo(propertyId).userViewable) {
//liberator.dump("propertyId - " + propManager.getPropertyInfo(propertyId).id);
properties.push(propManager.getPropertyInfo(propertyId).displayName);
}
@@ -772,13 +707,11 @@ function Player() //{{{
return properties;
},
sortBy: function sortBy(property, order)
{
sortBy: function sortBy(property, order) {
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
liberator.dump("Property: " + property);
switch (property.string)
{
switch (property.string) {
case "#":
case "Title":
pa.appendProperty(SBProperties.trackName, "a");