Move all the fullscreen events to the JavaScript file.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 27 Nov 2015 21:03:07 +0000 (22:03 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 27 Nov 2015 21:03:07 +0000 (22:03 +0100)
files/pr0n-fullscreen.js
templates/default/fullscreen-footer

index 2601aa14c3c8693183ca96331b7d5574a4fc5cf5..1557881f733a5ee260349520e19a4bd506ecd501 100644 (file)
@@ -1,10 +1,3 @@
-var req;
-
-function init_ajax()
-{
-       req = new XMLHttpRequest();
-}
-
 function find_width()
 {
        var dpr = find_dpr();
@@ -374,16 +367,13 @@ function fade_text(opacity)
 
 function select_image(evt, filename, selected)
 {
-       if (!req) {
-               return;
-       }
-
        if (selected) {
                draw_text("Selecting " + filename + "...");
        } else {
                draw_text("Unselecting " + filename + "...");
        }
        
+       var req = new XMLHttpRequest();
        req.open("POST", window.location.origin + "/select", false);
        req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        req.send("event=" + evt + "&filename=" + filename + "&selected=" + selected);
@@ -464,3 +454,35 @@ function toggle_immersive() {
        }
        relayout();
 }
+
+window.onload = function() {
+       relayout();
+       setInterval(check_for_hash_change, 1000);
+
+       var body = document.body;
+       body.onresize = function() { relayout(); };
+       body.onkeydown = function() { key_down(event.keyCode); };
+       body.onkeyup = function() { key_up(event.keyCode); };
+       body.onhashchange = function() { check_for_hash_change(); };
+       body.onclick = function() { check_for_hash_change(); };
+
+       var previous = document.getElementById('previous');
+       previous.onmousedown = function() { if (can_go_previous()) { set_opacity('previous', global_highlight_opacity); } };
+       previous.onmouseup = function() { if (can_go_previous()) { set_opacity('previous', global_default_opacity); go_previous(); } };
+       previous.onmouseout = function() { if (can_go_previous()) { set_opacity('previous', global_default_opacity); } };
+
+       var next = document.getElementById('next');
+       next.onmousedown = function() { if (can_go_next()) { set_opacity('next', global_highlight_opacity); } };
+       next.onmouseup = function() { if (can_go_next()) { set_opacity('next', global_default_opacity); go_next(); } };
+       next.onmouseout = function() { if (can_go_next()) { set_opacity('next', global_default_opacity); } };
+
+       var close = document.getElementById('close');
+       close.onmousedown = function() { set_opacity('close', global_highlight_opacity); };
+       close.onmouseup = function() { set_opacity('close', global_default_opacity); do_close(); };
+       close.onmouseout = function() { set_opacity('close', global_default_opacity); };
+
+       var options = document.getElementById('options');
+       options.onmousedown = function() { set_opacity('options', global_highlight_opacity); };
+       options.onmouseup = function() { set_opacity('options', global_default_opacity); toggle_optionmenu(); };
+       options.onmouseout = function() { set_opacity('options', global_default_opacity); };
+};
index 2a3ef75bd17f1bd2cffab87f29f5e9a232372305..04da855ccd86cfe5e076184ce9998bfd137aa132 100644 (file)
@@ -9,13 +9,13 @@ var global_infobox = true;
 // end generated
     </script>
   </head>
-  <body onresize="relayout();" onload="init_ajax(); relayout(); setInterval('check_for_hash_change()', 1000);" onkeydown="key_down(event.keyCode);" onkeyup="key_up(event.keyCode);" onhashchange="check_for_hash_change();" onclick="check_for_hash_change();">
+  <body>
     <div>
       <div class="container" id="main"><div id="iehack"></div></div>
-      <img id="previous" src="/previous.png" alt="&lt;-" onmousedown="if (can_go_previous()) set_opacity('previous', global_highlight_opacity)" onmouseup="if (can_go_previous()) { set_opacity('previous', global_default_opacity); go_previous(); }" onmouseout="if (can_go_previous()) { set_opacity('previous', global_default_opacity); }" />
-      <img id="next" src="/next.png" alt="-&gt;" onmousedown="if (can_go_next()) set_opacity('next', global_highlight_opacity)" onmouseup="if (can_go_next()) { set_opacity('next', global_default_opacity); go_next(); }" onmouseout="if (can_go_next()) { set_opacity('next', global_default_opacity); }" />
-      <img id="close" src="/close.png" alt="x" onmousedown="set_opacity('close', global_highlight_opacity)" onmouseup="set_opacity('close', global_default_opacity); do_close();" onmouseout="set_opacity('close', global_default_opacity);" />
-      <img id="options" src="/options.png" alt="=" onmousedown="set_opacity('options', global_highlight_opacity)" onmouseup="set_opacity('options', global_default_opacity); toggle_optionmenu();" onmouseout="set_opacity('options', global_default_opacity);" />
+      <img id="previous" src="/previous.png" alt="&lt;-" />
+      <img id="next" src="/next.png" alt="-&gt;" />
+      <img id="close" src="/close.png" alt="x" />
+      <img id="options" src="/options.png" alt="=" />
       <div id="optionmenu"><p><a id="origdownload">Download original image</a></p><p><a id="immersivetoggle" href="javascript:toggle_optionmenu();toggle_immersive();">Hide all decorations</a></p></div>
     </div>
   </body>