trunk/research/players/js/winlin.utility.js
/**
 * async refresh function call. to avoid multiple call.
 * @remark AsyncRefresh is for jquery to refresh the speicified pfn in a page;
 *      if angularjs, use AsyncRefresh2 to change pfn, cancel previous request for angularjs use singleton object.
 * @param refresh_interval the default refresh interval ms.
 * @see: http://blog.csdn.net/win_lin/article/details/17994347
 * the pfn can be implements as following:
 var async_refresh = new AsyncRefresh(pfn, 3000);
 function pfn() {
            if (!async_refresh.refresh_is_enabled()) {
                async_refresh.request(100);
                return;
            }
            $.ajax({
                type: 'GET', async: true, url: 'xxxxx',
                complete: function(){
                    if (!async_refresh.refresh_is_enabled()) {
                        async_refresh.request(0);
                    } else {
                        async_refresh.request(async_refresh.refresh_interval);
                    }
                },
                success: function(res){
                    // if donot allow refresh, directly return.
                    if (!async_refresh.refresh_is_enabled()) {
                        return;
                    }

                    // render the res.
                }
            });
        }
 */
async refresh function call. to avoid multiple call.
@remark AsyncRefresh is for jquery to refresh the speicified pfn in a page;
if angularjs, use AsyncRefresh2 to change pfn, cancel previous request for angularjs use singleton object.
@param refresh_interval the default refresh interval ms.

render the res.
async refresh function call . to avoid multiple call . @remark AsyncRefresh is for jquery to refresh the speicified pfn in a page ; if angularjs use AsyncRefresh2 to change pfn cancel previous request for angularjs use singleton object . @param refresh_interval the default refresh interval ms . render the res .
function AsyncRefresh(pfn, refresh_interval) {
    this.refresh_interval = refresh_interval;
    this.__handler = null;
    this.__pfn = pfn;
    this.__enabled = true;
}
function AsyncRefresh ( pfn , refresh_interval ) { this . refresh_interval = refresh_interval ; this . __handler = null ; this . __pfn = pfn ; this . __enabled = true ; }
async refresh function call.
async refresh function call .