This file contains 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
var text = "Long text with newlines"; | |
text.split(/\r\n?|\n/); // Preserves empty lines. | |
text.split(/[\r\n]+/); // Drops empty lines. |
This file contains 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
// Retrieve your data from locaStorage | |
var saveData = JSON.parse(localStorage.saveData || null) || {}; | |
// Store your data. | |
function saveStuff(obj) { | |
saveData.obj = obj; | |
// saveData.foo = foo; | |
saveData.time = new Date().getTime(); | |
localStorage.saveData = JSON.stringify(saveData); | |
} |
This file contains 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
var L = navigator.plugins.length; | |
document.write( | |
L.toString() + " Plugin(s)<br>" + | |
"Name | Filename | Description<br>"); | |
for (var i = 0; i < L; i++) { | |
document.write( | |
navigator.plugins[i].name + | |
" | " + navigator.plugins[i].filename + |
This file contains 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 createGUID() { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | |
var r = Math.random() * 16 | 0, | |
v = c == 'x' ? r : (r & 0x3 | 0x8); | |
return v.toString(16); | |
}); | |
} |