X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=files%2Fpr0n-fullscreen.js;h=95829951dfc8f0cd530b58ef102c76d95fba32f1;hp=efacecc4364aec3c78b4a233a8ba2907f9ed174c;hb=167f5a678e37c8e3d55fcded24419848dfe7d83e;hpb=9e74ede2b7ddaf65620930b048e0dba636f631a9 diff --git a/files/pr0n-fullscreen.js b/files/pr0n-fullscreen.js index efacecc..9582995 100644 --- a/files/pr0n-fullscreen.js +++ b/files/pr0n-fullscreen.js @@ -40,6 +40,20 @@ function find_width() return [null,null]; } +function parse_image_num(url, default_value) { + var url_array = (window.location.toString().split("#")); + if (url_array.length != 2) { + return default_value; + } + + var num = parseInt(url_array[1]); + if (num > 1 && num <= global_image_list.length) { // and then num != NaN + return (num - 1); + } else { + return default_value; + } +} + /* * pr0n can resize to any size we'd like, but we're much more likely * to have this set of fixed-resolution screens cached, so to increase @@ -148,9 +162,9 @@ function display_image_num(num, element_id) // size of the image center_image(num); - document.getElementById('linkbg1').href = global_bookmark_url_base + (num+1); - document.getElementById('linkbg2').href = global_bookmark_url_base + (num+1); - document.getElementById('linkbg3').href = global_bookmark_url_base + (num+1); + // replace the anchor part (if any) with the image number + var baseurl = (window.location.toString().split("#"))[0]; + window.location = baseurl + "#" + (num+1); } return img;