/** * Created by Vanush on 19.07.2017. */ //login function tenwebLogin() { var email = jQuery("#tenweb_email"); var pass = jQuery("#password"); var data = {}; data.action = 'tenweb_dashboard_login'; data.email = email.val(); data.password = pass.val(); data.type = 'login_user'; data.tenweb_nonce = jQuery('#tenweb_login_nonce').val(); if(tenwebIsValid([email,pass])){ jQuery("#error_response").hide(); jQuery("#button_login span.spinner").css({"visibility": "visible", "display": "inline-block"}); jQuery.ajax({ type: "POST", // dataType: 'json', url: tenweb.ajaxurl, data: data, success: function (response) { var response = JSON.parse(response); if (typeof response.error != "undefined") { var errorMessage = response.message == "Subscription could not be found." ? "Your subscription is expired. Renew subscription or choose another plan." : response.message; jQuery("#error_response").html(errorMessage).show(); jQuery("#button_login span.spinner").css({"visibility": "hidden", "display": "none"}); } else { location.reload(); } }, failure: function (errorMsg) { console.log('Failure' + errorMsg); }, error: function (error) { console.log(error); } }); } }; function tenwebIsValid(elem) { var hasError = 0; jQuery(elem).each(function(i, el){ var inValidEmail = false; if (el.prop("id") == "tenweb_email" && !tenwebIsValidEmail(el.val())) { inValidEmail = true; } if (el.val().trim() == "" || inValidEmail) { el.addClass("error_input"); el.next(".error_label").show(); hasError++; } else { el.removeClass("error_input"); el.next(".error_label").hide(); } }); if(!hasError) return true; return false; } function tenwebIsValidEmail(email) { var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } jQuery(document).ready(function () { jQuery("#twebman-login-form input").blur(function () { tenwebIsValid([jQuery(this)]); }); jQuery("#twebman-login-form input").keyup(function () { tenwebIsValid([jQuery(this)]); }); if (jQuery("#twebman-login-form").length) { jQuery(document).keypress(function (e) { if (e.which == 13) { tenwebLogin(); return false; } }); } //debug mode jQuery('#tenweb_clear_logs').on('click', function () { jQuery.ajax({ type: "POST", url: tenweb.ajaxurl, data: { action: "tenweb_clear_logs", tenweb_nonce: tenweb.ajaxnonce }, success: function (response) { window.location.reload(); }, failure: function (errorMsg) { window.location.reload(); }, error: function (error) { window.location.reload(); } }); }); jQuery('#tenweb_clear_cache, .tenweb_clear_cache_button').on('click', function () { window.tenWebClearCache(); }); window.tenWebClearCache = function() { jQuery.ajax({ type: "POST", url: tenweb.ajaxurl, data: { action: "tenweb_clear_cache", tenweb_nonce: tenweb.ajaxnonce }, success: function (response) { window.location.reload(); }, failure: function (errorMsg) { window.location.reload(); }, error: function (error) { window.location.reload(); } }); }; jQuery('#tenweb_check_curl').on('click', function () { jQuery.ajax({ type: "POST", url: tenweb.ajaxurl, data: { action: "tenweb_check_curl", tenweb_nonce: tenweb.ajaxnonce }, success: function (response) { console.log(response); }, failure: function (errorMsg) { console.log(response); }, error: function (error) { console.log(response); } }); }); jQuery("#self_update").on('click', function () { jQuery(this).find(".spinner").css({"display": "inline-block","visibility": "visible"}); jQuery.ajax({ type: "POST", url: tenweb.action_endpoint, data: { action: "update", origin: "10web", tenweb_nonce: tenweb.ajaxnonce, product_id: jQuery(this).data("id") }, beforeSend: function ( xhr ) { xhr.setRequestHeader( 'X-WP-Nonce', tenweb.ajaxnonce ); }, success: function (response) { window.location.reload(); }, failure: function (errorMsg) { window.location.reload(); }, error: function (error) { window.location.reload(); } }); }); jQuery("#tenweb_manager_products .tm_products_logout").on('click',function () { jQuery('#tenweb_manager_logout_form').submit(); }); /*Show Video*/ jQuery("#tenweb_connect_img").on('click',function () { var tenwebplayer = new YT.Player('iframe-container', { height: '675', width: '1200', videoId: 'KhqZDrTjaRM', playerVars: { autoplay: 1, modestbranding: 1, vq: 'hd2160', rel: 0, showinfo: 0, cc_load_policy: 0, iv_load_policy: 3, }, events: { 'onStateChange': tenwebstopCycle } }); jQuery("#video_container").show(); }); jQuery("#video_container").on('click',function(a){ jQuery(this).hide(); jQuery('.iframe-container iframe').remove(); jQuery('.iframe-container').html("
"); }); }); function tenwebstopCycle(event) { if(event.data === 0) { setTimeout( function(){ jQuery("#video_container").fadeOut(800); jQuery('.iframe-container iframe').remove(); jQuery('.iframe-container').html(""); },1000); } }