- var vstr = navigator.appVersion.split("MSIE");
- var v = parseFloat(vstr[1]);
- if (v >= 5.5 && v < 7.0 && document.body.filters) {
- var next = document.getElementById("next");
- next.outerHTML = "<span id=\"next\" style=\"display: inline-block; position: absolute; bottom: 0px; right: 0px; width: 50px; height: 50px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + next.src + "')\" onmousedown=\"if (can_go_next()) set_opacity('next', 1.0)\" onmouseup=\"if (can_go_next()) { set_opacity('next', 0.7); go_next(); }\" onmouseout=\"if (can_go_next()) { set_opacity('next', 0.7); }\" />";
-
- var previous = document.getElementById("previous");
- previous.outerHTML = "<span id=\"previous\" style=\"display: inline-block; position: absolute; bottom: 0px; right: 0px; width: 50px; height: 50px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + previous.src + "')\" onmousedown=\"if (can_go_previous()) set_opacity('previous', 1.0)\" onmouseup=\"if (can_go_previous()) { set_opacity('previous', 0.7); go_previous(); }\" onmouseout=\"if (can_go_previous()) { set_opacity('previous', 0.7); }\" />";
-
- var close = document.getElementById("close");
- close.outerHTML = "<span id=\"close\" style=\"display: inline-block; position: absolute; top: 0px; right: 0px; width: 50px; height: 50px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + close.src + "')\" onmousedown=\"set_opacity('close', 1.0)\" onmouseup=\"set_opacity('close', 0.7); do_close();\" onmouseout=\"set_opacity('close', 0.7);\" />";
+ set_opacity("text", opacity);
+ if (opacity > 0.0) {
+ opacity -= 0.03;
+ if (opacity < 0.0) {
+ opacity = 0.0;
+ }
+ setTimeout(function() { fade_text(opacity); }, 30);
+ } else {
+ var text = document.getElementById("text");
+ if (text !== null) {
+ text.parentNode.removeChild(text);
+ }
+ }
+}
+
+function select_image(evt, filename, selected)
+{
+ 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);
+
+ setTimeout(function() { fade_text(0.99); }, 30);
+}
+
+function key_down(which)
+{
+ if (which == 39) { // right
+ if (can_go_next()) {
+ set_opacity("next", global_highlight_opacity);
+ }
+ } else if (which == 37) { // left
+ if (can_go_previous()) {
+ set_opacity("previous", global_highlight_opacity);
+ }
+ } else if (which == 27) { // escape
+ set_opacity("close", global_higlight_opacity);
+ } else {
+ check_for_hash_change();
+ }
+}
+
+function key_up(which) {
+ if (which == 39) { // right
+ if (can_go_next()) {
+ set_opacity("next", global_default_opacity);
+ go_next();
+ }
+ } else if (which == 37) { // left
+ if (can_go_previous()) {
+ set_opacity("previous", global_default_opacity);
+ go_previous();
+ }
+ } else if (which == 27) { // escape
+ set_opacity("close", global_default_opacity);
+ do_close();
+ } else if (which == 32 && global_select) { // space
+ select_image(global_image_list[global_image_num][0], global_image_list[global_image_num][1], 1);
+ } else if (which == 85 && global_select) { // u
+ select_image(global_image_list[global_image_num][0], global_image_list[global_image_num][1], 0);
+ } else {
+ check_for_hash_change();
+ }
+}
+
+function parse_image_num(default_value) {
+ var num = parseInt(window.location.hash.substr(1));
+ if (num >= 1 && num <= global_image_list.length) { // and then num != NaN
+ return (num - 1);
+ } else {
+ return default_value;
+ }
+}
+window['parse_image_num'] = parse_image_num;
+
+function check_for_hash_change() {
+ var num = parse_image_num(-1);
+ if (num != -1 && num != global_image_num) {
+ global_image_num = num;
+ relayout();
+ }
+}
+
+function toggle_immersive() {
+ if (global_default_opacity == 0.7) {
+ global_disabled_opacity = 0.0;
+ global_default_opacity = 0.0;
+ global_highlight_opacity = 0.2;
+ global_infobox = false;
+ document.getElementById('immersivetoggle').innerHTML = 'Show decorations';
+ } else {
+ global_disabled_opacity = 0.1;
+ global_default_opacity = 0.7;
+ global_highlight_opacity = 1.0;
+ global_infobox = true;
+ document.getElementById('immersivetoggle').innerHTML = 'Hide all decorations';