/usr/share/shake/html/shake-util.js is in libghc-shake-data 0.13.2+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /*jsl:option explicit*/
"use strict";
/////////////////////////////////////////////////////////////////////
// JQUERY EXTENSIONS
jQuery.fn.enable = function (x)
{
// Set the values to enabled/disabled
return this.each(function () {
if (x)
$(this).removeAttr('disabled');
else
$(this).attr('disabled','disabled');
});
};
jQuery.getParameters = function()
{
// From http://stackoverflow.com/questions/901115/get-querystring-values-with-jquery/3867610#3867610
var params = {};
var a = /\+/g; // Regex for replacing addition symbol with a space
var r = /([^&=]+)=?([^&]*)/g;
var d = function (s) { return decodeURIComponent(s.replace(a, " ")); };
var q = window.location.search.substring(1);
while (true)
{
var e = r.exec(q);
if (!e) break;
params[d(e[1])] = d(e[2]);
}
return params;
};
/////////////////////////////////////////////////////////////////////
// STRING FORMATTING
function /* export */ showTime(x) // :: Double -> String
{
function digits(x){var s = String(x); return s.length === 1 ? "0" + s : s;}
if (x >= 3600)
{
x = Math.round(x / 60);
return Math.floor(x / 60) + "h" + digits(x % 60) + "m";
}
else if (x >= 60)
{
x = Math.round(x);
return Math.floor(x / 60) + "m" + digits(x % 60) + "s";
}
else
return x.toFixed(2) + "s";
}
function /* export */ showPerc(x) // :: Double -> String
{
return (x*100).toFixed(2) + "%";
}
function /* export */ plural(n,not1,is1) // :: Int -> Maybe String -> Maybe String -> String
{
return n === 1
? (is1 === undefined ? "" : is1)
: (not1 === undefined ? "s" : not1);
}
/////////////////////////////////////////////////////////////////////
// MISC
function sum(xs) // :: Num a => [a] -> a
{
var res = 0;
for (var i = 0; i < xs.length; i++)
res += xs[i];
return res;
}
function testRegExp(r, s)
{
if (typeof r === "string")
return s.indexOf(r) !== -1;
else
return r.test(s);
}
function execRegExp(r, s)
{
if (typeof r === "string")
return s.indexOf(r) === -1 ? null : [];
else
return r.exec(s);
}
function listEq(xs, ys) // :: Eq a => [a] -> [a] -> Bool
{
if (xs.length !== ys.length) return false;
for (var i = 0; i < xs.length; i++)
{
if (xs[i] !== ys[i])
return false;
}
return true;
}
function cache(str, f) // :: (k -> String) -> (k -> v) -> (k -> v)
{
var cache = {};
return function(k){
var s = str(k);
if (!(s in cache))
cache[s] = f(k);
return cache[s];
};
}
function recordEq(xs, ys) // :: Record -> Record -> Bool
{
function f(a,b)
{
for (var s in a)
{
if (a[s] !== b[s]) return false;
}
return true;
}
return f(xs,ys) && f(ys,xs);
}
function recordCopy(xs) // :: Record -> Record
{
var res = {};
for (var s in xs)
res[s] = xs[s];
return res;
}
function recordUnion(xs,ys) // :: Record -> Record -> Record -- left biased
{
var res = recordCopy(ys);
for (var s in xs)
res[s] = xs[s];
return res;
}
function concatNub(xs) // :: Eq a => [[a]] -> [a]
{
var res = [];
var seen = {};
for (var i = 0; i < xs.length; i++)
{
var x = xs[i];
for (var j = 0; j < x.length; j++)
{
var e = x[j];
if (!(e in seen))
{
seen[e] = null;
res.push(e);
}
}
}
return res;
}
|