diff --git a/var/www/modules/hiddenServices/templates/showDomain.html b/var/www/modules/hiddenServices/templates/showDomain.html index 30b078fb..655dbe31 100644 --- a/var/www/modules/hiddenServices/templates/showDomain.html +++ b/var/www/modules/hiddenServices/templates/showDomain.html @@ -166,16 +166,12 @@ ctx.webkitImageSmoothingEnabled = false; ctx.imageSmoothingEnabled = false; - /// wait until image is actually available img.onload = pixelate; + img.addEventListener("error", img_error); var draw_img = false; - img.onError = "img.onerror=null;img.src='{{ url_for('static', filename='image/AIL.png') }}';" - /// some image, we are not struck with CORS restrictions as we - /// do not use pixel buffer to pixelate, so any image will do img.src = "{{ url_for('showsavedpastes.screenshot', filename=screenshot) }}"; - /// MAIN function function pixelate() { /// use slider value @@ -195,14 +191,19 @@ /// draw original image to the scaled size ctx.drawImage(img, 0, 0, w, h); - /// then draw that scaled image thumb back to fill canvas - /// As smoothing is off the result will be pixelated + /// pixelated ctx.drawImage(canvas, 0, 0, w, h, 0, 0, canvas.width, canvas.height); } - /// event listeneners for slider and button blocks.addEventListener('change', pixelate, false); + + function img_error() { + img.onerror=null; + img.src="{{ url_for('static', filename='image/AIL.png') }}"; + blocks.value = 50; + pixelate; + } diff --git a/var/www/modules/showpaste/templates/show_saved_paste.html b/var/www/modules/showpaste/templates/show_saved_paste.html index 99b92a3f..72add804 100644 --- a/var/www/modules/showpaste/templates/show_saved_paste.html +++ b/var/www/modules/showpaste/templates/show_saved_paste.html @@ -596,16 +596,12 @@ var ctx = canvas.getContext('2d'), img = new Image(); ctx.webkitImageSmoothingEnabled = false; ctx.imageSmoothingEnabled = false; -/// wait until image is actually available img.onload = pixelate; +img.addEventListener("error", img_error); var draw_img = false; -img.onError = "img.onerror=null;img.src='{{ url_for('static', filename='image/AIL.png') }}';" -/// some image, we are not struck with CORS restrictions as we -/// do not use pixel buffer to pixelate, so any image will do img.src = "{{ url_for('showsavedpastes.screenshot', filename=crawler_metadata['screenshot']) }}"; -/// MAIN function function pixelate() { /// use slider value @@ -625,13 +621,18 @@ function pixelate() { /// draw original image to the scaled size ctx.drawImage(img, 0, 0, w, h); - /// then draw that scaled image thumb back to fill canvas - /// As smoothing is off the result will be pixelated + /// pixelated ctx.drawImage(canvas, 0, 0, w, h, 0, 0, canvas.width, canvas.height); } -/// event listeneners for slider and button +function img_error() { + img.onerror=null; + img.src="{{ url_for('static', filename='image/AIL.png') }}"; + blocks.value = 50; + pixelate; +} + blocks.addEventListener('change', pixelate, false);