summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Brill <egore911@gmail.com>2017-02-05 19:29:38 +0100
committerChristoph Brill <egore911@gmail.com>2017-02-05 19:29:38 +0100
commit9a429cd557819b16d3b184d1408ade1e50fb0fde (patch)
treebb2c4d098cb109ebbb2c78d630ef361b99306a72
parent65bdcf00d2cc44fa8b13ec638b9f6bad1a6a4da8 (diff)
Move static javascript to distinct file
-rwxr-xr-xindex.php125
-rw-r--r--js/script.js122
2 files changed, 123 insertions, 124 deletions
diff --git a/index.php b/index.php
index f6f4d47..ac06c17 100755
--- a/index.php
+++ b/index.php
@@ -81,25 +81,10 @@ if (!isset($_SERVER['HTTP_DNT']) || $_SERVER['HTTP_DNT'] != 1) {
if (isset($date)) {
echo ' <script type="text/javascript" src="js/core-min.js"></script>
<script type="text/javascript" src="js/sha1-min.js"></script>
+ <script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
<!--
-function showHideMenu() {
- var setupdiv = document.getElementById("setupdiv");
- showhidebutton = document.getElementById("showhidebutton");
- showhidebuttonimage = document.getElementById("showhidebuttonimage");
-
- if (setupdiv.style.visibility == "hidden") {
- setupdiv.style.visibility = "";
- showhidebutton.title = "Hide menu";
- showhidebuttonimage.src = "images/application_form_delete.png";
- } else {
- setupdiv.style.visibility = "hidden";
- showhidebutton.title = "Show menu";
- showhidebuttonimage.src = "images/application_form.png";
- }
-}
-
function prevDay() {
$s = document.getElementById("date");
$s.value="' . $prevday . '";
@@ -111,114 +96,6 @@ function nextDay() {
document.getElementById("datepick").submit();
}
-function addUser(username) {
-
- // The user was already in the list
- if (document.setup.highlight_names.value.indexOf(username) >= 0) {
-
- // Remove the username from the list
- var myvalue = document.setup.highlight_names.value;
- myvalue = myvalue.replace(username, "");
- myvalue = myvalue.replace(/;;/g,";");
- myvalue = myvalue.replace(/^;/, "");
- myvalue = myvalue.replace(/;$/, "");
- document.setup.highlight_names.value = myvalue;
-
- // Unmark the lines of the user
- for (var k = 0; k < document.styleSheets.length; k++) {
- var rules = document.styleSheets[k].cssRules || document.styleSheets[k].rules;
- for (var x = 0; x < rules.length; x++) {
- if (rules[x].selectorText == (\'span.user_\' + username)) {
- rules[x].style.color = \'\';
- }
- }
- }
-
- // Now drop the username from the colorlist
- var colorlist = document.getElementById(\'usernames\');
- var colorlistelement = document.getElementById(\'user_\' + username);
- colorlist.removeChild(colorlistelement);
-
- } else {
-
- // Add the username to the list
- if (document.setup.highlight_names.value != \'\') {
- document.setup.highlight_names.value += \';\';
- }
- document.setup.highlight_names.value += username;
-
- // Mark all the lines of the newly selected user
- var color = CryptoJS.SHA1(username).toString().substr(0, 6);
- var styleSheet = document.styleSheets[0];
- if (styleSheet.addRule) {
- styleSheet.addRule(\'span.user_\' + username , \'color: #\' + color, 0);
- } else if (styleSheet.insertRule) {
- styleSheet.insertRule(\'span.user_\' + username + \' { color: #\' + color + \'; }\', 0);
- } else {
- document.getElementById("datepick").submit();
- }
-
- // Now add the username to the colorlist
- var colorlist = document.getElementById(\'usernames\');
- var colorlistelement = document.createElement(\'span\');
- colorlistelement.setAttribute(\'id\', \'user_\' + username);
- colorlistelement.setAttribute(\'class\', \'user_\' + username);
- colorlistelement.style.display = \'block\';
- colorlistelement.innerHTML = \'<a href="javascript:addUser(\\\'\' + username + \'\\\');" style="color: inherit;">\' + username + \'</a>\';
- colorlist.appendChild(colorlistelement);
- }
-
- document.cookie = \'stored_users=\' + escape(document.setup.highlight_names.value) + \'; path=/\';
-}
-
-// Stuff for drag and drop copied from http://aktuell.de.selfhtml.org/artikel/dhtml/draganddrop/
-
-//Das Objekt, das gerade bewegt wird.
-var dragobjekt = null;
-
-// Position, an der das Objekt angeklickt wurde.
-var dragx = 0;
-var dragy = 0;
-
-// Mausposition
-var posx = 0;
-var posy = 0;
-
-
-function draginit() {
- // Initialisierung der berwachung der Events
-
- document.onmousemove = drag;
- document.onmouseup = dragstop;
-}
-
-
-function dragstart(element) {
- //Wird aufgerufen, wenn ein Objekt bewegt werden soll.
- dragobjekt = element;
- dragx = posx - dragobjekt.offsetLeft;
- dragy = posy - dragobjekt.offsetTop;
-}
-
-
-function dragstop() {
- //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
- dragobjekt=null;
-}
-
-
-function drag(ereignis) {
- //Wird aufgerufen, wenn die Maus bewegt wird und bewegt bei Bedarf das Objekt.
-
- posx = document.all ? window.event.clientX : ereignis.pageX;
- posy = document.all ? window.event.clientY : ereignis.pageY;
- if(dragobjekt != null) {
- dragobjekt.style.left = (posx - dragx) + "px";
- dragobjekt.style.top = (posy - dragy) + "px";
- }
-}
-
-
//-->
</script>'.PHP_EOL;
diff --git a/js/script.js b/js/script.js
new file mode 100644
index 0000000..55d16d1
--- /dev/null
+++ b/js/script.js
@@ -0,0 +1,122 @@
+function showHideMenu() {
+ var setupdiv = document.getElementById("setupdiv");
+ showhidebutton = document.getElementById("showhidebutton");
+ showhidebuttonimage = document.getElementById("showhidebuttonimage");
+
+ if (setupdiv.style.visibility == "hidden") {
+ setupdiv.style.visibility = "";
+ showhidebutton.title = "Hide menu";
+ showhidebuttonimage.src = "images/application_form_delete.png";
+ } else {
+ setupdiv.style.visibility = "hidden";
+ showhidebutton.title = "Show menu";
+ showhidebuttonimage.src = "images/application_form.png";
+ }
+}
+
+function addUser(username) {
+
+ // The user was already in the list
+ if (document.setup.highlight_names.value.indexOf(username) >= 0) {
+
+ // Remove the username from the list
+ var myvalue = document.setup.highlight_names.value;
+ myvalue = myvalue.replace(username, "");
+ myvalue = myvalue.replace(/;;/g,";");
+ myvalue = myvalue.replace(/^;/, "");
+ myvalue = myvalue.replace(/;$/, "");
+ document.setup.highlight_names.value = myvalue;
+
+ // Unmark the lines of the user
+ for (var k = 0; k < document.styleSheets.length; k++) {
+ var rules = document.styleSheets[k].cssRules || document.styleSheets[k].rules;
+ for (var x = 0; x < rules.length; x++) {
+ if (rules[x].selectorText == ('span.user_' + username)) {
+ rules[x].style.color = '';
+ }
+ }
+ }
+
+ // Now drop the username from the colorlist
+ var colorlist = document.getElementById('usernames');
+ var colorlistelement = document.getElementById('user_' + username);
+ colorlist.removeChild(colorlistelement);
+
+ } else {
+
+ // Add the username to the list
+ if (document.setup.highlight_names.value != '') {
+ document.setup.highlight_names.value += ';';
+ }
+ document.setup.highlight_names.value += username;
+
+ // Mark all the lines of the newly selected user
+ var color = CryptoJS.SHA1(username).toString().substr(0, 6);
+ var styleSheet = document.styleSheets[0];
+ if (styleSheet.addRule) {
+ styleSheet.addRule('span.user_' + username , 'color: #' + color, 0);
+ } else if (styleSheet.insertRule) {
+ styleSheet.insertRule('span.user_' + username + ' { color: #' + color + '; }', 0);
+ } else {
+ document.getElementById("datepick").submit();
+ }
+
+ // Now add the username to the colorlist
+ var colorlist = document.getElementById('usernames');
+ var colorlistelement = document.createElement('span');
+ colorlistelement.setAttribute('id', 'user_' + username);
+ colorlistelement.setAttribute('class', 'user_' + username);
+ colorlistelement.style.display = 'block';
+ colorlistelement.innerHTML = '<a href="javascript:addUser(\'' + username + '\');" style="color: inherit;">' + username + '</a>';
+ colorlist.appendChild(colorlistelement);
+ }
+
+ document.cookie = 'stored_users=' + escape(document.setup.highlight_names.value) + '; path=/';
+}
+
+// Stuff for drag and drop copied from http://aktuell.de.selfhtml.org/artikel/dhtml/draganddrop/
+
+//Das Objekt, das gerade bewegt wird.
+var dragobjekt = null;
+
+// Position, an der das Objekt angeklickt wurde.
+var dragx = 0;
+var dragy = 0;
+
+// Mausposition
+var posx = 0;
+var posy = 0;
+
+
+function draginit() {
+ // Initialisierung der berwachung der Events
+
+ document.onmousemove = drag;
+ document.onmouseup = dragstop;
+}
+
+
+function dragstart(element) {
+ //Wird aufgerufen, wenn ein Objekt bewegt werden soll.
+ dragobjekt = element;
+ dragx = posx - dragobjekt.offsetLeft;
+ dragy = posy - dragobjekt.offsetTop;
+}
+
+
+function dragstop() {
+ //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
+ dragobjekt=null;
+}
+
+
+function drag(ereignis) {
+ //Wird aufgerufen, wenn die Maus bewegt wird und bewegt bei Bedarf das Objekt.
+
+ posx = document.all ? window.event.clientX : ereignis.pageX;
+ posy = document.all ? window.event.clientY : ereignis.pageY;
+ if(dragobjekt != null) {
+ dragobjekt.style.left = (posx - dragx) + "px";
+ dragobjekt.style.top = (posy - dragy) + "px";
+ }
+}