var _rootpath = '../../'; var _logged = false; function goto (page) { var content = Ext.get('content'); Ext.select('.links').each(function(e){ e.setStyle({ display:'none' }); }); if (page == 1) { if (Ext.fly('shop') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('shop'); } else if (page == 2) { if (Ext.fly('auction') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('auction'); } else if (page == 3) { if (!Ext.fly('news')) { var para = Ext.urlEncode(n); var code = ''; content.insertHtml('beforeEnd', code); } showPage('news'); } else if (page == 4) { if (!Ext.fly('video')) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('video'); } else if (page == 5) { if (!Ext.fly('account')) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('account'); } else if (page == 10) { if (Ext.fly('auction2') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('auction2'); } else if (page == 11) { if (Ext.fly('auction3') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('auction3'); } else if (page == 12) { if (Ext.fly('auction4') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('auction4'); } else if (page == 13) { if (Ext.fly('auction5') == null) { var code = ''; content.insertHtml('beforeEnd', code); } showPage('auction5'); } } // goto function showPage (page) { Ext.fly(page).fadeIn({ easing: 'easeOut', duration: 2 }); } // showPage function generate_ebay (e) { var para = Ext.urlEncode(e); var code = ''; document.write(code); } // generate_ebay function checkAuth () { if (Ext.get('popup') == null) { console.log('page not ready'); return; } if (_logged) { Ext.get('settings').setStyle({ display:'block' }); openPopup(); return; } Ext.Ajax.request({ url: _rootpath+'auth.php', method: 'POST', success: function(response, opts) { var stt = response.responseText; if (!stt || stt == '0' || stt === 0) { Ext.get('login').setStyle({ display:'block' }); openPopup(); } else { // logged showSetting(stt); setTimeout('openPopup()', 1000); } }, failure: function(response, opts) { // what to do? } }); } // checkAuth function openPopup () { if (!Ext.get('overlay')) { Ext.DomHelper.append(document.body, { id: 'overlay', style: 'position:absolute; top:0; left:0; background-color:#fff; display:none;' }); Ext.fly('overlay').on('click', closePopup); } var el = Ext.get('overlay'); el.setHeight(Ext.getBody().getHeight()); el.setWidth(Ext.getBody().getWidth()); el.fadeIn({ easing: 'easeOut', endOpacity: .6, duration: .5 }); var dwidth = document.documentElement.clientWidth; var dheight = document.documentElement.clientHeight; var popup = Ext.get('popup'); var eheight = popup.getHeight(); var scroll = Ext.getBody().getScroll(); var left = Math.round((dwidth - popup.getWidth()) / 2); var top = Math.round((dheight - eheight) / 2); var top2 = top + scroll.top; popup.setLeft(left); popup.setTop(scroll.top-eheight); popup.show(); popup.moveTo(left, top2, { easing: 'easeOut', duration: 1, callback: function() { popup.setStyle({ position:'fixed', top:top+'px', left:left+'px' }); } }); } // settings function closePopup () { var el = Ext.get('popup'); var h = el.getHeight(); var s = Ext.getBody().getScroll().top; var y = s - h; var x = el.getX(); var ct = Math.round((document.documentElement.clientHeight - h) / 2) + s; Ext.fly('overlay').fadeOut({ easing: 'easeOut', duration: .5, useDisplay: true }); el.setStyle({ position:'absolute', top:ct+'px' }); el.moveTo(x, y, { easing: 'easeIn', duration: 1, callback: function() { //el.setStyle({ top:'-'+h+'px', left:x+'px' }); el.hide(); Ext.get('settings').setStyle({ display:'none' }); Ext.get('login').setStyle({ display:'none' }); } }); } // closePopup function login () { var el = Ext.get('login'); var msg = Ext.get('message'); var pwd = Ext.get('password').getValue(); if (!pwd) { Ext.getDom('message').innerHTML = 'Please enter password'; msg.dom.className = 'error'; if (!msg.hasActiveFx()) { msg.slideIn('t').pause(5).slideOut('t', { useDisplay:true }); } return false; } el.slideOut('l', { easing: 'easeOut', useDisplay: true, callback: function() { checkLogin(); } }); return false; } // login function checkLogin () { var msg = Ext.get('message'); msg.dom.innerHTML = 'verifying..'; msg.dom.className = 'loading'; msg.slideIn('l', { easing:'easeOut' }); Ext.Ajax.request({ url: _rootpath+'auth.php', method: 'POST', success: function(response, opts) { msg.slideOut('l', { easing: 'easeOut', useDisplay: true, callback: function() { showSetting(response.responseText); } }); }, failure: function(response, opts) { // what to do? msg.slideOut('l', { easing: 'easeOut', useDisplay: true }); }, params: 'password='+Ext.fly('password').getValue() }); } // checkLogin function showSetting (stt) { var el = Ext.get('settings'); var msg = Ext.get('message'); if (!stt || stt == '0' || stt === 0) { Ext.getDom('message').innerHTML = 'Enter wrong password'; Ext.fly('password').dom.value = ''; msg.dom.className = 'error'; msg.slideIn('l').pause(5).slideOut('t', { useDisplay:true }); Ext.fly('login').slideIn('l', { easing: 'easeOut' }); } else { var obj = eval('('+stt+')'); _logged = true; Ext.each(obj, function(o){ Ext.fly(o.k).dom.value = o.v; }); el.slideIn('l', { easing: 'easeOut' }); } } // showSetting function save () { var msg = Ext.get('message'); Ext.Ajax.request({ url: _rootpath+'save.php', form: 'settingsForm', success: function(response, opts) { var res = response.responseText; if (res) { Ext.getDom('message').innerHTML = 'Settings saved successfully!'; msg.dom.className = 'notice'; msg.slideIn('l').pause(2).fadeOut({ useDisplay:true }); var close = this.closePopup; setTimeout(function(){ close(); }, 1000); } } }); return false; } // save function loadDom () { Ext.Ajax.request({ url: _rootpath+'popup.inc.html', success: function(response, opts) { var html = response.responseText; if (html) { Ext.getBody().insertHtml('beforeEnd', html); } } }); } // loadDom Ext.onReady(function() { goto(1); loadDom(); });