var temp=[]; $(document).ready(function() { // console.log('1: ąćęłńóśźż'); $('form.rof input[type=text], form.rof input[type=password]').each(function(i) { if ('' == $(this).val()) { $('#'+$(this).attr('id')+'_alt').css('display', 'block'); } // $('#mainInvitaion').hide(); $(this).focus(function(){ $('#'+$(this).attr('id')+'_alt').css('display', 'none'); }); $(this).blur(function(){ if ('' == $(this).val()) $('#'+$(this).attr('id')+'_alt').css('display', 'block'); }); }); $('#userbar a').mouseover(function(){ // $(this).css('color', '#275291'); $(this).css('text-decoration', 'underline'); }); $('#userbar a').mouseout(function(){ $(this).css('text-decoration', 'none'); // $(this).css('color', '#ffffff'); }); $('.fl a').mouseover(function(){ $(this).css('text-decoration', 'underline'); }); $('.fl a').mouseout(function(){ $(this).css('text-decoration', 'none'); }); // $("#zipCode").mask("99/99/9999", {placeholder:" "}); // $('#next').click(checkLogin()); // Nawigacja if (0 < $("#nav li").length) { url_fragments = window.location.toString().split('#'); if (2 == url_fragments.length) show_panel(url_fragments[1]); else { url_fragments = $('#nav li:first a').attr('href').split('#'); if (2 == url_fragments.length) { show_panel(url_fragments[1]); } } $('#nav a').click(function(){ url_fragments = $(this).attr('href').split('#'); if (2 == url_fragments.length) { show_panel(url_fragments[1]); } }); } if (0 < $("#navigation li").length) { url_fragments = window.location.toString().split('#'); if (2 == url_fragments.length) show_panel(url_fragments[1]); else { url_fragments = $('#navigation li:first a').attr('href').split('#'); if (2 == url_fragments.length) { show_panel(url_fragments[1]); } } $('#navigation a').click(function(){ url_fragments = $(this).attr('href').split('#'); if (2 == url_fragments.length) { show_panel(url_fragments[1]); } }); } $('#mainInvitaion').hide(); }); var decision; var avilableMoney = false; var amountEurogramols; function show_panel(panel) { $('.panel').hide(); $('#'+panel+'.panel').show(); $('#nav li').removeClass('sel'); $('#nav li a[href$=#'+panel+']').parent().addClass('sel'); } function format_seconds(seconds) { minutes = Math.floor(seconds/60); sMinutes = (10 > minutes) ? '0'+minutes : minutes; seconds = seconds - (minutes*60); sSeconds = (10 > seconds) ? '0'+seconds : seconds; return sMinutes+':'+sSeconds; } function sessions_timer() { refresh = false; $.each(games_sessions, function(){ this.t_minus--; if (0 >= this.t_minus) { refresh = true; this.t_minus = 0; } $('#session_'+this.hash+' h1').html(format_seconds(this.t_minus)); }); /* if (refresh) { games_sessions = null; get_games(); } */ get_games(); window.setTimeout(sessions_timer, 1000); } function get_games() { $.getJSON('/ajax/stat/', function(data){ games_sessions = data; // $('.games_sessions').html('

Otwarte gry i quizy

'); $('.games_sessions').html('

Obstawiasz 1zł - Wygrywasz 2zł
Zasada połowa szybszych graczy zawsze wygrywa

'); $.each(games_sessions, function(){ if(this.invitation != null) { // temp=this.invitation.game_hash; temp.push(this.invitation.game_hash); var html='
'; var typeGame = this.invitation.game+' '; if(this.invitation.game == 'Quiz') { typeGame = 'Quizu:'; } html+='' html+='
'; html+=''+this.invitation.invator+' zaprasza Cię do rundy '+this.invitation.round+'
'+typeGame+'
'; if(this.invitation.gameName!="") { html+=' '+this.invitation.gameName+'
'; } html+='s: '+this.invitation.state+' '; html+='w: '+this.invitation.winning+'
'; html+='dolącz
'; html+='
'; $('#mainInvitaion').append(html); var len = temp.length; $('#'+temp[len-1]+"_00").click(function() { $('#'+temp[len-1]).remove(); }); $('#'+temp[len-1]).mouseover(function() { $('#'+temp[len-1]).removeClass('invitation'); $('#'+temp[len-1]).addClass('invitationOver'); }); $('#'+temp[len-1]).mouseout(function() { $('#'+temp[len-1]).removeClass('invitationOver'); $('#'+temp[len-1]).addClass('invitation'); }); $('#mainInvitaion').show(); $( "#mainInvitaion" ).dialog( {position: ['right','top'], width: 230, closeText: ''}); // $('#mainInvitaion').dialog(); this.invitation = null; } else { var gameName = ''; switch(this.game) { case 1: { photoName = '/i/memo_small.png'; break; } case 2: { photoName = '/i/sudoku_small.png'; break; } case 3: { if(this.photo == "none") { photoName = '/i/quiz_small.png'; } else { photoName = '/admin/public/files/quizesFiles/'+this.photo+'_small.jpg'; } break; } case 4: { photoName = '/i/puzzle_small.png'; break; } } var state; if(this.round == 1) { state = 10; } if(this.round == 2) { state = 20; } if(this.round == 3) { state = 40; } html = '
'+ '

Start za:
'+format_seconds(this.t_minus)+'

'+ ''+ '

'+ ''+ // 'Graczy: '+this.players+''+ 'Oczekujący gracze: '+this.players+''+ // 'Runda: '+this.round+''+ // 'Stawka: '+state+'E'+ '

'+ '
'; $('.games_sessions').append(html); } }); }); } function checkLogin() { console.log('2: ąćęłńóśźż'); var email = $('#email').val(); var pass = $('#pass').val(); $.ajax({ type: 'POST', url: '/ajax/checkUserLogin/', data: { email: email, pass: pass }, dataType: 'json', success: function(response) { if(response == 'ok') { $('#wyplac_zlotowki').html(''); var html = '

Wypłać swoje eurogramole

'+ '

Krok 2/3

'+ '

Wybierz konto, na które chcesz wypłacić swoją nagrodę

'+ '

'+ '

bankowe

' // '

bankowe

'; // '

bankowe

'; $('#wyplac_zlotowki').html(html); } else { alert('Wprowadzono niepoprawne dane.'); } } }); } function saveWhichMethod(dec) { decision = dec; $('#wyplac_zlotowki').html(''); var html = '

Wypłać swoje eurogramole

'+ '

Krok 3/3

'; switch(decision) { case 1: { html += '

Podaj kwotę Eurogramoli jaką chcesz wymienić na złotówki oraz uzupełnij dane bankowe.

'+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ '
Kwota w EUGKwota w PLN
'+ ''+ ''+ ''+ '
'+ 'Numer rachunku bankowego'+ '
'+ ''+ ''+ ''+ '
'+ 'Imię'+ '
'+ ''+ ''+ ''+ '
'+ 'Nazwisko'+ '
'+ ''+ ''+ ''+ '
'+ 'Ulica i numer'+ '
'+ ''+ ''+ ''+ '
'+ 'Kod pocztowy'+ '
'+ ''+ ''+ ''+ '
'+ 'Miejscowość'+ '
'+ ''+ ''+ ''+ '
'+ '

';; break; } case 2: { html += '

Podaj kwotę Eurogramoli jaką chcesz wymienić na złotówki oraz adres email, do którego jest przypisane twoje konto.

'+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ '
Kwota wypłaty w eurogramolachKwota a PLN
'+ ''+ ''+ ''+ '
'+ 'Email'+ '
'+ ''+ '
'+ '

'; break; } case 3: { break; } } $('#wyplac_zlotowki').html(html); $('#zipCode').mask("99-999"); $('#bankAccountNumber').mask("99999999999999999999999999"); } function checkEmail(email) { $.ajax({ type: 'POST', url: '/ajax/checkEmail/', data: { email: email, }, dataType: 'json', success: function(response) { if(!response) { alert('Podałeś niepoprawny adres email, lub podana kwota jest niepoprawna.'); } } }); } function checkAvilableEurogramols(val) { $.ajax({ type: 'POST', url: '/ajax/checkUserAvilableEurogramols/', data: { eurogramols: val }, dataType: 'json', success: function(response) { if(response == null) { $('#money').attr('value', val/100); avilableMoney = true; } else { avilableMoney = false; $('#money').attr('value', 0); $('#eurogramols').attr('value', 0); alert(response); } } }); } /** * Wypłata pieniędzy z konta */ function giveMoney() { var validate = true; // alert($('#bankAccountNumber').val()); if(decision == 1) { $.ajax({ type: 'POST', url: '/ajax/checkUserBankAccount/', data: { bankAccount: $('#bankAccountNumber').val() }, dataType: 'json', success: function(response) { if(response != null) { $('#bankAccountNumberError').html(response); } else { $('#bankAccountNumberError').html(''); } validateMoreInputs(response); } }); } if(decision == 2) { // alert($('#eurogramols').val()); $.ajax({ type: 'POST', url: '/ajax/giveMoney/', data: { email: $('#email').val(), eurogramols: $('#erogramols').val(), decision: 2 }, dataType: 'json', success: function(response) { if(response != null) { $('#wyplac_zlotowki').html(''); $('#accountEurogramols').html(response[0]+' EUG ('+response[1]+' PLN)'); giveAnswerAfterGivingMoney('wyplac_zlotowki'); } else { alert('Nie udało sie wypłacić pieniędzy. Proszę spróbować póżniej.'); } } }); } } function validateMoreInputs(val) { validateBankAccount = false; validate = true; if(val == null) { validateBankAccount = true; } if($('#name').val() == '') { $('#nameError').html('Pole "Imię" jest polem wymaganym.'); validate = false; } else { $('#nameError').html(''); } if($('#sureName').val() == '') { $('#sureNameError').html('Pole "Nazwisko" jest polem wymaganym.'); validate = false; } else { $('#sureNameError').html(''); } if($('#street').val() == '') { $('#streetError').html('Pole "Ulica i numer" jest polem wymaganym.'); validate = false; } else { $('#streetError').html(''); } if($('#zipCode').val() == '') { $('#zipCodeError').html('Pole "Kod pocztowy" jest polem wymaganym.'); validate = false; } else { $('#zipCodeError').html(''); } if($('#cityName').val() == '') { $('#cityError').html('Pole "Miejscowość" jest polem wymaganym.'); validate = false; } else { $('#cityError').html(''); } if(validate && validateBankAccount && avilableMoney) { $.ajax({ type: 'POST', url: '/ajax/giveMoney/', data: { bankAccount: $('#bankAccountNumber').val(), eurogramols: $('#eurogramols').val(), name: $('#name').val(), sureName: $('#sureName').val(), street: $('#street').val(), zipCode: $('#zipCode').val(), city: $('#city').val() }, dataType: 'json', success: function(response) { if(response != null) { $('#wyplac_zlotowki').html(''); $('#accountEurogramols').html(response[0]+' EUG ('+response[1]+' PLN)'); giveAnswerAfterGivingMoney('wyplac_zlotowki'); alert($('#bankAccountNumber').val()); } else { alert('Nie udało sie wypłacić pieniędzy. Proszę spróbować póżniej.'); } } }); } else { alert('nie wypłacaj'); } } function giveAnswerAfterGivingMoney(elementId) { var html = '

Wypłać swoje eurogramole

'+ '

'; html += '

Zgłoszenie przyjęte!

'+ '

'+ '

Twoje konto zostanie zasilone w ciągu max 3 dni roboczych.

'; $('#'+elementId).html(html); } function payByDotPay(number) { $('#fromInputId').val('36996'); var money; $('#fromInputUrlc').val('http://gramol.pl/dotpay.html'); switch(number) { case 1: { $('#fromInputKwota').val('2'); $('#fromInputOpis').val('Oplata za 100 eurogramoli.'); money = 1; break; } case 2: { $('#fromInputKwota').val('5'); $('#fromInputOpis').val('Oplata za 250+50 eurogramoli.'); money = 3; break; } case 3: { $('#fromInputKwota').val('10'); $('#fromInputOpis').val('Oplata za 500+200 eurogramoli.'); money = 7; break; } case 4: { $('#fromInputKwota').val('20'); $('#fromInputOpis').val('Oplata za 1000+500 eurogramoli.'); money = 15; break; } case 5: { $('#fromInputKwota').val('50'); $('#fromInputOpis').val('Oplata za 2500+1500 eurogramoli.'); money = 40; break; } } $.ajax( { type: 'POST', url: '/ajax/sendDotPay/', data: { value: money, sms: 0 }, dataType: 'json', success: function(response) { $('#formInputControl').val(response); if(response != null) { document.forms['dotpay'].submit(); } } }); } function smsChargingAmount(amount) { amountEurogramols = amount; $('#doladuj_eurogramole').css('display', 'none'); $('#smsem').css('display', 'block'); switch(amount) { case 100: { phoneNumber = '72068'; smsCost = "2 zł netto (2,44 zł brutto)"; break; } case 250: { phoneNumber = '75068'; smsCost = "5 zł netto (6,10 zł brutto)"; break; } case 500: { phoneNumber = '79068'; smsCost = "9 zł netto (10,98 zł brutto)"; break; } case 1000: { phoneNumber = '91968'; smsCost = "19 zł netto (23,18 zł brutto)"; break; } default: { document.location = "http://dev.gramol.pl"; break; } } $('#amount').html('AP.GRAMOL'+amountEurogramols); $('#amountEug').html(amountEurogramols+' Eurogramoli'); $('#smsCost').html('Koszt SMS: '+smsCost); $('#genid').val(amountEurogramols); $('#phoneNumber').html(phoneNumber); } function setVisibleFalse(fielId) { $('#'+fielId).css('display', 'none'); } function setVisibleTrue(fielId) { $('#'+fielId).css('display', 'block'); } function closeInvitation(tt,te) { $('#'+tt).remove(); }