2022-06-09 15:53:29 +02:00
|
|
|
/**
|
|
|
|
* JS povezani s prijavo in registracijo
|
|
|
|
*/
|
2022-06-27 16:10:51 +02:00
|
|
|
(function ($) {
|
2022-06-09 15:53:29 +02:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
// To understand behaviors, see https://drupal.org/node/756722#behaviors
|
2022-06-27 16:10:51 +02:00
|
|
|
/* Drupal.behaviors.prijavaInRegistracija = {
|
2022-06-09 15:53:29 +02:00
|
|
|
attach: function (context, settings) {
|
2022-06-27 16:10:51 +02:00
|
|
|
}
|
|
|
|
};*/
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery(document).ready(function () {
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-09-13 09:38:01 +02:00
|
|
|
// Ob zaprtju modala odstranimo vse napake
|
|
|
|
jQuery('.closemodal').on('click', function(){
|
|
|
|
jQuery('.error-message').hide();
|
|
|
|
});
|
|
|
|
|
2022-07-14 17:41:41 +02:00
|
|
|
/*
|
|
|
|
* LOGIN SKRIPTE
|
|
|
|
*/
|
|
|
|
jQuery('#modal-open-login, .odpri-login').on('click', function () {
|
|
|
|
document.cookie = "nakup=1;expires=Thu, 01 Jan 1970 00:00:01 GMT";
|
|
|
|
|
|
|
|
odpriAaiLoginObvestilo();
|
|
|
|
});
|
|
|
|
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('.nakup-brez-registracije').on('click', function () {
|
|
|
|
var paket = jQuery(this).attr('data-paket');
|
|
|
|
|
|
|
|
var cas = new Date();
|
|
|
|
cas.setMinutes(cas.getMinutes() + 120);
|
|
|
|
document.cookie = "nakup=1;expires=" + cas + ";path=/";
|
|
|
|
document.cookie = "paket=" + paket + ";expires=" + cas + ";path=/";
|
|
|
|
|
|
|
|
odpriAaiLoginObvestilo();
|
|
|
|
});
|
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Drupal nova prijava
|
2022-07-14 17:41:41 +02:00
|
|
|
jQuery('#forma-prijava .submit-prijava').on('click', function(){
|
2022-06-27 16:10:51 +02:00
|
|
|
izvediPrijavoUporabnika();
|
|
|
|
});
|
|
|
|
jQuery('.prijava-password-input').keyup(function(e){
|
|
|
|
if(e.keyCode == 13){
|
|
|
|
izvediPrijavoUporabnika();
|
|
|
|
}
|
|
|
|
});
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Odpremo drop down menu za uporabnika
|
|
|
|
jQuery('#user-login-menu').on('click', function () {
|
|
|
|
jQuery('#user-menu').toggle();
|
|
|
|
});
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Obnovitev gesla
|
|
|
|
jQuery('#open-modal-lost-password').on('click', function () {
|
|
|
|
jQuery('#modal-login').hide();
|
|
|
|
jQuery('#modal-lost-password').css('display', 'flex');
|
|
|
|
});
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#submit-lost-password').on('click', function () {
|
|
|
|
jQuery('.obvestilo').empty().hide();
|
|
|
|
jQuery('#input-obnovitev-email').removeClass('error');
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
var emailObnovitev = jQuery('#obnovitev-gesla-email').val();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (emailObnovitev.length == 0 || emailObnovitev.length > 1 && (emailObnovitev.search('@') == -1 || emailObnovitev.indexOf('.') == -1)) {
|
|
|
|
jQuery('#input-obnovitev-email').addClass('error');
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
return false;
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// V kolikor je vse ok poljemo POST request, da preverimo v bazi
|
|
|
|
jQuery.post('/api/drupal/reset_password', {
|
|
|
|
email: emailObnovitev,
|
|
|
|
ajax: true,
|
|
|
|
jezik: pridobiJezik()
|
|
|
|
}).done(function (val) {
|
|
|
|
val = JSON.parse(val);
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#modal-lost-password .w-form-done').html('').hide();
|
|
|
|
jQuery('#modal-lost-password .w-form-fail').hide();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (val.type == 'success') {
|
2022-09-08 16:06:29 +02:00
|
|
|
jQuery('#modal-lost-password .w-form-done').html('<div>' + val.data.text + '</div>').show();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Če je bil email uspešno poslal potem okno zapremo po 5 sekundah
|
|
|
|
setTimeout(function () {
|
|
|
|
jQuery("#modal-lost-password").hide();
|
|
|
|
jQuery('#modal-lost-password .w-form-done').hide();
|
|
|
|
jQuery("#obnovitev-gesla").val('');
|
|
|
|
}, 2000);
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
} else {
|
|
|
|
// Napaka, če email ne obstaja v bazi
|
2022-06-29 00:15:49 +02:00
|
|
|
jQuery('#modal-lost-password #error-lost-password').html('<div>' + val.data.text + '</div>').show();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-06-09 15:53:29 +02:00
|
|
|
|
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// AKtivacija izgubljenega gesla
|
|
|
|
if (window.location.hash == '#aktivacija-gesla') {
|
|
|
|
jQuery('#modal-lost-password-activate').show();
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#submit-lost-password-activation').on('click', function () {
|
|
|
|
jQuery('.w-form-fail').hide();
|
|
|
|
jQuery('.error').removeClass('error');
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
var email = jQuery('#aktivacija-email').val();
|
|
|
|
var geslo = jQuery('#aktivacija-geslo').val();
|
|
|
|
var koda = '';
|
|
|
|
var jezik = jQuery('#modal-lost-password [name="jezik"]').val();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
var results = new RegExp('[\?&]code=([^&#]*)').exec(window.location.href);
|
|
|
|
if (results[1].length > 10)
|
|
|
|
koda = results[1];
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (email.length == 0 || geslo.length == 0 || koda.length == 0) {
|
|
|
|
jQuery('#error-aktivacija-gesla').show();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (email.length == 0) {
|
|
|
|
jQuery('#aktivacija-email').addClass('error');
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (geslo.length == 0) {
|
|
|
|
jQuery('#aktivacija-geslo').addClass('error');
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
return false;
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// V kolikor je vse ok poljemo POST request, da preverimo v bazi
|
|
|
|
jQuery.post('/frontend/api/api.php?action=reset_password_activate', {
|
|
|
|
email: email,
|
|
|
|
pass: geslo,
|
|
|
|
code: koda,
|
|
|
|
ajax: true,
|
|
|
|
lang: jezik
|
|
|
|
}).done(function (val) {
|
|
|
|
val = JSON.parse(val);
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#error-aktivacija-gesla').removeClass('w-form-fail').removeClass('w-form-done').html('').hide();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if (val.type == 'success') {
|
|
|
|
jQuery('#error-aktivacija-gesla').addClass('w-form-done').html('<div>' + val.text + '</div>').show();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Če je bil email uspešno poslal potem okno zapremo po 5 sekundah
|
|
|
|
setTimeout(function () {
|
|
|
|
window.location.href = val.action;
|
|
|
|
}, 5000);
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
} else {
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
// Napaka, če email ne obstaja v bazi
|
|
|
|
jQuery('#error-aktivacija-gesla').addClass('w-form-fail').html('<div>' + val.text + '</div>').show();
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-07-14 17:41:41 +02:00
|
|
|
/** END LOGIN SKRIPTE **/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* REGISTRACIJA UPORABNIKA IN SKRIPTE POVEZANE S TEM
|
|
|
|
*/
|
|
|
|
// Forma za registracijo
|
|
|
|
jQuery('#registracija-uporabnika .submit-btn').on('click', function (event) {
|
|
|
|
jQuery('.error-field').removeClass('error-field');
|
|
|
|
jQuery('.error').removeClass('error');
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('.error-empty, .error-message').hide();
|
2022-07-14 17:41:41 +02:00
|
|
|
|
|
|
|
// Obravnamo manjkajoča polja
|
|
|
|
if (jQuery('#register-form [name="email"]').val().length < 2) {
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('#register-form [name="email"]').addClass('error error-field').siblings('.error-empty').addClass('error').show();
|
2022-07-14 17:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (jQuery('#register-form [name="ime"]').val().length < 2) {
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('#register-form [name="ime"]').addClass('error error-field').siblings('.error-empty').addClass('error').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jQuery('#register-form #geslo').val().length < 2) {
|
|
|
|
jQuery('#register-form #geslo').addClass('error error-field').siblings('.error-empty').addClass('error').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jQuery('#register-form #geslo2').val().length < 2) {
|
|
|
|
jQuery('#register-form #geslo2').addClass('error error-field').siblings('.error-empty').addClass('error').show();
|
2022-07-14 17:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!jQuery('#register-form [name="agree"]').is(':checked')) {
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('#register-form [name="agree"]').addClass('error').siblings('#agreelabel, .checkbox-display').addClass('error').find('.error-empty').addClass('error').show();
|
2022-07-14 17:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (jQuery('#register-form [name="email"]').val().length == 0 ||
|
|
|
|
jQuery('#register-form [name="ime"]').val().length == 0 ||
|
|
|
|
!jQuery('#register-form [name="agree"]').is(':checked')
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
var sendVariables = jQuery('#registracija-uporabnika :input').serialize();
|
|
|
|
sendVariables += '&ajax=1';
|
|
|
|
|
|
|
|
jQuery.post('/api/drupal/register', sendVariables, function (data) {
|
|
|
|
jQuery('.napaka-registracija').hide();
|
|
|
|
|
|
|
|
var response = JSON.parse(data);
|
|
|
|
jQuery('.error-field').removeClass('error-field');
|
|
|
|
|
|
|
|
if (response.type && response.type == 'success') {
|
|
|
|
jQuery('#reg-confirm-email').text(jQuery('#register-form [name="email"]').val());
|
|
|
|
jQuery('#reg-confirm-ime').text(jQuery('#register-form [name="ime"]').val());
|
|
|
|
jQuery('#reg-confirm-geslo').text('****');
|
|
|
|
jQuery('#reg-confirm-gdpr').text('NE');
|
|
|
|
|
|
|
|
if (window.location.href.search('/d/en') > 0) {
|
|
|
|
if (jQuery('#GdprAgree').is(':checked')) {
|
|
|
|
jQuery('#reg-confirm-gdpr').text('YES');
|
|
|
|
} else {
|
|
|
|
jQuery('#reg-confirm-gdpr').text('NO');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (jQuery('#GdprAgree').is(':checked')) {
|
|
|
|
jQuery('#reg-confirm-gdpr').text('DA');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jQuery('#register-form [name="geslo"]').val().length == 0) {
|
|
|
|
jQuery('#reg-confirm-geslo').text('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery('#register-form').hide();
|
|
|
|
jQuery('.glavni-naslov').hide();
|
|
|
|
jQuery('#register-form-confirm').css('display', 'flex');
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Izpišemo napake
|
|
|
|
if(response.type == 'error') {
|
|
|
|
if (response.data.napaka && response.data.napaka.length > 0) {
|
|
|
|
jQuery('.napaka-registracija').show();
|
|
|
|
|
|
|
|
var napake = '';
|
|
|
|
jQuery.each(response.data.napaka, function (key, val) {
|
|
|
|
napake += '<div>' + val + '</div>';
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery('.napaka-registracija').html(napake);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error_email) {
|
|
|
|
jQuery('#register-form [name="email"]').addClass('error-field');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error_ime) {
|
|
|
|
jQuery('#register-form [name="ime"]').addClass('error-field');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error_geslo) {
|
|
|
|
jQuery('#register-form [name="geslo"]').addClass('error-field');
|
|
|
|
jQuery('#register-form [name="geslo2"]').addClass('error-field');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.data.new_username.length > 0) {
|
|
|
|
jQuery('#register-form #registracija-vzdevek').val(response.data.new_username);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Ponastavi reCaptcho
|
|
|
|
if (grecaptcha) {
|
|
|
|
grecaptcha.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// Pri potrditvi omogočimo gum nazaj
|
|
|
|
jQuery('#reg-confirm-back').on('click', function () {
|
|
|
|
jQuery('#register-form-confirm').hide();
|
|
|
|
jQuery('#register-form').css('display', 'flex');
|
|
|
|
});
|
|
|
|
|
2022-10-26 17:06:04 +02:00
|
|
|
// Pri potrditvi omogočimo gum nazaj
|
|
|
|
jQuery('#lost-password-back').on('click', function () {
|
|
|
|
jQuery('#modal-lost-password').hide();
|
|
|
|
jQuery('#modal-login').css('display', 'flex');
|
|
|
|
});
|
|
|
|
|
2022-07-14 17:41:41 +02:00
|
|
|
//Pošljemo potrditven email
|
|
|
|
jQuery('#reg-confirm-next').on('click', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
var sendVariables = jQuery('#registracija-uporabnika :input').serialize();
|
|
|
|
sendVariables += '&ajax=1';
|
|
|
|
|
|
|
|
jQuery.post('/api/drupal/register_confirm', sendVariables, function (data) {
|
|
|
|
var response = JSON.parse(data);
|
|
|
|
|
|
|
|
if (response.type && response.type == 'success') {
|
|
|
|
var text = jQuery('#register-form-email-sent').html().replace(/SFMAIL/gi, jQuery('#reg-confirm-email').text());
|
|
|
|
jQuery('#register-form-email-sent').html(text);
|
|
|
|
|
|
|
|
jQuery('#reg-confirm-email').text('');
|
|
|
|
jQuery('#reg-confirm-ime').text('');
|
|
|
|
jQuery('#reg-confirm-geslo').text('');
|
|
|
|
jQuery('#reg-confirm-gdpr').text('');
|
|
|
|
|
|
|
|
// Počistimo formo
|
|
|
|
jQuery(':input', '#register-form')
|
|
|
|
.not(':button, :submit')
|
|
|
|
.val('')
|
|
|
|
.removeAttr('checked');
|
|
|
|
|
|
|
|
jQuery('#register-form-confirm').hide();
|
|
|
|
jQuery('#register-form-email-sent').css('display', 'flex');;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-09-13 09:38:01 +02:00
|
|
|
// GUmbi na desni front
|
|
|
|
jQuery('#odpri-prijavo, .odpri-prijavo').on('click', function () {
|
|
|
|
jQuery('.error-message').html('').hide();
|
|
|
|
jQuery('.rexister-modal').hide();
|
|
|
|
jQuery('#modal-login').css('display', 'flex');
|
|
|
|
});
|
|
|
|
jQuery(document).on('click', "#odpri-registracijo", function () {
|
|
|
|
jQuery('.rexister-modal').hide();
|
|
|
|
jQuery('.error-message').html('').hide();
|
|
|
|
jQuery('#modal-registration').css('display', 'flex');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (window.location.hash == '#neregistriran-uporabnik') {
|
|
|
|
jQuery('#spletna-uporaba-modal').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery(document).on('click', '#gumb-spletna-uporaba, .gumb-spletna-uporaba', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if(jQuery('html')[0].lang == 'sl') {
|
|
|
|
odpriAaiLoginObvestilo();
|
|
|
|
} else {
|
|
|
|
jQuery('#spletna-uporaba-modal').show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
jQuery('#gumb-lastna-namestitev').on('click', function () {
|
|
|
|
jQuery('#lastna-namestitev-modal').show();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Odjava v Drupalu
|
|
|
|
jQuery('#poslji-odjavo').on('click', function(){
|
|
|
|
jQuery.post(jQuery('[name="odjava"]').attr('action'), {
|
|
|
|
ajax: true,
|
|
|
|
}, function (data) {
|
|
|
|
var response = JSON.parse(data);
|
|
|
|
|
|
|
|
if(response.type == 'success') {
|
|
|
|
setTimeout(function () {
|
|
|
|
window.location = response.data.url;
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
});
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
})(jQuery);
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
function izvediPrijavoUporabnika()
|
|
|
|
{
|
|
|
|
// ODstranimo vse napake
|
|
|
|
jQuery('.error-field').removeClass('error-field');
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery('.error-empty, .error-message').hide();
|
2022-06-27 07:58:26 +02:00
|
|
|
|
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery(':input[required]:visible').each(function () {
|
|
|
|
if (jQuery(this).val() == '') {
|
2022-11-04 08:37:16 +01:00
|
|
|
jQuery(this).addClass('error-field').siblings('.error-empty').addClass('error').show();
|
2022-06-27 16:10:51 +02:00
|
|
|
}
|
|
|
|
});
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if( jQuery('.error-field').length > 0){
|
|
|
|
return false;
|
|
|
|
}
|
2022-06-27 07:58:26 +02:00
|
|
|
|
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#prijava-1ka .error-message').empty().hide();
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
var sendVariables = jQuery('#forma-prijava :input').serialize();
|
|
|
|
var url = jQuery('#forma-prijava').attr('action');
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery.post(url, sendVariables, function (data) {
|
|
|
|
var response = JSON.parse(data);
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
if(response.type == 'success'){
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
return window.location = response.data.url;
|
2022-06-27 07:58:26 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
} else if(response.type == 'error') {
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
let sporocilo = vrniBesediloNapake(response.data);
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
jQuery('#prijava-1ka .error-message').append(sporocilo).show();
|
2022-06-09 15:53:29 +02:00
|
|
|
|
2022-06-27 16:10:51 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-06-09 15:53:29 +02:00
|
|
|
|
|
|
|
function vrniBesediloNapake(besedilo){
|
|
|
|
let sporocilo;
|
|
|
|
|
|
|
|
if(jQuery.isArray(besedilo)){
|
|
|
|
sporocilo = '<ul>';
|
|
|
|
|
|
|
|
jQuery.each(besedilo, function (index, value){
|
|
|
|
sporocilo += '<li>' + value + '</li>';
|
|
|
|
});
|
|
|
|
|
|
|
|
sporocilo += '</ul>';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
sporocilo = besedilo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sporocilo;
|
|
|
|
}
|
|
|
|
|
|
|
|
function CheckEmail(text) {
|
|
|
|
jQuery('#modal-registration .w-form-fail').html('').hide();
|
|
|
|
jQuery('.w-input').removeClass('error');
|
|
|
|
|
|
|
|
var text = text || 'Prosimo, popravite email';
|
|
|
|
var Email = jQuery('#register-form [name="email"]').val();
|
|
|
|
|
|
|
|
if (Email.length > 1 && (Email.search('@') == -1 || Email.indexOf('.') == -1)) {
|
|
|
|
jQuery('#modal-registration .w-form-fail').html('<div>' + text + '</div>').show();
|
|
|
|
jQuery('#modal-registration [type="email"]').addClass('error');
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function InsertName() {
|
|
|
|
var Email = jQuery('#register-form [name="email"]').val();
|
|
|
|
var lokacija = Email.search('@');
|
|
|
|
|
|
|
|
if (Email.search('@') == -1) {
|
|
|
|
lokacija = Email.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
var Ime = Email.substring(0, lokacija);
|
|
|
|
if (jQuery('#register-form [name="ime"]').val().length < 2) {
|
|
|
|
jQuery('#register-form [name="ime"]').val(Ime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function CheckEmailTypo(text) {
|
|
|
|
var email = jQuery('#register-form [name="email"]').val();
|
|
|
|
var domains = ['gmail.com', 'hotmail.com', 'guest.arnes.si', 'siol.net'];
|
|
|
|
|
|
|
|
var splitEmail = email.split('@');
|
|
|
|
|
|
|
|
for (var i = 0; i < domains.length; i++) {
|
|
|
|
var domain = domains[i];
|
|
|
|
|
|
|
|
if (preveriZaTipkarskoNapakoVemailu(splitEmail[1], domain)) {
|
|
|
|
jQuery('#modal-registration .w-form-fail').html('<div>' + text + ' <b>@' + domain + '</b>?</div>').show();
|
|
|
|
return jQuery('#modal-registration [type="email"]').addClass('error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function preveriZaTipkarskoNapakoVemailu(uporabnikovaDomena, domena) {
|
|
|
|
// Domeni se ujemata
|
|
|
|
if (uporabnikovaDomena && domena && uporabnikovaDomena.includes(domena))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
//Preverimo če vsebuje dve piki ali vejico
|
|
|
|
if (new RegExp('(\\.{2})|(\,)').test(uporabnikovaDomena) && uporabnikovaDomena.substring(0, 3) == domena.substring(0, 3)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// domeno razbijemo, da preverimo napake za posamezne črke gm|ail
|
|
|
|
for (var i = 1; i < domena.length; i++) {
|
|
|
|
var prviDel = domena.substring(0, i);
|
|
|
|
var preostenekBesede = domena.substring(i);
|
|
|
|
|
|
|
|
|
|
|
|
// preverimo, če so črke napačne
|
|
|
|
if (new RegExp(prviDel + '.' + preostenekBesede.substring(1)).test(uporabnikovaDomena)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// preverimo, če je dodana črka preveč
|
|
|
|
if (new RegExp(prviDel + '.' + preostenekBesede).test(uporabnikovaDomena)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// majkajoča črka
|
|
|
|
if (preostenekBesede !== 'mail' && new RegExp('(' + prviDel + '{0}' + preostenekBesede + ')|(' + domena + '{0})').test(uporabnikovaDomena)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (domena == 'gmail.com' && new RegExp('gmail.si|gmail.net').test(uporabnikovaDomena) ||
|
|
|
|
domena == 'guest.arnes.si' && new RegExp('arnes.si').test(uporabnikovaDomena) ||
|
|
|
|
domena == 'siol.net' && new RegExp('siol.com').test(uporabnikovaDomena)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (domena == 'hotmail.com' && new RegExp('hotmail.si').test(uporabnikovaDomena)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// test for switched letters
|
|
|
|
var switchedLetters = [
|
|
|
|
domena.substring(0, i - 1),
|
|
|
|
domena.charAt(i),
|
|
|
|
domena.charAt(i - 1),
|
|
|
|
domena.substring(i + 1)
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
if (uporabnikovaDomena.includes(switchedLetters)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-06-27 07:58:26 +02:00
|
|
|
function pridobiJezik() {
|
2022-06-09 15:53:29 +02:00
|
|
|
return jQuery('html')[0].lang;
|
|
|
|
}
|
|
|
|
|
|
|
|
function odpriAaiLoginObvestilo(){
|
|
|
|
jQuery('.modal-intro-title').hide();
|
|
|
|
jQuery('.nakup-prijava').hide();
|
|
|
|
jQuery('.modal-intro-login-text').css('display', 'flex');
|
|
|
|
|
2022-06-27 07:58:26 +02:00
|
|
|
if(pridobiJezik() == 'sl') {
|
2022-06-09 15:53:29 +02:00
|
|
|
jQuery('#modal-open-1ka').removeClass('modal-goto-registration').addClass('modal-open-login-obrazec');
|
|
|
|
jQuery('#modal-info-login').css('display', 'flex');
|
|
|
|
|
|
|
|
// V kolikor gre za nakup prikažemo še obvestilo o nakupu
|
|
|
|
if (document.cookie.indexOf('nakup=') > 0) {
|
|
|
|
jQuery('.nakup-prijava').css('display', 'flex');
|
|
|
|
}
|
|
|
|
} else {
|
2022-09-08 10:03:15 +02:00
|
|
|
jQuery('#modal-login').css('display', 'flex');
|
2022-06-09 15:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
2022-08-19 00:48:36 +02:00
|
|
|
|
|
|
|
function CookieAlert(link, jezik, url) {
|
|
|
|
var link = link || '/';
|
|
|
|
var jezik = jezik || 'sl';
|
|
|
|
var url = url || false;
|
|
|
|
|
|
|
|
if (link == 'fb') {
|
|
|
|
link = '/frontend/api/api.php?action=login_facebook';
|
|
|
|
// link = 'https://www.1ka.si/fb_login.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (link == 'google') {
|
|
|
|
// link = '/frontend/api/api.php?action=login_google';
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (link == 'aai') {
|
|
|
|
link = 'https://aai.1ka.si/Shibboleth.sso/Login';
|
|
|
|
}
|
|
|
|
|
|
|
|
var da = 'Nadaljuj';
|
|
|
|
var ne = 'Prekliči';
|
|
|
|
if (jezik == 'en') {
|
|
|
|
var da = 'Continue';
|
|
|
|
var ne = 'Cancel';
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery('#kuki').dialog({
|
|
|
|
height: "auto",
|
|
|
|
width: 520,
|
|
|
|
dialogClass: 'pojavno-okno-1ka',
|
|
|
|
modal: true,
|
|
|
|
buttons: [{
|
|
|
|
text: da,
|
|
|
|
class: "gumbi-pri-zunanji-prijavi",
|
|
|
|
click: function () {
|
|
|
|
jQuery(this).dialog("close");
|
|
|
|
|
|
|
|
document.location.href = link;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
text: ne,
|
|
|
|
click: function () {
|
|
|
|
jQuery(this).dialog("close");
|
|
|
|
if (url) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.location.href = '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
// Če strinjanje ne obstaja, prikažemo vse gumbe
|
|
|
|
if(jQuery('#pogoji-strinjanje').length == 0)
|
|
|
|
jQuery('.gumbi-pri-zunanji-prijavi').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Za google prijavo moramo postati formo - kar sestavimo direktno url
|
|
|
|
/*
|
|
|
|
<form id="googleLoginForm" action="https://accounts.google.com/o/oauth2/auth" method="get" style="display: none;">
|
|
|
|
<input type="hidden" name="response_type" value="code" />
|
|
|
|
<input type="hidden" name="client_id" value="<?=$google_login_client_id?>" />
|
|
|
|
<input type="hidden" name="redirect_uri" value="https://www.1ka.si/utils/google-oauth2.php" />
|
|
|
|
<input type="hidden" name="state" value="<?=(isset ($_GET['regFromEnglish']) && $_GET['regFromEnglish']=="1"?'regFromEnglish':'')?>" />
|
|
|
|
<input type="hidden" name="scope" value="email" />
|
|
|
|
<input type="hidden" name="access_type" value="online" />
|
|
|
|
<input type="hidden" name="prompt" value="consent" />
|
|
|
|
<input type="hidden" name="openid.realm" value="https://www.1ka.si" />
|
|
|
|
</form>
|
|
|
|
*/
|
|
|
|
function CookieAlertGoogle(jezik, url) {
|
|
|
|
//var link = link || '/';
|
|
|
|
var jezik = jezik || 'sl';
|
|
|
|
var url = url || false;
|
|
|
|
|
|
|
|
// Sestavimo url
|
|
|
|
var url = 'https://accounts.google.com/o/oauth2/auth?';
|
|
|
|
|
|
|
|
url += 'response_type=code';
|
|
|
|
url += '&client_id=944153399779-m39ehn45vm6b64l0sac7hphtpm0esgqs.apps.googleusercontent.com';
|
|
|
|
url += '&redirect_uri=https://www.1ka.si/frontend/api/google-oauth2.php';
|
|
|
|
|
|
|
|
if(jezik == 'en')
|
|
|
|
url += '&state=regFromEnglish';
|
|
|
|
else
|
|
|
|
url += '&state=';
|
|
|
|
|
|
|
|
url += '&scope=email';
|
|
|
|
url += '&access_type=online';
|
|
|
|
url += '&prompt=consent';
|
|
|
|
url += '&openid.realm=https://www.1ka.si';
|
|
|
|
|
|
|
|
|
|
|
|
var da = 'Nadaljuj';
|
|
|
|
var ne = 'Prekliči';
|
|
|
|
if (jezik == 'en') {
|
|
|
|
var da = 'Continue';
|
|
|
|
var ne = 'Cancel';
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery('#kuki').dialog({
|
|
|
|
height: "auto",
|
|
|
|
width: 520,
|
|
|
|
dialogClass: 'pojavno-okno-1ka',
|
|
|
|
modal: true,
|
|
|
|
buttons: [{
|
|
|
|
text: da,
|
|
|
|
class: "gumbi-pri-zunanji-prijavi",
|
|
|
|
click: function () {
|
|
|
|
jQuery(this).dialog("close");
|
|
|
|
|
|
|
|
document.location.href = url;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
text: ne,
|
|
|
|
click: function () {
|
|
|
|
|
|
|
|
jQuery('#pogoji-strinjanje').attr('checked', false);
|
|
|
|
jQuery(this).dialog("close");
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.location.href = '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
// Če strinjanje ne obstaja, prikažemo vse gumbe
|
|
|
|
if(jQuery('#pogoji-strinjanje').length == 0)
|
|
|
|
jQuery('.gumbi-pri-zunanji-prijavi').show();
|
|
|
|
}
|