GUID generator (nonfiction): Difference between revisions

From Gnomon Chronicles
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 2: Line 2:


<code>
<code>
<nowiki>
var Guid = (function () {
var Guid = (function () {
     function Guid(guid) {
     function Guid(guid) {
Line 27: Line 26:
     return Guid;
     return Guid;
}());
}());
Guid.MakeNew().ToString();
Guid.MakeNew().ToString();
</nowiki>
</code>
</code>


[[Category:Nonfiction (nonfiction)]]
[[Category:Nonfiction (nonfiction)]]
[[Category:To do (nonfiction)]]
[[Category:To do (nonfiction)]]

Latest revision as of 08:27, 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();