GUID generator (nonfiction): Difference between revisions
From Gnomon Chronicles
(Created page with "GUID generator (JavaScript): <code> var Guid = (function () { function Guid(guid) { this.guid = guid; this._guid = guid; } Guid.prototype.ToString...") |
No edit summary |
||
Line 2: | Line 2: | ||
<code> | <code> | ||
<nowiki> | |||
var Guid = (function () { | var Guid = (function () { | ||
function Guid(guid) { | function Guid(guid) { | ||
Line 28: | Line 29: | ||
Guid.MakeNew().ToString(); | Guid.MakeNew().ToString(); | ||
</nowiki> | |||
</code> | </code> | ||
[[Category:Nonfiction (nonfiction)]] | [[Category:Nonfiction (nonfiction)]] | ||
[[Category:To do (nonfiction)]] | [[Category:To do (nonfiction)]] |
Revision as of 09:26, 17 May 2019
GUID generator (JavaScript):
var Guid = (function () {
function Guid(guid) {
this.guid = guid;
this._guid = guid;
}
Guid.prototype.ToString = function () {
return this.guid;
};
// Static member
Guid.MakeNew = function () {
var result;
var i;
var j;
result = "";
for (j = 0; j < 12; j++) {
if (j == 8 || j == 12 || j == 16 || j == 20)
result;
i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
result = result + i;
}
return new Guid(result);
};
return Guid;
}());
Guid.MakeNew().ToString();