Created
September 8, 2011 13:15
-
-
Save watagashi/1203362 to your computer and use it in GitHub Desktop.
Online Study TokyoBouldering.js – Lingr http://lingr.com/room/tkbjs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.method = function (name, func) { | |
if (!this.prototype[name]) { | |
this.prototype[name] = func; | |
return this; | |
} | |
}; | |
String.method('entityify', function () { | |
var character = { | |
'<' : '<', | |
'>' : '>', | |
'&' : '&', | |
'"' : '"' | |
}; | |
return function () { | |
return this.replace(/[<>&"]/g, function (c) { | |
return character[c]; | |
}); | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment