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'),
|
public: pathJoin(__dirname, 'public'),
|
||||||
debug: isDebug,
|
debug: isDebug,
|
||||||
swc: {
|
swc: {
|
||||||
es: 'es5',
|
es: 'es2021',
|
||||||
},
|
},
|
||||||
vars: {
|
vars: {
|
||||||
html: {}, // BUG: if this isn't definited prior, assproc will fail
|
html: {}, // BUG: if this isn't definited prior, assproc will fail
|
||||||
|
|
|
@ -26,10 +26,7 @@ body {
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 25%;
|
height: 25%;
|
||||||
z-index: 0;
|
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%);
|
background: linear-gradient(to bottom, #db5176 0%, #ff9290 100%);
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#db5176', endColorstr='#ff9290', GradientType=0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.background-gradient-bottom {
|
.background-gradient-bottom {
|
||||||
|
@ -39,10 +36,7 @@ body {
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 25%;
|
height: 25%;
|
||||||
z-index: 0;
|
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%);
|
background: linear-gradient(to bottom, #ff9290 0%, #4c8999 100%);
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff9290', endColorstr='#4c8999', GradientType=0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
|
|
@ -1,100 +1,41 @@
|
||||||
#vars window build
|
#vars window build
|
||||||
|
|
||||||
var createXHR = function() {
|
const getRemoteString = url => {
|
||||||
if('all' in document && !('atob' in window) && 'XDomainRequest' in window)
|
return new Promise((resolve, reject) => {
|
||||||
return new XDomainRequest;
|
const xhr = new XMLHttpRequest;
|
||||||
|
xhr.onload = ev => { resolve(xhr.responseText); };
|
||||||
if('XMLHttpRequest' in window)
|
xhr.onerror = ev => { reject(); };
|
||||||
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 });
|
|
||||||
};
|
|
||||||
xhr.open('GET', url);
|
xhr.open('GET', url);
|
||||||
xhr.send();
|
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() {
|
(async () => {
|
||||||
var fields = document.querySelectorAll('.js-address');
|
const fields = document.querySelectorAll('.js-address');
|
||||||
var urls = { ipv4: window.IPV4_LOOKUP, ipv6: window.IPV6_LOOKUP };
|
const urls = { ipv4: window.IPV4_LOOKUP, ipv6: window.IPV6_LOOKUP };
|
||||||
|
|
||||||
for(var i = 0; i < fields.length; ++i)
|
for(const field of fields) {
|
||||||
(function(field) {
|
const valueField = field.querySelector('.js-address-value');
|
||||||
var valueField = field.querySelector('.js-address-value');
|
|
||||||
if(valueField === null)
|
if(valueField === null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var setValueField = function(text) {
|
valueField.textContent = 'loading...';
|
||||||
valueField['textContent' in valueField ? 'textContent' : 'innerText'] = text;
|
|
||||||
};
|
|
||||||
|
|
||||||
setValueField('loading...');
|
const subdomain = field.getAttribute('data-subdomain');
|
||||||
|
|
||||||
var subdomain = field.getAttribute('data-subdomain');
|
|
||||||
if(typeof subdomain !== 'string' && !(subdomain in urls))
|
if(typeof subdomain !== 'string' && !(subdomain in urls))
|
||||||
return;
|
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) {
|
copyButton.onclick = async () => {
|
||||||
setValueField('not available');
|
await navigator.clipboard.writeText(ipAddr);
|
||||||
return;
|
};
|
||||||
|
} catch(ex) {
|
||||||
|
valueField.textContent = 'not available';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setValueField(info.text);
|
|
||||||
|
|
||||||
if(copyButton)
|
|
||||||
copyButton.onclick = function() { copyTextInElement(valueField); };
|
|
||||||
});
|
|
||||||
})(fields[i]);
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue