From da9eed8e90dcf1eac6ea6c3a9db837b9cf5dab4b Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 27 Nov 2015 22:03:07 +0100 Subject: [PATCH] Move all the fullscreen events to the JavaScript file. --- files/pr0n-fullscreen.js | 44 +++++++++++++++++++++-------- templates/default/fullscreen-footer | 10 +++---- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/files/pr0n-fullscreen.js b/files/pr0n-fullscreen.js index 2601aa1..1557881 100644 --- a/files/pr0n-fullscreen.js +++ b/files/pr0n-fullscreen.js @@ -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); }; +}; diff --git a/templates/default/fullscreen-footer b/templates/default/fullscreen-footer index 2a3ef75..04da855 100644 --- a/templates/default/fullscreen-footer +++ b/templates/default/fullscreen-footer @@ -9,13 +9,13 @@ var global_infobox = true; // end generated - +
- <- - -> - x - = + <- + -> + x + =
-- 2.39.2