Name: SUBJECT IS TOO FUCKING LONG 2009-03-07 10:56
Hello EXPERT JAVASCRIPT PROGRAMMERS.
Have you ever heard of these things called bookmarklets? These browser-portable pieces of code perform an action over a webpage when invoked from (typically) a bookmark, such as, for example, creating a new document containing all linked images:
Your task is to modify this naïve example to add the following features:
1. Remove duplicate entries.
2. Clamp width to a certain value, preserving aspect ratio.
3. Pad height vertically (with additional HTML elements) so that an integer number of images is displayed for every block of n pixels, for some n.
The first should be EASY AS FUCK, the second and third ones might be IMPOSSIBLE.
Have you ever heard of these things called bookmarklets? These browser-portable pieces of code perform an action over a webpage when invoked from (typically) a bookmark, such as, for example, creating a new document containing all linked images:
javascript:(function(){function I(u){var t=u.split('.'),e=t[t.length-1].toLowerCase();return {gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function hE(s){return s.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');}var q,h,i,z=open().document;z.write('<p>Images linked to by '+hE(location.href)+':</p><hr>');for(i=0;q=document.links[i];++i){h=q.href;if(h&&I(h))z.write('<p>'+q.innerHTML+' ('+hE(h)+')<br><img src="'+hE(h)+'">');}z.close();})()Your task is to modify this naïve example to add the following features:
1. Remove duplicate entries.
2. Clamp width to a certain value, preserving aspect ratio.
3. Pad height vertically (with additional HTML elements) so that an integer number of images is displayed for every block of n pixels, for some n.
The first should be EASY AS FUCK, the second and third ones might be IMPOSSIBLE.