Update library

This commit is contained in:
Piro / YUKI Hiroshi 2013-11-07 21:16:50 +09:00
parent 10817a04d0
commit a13cbb754f

View File

@ -42,7 +42,7 @@ if (typeof window == 'undefined' ||
} }
(function() { (function() {
const currentRevision = 10; const currentRevision = 13;
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
@ -103,24 +103,50 @@ if (typeof window == 'undefined' ||
} }
}, },
getLocalizedPref : function(aPrefstring)
{
try {
return this.getPref(aPrefstring, Ci.nsIPrefLocalizedString).data;
} catch(e) {
return this.getPref(aPrefstring);
}
},
getDefaultPref : function(aPrefstring, aInterface) getDefaultPref : function(aPrefstring, aInterface)
{ {
return this.getPref(aPrefstring, this.DefaultPrefs, aInterface); return this.getPref(aPrefstring, this.DefaultPrefs, aInterface);
}, },
setPref : function(aPrefstring, aNewValue, aBranch) setPref : function(aPrefstring, aNewValue)
{ {
aBranch = aBranch || this.Prefs; var branch = this.Prefs;
var interface = null;
if (arguments.length > 2) {
for (let i = 2; i < arguments.length; i++)
{
let arg = arguments[i];
if (!arg)
continue;
if (arg instanceof Ci.nsIPrefBranch)
branch = arg;
else
interface = arg;
}
}
if (interface &&
aNewValue instanceof Ci.nsISupports) {
return branch.setComplexValue(aPrefstring, interface, aNewValue);
}
switch (typeof aNewValue) switch (typeof aNewValue)
{ {
case 'string': case 'string':
return aBranch.setCharPref(aPrefstring, unescape(encodeURIComponent(aNewValue))); return branch.setCharPref(aPrefstring, unescape(encodeURIComponent(aNewValue)));
case 'number': case 'number':
return aBranch.setIntPref(aPrefstring, parseInt(aNewValue)); return branch.setIntPref(aPrefstring, parseInt(aNewValue));
default: default:
return aBranch.setBoolPref(aPrefstring, !!aNewValue); return branch.setBoolPref(aPrefstring, !!aNewValue);
} }
}, },
@ -145,7 +171,8 @@ if (typeof window == 'undefined' ||
{ {
var foundChildren = {}; var foundChildren = {};
var possibleChildren = []; var possibleChildren = [];
var actualChildren = this.getDescendant(aRoot, aBranch) var actualChildren = [];
this.getDescendant(aRoot, aBranch)
.forEach(function(aPrefstring) { .forEach(function(aPrefstring) {
var name = aPrefstring.replace(aRoot, ''); var name = aPrefstring.replace(aRoot, '');
if (name.charAt(0) == '.') if (name.charAt(0) == '.')