Removed older browser stuff.
This commit is contained in:
parent
e4b551a789
commit
d0ba2970bd
3 changed files with 29 additions and 94 deletions
2
build.js
2
build.js
|
@ -13,7 +13,7 @@ const exec = require('util').promisify(require('child_process').exec);
|
|||
public: pathJoin(__dirname, 'public'),
|
||||
debug: isDebug,
|
||||
swc: {
|
||||
es: 'es5',
|
||||
es: 'es2021',
|
||||
},
|
||||
vars: {
|
||||
html: {}, // BUG: if this isn't definited prior, assproc will fail
|
||||
|
|
|
@ -26,10 +26,7 @@ body {
|
|||
right: 0;
|
||||
height: 25%;
|
||||
z-index: 0;
|
||||
background: -moz-linear-gradient(top, #db5176 0%, #ff9290 100%);
|
||||
background: -webkit-linear-gradient(top, #db5176 0%, #ff9290 100%);
|
||||
background: linear-gradient(to bottom, #db5176 0%, #ff9290 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#db5176', endColorstr='#ff9290', GradientType=0);
|
||||
}
|
||||
|
||||
.background-gradient-bottom {
|
||||
|
@ -39,10 +36,7 @@ body {
|
|||
right: 0;
|
||||
height: 25%;
|
||||
z-index: 0;
|
||||
background: -moz-linear-gradient(top, #ff9290 0%, #4c8999 100%);
|
||||
background: -webkit-linear-gradient(top, #ff9290 0%, #4c8999 100%);
|
||||
background: linear-gradient(to bottom, #ff9290 0%, #4c8999 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff9290', endColorstr='#4c8999', GradientType=0);
|
||||
}
|
||||
|
||||
.container {
|
||||
|
|
|
@ -1,100 +1,41 @@
|
|||
#vars window build
|
||||
|
||||
var createXHR = function() {
|
||||
if('all' in document && !('atob' in window) && 'XDomainRequest' in window)
|
||||
return new XDomainRequest;
|
||||
|
||||
if('XMLHttpRequest' in window)
|
||||
return new XMLHttpRequest;
|
||||
|
||||
if('ActiveXObject' in window)
|
||||
try {
|
||||
return new ActiveXObject('Msxml2.XMLHTTP');
|
||||
} catch(e) {
|
||||
try {
|
||||
return new ActiveXObject('Microsoft.XMLHTTP');
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
throw 'no impl';
|
||||
}
|
||||
|
||||
var getRemoteString = function(url, callback) {
|
||||
try {
|
||||
var xhr = createXHR();
|
||||
xhr.onload = function(ev) {
|
||||
callback({ success: true, info: ev, text: xhr.responseText });
|
||||
};
|
||||
xhr.onerror = function(ev) {
|
||||
callback({ success: false, info: ev });
|
||||
};
|
||||
const getRemoteString = url => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest;
|
||||
xhr.onload = ev => { resolve(xhr.responseText); };
|
||||
xhr.onerror = ev => { reject(); };
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
} catch(ex) {
|
||||
callback({ success: false, info: ex });
|
||||
}
|
||||
};
|
||||
|
||||
var copyTextInElement = function(target, skipClipboardAPI) {
|
||||
if(!skipClipboardAPI && 'clipboard' in navigator) {
|
||||
// for some reason I'm supporting IE8 with this and it gets mad over the catch keyword...
|
||||
navigator.clipboard.writeText(target.textContent)['catch'](function(ex) {
|
||||
copyTextInElement(target, true);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if('execCommand' in document) {
|
||||
if('createTextRange' in document.body) { // MSIE
|
||||
var range = document.body.createTextRange();
|
||||
range.moveToElementText(target);
|
||||
range.select();
|
||||
} else if('getSelection' in window) { // Mozilla
|
||||
var select = window.getSelection();
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(target);
|
||||
select.removeAllRanges();
|
||||
select.addRange(range);
|
||||
} else return;
|
||||
|
||||
document.execCommand('copy');
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
(function() {
|
||||
var fields = document.querySelectorAll('.js-address');
|
||||
var urls = { ipv4: window.IPV4_LOOKUP, ipv6: window.IPV6_LOOKUP };
|
||||
(async () => {
|
||||
const fields = document.querySelectorAll('.js-address');
|
||||
const urls = { ipv4: window.IPV4_LOOKUP, ipv6: window.IPV6_LOOKUP };
|
||||
|
||||
for(var i = 0; i < fields.length; ++i)
|
||||
(function(field) {
|
||||
var valueField = field.querySelector('.js-address-value');
|
||||
for(const field of fields) {
|
||||
const valueField = field.querySelector('.js-address-value');
|
||||
if(valueField === null)
|
||||
return;
|
||||
|
||||
var setValueField = function(text) {
|
||||
valueField['textContent' in valueField ? 'textContent' : 'innerText'] = text;
|
||||
};
|
||||
valueField.textContent = 'loading...';
|
||||
|
||||
setValueField('loading...');
|
||||
|
||||
var subdomain = field.getAttribute('data-subdomain');
|
||||
const subdomain = field.getAttribute('data-subdomain');
|
||||
if(typeof subdomain !== 'string' && !(subdomain in urls))
|
||||
return;
|
||||
|
||||
var copyButton = field.querySelector('.js-address-copy');
|
||||
const copyButton = field.querySelector('.js-address-copy');
|
||||
|
||||
getRemoteString(urls[subdomain], function(info) {
|
||||
try {
|
||||
const ipAddr = await getRemoteString(urls[subdomain]);
|
||||
valueField.textContent = ipAddr;
|
||||
|
||||
if(!info.success) {
|
||||
setValueField('not available');
|
||||
return;
|
||||
copyButton.onclick = async () => {
|
||||
await navigator.clipboard.writeText(ipAddr);
|
||||
};
|
||||
} catch(ex) {
|
||||
valueField.textContent = 'not available';
|
||||
}
|
||||
}
|
||||
|
||||
setValueField(info.text);
|
||||
|
||||
if(copyButton)
|
||||
copyButton.onclick = function() { copyTextInElement(valueField); };
|
||||
});
|
||||
})(fields[i]);
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue