1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 11:27:58 +01:00

Make :style better

This commit is contained in:
Kris Maglione
2008-10-04 19:22:54 +00:00
parent 2ebb57fe93
commit 4b4e578dc3
4 changed files with 107 additions and 40 deletions

View File

@@ -172,6 +172,20 @@ liberator.util = { //{{{
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
},
escapeRegex: function (str)
{
return str.replace(/([\\{}()[\].?*+])/g, "\\$1");
},
// Flatten an array:
// [["foo", "bar"], ["baz"]] -> ["foo", "bar", "baz"]
flatten: function (ary)
{
if (ary.length == 0)
return [];
return Array.concat.apply(Array, ary);
},
formatBytes: function (num, decimalPlaces, humanReadable)
{
const unitVal = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
@@ -416,6 +430,18 @@ liberator.util = { //{{{
return urls;
},
uniq: function (ary)
{
let ret = [];
for (let [,item] in Iterator(ary.sort()))
{
if (item != last || !ret.length)
ret.push(item);
var last = item;
}
return ret;
},
xmlToDom: function (node, doc)
{
switch (node.nodeKind())