GUID generator (nonfiction)

From Gnomon Chronicles
Revision as of 08:26, 17 May 2019 by Admin (talk | contribs) (Created page with "GUID generator (JavaScript): <code> var Guid = (function () { function Guid(guid) { this.guid = guid; this._guid = guid; } Guid.prototype.ToString...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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();