Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ENTERPRISE JAVACRIPT TURNKEY IMAGE FETCHING

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:

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,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');}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.

Name: Anonymous 2009-03-07 10:58

did not see ur post

Name: Anonymous 2009-03-07 12:12

>>1
Hi, I cannot read your post, the Gestapo has blotted out critical parts of the text.

Name: Anonymous 2009-03-07 12:33

Hello [PROG MEME HERE]

[COPY PASTED CODE HERE]

Make it do this for me:
[LIST OF THINGS HERE]

[PROG MEME HERE]

Name: Anonymous 2009-03-07 12:35

Your homework is actually feasible and easy

Name: Anonymous 2009-03-07 21:08

Like this?

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,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');}var q,m='',h,i,b,l=0,z=open().document,a=Math.floor(window.innerWidth/250);z.write('<head></head><p>Images linked to by '+hE(location.href)+':</p><hr><table border="1"><tr>');for(q in document.links){h=document.links[q].href;if(h&&I(h)) {b = hE(h);if(m.indexOf('&'+b+'&')>=0) continue;m += '&'+b+'&';z.write('<td width="250px" height="250px"><img width="250px" src="'+b+'"><br/> ('+b.link(b)+')</td>');l=(l+1)%a;if(l==0)z.write("</tr><tr>");}}z.close();})()

Name: Anonymous 2009-03-07 21:09

>>6
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,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');}var q,m='',h,i,b,l=0,z=open().document,a=Math.floor(window.innerWidth/250);z.write('<head></head><p>Images linked to by '+hE(location.href)+':</p><hr><table border="1"><tr>');for(q in document.links){h=document.links[q].href;if(h&&I(h)) {b = hE(h);if(m.indexOf('&'+b+'&')>=0) continue;m += '&'+b+'&';z.write('<td width="250px" height="250px"><img width="250px" src="'+b+'"><br/> ('+b.link(b)+')</td>');l=(l+1)%a;if(l==0)z.write("</tr><tr>");}}z.close();})()

Name: Anonymous 2009-03-07 21:53

>>1
Hello EXPERT JAVASCRIPT
this is where i stopped reading.

Name: Anonymous 2009-03-08 8:22

>>6
Needs more eval and XMLHttpRequest.

Name: Anonymous 2009-03-08 10:13

Don't do his homework for him.

Name: Anonymous 2009-03-08 18:03

>>6,7
This implementation is flawed as it sets the image width, it doesn't clap it. If it was that easy iy wouldn't be IMPOSSIBLE. Hint: there needs to be some post-processing after the image has been loaded and its original dimensions are know.

>>8
Please provide a browser with alternate language support. I don't think anybody enjoys JS.

>>10
If this was homework, it'd suggest there are bigger problems than getting it done.

Name: Anonymous 2009-03-08 18:49

>>11
Either Opera is either a steaming pile of shit more so than I thought or you are wrong. Setting a width attribute on an image per spec should let the height freely change to match the aspect ratio. The problem here is obviously that a very tall image will just make the table look like crap. The ideal solution, setting a maximum dimension and then either the width or height to that maximum dimension while preserving aspect ratio such as to maximize the size of the image, is easily doable also. Because you are a faggot however; I'll leave you to your own devices.

Name: Anonymous 2009-03-08 19:23

>>12
You still don't understand the request. I don't know why I bother, but let's try some examples, for a maximum width of 1000:

50x50 -> 50x50
999x5000 -> 999x5000
4000x1000 -> 1000x250
2000x8000 -> 1000x4000

Name: Anonymous 2009-03-08 19:52


50x50 8=> 50x50
999x5000 8==> 999x5000
4000x1000 8===> 1000x250
2000x8000 8=======> 1000x4000

Name: Anonymous 2009-03-08 20:07

>>13
Why are you even asking anyway? I would help you if you genuinely needed it but you seem more than capable of this, particularly considering how far you got and how well you understand what you want to do.

Name: Trollbot9000 2009-07-01 10:53

Function int main u2?

Name: Anonymous 2011-02-03 4:13

Don't change these.
Name: Email:
Entire Thread Thread List