Rev 424 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
385 | daniel-mar | 1 | /* |
2 | * OIDplus 2.0 |
||
511 | daniel-mar | 3 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
385 | daniel-mar | 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 | function copyToClipboard(elem) { |
||
19 | // Source: https://stackoverflow.com/questions/22581345/click-button-copy-to-clipboard-using-jquery |
||
20 | |||
21 | // create hidden text element, if it doesn't already exist |
||
22 | var targetId = "_hiddenCopyText_"; |
||
23 | var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA"; |
||
24 | var origSelectionStart, origSelectionEnd; |
||
25 | if (isInput) { |
||
26 | // can just use the original source element for the selection and copy |
||
27 | target = elem; |
||
28 | origSelectionStart = elem.selectionStart; |
||
29 | origSelectionEnd = elem.selectionEnd; |
||
30 | } else { |
||
31 | // must use a temporary form element for the selection and copy |
||
32 | target = document.getElementById(targetId); |
||
33 | if (!target) { |
||
34 | var target = document.createElement("textarea"); |
||
35 | target.style.position = "absolute"; |
||
36 | target.style.left = "-9999px"; |
||
37 | target.style.top = "0"; |
||
38 | target.id = targetId; |
||
39 | document.body.appendChild(target); |
||
40 | } |
||
41 | target.textContent = elem.textContent; |
||
42 | } |
||
43 | // select the content |
||
44 | var currentFocus = document.activeElement; |
||
45 | target.focus(); |
||
46 | target.setSelectionRange(0, target.value.length); |
||
47 | |||
48 | // copy the selection |
||
49 | var succeed; |
||
50 | try { |
||
51 | succeed = document.execCommand("copy"); |
||
52 | } catch(e) { |
||
53 | succeed = false; |
||
54 | } |
||
55 | // restore original focus |
||
56 | if (currentFocus && typeof currentFocus.focus === "function") { |
||
57 | currentFocus.focus(); |
||
58 | } |
||
59 | |||
60 | if (isInput) { |
||
61 | // restore prior selection |
||
62 | elem.setSelectionRange(origSelectionStart, origSelectionEnd); |
||
63 | } else { |
||
64 | // clear temporary content |
||
65 | target.textContent = ""; |
||
66 | } |
||
67 | return succeed; |
||
68 | } |
||
69 | |||
70 | function refresh_whois_url_bar() { |
||
71 | document.getElementById('whois_url_bar_section').style.display = "Block"; // because of NoScript |
||
72 | |||
73 | var format = ""; |
||
74 | var radios = document.getElementsByName('format'); |
||
75 | |||
76 | for (var i = 0, length = radios.length; i < length; i++) { |
||
77 | if (radios[i].checked) { |
||
78 | format = radios[i].value; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | document.getElementById('whois_url_bar').innerHTML = getSystemUrl() + 'plugins/publicPages/100_whois/whois/webwhois.php?format=' + format + '&query=' + encodeURIComponent(document.getElementById('whois_query').value); |
||
83 | } |