Subversion Repositories oidplus

Rev

Rev 782 | View as "text/javascript" | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * OIDplus 2.0
  3.  * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17.  
  18. var OIDplusObjectTypePluginGuid = {
  19.  
  20.         oid: "1.3.6.1.4.1.37476.2.5.2.4.8.3",
  21.  
  22.         generateRandomGUID: function() {
  23.                 /*
  24.                 // https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
  25.             // http://www.ietf.org/rfc/rfc4122.txt
  26.             var s = [];
  27.             var hexDigits = "0123456789abcdef";
  28.             for (var i = 0; i < 36; i++) {
  29.                 s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  30.             }
  31.             s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
  32.             s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
  33.             s[8] = s[13] = s[18] = s[23] = "-";
  34.  
  35.             var uuid = s.join("");
  36.             $("#id").val(uuid);
  37.                  */
  38.  
  39.                 $("#id").val(_L("Please wait..."));
  40.                 $.ajax({
  41.                         url:"ajax.php",
  42.                         method:"POST",
  43.                         beforeSend: function(jqXHR, settings) {
  44.                                 $.xhrPool.abortAll();
  45.                                 $.xhrPool.add(jqXHR);
  46.                         },
  47.                         complete: function(jqXHR, text) {
  48.                                 $.xhrPool.remove(jqXHR);
  49.                         },
  50.                         data: {
  51.                                 csrf_token:csrf_token,
  52.                                 plugin:OIDplusPagePublicObjects.oid,
  53.                                 action:"generate_uuid"
  54.                         },
  55.                         error: oidplus_ajax_error,
  56.                         success: function (data) {
  57.                                 oidplus_ajax_success(data, function (data) {
  58.                                         $("#id").val(data.uuid);
  59.                                         //alertSuccess(_L("OK! Generated UUID %1", data.uuid));
  60.                                 });
  61.                         }
  62.                 });
  63.         }
  64.  
  65. };
  66.