44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
var link = location.protocol + "//" + location.host + "/link" + location.search;
|
|
var popupLink = location.protocol + "//" + location.host + "/popup" + location.search;
|
|
|
|
history.replaceState(null, "", link);
|
|
document.title = parseQueryParams().name + " - Popup Timer";
|
|
|
|
if (navigator.platform.match(/Mac/i)) {
|
|
document.getElementById("win").style.display = "none";
|
|
document.getElementById("mac").style.display = "inline";
|
|
}
|
|
|
|
[].slice.call(document.getElementsByClassName("type")).forEach(function(elem) {
|
|
elem.innerText = parseQueryParams().name.toLowerCase();
|
|
});
|
|
|
|
document.getElementById("open-popup").onclick = function() {
|
|
window.open(
|
|
popupLink,
|
|
"PopupTimer" + Date.now(),
|
|
"width=250,height=100,menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=no"
|
|
);
|
|
}
|
|
|
|
document.getElementById("back").onclick = function() {
|
|
if (window.opener)
|
|
window.close();
|
|
else
|
|
location.href = "/";
|
|
}
|
|
|
|
function parseQueryParams() {
|
|
if (location.search === "" || location.search.indexOf("?") !== 0) return {};
|
|
var result = {};
|
|
location.search.substr(1).split("&").forEach(function(str) {
|
|
var key = str.split("=")[0];
|
|
var value;
|
|
if (str.split("=").length > 1) value = str.split("=")[1];
|
|
else value = null;
|
|
result[key] = value;
|
|
});
|
|
return result
|
|
}
|
|
|