Subversion Repositories oidplus

Rev

Rev 1288 | 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 OIDplusPagePublicWhois = {
  19.  
  20.         openInBrowser: function() {
  21.                 var url = $("#whois_url_bar")[0].innerText;
  22.                 //document.location.href = url;
  23.                 window.open(url);
  24.         },
  25.  
  26.         refresh_whois_url_bar: function() {
  27.                 var query = "";
  28.                 // -------------------------------------------------------------
  29.                 var obj = $("#whois_query")[0].value.trim();
  30.                 var tmp = obj.split(":");
  31.                 var ns = tmp.shift();
  32.                 var id = tmp.join(":");
  33.                 if (!/^[a-z0-9]+$/.test(ns) || id.includes("$")) {
  34.                         $("#whois_query_invalid")[0].style.display = "Inline";
  35.                 } else {
  36.                         $("#whois_query_invalid")[0].style.display = "None";
  37.                 }
  38.                 query = ns + ":" + id;
  39.                 // -------------------------------------------------------------
  40.                 var format = "text";
  41.                 var radios = $("[name=format]");
  42.                 for (var i = 0, length = radios.length; i < length; i++) {
  43.                         if (radios[i].checked) {
  44.                                 format = radios[i].value;
  45.                         }
  46.                 }
  47.                 if (format != "text") query += "$format="+format;
  48.                 // -------------------------------------------------------------
  49.                 var auth = $("#whois_auth")[0].value;
  50.                 var invalid_tokens = false;
  51.                 if (auth != "") {
  52.                         var tokens = auth.split(",");
  53.                         for (var i=0; i<tokens.length; i++) {
  54.                                 var token = tokens[i];
  55.                                 if ((token == "") || token.includes("$") || token.includes("=")) {
  56.                                         invalid_tokens = true;
  57.                                         break;
  58.                                 }
  59.                                 tokens[i] = token.trim();
  60.                         }
  61.                         auth = tokens.join(",");
  62.                 }
  63.                 if (invalid_tokens) {
  64.                         $("#whois_auth_invalid")[0].style.display = "Inline";
  65.                         auth = "";
  66.                 } else {
  67.                         $("#whois_auth_invalid")[0].style.display = "None";
  68.                 }
  69.                 if (auth != "") query += "$auth="+auth;
  70.                 // -------------------------------------------------------------
  71.                 // var sys = getSystemUrl(false);
  72.                 var sys = oidplus_webpath_absolute_canonical;
  73.                 $("#whois_url_bar")[0].innerText = sys + 'plugins/viathinksoft/publicPages/100_whois/whois/webwhois.php?query=' + encodeURIComponent(query);
  74.  
  75.                 $("#whois_query_bar")[0].innerText = query;
  76.         }
  77.  
  78. };
  79.