![]() Equipping You to Communicate Effectively | support CMN & share a library of 19K+ images, videos, etc Go Pro! |
![]() | ![]() |
| |||||||
| Website Coding Discussions PHP, MySQL, Java, Javascript, ASP, etc. |
![]() |
| | Thread Tools | Search this Thread | Rate Thread | Display Modes |
| ||||
| vGrabber Why?: Some of you may have heard of http://www.churchmediadesign.tv, if not, I suggest you go check it out, it's a great resource. Anyway, after receiving this via Twitter, "anyone know how to create a javascript bookmarklet?" I thought it might be an interesting new venture to learn some javascript since I don't really have any experience with it. Thoughts: I know this little toy has a limited usefulness, as not too many people need to regularly grab thumbnails from Vimeo videos, but hey, why not. Anyway, review it as you like, let me know what you think. I send the following to Brad upon finishing it this afternoon. Understand it's very basic and lacks some common conveniences, such as any way to close the pop-up after it's loaded... suggestions on how to make the window close would be gladly heard. What it does: 1. Load an iframe via javascript. 2. Fetch the referring URL e.g., vimeo.com/9139405 or www.vimeo.com/9139405, we’ll use this to determine which video you’d like the thumb nail for. 3. Explode the URL into pieces so we can gather the information bits we need from it and place them into a PHP array. The array looks like so: [0] => http: [1] => [2] => vimeo.com [3] => 9139405 4. Use the array we just created to verify that it contains either vimeo.com, or www.vimeo.com, this helps limit the number of errors you’ll see if the tool is misused. 5. Assuming it’s an actual vimeo.com page, we then create a link to the XML file containing the thumbnail locations required. This is achieved using http://vimeo.com/api/v2/video/'.$vimeoID[3].'.xml', Where $vimeoID[3] is a piece of the array we exploded earlier. This is basically the unique identifier for the video, allowing us to find the XML required. 6. Upon verification, using http://vimeo.com/api/v2/video/9139405.xml as our feed, we can then send it to a curl SimpleXML function that will essentially explode the feed into an array. 7. Since everything is now broken down into a convenient array, we simply need to make a few print or echo calls, and dump the URL into some text boxes, or just as a string so they can be copied easily. Bookmarklet Code: Code: javascript:(function(){var%20d=document,b=d.body,e=d.getElementById('ecomblum');if(e)e.parentNode.removeChild(e);e=d.createElement('div');e.id='ecomblum';e.innerHTML=' |