var currlang; var rootdomain = "http://www.oxygenwifi.com/"; // change this and rootdomain in web.config var applicationname = "access3"; // change this and applicationname in web.config function loadUI(uiparams) { if (uiparams.error == "no error") { var topmsg = uiparams.dataset[0].initpagemessage; //getParameterFromString("initpagemessage", uiparams); $('#topmsg').attr("value", topmsg); } } function getParameter(paramName) { var searchString = window.location.search.substring(1); if (searchString.length == 0) { var pp = window.location.href.split("#"); if (pp.length > 1) searchString = pp[1]; else searchString = ""; } var i, val, params = searchString.split("&"); for (i = 0; i < params.length; i++) { val = params[i].split("="); if (val[0] == paramName) { return unescape(val[1]); } } return null; } function getParameterFromString(paramName, stringtosearch) { var searchString = stringtosearch.substring(0), i, val, params = searchString.split("|"); for (i = 0; i < params.length; i++) { val = params[i].split("="); if (val[0] == paramName) { return unescape(val[1]); } } return null; } function getInitPageSettings(strName, resfunc) { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'getinitpage', locationid: strName }, dataType: 'jsonp', success: function (resp) { resfunc(resp); } }); } function UseLoginInfo(ltoken, mlike) { $.getJSON('https://graph.facebook.com/v2.4/me?callback=?&access_token=' + ltoken, function (response) { var bday = (response.birthday) ? response.birthday : ""; var fname = (response.first_name) ? response.first_name : ""; var gender = (response.gender) ? response.gender : ""; var fbid = (response.id) ? response.id : "0"; var lname = (response.last_name) ? response.last_name : ""; var fblink = (response.link) ? response.link : ""; var fblocale = (response.locale) ? response.locale : ""; var fbname = (response.name) ? response.name : ""; var fbtzone = (response.timezone) ? response.timezone : ""; var fbuser = (response.username) ? response.username : ""; var fbverified = (response.verified) ? response.verified : ""; var femail = (response.email) ? response.email : ""; var mustlike = (mlike == 'mlike') ? 1 : 0; var ltype = (mustlike == 1) ? 1 : 2; var fhtown = (response.hometown) ? response.hometown.name : ""; InsertAttempt(ltype, fbid, mustlike, 1, fbname, fname, lname, fblink, fbuser, gender, fblocale, bday, femail, fhtown); }); } function LoginWithScope(anAddr) { var fbstate = ($('#ltype').text() == 1) ? 'mlike' : 'nolike'; var lonly = $('#lonly').val(); var aUrl = ""; // Production if (anAddr == undefined) anAddr = rootdomain; if (lonly == '') aUrl = anAddr + applicationname + '/fbredir.aspx?state=' + fbstate; else aUrl = lonly + '?username=tempuser1&password=123&popup=false&dst=' + anAddr + applicationname + '/fbredir.aspx?state=' + fbstate; window.location = aUrl; } function GetLoginSettings() { //peirazw to href apo ta ").attr('src', resp.dataset[0].profpictureid); $('#profimage').empty().append($primg); //$('#offsetxvalue').text(resp.dataset[0].offsetx); //$('#offsetyvalue').text(resp.dataset[0].offsety); $('#fbcover').css({ "margin-top": - resp.dataset[0].offsety + "px", "margin-left": resp.dataset[0].offsetx + "px" }); var strmac = $('#mac').val(); var errpg = getParameter('errpage'); if ($('#ios').val() == 'true') { if ($('#itype').val() == 'fb' && errpg != '1') window.location = './Fbredir.aspx?state=mlike'; if ($('#itype').val() == 'mail') // production window.location = './LoginwithEmail.aspx?mac=' + strmac; // 'http://www.oxygenwifi.com/LoginwithEmail.aspx?mac=' + strmac; if ($('#itype').val() == 'pw') window.location = './PasswLogin.aspx'; if ($('#itype').val() == 'cn') window.location = './PasswLogin.aspx?ps=1'; } else { var lcount = 0; if ($('#ioscaptive').val() == "yes") { if (resp.dataset[0].loginwithpassword != 1) { $('#pwbutton').attr('class', 'notshown w0'); $('#pwiphone').attr('class', 'notshown w0'); $('#fbbutton3').attr('class', 'notshown w0'); $('#pwdiv').attr('class', 'notshown w0'); $('#pwdiv2').attr('class', 'notshown w0'); } else { $('#pwbutton').attr('class', 'notshown w0'); $('#pwiphone').removeAttr('class'); $('#fbbutton3').attr('class', 'loginbox pwbox1'); $('#pwdiv').attr('class', 'notshown w0'); $('#pwdiv2').removeAttr('class'); lcount++; } if (resp.dataset[0].loginwithfb != 1) { $('#fbbutton').attr('class', 'notshown w0'); $('#fbiphone').attr('class', 'notshown w0'); $('#fbbutton1').attr('class', 'notshown w0'); $('#fbdiv').attr('class', 'notshown w0'); $('#fbdiv2').attr('class', 'notshown w0'); } else { $('#fbbutton').attr('class', 'notshown w0'); $('#fbiphone').removeAttr('class'); $('#fbbutton1').attr('class', 'loginbox fbbox1'); $('#fbdiv').attr('class', 'fa fa-facebook fa-3x'); $('#fbdiv2').removeAttr('class'); lcount++; } if (resp.dataset[0].loginwithemail != 1) { $('#owbutton').attr('class', 'notshown w0'); $('#emailiphone').attr('class', 'notshown w0'); $('#fbbutton2').attr('class', 'notshown w0'); $('#maildiv').attr('class', 'notshown w0'); $('#maildiv2').attr('class', 'notshown w0'); } else { $('#owbutton').attr('class', 'notshown w0'); $('#emailiphone').removeAttr('class'); $('#fbbutton2').attr('class', 'loginbox oxbox1'); $('#maildiv').attr('class', 'notshown w0'); $('#maildiv2').removeAttr('class'); lcount++; } if ((resp.dataset[0].loginwithpassword != 1) && (resp.dataset[0].loginwithemail != 1) && (resp.dataset[0].loginwithfb != 1)) { $('#cnbutton').attr('class', 'notshown w0'); $('#cniphone').removeAttr('class'); $('#fbbutton4').attr('class', 'loginbox cnbox1'); $('#cndiv').attr('class', 'notshown w0'); $('#cndiv2').Attr('class', 'btn btn-sunny btn-lg animated bounceInUp'); } } else { if (resp.dataset[0].loginwithpassword != 1) { $('#pwbutton').attr('class', 'notshown w0'); $('#pwiphone').attr('class', 'notshown w0'); $('#fbbutton3').attr('class', 'notshown w0'); $('#pwdiv').attr('class', 'notshown w0'); $('#pwdiv2').attr('class', 'notshown w0'); } else { $('#pwbutton').attr('class', 'loginbox pwbox1'); $('#pwiphone').attr('class', 'notshown w0'); $('#fbbutton3').attr('class', 'notshown w0'); $('#pwdiv').attr('class', 'fa fa-unlock-alt fa-3x'); $('#pwdiv2').attr('class', 'notshown w0'); lcount++; } if (resp.dataset[0].loginwithfb != 1) { $('#fbbutton').attr('class', 'notshown w0'); $('#fbiphone').attr('class', 'notshown w0'); $('#fbbutton1').attr('class', 'notshown w0'); $('#fbdiv').attr('class', 'notshown w0'); $('#fbdiv2').attr('class', 'notshown w0'); } else { $('#fbbutton').attr('class', 'loginbox fbbox1'); $('#fbiphone').attr('class', 'notshown w0'); $('#fbbutton1').attr('class', 'notshown w0'); $('#fbdiv').attr('class','fa fa-facebook fa-3x'); $('#fbdiv2').attr('class', 'notshown w0'); lcount++; } if (resp.dataset[0].loginwithemail != 1) { $('#owbutton').attr('class', 'notshown w0'); $('#emailiphone').attr('class', 'notshown w0'); $('#fbbutton2').attr('class', 'notshown w0'); $('#mailbtn').attr('class', 'notshown w0'); $('#maildiv2').attr('class', 'notshown w0'); } else { $('#owbutton').attr('class', 'loginbox oxbox1'); $('#emailiphone').attr('class', 'notshown w0'); $('#fbbutton2').attr('class', 'notshown w0'); $('#mailbtn').attr('class', 'fa fa-envelope fa-3x'); $('#maildiv2').attr('class', 'notshown w0'); lcount++; } if ((resp.dataset[0].loginwithpassword != 1) && (resp.dataset[0].loginwithemail != 1) && (resp.dataset[0].loginwithfb != 1)) { $('#cnbutton').attr('class', 'loginbox cnbox1'); $('#cniphone').attr('class', 'notshown w0'); $('#fbbutton4').attr('class', 'notshown w0'); $('#cndiv').attr('class', 'btn btn-sunny btn-lg animated bounceInUp'); $('#cndiv2').attr('class', 'notshown w0'); } else { //alert('test'); $('#cnbutton').attr('class', 'loginbox cnbox1'); $('#cniphone').attr('class', 'notshown w0'); $('#fbbutton4').attr('class', 'notshown w0'); $('#cndiv').attr('class', 'notshown w0'); $('#cndiv2').attr('class', 'notshown w0'); } } var lmessage = ''; switch (lcount) { case 0: $('.w0').css('display', 'block'); lmessage = currlang.PressConnect; // 'Πατήστε σύνδεση και αποκτήστε'; break; case 3: lmessage = currlang.ThreeButton; // 'Κάντε Login με όποιο τρόπο επιθυμείτε και αποκτήστε'; break; case 1: $('.w0').css('display', 'block'); if (resp.dataset[0].loginwithpassword == 1) lmessage = currlang.LoginPwd; // 'Κάντε Login με password και αποκτήστε'; if (resp.dataset[0].loginwithemail == 1) lmessage = currlang.LoginEmail; // 'Κάντε Login με e-mail και αποκτήστε'; if (resp.dataset[0].loginwithfb == 1) lmessage = currlang.LoginFB; // 'Κάντε Login με Facebook και αποκτήστε'; break; case 2: if ((resp.dataset[0].loginwithpassword == 1) && (resp.dataset[0].loginwithemail == 1)) lmessage = currlang.LoginemailorPwd; // 'Κάντε Login με e-mail ή password και αποκτήστε'; if ((resp.dataset[0].loginwithpassword == 1) && (resp.dataset[0].loginwithfb == 1)) lmessage = currlang.LoginFBorPwd; //'Κάντε Login με Facebook ή password και αποκτήστε'; if ((resp.dataset[0].loginwithfb == 1) && (resp.dataset[0].loginwithemail == 1)) lmessage = currlang.LoginFBoremail; //'Κάντε Login με Facebook ή e-mail και αποκτήστε'; break; } $('#lmessagespan').text(lmessage); } /* if (resp.dataset[0].loginwithpassword != 1) { $('#pwbutton').attr('class', 'notshown'); $('#pwiphone').removeAttr('class', 'notshown'); $('#fbbutton3').attr('class', 'notshown'); }*/ } else { $('#fbbutton').attr('class', 'notshown'); $('#owbutton').attr('class', 'notshown'); $('#pwbutton').attr('class', 'notshown'); $('#agterms').attr('class', 'notshown'); $('#loginspan').attr('class', 'notshown'); if (resp.error == "no data") $('#loginmessage').text('Υπηρεσία μη ενεργή'); else $('#loginmessage').text(resp.error); } $('#startingdiv').attr('class', 'PcDiv'); $('#mainimage').width($('#headerdiv').width()); // $('#mainimage').css({ 'left': $('#headerdiv').position().left }); } }); } function InsertAttempt(logintype, fbid, mustlike, lsuccess, fbname, fname, lname, fblink, fbuser, gender, fblocale, bday, femail, fhtown) { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'InsertAttempt', logintype: logintype, fbid: fbid, mustlike: mustlike, lsuccess: lsuccess, fbname: fbname, fname: fname, lname: lname, fblink: fblink, fbuser: fbuser, gender: gender, fblocale: fblocale, bday: bday, femail: femail, fhtown: fhtown }, dataType: 'jsonp', success: function (resp) { var resperror='no error'; if (resp!=undefined) {resperror=resp.error;} if (resperror == "no error") { if (logintype == 1 || logintype == 2) { var fbtoken = getParameter('access_token'); if (fbtoken.length > 0) fbtoken = 'ltoken=' + fbtoken; ////window.location = "Welcome.aspx" + fbtoken; //if (mustlike == 1) window.location = "Fblike.aspx?" + fbtoken; //else //getAccess('fb', fbtoken); //// window.location = "GAccess.aspx?lt=fb&" + fbtoken; } } else $('#loginmessage').text(resp.error); } }) } function loadLoginUI(uiparams) { if (uiparams.error == "no error") { var topmsg = uiparams.dataset[0].initpagemessage; //getParameterFromString("initpagemessage", uiparams); // $('#topmsg').attr("value", topmsg); } } function SaveUrlParams() { var chapid = "";// getParameter("chap-id"); var loginonly = getParameter("link-login-only"); var linkorig = getParameter("link-orig"); var chapchallenge = ""; //getParameter("chap-challenge"); var servername = getParameter("server-name"); var mac = getParameter("mac"); var ipaddr = getParameter("ip"); var bragent = navigator.userAgent; var brname = $.ua.browser.name, brversion = $.ua.browser.version, osname = $.ua.os.name; osver = $.ua.os.version; devmodel = $.ua.device.model; devtype = $.ua.device.type; devvendor = $.ua.device.vendor; if (!servername || servername=="null") { $('#errmsg').text('No hotspot info supplied'); } else { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'SaveUrlParams', chapid: chapid, loginonly: loginonly, linkorig: linkorig, chapchallenge: chapchallenge, servername: servername, mac: mac, ipaddr: ipaddr, bragent: bragent, brname: brname, brversion: brversion, osname: osname, osver: osver, devmodel: devmodel, devtype: devtype, devvendor: devvendor }, dataType: 'jsonp', success: function (resp) { if (resp.error == "no error") window.location = "./LoginPage.aspx" else $('#errmsg').text(resp.error); } }); } } function GetWelcomeSettings() { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'GetWelcomeSettings' }, dataType: 'jsonp', success: function (resp) { if (resp.error == "no error") { lcfg = resp; // ChangeColors(resp.dataset[0].splashcolorstyle); // $('#logoimage').attr('src', './Images/' + resp.dataset[0].splashbrandimage); // FitLogoImage(resp.dataset[0].splashbrandimagestyle); // $('#logotext').text(resp.dataset[0].splashbrand); //$('#mainimage').attr('src', './Images/' + resp.dataset[0].splashmainimage); $('#pmessage').text(resp.dataset[0].fbpostingtext); GetOffers(); GetOffersCustom(); GetAllMenu(); DrawNav(2); if (resp.dataset[0].logintype != 3) { if (resp.dataset[0].logintype == 2) { $('#fblike').attr('class', 'notshown'); $('#alreadylike').attr('class', 'messagediv'); } if (resp.dataset[0].logintype == 1) { var ltoken = getParameter('ltoken'); if (ltoken) { $('#Div2').attr('data-href', resp.dataset[0].facebookpage); $.getJSON('https://graph.facebook.com/v2.4/me/likes/' + resp.dataset[0].facebookpageid + '?callback=?&access_token=' + ltoken, function (response) { if (!response.error) { if (response.data.length > 0) { $('#fblike').attr('class', 'notshown'); //CheckPosting(); } else { $('#fblike').removeAttr('class'); $('#campaigns').attr('class', 'notshown'); // $('#gonet').attr('class', 'notshown'); $('#arrowtext').attr('class', 'notshown'); $('#alreadylike').attr('class', 'notshown'); } } }) } else { $('#fblike').attr('class', 'notshown'); $('#alreadylike').attr('class', 'notshown'); } } } else { $('#fblike').attr('class', 'notshown'); $('#alreadylike').attr('class', 'notshown'); } } else { $('#fblike').attr('class', 'notshown'); $('#alreadylike').attr('class', 'notshown'); if (resp.error == "no data") $('#errordiv').text('Υπηρεσία μη ενεργή'); else $('#errordiv').text(resp.error); } $('#startingdiv').attr('class', 'PcDiv'); } }) } function CheckToken() { var fstate = getParameter('state'); var ferror = getParameter('error_reason'); var fbtoken if (fstate) { if (ferror) { if (ferror == 'user_denied') { window.location = 'ErrorPage.aspx'; } else { window.location = 'LoginPage.aspx'; } } else { fbtoken = getParameter('access_token'); var mlike = getParameter('state'); if (fbtoken) UseLoginInfo(fbtoken, mlike); } } else { // var postid = getParameter('post_id') // if (!postid) postid = 0; window.location = 'Welcome.aspx'; } } var DoLogin = function (postmsg) { if (postmsg == '1') { PostMessage("This is a test message and its lovely it here!", function () { doredirect(); }); } else { doredirect(); } }; var doredirect = function () { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'GetSavedUrl' }, dataType: 'jsonp', success: function (resp) { if (resp.error == "no error") { if (resp.loginonly == "") { //$('#errordiv').text('Not valid data'); var rurl = (lcfg.dataset[0].redirecturl == "") ? 'https://www.google.com/' : lcfg.dataset[0].redirecturl; window.location = rurl; } else { var rurl = (lcfg.dataset[0].redirecturl == "") ? resp.linkorig : lcfg.dataset[0].redirecturl; if (rurl == "") rurl = 'https://www.google.com/'; var passwd = "123"; //hexMD5(resp.chapid + lcfg.username + resp.chapchallenge); window.location = resp.loginonly + '?username=' + escape(lcfg.dataset[0].username) + "&password=" + passwd + "&dst=" + escape(rurl) + "&popup=true"; } } } }); /* var username = "hpuser1"; if (!chapid) { window.location = "http://www.oxygenwifi.com"; } else { var passwd = hexMD5(chapid + 'abc' + chapchallenge); window.location = loginonly + '?username=' + escape(username) + "&password=" + passwd + "&dst=" + escape(linkorig) + "&popup=true"; }*/ }; function WriteLike() { //debugger; $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'WriteLike' }, dataType: 'jsonp', success: function (resp) { // getAccess('fbl','1'); //console.log('getAccess WriteLike'); //getAccess('fb','1'); } }); } function WriteLikeExtra(extraFbId) { //debugger; $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'WriteLikeExtra', ExtraFBId: extraFbId }, dataType: 'jsonp', success: function (resp) { } }); } function writeCheckin(fbid, locationid){ $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'WriteCheckIn', fbid:fbid, locationid:locationid }, dataType: 'jsonp', success: function (resp) { getAccess('fb','1'); } }); } function FlotTest() { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'flottest' }, dataType: 'jsonp', success: function (resp) { alert(resp.error); } }); } function CheckPosting() { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'CheckPosting' }, dataType: 'jsonp', success: function (resp) { if (resp.error == "no error") { if (resp.dataset[0].canpost == '1') $('#alreadylike').attr('class', 'messagediv'); else $('#alreadylike').attr('class', 'notshown'); } else { $('#alreadylike').attr('class', 'notshown'); } } }); } function ChangeColors(style) { var bcolor, fcolor, tcolor; switch (style) { case 'WhiteBlue': bcolor = '#FFFFFF'; fcolor = '#2980b9'; tcolor = '#000000'; break; case 'Blue': bcolor = '#3498db'; fcolor = '#2980b9'; tcolor = '#000000'; break; case 'Red': bcolor = '#e74c3c'; fcolor = '#c0392b'; tcolor = '#FFFFFF'; break; case 'WhiteRed': bcolor = '#FFFFFF'; fcolor = '#c0392b'; tcolor = '#000000'; break; case 'WhiteTurq': bcolor = '#FFFFFF'; fcolor = '#16A085'; tcolor = '#000000'; break; case 'Turq': bcolor = '#1ABC9C'; fcolor = '#16A085'; tcolor = '#FFFFFF'; break; case 'WhiteEmerald': bcolor = '#FFFFFF'; fcolor = '#27ae60'; tcolor = '#000000'; break; case 'Emerald': bcolor = '#2ecc71'; fcolor = '#27ae60'; tcolor = '#FFFFFF'; break; case 'WhiteMagenta': bcolor = '#FFFFFF'; fcolor = '#8e44ad'; tcolor = '#000000'; break; case 'Magenta': bcolor = '#9b59b6'; fcolor = '#8e44ad'; tcolor = '#FFFFFF'; break; case 'WhiteGrey': bcolor = '#ffffff'; fcolor = '#2c3e50'; tcolor = '#000000'; break; case 'Grey': bcolor = '#34495e'; fcolor = '#2c3e50'; tcolor = '#FFFFFF'; break; case 'WhiteYellow': bcolor = '#ffffff'; fcolor = '#f39c12'; tcolor = '#000000'; break; case 'Yellow': bcolor = '#f1c40f'; fcolor = '#f39c12'; tcolor = '#FFFFFF'; break; case 'WhiteOrange': bcolor = '#ffffff'; fcolor = '#d35400'; tcolor = '#000000'; break; case 'Orange': bcolor = '#e67e22'; fcolor = '#d35400'; tcolor = '#FFFFFF'; break; case 'Silver': bcolor = '#ecf0f1'; fcolor = '#bdc3c7'; tcolor = '#000000'; break; case 'Concrete': bcolor = '#95a5a6'; fcolor = '#7f8c8d'; tcolor = '#000000'; break; } } function FitLogoImage(istyle) { switch (istyle) { case '1': $('#logoimage').attr('class', 'strech'); break; case '2': $('#logoimage').attr('class', 'fitheight'); break; case '3': $('#logoimage').attr('class', 'fitwidth'); break; } } function GetOffers() { var strtosearch = ""; var dolcheck = 0; //vgazei to filtrarisma me ta likes if (wfbid != "" && wfbid != "0" && wltkn != "" && dolcheck == 1 ) { FB.api('/me/likes?fields=category_list&limit=50?access_token=' + wltkn, function (response) { if (!response.error) { for (var i = 0; i < response.data.length; i++) { if (response.data[i].category_list) { for (var j = 0; j < response.data[i].category_list.length; j++) { strtosearch += response.data[i].category_list[j].name + "; "; } } } GetOffersReal(strtosearch); } else { GetOffersReal(''); } } ); } else { GetOffersReal(''); } } function GetOffersReal(strtosearch) { $.ajax({ url: './Handlers/Handler1.ashx', type: 'POST', cache: false, data: { command: 'GetOffers', tosearch: strtosearch }, dataType: 'jsonp', success: function (resp) { if (resp.error == "no error") { var strHtm; for (var i = 0; i < resp.dataset.length; i++) { if (resp.dataset[i].offerstatus == 1) { strHtm = '