mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
use underscore.js
This commit is contained in:
parent
692e77b4e5
commit
e559df18ce
13 changed files with 1069 additions and 113 deletions
|
@ -33,56 +33,6 @@ function object(o)
|
|||
f.prototype = o;
|
||||
return new f();
|
||||
}
|
||||
|
||||
function extend(obj, props)
|
||||
{
|
||||
for (var p in props)
|
||||
{
|
||||
obj[p] = props[p];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
var forEachImpl = function(fn){
|
||||
for (var i = 0; i < this.length; i++)
|
||||
{
|
||||
var result = fn(this[i], i, this);
|
||||
}
|
||||
}
|
||||
|
||||
function mapImpl(fn)
|
||||
{
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < this.length; i++)
|
||||
{
|
||||
if (fn) result.push(fn(this[i], i, this));
|
||||
else result.push(this[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// From underscore.js
|
||||
var keysImpl =function(obj) {
|
||||
if (obj !== Object(obj)) throw new TypeError('Invalid object');
|
||||
var keys = [];
|
||||
for (var key in obj) if (obj.hasOwnProperty(key)) keys.push(key);
|
||||
|
||||
return keys;
|
||||
};
|
||||
|
||||
Array.prototype.forEach = Array.prototype.forEach || forEachImpl;
|
||||
Array.prototype.each = Array.prototype.each || forEachImpl;
|
||||
Array.prototype.map = Array.prototype.map || mapImpl;
|
||||
Object.keys = Object.keys || keysImpl;
|
||||
|
||||
function isArray(testObject)
|
||||
{
|
||||
return testObject && typeof testObject === 'object' && !(testObject.propertyIsEnumerable('length')) && typeof testObject.length === 'number';
|
||||
}
|
||||
|
||||
var userAgent = (((function () {return this;})().navigator || {}).userAgent || 'node-js').toLowerCase();
|
||||
|
||||
// Figure out what browser is being used (stolen from jquery 1.2.1)
|
||||
|
@ -144,12 +94,9 @@ function htmlPrettyEscape(str)
|
|||
}
|
||||
|
||||
var noop = function(){};
|
||||
var identity = function(x){return x};
|
||||
|
||||
exports.isNodeText = isNodeText;
|
||||
exports.object = object;
|
||||
exports.extend = extend;
|
||||
exports.isArray = isArray;
|
||||
exports.browser = browser;
|
||||
exports.getAssoc = getAssoc;
|
||||
exports.setAssoc = setAssoc;
|
||||
|
@ -157,4 +104,3 @@ exports.binarySearch = binarySearch;
|
|||
exports.binarySearchInfinite = binarySearchInfinite;
|
||||
exports.htmlPrettyEscape = htmlPrettyEscape;
|
||||
exports.noop = noop;
|
||||
exports.identity = identity;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue