3 if (typeof(window.innerWidth) == 'number') {
5 return [window.innerWidth, window.innerHeight];
6 } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
7 // IE 6+ in 'standards compliant mode'
8 return [document.documentElement.clientWidth, document.documentElement.clientHeight];
9 } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
11 return [document.body.clientWidth, document.body.clientHeight];
17 * pr0n can resize to any size we'd like, but we're much more likely
18 * to have this set of fixed-resolution screens cached, so to increase
19 * performance, we round down to the closest fit and use that.
21 function reduce_to_fixed_width(size)
34 for (i = 0; i < fixed_sizes.length; ++i) {
35 if (size[0] >= fixed_sizes[i][0] && size[1] >= fixed_sizes[i][1])
36 return fixed_sizes[i];
41 function display_image(width, height, evt, filename, element_id)
43 var url = "http://" + global_vhost + "/" + evt + "/" + width + "x" + height + "/" + filename;
44 var img = document.getElementById(element_id);
47 img.parentNode.removeChild(img);
50 img = document.createElement("img");
58 var main = document.getElementById("main");
59 main.appendChild(img);
64 function prepare_preload(img, width, height, evt, filename)
66 // cancel any pending preload
67 var preload = document.getElementById("preload");
68 if (preload != null) {
70 preload.parentNode.removeChild(preload);
73 if (document.all) { // IE-specific
74 img.onload = "display_image(" + width + "," + height + ",\"" + evt + "\",\"" + filename + "\",\"preload\");";
76 img.onload = function() { display_image(width, height, evt, filename, "preload"); }
82 var size = find_width();
83 var adjusted_size = reduce_to_fixed_width(size);
85 var img = display_image(adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num], "image");
87 prepare_preload(img, adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num + 1]);
90 // center the image on-screen
91 var main = document.getElementById("main");
92 main.style.position = "absolute";
93 main.style.left = (size[0] - adjusted_size[0]) / 2 + "px";
94 main.style.top = (size[1] - adjusted_size[1]) / 2 + "px";
95 main.style.width = adjusted_size[0] + "px";
96 main.style.height = adjusted_size[1] + "px";
97 main.style.lineHeight = adjusted_size[1] + "px";
99 set_opacity("previous", can_go_previous() ? 0.7 : 0.1);
100 set_opacity("next", can_go_next() ? 0.7 : 0.1);
101 set_opacity("close", 0.7);
104 function set_opacity(id, amount)
106 var elem = document.getElementById(id);
107 if (typeof(elem.style.opacity) != 'undefined') { // W3C
108 elem.style.opacity = amount;
109 } else if (typeof(elem.style.mozOpacity) != 'undefined') { // older Mozilla
110 elem.style.mozOpacity = amount;
111 } else if (typeof(elem.style.filter) != 'undefined') { // IE
112 if (elem.style.filter.indexOf("alpha") == -1) {
113 // add an alpha filter if there isn't one already
114 if (elem.style.filter) {
115 elem.style.filter += " ";
117 elem.style.filter = "";
119 elem.style.filter += "alpha(opacity=" + (amount*100.0) + ")";
121 elem.filters.alpha.opacity = (amount * 100.0);
123 } else { // no alpha support
125 elem.style.visibility = "visible";
126 elem.style.zorder = 1;
128 elem.style.visibility = "hidden";
133 function can_go_previous()
135 return (global_image_num > 0);
138 function go_previous()
140 if (!can_go_previous())
145 var adjusted_size = reduce_to_fixed_width(find_width());
147 var img = display_image(adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num], "image");
148 if (can_go_previous()) {
149 set_opacity("previous", 0.7);
150 prepare_preload(img, adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num - 1]);
152 set_opacity("previous", 0.1);
154 set_opacity("next", can_go_next() ? 0.7 : 0.1);
157 function can_go_next()
159 return (global_image_num < global_image_list.length - 1);
169 var adjusted_size = reduce_to_fixed_width(find_width());
171 var img = display_image(adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num], "image");
173 set_opacity("next", 0.7);
174 prepare_preload(img, adjusted_size[0], adjusted_size[1], global_evt, global_image_list[global_image_num + 1]);
176 set_opacity("next", 0.1);
178 set_opacity("previous", can_go_previous() ? 0.7 : 0.1);
181 function key_down(which)
183 if (which == 39) { // right
185 set_opacity("next", 0.99);
187 } else if (which == 37) { // left
188 if (can_go_previous()) {
189 set_opacity("previous", 0.99);
194 function key_up(which) {
195 if (which == 39) { // right
197 set_opacity("next", 0.7);
200 } else if (which == 37) { // left
201 if (can_go_previous()) {
202 set_opacity("previous", 0.7);
210 window.location = global_return_url;
213 // enable the horrible horrible IE PNG hack
214 function ie_png_hack()
216 var vstr = navigator.appVersion.split("MSIE");
217 var v = parseFloat(vstr[1]);
218 if (v >= 5.5 && v < 7.0 && document.body.filters) {
219 var next = document.getElementById("next");
220 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); }\" />";
222 var previous = document.getElementById("previous");
223 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); }\" />";