Posts

Showing posts with the label javascript

Delicious linkroll, revised

Based on this comment in a previous blog post on rolling my own Delicious linkroll , I modified my code to sort the recent bookmarks alphabetically. I also added encoded URIs and escaped HTMLs to — hopefully — make the code XSS-safe. Here it is: Script available at Github Gist. I know, I should have used Delicious' version 2 of the JSON feeds and callbacks — will get to that soon. ;) For now, see the code at work here .

Revisiting my tumblog

I've made several improvements to my tumblog . Previously , I merely plugged in the RSS output from Yahoo! Pipes to Feedburner, and served up the content using Buzzboost. Using techniques from Cristiano Betta's lifestream and elsewhere , I simplified and modularized the Yahoo! Pipes mashup . I then used the pipe's JSON output and styled it with some simple CSS. I didn't want too much dependence on other JavaScript libraries so I used native code as much as possible, except for dynamically loading the JSON object from Pipes (for which I used the JSONscriptRequest class). I'm still having trouble getting the logic of reloading the content asynchronously: for now, I simply destroy the child element containing the tumblog items and rewrite everything -- expensive, I know. I've also been thinking of creating a Google Gadget out of this, but the iGoogle API's FetchFeedAsJSON method is somewhat limited. I may have to use my current approach of dynamically creatin...

2007 in pictures

Image
Cover-flow style , courtesy of MooFlow tools . The photos were compiled from Flickr . I was attempting to automate the process ala- fd's Flickr toys , what with the Flickr API's fantastic use of JSON responses (no need for server-side nor cross-site xHTTP requests). Alas, my days were packed. But I'm getting the hang of it. I'm relearning JavaScript along the way (I could actually rebuild a DOM tree from the JSON response, cool). One thing that would have made my coding easier: an API wrapper for JavaScript. Anyway, enjoy. Kudos to Naraoya and ATIS547 for the borrowed pics.

Google translation bookmarklet

Image
I've been visiting a few foreign - language sites lately, and Google Translate is a great tool, if a bit awkward. I created a bookmarklet that will point the site to Google Translate . I then added a keyword ("gt") so that when I'm in the site, I can just press F6, and enter the keyword.

Snag movie audio tracks

Okay, watching movies in the workplace is a definite no-no, but they didn't say anything about listening to movies . But I'd rather do it offline, so I whipped up a little bookmarklet that will snag the .MP3 URL off the movies I chose. First off, select a movie from the list . Then list all the URLs in that page by using Javascript's document.links object. I noticed that the URI for the MP3 link is always the ninth, so just get the ninth URL: document.links[8].href . Using a regular expression, winnow the URL: document.links[8].href.replace(new RegExp('[?&=]','g'),' ').split(' ')[2] Drop in the javascript resource header, and voila! here's the bookmarklet that will grab audio track's URL for download. Right-click and bookmark the link. Or, drag and drop the link to the bookmarks toolbar.

Clever Javascript hack

Go to Flickr.com, view any photostream. Clear the address bar, and type the following: javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){ for(i=0; i-DIL; i++) { DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5 } R++ } setInterval('A()',5); void(0); Sit back, and marvel. Via Google Blogoscoped .

Google Maps API experiment, revisited

Apparently, I goofed. When I visited my Google Maps API project this morning, the map was missing! Thanks to Migs Paraz for pointing that out. In the previous version, I added a few div items that shouldn't be there (in the spirit of separating content, presentation and behavior in the code). I cleaned the code a bit: completely separating the Javascript code to another file so the HTML will not be cluttered, and added an if (GBrowserIsCompatible()) check. The XML is still as it is. Will have to consult with the content developers on what other info to include. And I'm still not sure about the GPS locations because I just gathered the samples from Global Gazetteer Version 2.1 . Will have to check with the GIS people on Monday. For now, here it is . It's really not that much: there's a list of interesting points on the left that you can click to display info on the map. I'll be adding the relevant information soon, such as the websites, statistics and related link...

Roll your own del.icio.us link roll

There is, of course, a ready-made Javascript code to include the latest del.icio.us postings to your blog or web page, but if you want to 'beautify' it, take a look at what I've done. I used del.icio.us' JSON object, named Delicious.posts that contains the latest bookmarks. I snatched the code from the del.icio.us JSON help page and added a few enhancements, like the extended note and the associated tags. This is the code: latest del.icio.us postings \\ latest del.icio.us postings First, set up the HTML container for the heading and the postings. The Delicious.posts object is fetched using: The script iterates through the object, parsing the URL ( Delicious.posts[i].u ), description ( d ), and extended note, if any ( n ). The inner j loop iterates through the tags ( t ). The script also fetches the page icon of each link. To roll your own, just replace the username in: and var tagu = 'http://del.icio.us/iandexter/' + post.t[j]; Paste in the code som...

"Bookmark this site" script

I know this has been done elsewhere — and better. Just want to put down for posterity. Still looking for Gecko alternative... Update : By gulay! I got it! Bookmark this site Geez, it was that simple. Update: Here's a more compact version, without the need for the Javascipt above. Bookmark this site