" /> Yuan.CC Web Experiments: August 2005 Archives

« July 2005 | Main | September 2005 »

August 30, 2005

Typhoon in Google Maps

Tags: Mashups

TAILIM Typhoon

Here's a small google maps app to display the live and historical paths of typhoons near Taiwan in southeast Asia. It records all paths of typhoons since year 2005.

The 4th typhoon of 2005 near Taiwan has showed up this morning. The weather report predicts it will move toward Taiwan. The records of typhoon are fetched from Central Weather Bureau of Taiwan automatically every 30 mins.

The story was posted to Google Maps Mania.
http://webdev.yuan.cc/typhoon/
http://www.cwb.gov.tw/ (Central Weather Bureau of Taiwan)

August 25, 2005

My scripts in Userscripts.org

Tags: GMiF , Greasemonkey

I've officially added GMiF to Userscripts.org. The anonymous post of old version of GMiF has been removed.

You can get the latest GMiF via either my official site http://webdev.yuan.cc/gmif/ , or via Userscripts.org http://userscripts.org/scripts/show/1574.

Or, you can check all my scripts in Userscripts.org.

August 20, 2005

[Ajax] Hacking Rojo - Ajaxize 'Mark as Read' function

Tags: Ajax , Greasemonkey , Rojo

Since my previous work 'an Ajax Wrapper for Rojo' has replaced the iframe remote scripting by XMLHttpRequest, some slow 'loading whole page' transactions of Rojo need remodeling now. Well, I use the term "Ajaxize" which means turning the old-fashioned transactions of cross-pages into Ajax approach. The first one I've done is to make "Mark as Read" as a background transaction.

The script 'rojo.ajax.user.js' is now version 1.1 and has the following features:

1. Override the Remote object(remote scripting) by an Ajax wrapper. 2. Mark as read is now Ajax and reset the unread count on the LHS menu.

Download: rojo.ajax.user.js

The code is simple. Just 'click' the 'Mark as Read' url by XMLHttpRequest, and then reset the counter in LHS menu.

Ajax.Mark_as_Read = function() {

    var markasread = document.getElementById("markReadLink");
    if( markasread ) {
        var url = markasread.href;
        markasread.href = 'javascript:;';
        var callback = function() {
            var li = document.getElementsByTagName('li');
            for(var i=0; i < li.length; i++) {
                if( li[i].className == 'selected subscription unread' ) {
                    li[i].getElementsByTagName('span')[0].innerHTML = '';
                }
            }
        }
        markasread.onclick = function() {
            Remote.execRequest(url, callback, null);
        }
    }
}

August 18, 2005

[Ajax] Hacking Rojo - an Ajax Wrapper for Rojo

Tags: Ajax , Greasemonkey , Rojo

Rojo is a great web-based RSS reader. It supports tagging not only feeds but also article entries. The user interface is neat and well organized. The use of DHTML and CSS makes the site easier reading and more accessible.

As we already knew, Rojo uses a lot of DHTML + Javascript techniques to enhance the user interface. Despite Rojo has the modern design of tagging and social share, it seems not to be an Ajax approach I talked in my previous post, "Hacking Rojo - Rojo is not Ajax? ". Rojo retrieve asynchronous data by remote scripting with iframe, not by calling XMLHttpRequest. There would be a little bit slower when using remote script instead of XMLHttpRequest. Therefore I did a small experiment to replace the iframe remote script by the Ajax way. The Greasemonkey user script can meet my need to override the methods of Remote object in Rojo.

This Greasemonkey user script is a wrapper for Rojo to replace its iframe request by the XMLHttpRequest function. The data retrivial will proceed in background, so the browser won't be seen in loading pages any more. After installing the script, the response of using Rojo should become faster.

Download: rojo.ajax.user.js

Let's take a look at the two original methods of Remote object.

Remote.execRequest = function(resource, callback, callbackArguments) {
    //NOTE: we need to prevent corruption here due to multi-threaded IO and
    //non-blocking UI controls in IE/Mozilla

    this.callback = callback;
    this.callbackArguments = callbackArguments;
    this.waitingForResponse = true;
    this.changeIFrameLocation(resource);
}

Remote.iFrameOnLoad = function() {

    if ( this.callback != null ) {
        var currentCallback = this.callback;
        var currentCallbackArguments = this.callbackArguments;
        this.callback = null;
        this.callbackArguments = null;
        this.resource = null;
        this.waitingForResponse = false;
        if (this.requests.length > 0) {
            var nextRequest = Util.shift(this.requests);
            this.waitingForResponse = true;
            this.execRequest(nextRequest.resource, nextRequest.callback,
                             nextRequest.callbackArguments);
        }
        var iframeContents = Remote.getIFrameContents();
        if (currentCallbackArguments == undefined ||
            currentCallbackArguments == null) {
            currentCallbackArguments = new Array();
        }
        currentCallbackArguments[currentCallbackArguments.length] = iframeContents;
        currentCallback.apply(null, currentCallbackArguments);
    }
}

Now we can override the above two methods by the following new methods with a real Ajax XMLHttpRequest call.

Remote.fakeiFrameOnLoad = function(result) {
    if ( this.callback != null ) {
        var currentCallback = this.callback;
        var currentCallbackArguments = this.callbackArguments;
        this.callback = null;
        this.callbackArguments = null;
        this.resource = null;
        this.waitingForResponse = false;
        if (this.requests.length > 0) {
            var nextRequest = Util.shift(this.requests);
            this.waitingForResponse = true;
            this.execRequest(nextRequest.resource, nextRequest.callback, nextRequest.callbackArguments);
        }

        var iframeContents = result;
        if (currentCallbackArguments == undefined || currentCallbackArguments == null) {
            currentCallbackArguments = new Array();
        }
        currentCallbackArguments[currentCallbackArguments.length] = iframeContents;
        currentCallback.apply(null, currentCallbackArguments);
    }
}

Remote.execRequest = function(resource, callback, callbackArguments) {
    this.callback = callback;
    this.callbackArguments = callbackArguments;
    this.waitingForResponse = true;
//    this.changeIFrameLocation(resource);

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4) {
            if (xmlhttp.status==200) Remote.fakeiFrameOnLoad(xmlhttp.responseText);
        }
    }
    xmlhttp.open('GET', resource, true);
    xmlhttp.send(null);
}

August 11, 2005

LfVr: moving navigation box to left side

Tags: LfVr

To get a better using experience, I moved the nagivating box of photostream from the photo window to left. So the div boxes of photo/description/navigation won't float around when clicking prev/next link.

August 09, 2005

Flickr Comments in your blog

Tags: Flickr General

Flickr Comments Box for Blog

I create a new script that can load your recent flickr comments and embed into your blog or web site.

Bloggers love flickr so much because of the free and unlimited space. The community of flickr usually overlaps the readers of our blogs. We already have the flickr badges to show our photos. Now we can put a comments box in our blog.

This script, a variation of 'Recent comments in photostream', can embed flickr comments in your blog.

Usage:

Include the following script in your HTML.

Control variables:

....... HTML head .......
<script>
// your flickr userid (nsid)
flickr_nsid = '62869273@N00';
// the title
flickr_comments = 'My Flickr Comments';
// open comments box by default
flickr_open = true;
</script>
....... HTML head .......

....... HTML body .......
<script src="http://webdev.yuan.cc/flickr/flickr.comments.js"></script>
....... HTML body .......

Following is the sample CSS style. It can let you control the looking appearance to fit your blog.


<style>
#flickr_comments {
width: 200px;
padding:5px;
border:1px;
background-color:#eeeeee;
}
#flickr_comments span {
font-size: 13px;
font-family: Verdana, Arial, sans-serif;
text-transform: uppercase;
}
#commentList {
margin:0px;padding:0;
}
#commentList ul {
margin:3px;
padding:0;
min-height:72px;
}
#commentList ul img {
float:right;
width:70px;
border:0px;
border-color: #ffffff;
margin:5px;
}
#commentList ul p {
padding-top:2px;
padding-left:2px;
padding-right:20px;
padding-bottom:0px;
color: #666666;
font-family: Verdana, Arial, sans-serif;
font-size: 11px;
}
#commentList ul a {
color: #666666;
font-family: Verdana, Arial, sans-serif;
font-size: 11px;
}
</style>

August 08, 2005

New features of GMiF 3.0 Beta

Tags: GMiF , Greasemonkey , Mashups

Two new features of GMiF 3.0beta:

  1. If you 'Play' the geostream, the stream will slide to from right to left and the map will move to the location to show the focused photo at interval of every 3 seconds.
  2. The map size can be widened now. Two control buttons are added: 'Widen' and 'Narrow'. So you can enlarge the map either by the width or length.

The two features are for GMiF 3.0 only. You don't need to re-install the user script. You only need to press Ctrl+F5 once when viewing any photo page, firefox will force to reload the latest gmif.js library.

August 04, 2005

GMiF v3.0 beta

Tags: GMiF , Greasemonkey , Mashups

The GMiF version 3.0 beta is out for testing. The reason I jump to v3.0 is because I reconstruct a lot of codes both in structures and modules. However, users won't feel too many changes of user interface. BTW, the GM 0.5 beta is also available. GMiF 3.0 is mainly developed and tested with it.

The major changes in v3.0:

  1. Loading GMiF js library dynamically
    Now GMiF starts to load js library at runtime. GMiF itself registered in Greasemonkey is only a shell. The main js library is loading dynamically. If everything is going well, hopefully, users don't need to upgrade GMiF anymore. You can always has the latest GMiF online js library.
  2. 'Play' geotagged photostream
    At the bottom of maps is the geotagged photostream of current photo owner. A button 'Play' is added to have the stream moving from right to left. You will see the whole geostream without clicking next/prev buttons.
  3. "Where is owner" feature
    This is a new feature to tell people where you are now. Image that you are traveling, away from home, or just out of town. You can specify a geotagged photo to show the place you are now. The only thing you need to do is add a new tag "GMiF:herenow" to the photo. The GMiF will display your current location in Maps and use the photo as the icon.

    A more interesting application is, if you have an GPS enabled camera, that you can post the photo via laptop+WiFi or GPRS/3G cellphone by email, your friends will know where you are now. GMiF will always fetch the latest photo tagged with 'GMiF:herenow'. You don't need to worry you have too many 'GMiF:herenow' tagged photo.

Please note that GMiF 3.0 is testing fully in the following environment: Firefox 1.0.6 + Greasemonkey 0.5 beta. If you encounter any problems, simply re-install v2.3 will bring you back.

Thanks for the test drive. Your help is appreciated.

Download GMiF 3.0 - flickr.gmap_v3.0.user.js

Download GMiF 2.3 - flickr.gmap_v2.3.user.js

GM script: Textarea Enlargement in Flickr

Tags: Flickr General , Greasemonkey

The textarea in Flickr is too small. Sometimes the message we need to input is too long, even including some HTML codes. This script can enlarge the rows of textarea.

Download: flickr.textarea.user.js

August 01, 2005

GMiF v2.3 - a new release of Google Maps in Flickr

Tags: GMiF

GMiF v2.3

The new version 2.3 is released, and some new features are added.

1. Add the owner's geotagged photostream below the map.

You can click the photo thumb to move the map to the location of it. You can also click the buttom 'First/Prev/Next/End' to see more photos thumbs in the stream.

2. Display the city on map where the photo owner lives in.
GMiF gets the lat/lon info of the city where the owner lives from the user profile. The owner needs to set his current living city as the following pattern: City (lat,lon)

e.g. San Francisco (37.772343,-122.444687)


3. Upgrade to maps.14.js. The embedded map can be shown in Hybrid mode now.

Download GMiF 2.3 - flickr.gmap.user.js

Unfortunately, the greasemonkey still stays in 0.3.5, so following capabilities remain broken: 1. post to geobloggers; 2. add comments; 3. get nearby photos.

Google Ads

Powered by
Movable Type 3.2