/** * Misc utilities */ function dummy(){return} function _store_put(val){ _store_init(); var id = unid(); window['$storage'][id] = val; return id; } function _store_get(id){ _store_init(); if (typeof window['$storage'][id]!='undefined') return window['$storage'][id]; return; } function _store_del(id){ if (typeof window['$storage'][id]!='undefined'){ try{ window['$storage'][id] = dummy(); delete window['$storage'][id]; } catch(e){} } } function _store_init(){ if (typeof window['$storage']=='undefined') window['$storage'] = {}; } function UUID(){this.id='a'+(UUID.starter++);} UUID.starter = (new Date().getTime()); UUID.prototype.valueOf=function(){return this.id;} UUID.prototype.toString=function(){return this.id;} function unid(){return (new UUID().id)} /** * Dimensions */ function getWindowSize(){ var size = { width: window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth), height: window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight) }; return size; }; function getWindowScrollOffset(){ return (document.documentElement.scrollTop || document.body.scrollTop) + 'px'; }; /** * Dialog */ function dlg(title,content){ var ie6 = (window.external && typeof window.XMLHttpRequest == "undefined" ); // NOTE: some IE6 detection need to be here var popup = d('spop'); var dialog = popup.getElementsByTagName('table')[0] || {}; dialog.width = '100%'; var wrapper_id = 'popup_wrapper'; if (popup.parentNode.id==wrapper_id){ var wrapper = popup.parentNode; } else { var wrapper = document.createElement('div'); wrapper.id = wrapper_id; popup.parentNode.appendChild(wrapper); wrapper.appendChild(popup); } var popup_title = d('popup_title'); var popup_container = d('popup_content'); // NOTE: we do not want to display empty dialogs if (!content || !popup) return; var ie6scroll = function(){ // BlockBox _css(popup,{ top: getWindowScrollOffset() }); }; var positionPrompt = function(){ var wsize = getWindowSize(); // BlockBox _css(wrapper,{ position: (ie6)? "absolute" : "fixed", height: wsize.height, width: "100%", top: (ie6)? getWindowScrollOffset():0, left: 0, right: 0, bottom: 0 }); // BlockFader //jqif.css({ position: "absolute", height: wsize.height, width: "100%", top: 0, left: 0, right: 0, bottom: 0 }); //clog((popup.clientWidth/2)); // Dialog _css(popup,{ position: "absolute", top: "100px", left: (wsize.width/2-popup.clientWidth/2)+'px' }); }; var hideDlg = function(){ //clog('Hide'); //_css(wrapper,{display:'none'}); _css(wrapper,{visibility:'hidden','z-index':-1}); } var showDlg = function(){ positionPrompt(); //_css(wrapper,{display:'block'}); _css(wrapper,{visibility:'visible','z-index':1000}); _css(popup,{visibility:'visible'}); } // NOTE: our dialogs are not modal and dragable, so not binding events, but firing if (!popup.hasAttribute('binded')){ var inputs = popup_container.parentNode.getElementsByTagName('input'); for (var i=0; i