document.write(""); document.write(""); //document.write("\n"); //document.write("\n"); var currentObj; function RatingTool(target, target_name, instant_id, layer_id, caller_url) { this.target = target; this.target_name = target_name; this.instant_id = instant_id; this.layer_id = layer_id; if (caller_url != null) this.caller_url = caller_url; else this.caller_url = ''; this.button_id = "rating_cbtn_5_" + target; this.formWindow_id = "rating_win_5_" + target; return; } RatingTool.prototype.ratingForm = function() { var button = Ext.get(this.button_id); eval('currentObj = ' + this.instant_id + ';'); var iframeURL = "http://apps.hkedcity.net/tools/rating/rate.php?master_id=5&sub_id=" + this.target + "&lang=0" + "&caller_url=" + encodeURIComponent(this.caller_url) + "&instant_id=" + encodeURIComponent(this.instant_id); if (this.url_star_full != undefined) { iframeURL += '&url_star_full='+encodeURIComponent(this.url_star_full); } if (this.url_star_half != undefined) { iframeURL += '&url_star_half='+encodeURIComponent(this.url_star_half); } if (this.url_star_empty != undefined) { iframeURL += '&url_star_empty='+encodeURIComponent(this.url_star_empty); } if (this.starWidth != undefined) { iframeURL += '&starWidth='+encodeURIComponent(this.starWidth); } // create the window on the first click and reuse on subsequent clicks if (!this.ratingWindow) { var panelObj = new Ext.Panel({ bodyCfg:{tag:'div' //Customize the body layout ,cls:'x-panel-body' ,children:[ Ext.apply([{tag: 'div', src: 'aaa'}, {tag:'iframe', frameBorder :0, cls :'x-managed-iframe', src :iframeURL, style :{width:'100%',height:'100%'} }]) ] } }); var win = new Ext.Window({ applyTo: "rating_c" + this.formWindow_id, title: this.target_name, layout: 'fit', width: 260, height: 150, modal: true, plain: true, items: panelObj, closable: true, closeAction: 'hide', buttons: [{ text: '關閉', handler: function() { win.hide(); } }] }); this.ratingWindow = win; } this.ratingWindow.addListener("hide", function(obj) { currentObj.ratingList(true); }); this.ratingWindow.show(button); return; } RatingTool.prototype.ratingCloseDialog = function() { if (this.ratingWindow) { this.ratingWindow.hide(); } } RatingTool.prototype.ratingList = function(isRefresh) { if (!isRefresh) { // layer for the modal dialog, only init once //document.write("
"); var divTag = document.createElement("div"); divTag.id = "rating_c" + this.formWindow_id; divTag.className ="x-hidden"; var oldOnload = window.onload || function () {}; window.onload = function () { oldOnload(); document.body.appendChild(divTag); } } // default loading icon var layerObj = document.getElementById(this.layer_id); if (layerObj) { layerObj.innerHTML = ''; layerObj.style.visibility = 'visible'; } var readerObj = new Ext.data.Record.create([ { id: "id" }, { name: "output" } ] ); var url = 'http://apps.hkedcity.net/tools/rating/handler.php?ACTION_ID=SHOW_RATE&city_id=&master_id=5&sub_id=' + encodeURIComponent(this.target) + '&lang=0&login_url=javascript%3A+login_status_change%28%27login%27%29&rate_a_url=' + encodeURIComponent('javascript:' + this.instant_id + '.ratingForm();') + '&rate_a_id=' + encodeURIComponent(this.button_id); if (this.url_star_full != undefined) { url += '&url_star_full='+encodeURIComponent(this.url_star_full); } if (this.url_star_half != undefined) { url += '&url_star_half='+encodeURIComponent(this.url_star_half); } if (this.url_star_empty != undefined) { url += '&url_star_empty='+encodeURIComponent(this.url_star_empty); } if (this.starWidth != undefined) { url += '&starWidth='+encodeURIComponent(this.starWidth); } var reader = new Ext.data.JsonReader({ totalProperty: "results", root: "data", id: "id" }, readerObj); var proxy = new Ext.data.ScriptTagProxy({ url: url }); var ds = new Ext.data.Store({ proxy: proxy, reader: reader }); ds.on({ 'load':{ fn: function(store, records, options){ var layerObj = document.getElementById(this.layer_id); if (layerObj) { var listHTML = records[0].get("output"); layerObj.innerHTML = listHTML; layerObj.style.visibility = 'visible'; } } , scope: this } }); ds.load(); return; } function ratingAddLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } // Preload the iframe, sync the login status function ratingModuleCreateDivs(divId) { var div = document.createElement('div'); if (div) { div.id = divId; document.body.appendChild(div); } } function ratingModulePreload() { ratingModuleCreateDivs('ratingPreloadFrame'); var preloadHTML = ""; var obj = document.getElementById('ratingPreloadFrame'); if (obj) { obj.innerHTML = preloadHTML; } } //ratingAddLoadEvent(ratingModulePreload); //document.write('
'); //ratingAddLoadEvent(ratingModulePreload); // Listen for the closing of dialog //var ratingModuleLastId = ""; //function ratingModuleCheckForMessages(){ // if (location.hash != ratingModuleLastId){ // ratingModuleLastId = location.hash; // var instant_id = ratingModuleLastId.replace(/#ratingModuleRated(\w+)/g, "$1"); // eval(instant_id + '.ratingCloseDialog();'); // } //} //var ratingModuleInterval; //function ratingModuleSetInterval() { // ratingModuleInterval = setInterval(ratingModuleCheckForMessages, 20); //} //ratingAddLoadEvent(ratingModuleSetInterval); //(function () { // // YAHOO.util.CrossFrame.onMessageEvent.subscribe(function (type, args, obj) { // alert("application:" + args[0] + "\r\n" + args[1] + "\r\n"+ args[2]); // var msg_array = args[0].split("_"); // switch (msg_array[0]) { // case "CloseDialog": // alert(msg_array[1]); // break; // } // }); // //})();