1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Modularized Javascript

This commit is contained in:
Krateng
2019-03-24 16:04:44 +01:00
parent 3f22d6bc75
commit 011b6f6d91
7 changed files with 203 additions and 167 deletions

View File

@@ -4,8 +4,11 @@
<head>
<meta charset="UTF-8" />
<title>Maloja - Setup</title>
<script src="javascript/cookies.js"></script>
<script>
function replaceurls() {
url = window.location.origin
s = document.getElementsByName("serverurl")
@@ -20,26 +23,34 @@
}
function activateRuleModule(e,filename) {
keys = "filename=" + encodeURIComponent(filename)
if (apikeycorrect) {
keys = "filename=" + encodeURIComponent(filename)
apikey = document.getElementById("apikey").value
keys += "&key=" + encodeURIComponent(apikey)
console.log(keys)
var xhttp = new XMLHttpRequest();
xhttp.open("POST","/db/importrules", true);
xhttp.send(keys);
var xhttp = new XMLHttpRequest();
xhttp.open("POST","/db/importrules", true);
xhttp.send(keys);
e.innerHTML = e.innerHTML.replace("Add","Remove")
e.getAttributeNode("onclick").value = e.getAttribute("onclick").replace("activate","deactivate")
/* Nobody ever look at this code please */
e.innerHTML = e.innerHTML.replace("Add","Remove")
e.getAttributeNode("onclick").value = e.getAttribute("onclick").replace("activate","deactivate")
/* Nobody ever look at this code please */
}
}
function deactivateRuleModule(e,filename) {
keys = "remove&filename=" + encodeURIComponent(filename)
if (apikeycorrect) {
keys = "remove&filename=" + encodeURIComponent(filename)
apikey = document.getElementById("apikey").value
keys += "&key=" + encodeURIComponent(apikey)
var xhttp = new XMLHttpRequest();
xhttp.open("POST","/db/importrules", true);
xhttp.send(keys);
var xhttp = new XMLHttpRequest();
xhttp.open("POST","/db/importrules", true);
xhttp.send(keys);
e.innerHTML = e.innerHTML.replace("Remove","Add")
e.getAttributeNode("onclick").value = e.getAttribute("onclick").replace("deactivate","activate")
e.innerHTML = e.innerHTML.replace("Remove","Add")
e.getAttributeNode("onclick").value = e.getAttribute("onclick").replace("deactivate","activate")
}
}
</script>
@@ -53,7 +64,7 @@
</head>
<body onload="replace()">
<body onload="replace();insertAPIKeyFromCookie()">
<table class="top_info">
<tr>
<td class="image">
@@ -99,7 +110,11 @@
After you've scrobbled for a bit, you might want to check the <a class="textlink" href="/issues">Issues page</a> to see if you need to set up some rules. You can also manually add rules in your server's "rules" directory - just add your own .tsv file and read the instructions on how to declare a rule.
<br/><br/>
You can also set up some predefined rulesets right away!
You can also set up some predefined rulesets right away! Enter your API key and click the buttons.
<br/>
API Key:
<input id='apikey' onchange='checkAPIkey()' style='width:300px;'/>
<br/><br/>
KEY_PREDEFINED_RULESETS
@@ -117,4 +132,6 @@
Done! Visit <a class="textlink" href="/"><span name="serverurl">yourserver.tld</span></a> (or your public / proxy URL) to look at your overview page. Almost everything is clickable!
</body>
</html>