/** * Created by Vanush on 19.07.2017. */ //login var wordsAnimate = 0; var playVideo = 0; 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 tenweb_play_video(index) { jQuery("#manager_components_videos_content > div").removeClass("bottom"); jQuery("#manager_components_videos_content > div.top").addClass("bottom"); jQuery("#manager_components_videos_content > div").removeClass("top"); jQuery("#manager_components_videos_content > div#" + index + "_content").addClass("top"); if(jQuery("#manager_components_videos_content > div#" + index + "_content video").length) { jQuery("#manager_components_videos_content > div:not(#" + index + "_content) video").each(function() { jQuery(this).unbind("ended"); }); tenwebManagerVideoEnd(jQuery("#manager_components_videos_content > div#" + index + "_content video")); var video = jQuery("#manager_components_videos_content > div#" + index + "_content video").get(0); video.currentTime = 0; video.play(); const e = 30; jQuery("#manager_components_videos_content > div#" + index + "_content video").on("timeupdate", function() { var g = video.currentTime / video.duration * 100; jQuery("div#" + index + " .loading_svg .spinner").css("stroke-dasharray", g / 100 * e + " " + e); }); } } function swipeVideos(videoIndex){ var left = -283; jQuery("#manager_components_videos_tabs").animate({left:left * videoIndex},400); jQuery("#manager_components_videos_tabs > div").removeClass("active"); jQuery("#manager_components_videos_tabs > div").eq(videoIndex).addClass("active"); tenweb_play_video(jQuery("#manager_components_videos_tabs > div").eq(videoIndex).attr("id")); } function tenwebManagerVideoEnd(el) { el.bind("ended", function() { var index = jQuery(this).parent().attr("data-id"); jQuery("#manager_components_videos_tabs > div").removeClass("active"); jQuery("#manager_components_videos_tabs #"+ index).addClass("active"); if(matchMedia('screen and (max-width: 767px)').matches){ swipeVideos(jQuery("#manager_components_videos_tabs #"+ index).index()); } else { tenweb_play_video(index); } }); } function scrollFunction(){ var windowTop = jQuery(window).scrollTop(); var windowHeight = jQuery(window).height(); if(jQuery("#manager_components_videos_content > div#hosting_content video").length && playVideo === 0) { if (windowTop + windowHeight > jQuery("#manager_components_videos_container").offset().top ) { jQuery("#manager_components_videos_tabs #hosting").addClass("active"); tenweb_play_video("hosting"); playVideo++; } } if(jQuery(".animate-words").length && wordsAnimate === 0) { jQuery(".animate-words").addClass("animate"); jQuery("#manager_header,#manager_section_1").addClass("animate"); setTimeout(function(){ jQuery("#manager_section_1").addClass("animated"); }, 800); wordsAnimate++; } } 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( window ).scroll(function() { scrollFunction(); }); jQuery(document).ready(function () { scrollFunction(); if(jQuery("#plugin-reviews").length){ jQuery("#plugin-reviews .single-item").slick({ dots: true }); } jQuery("body").on( "click", "#manager_components_videos_tabs > div", function() { if(!matchMedia('screen and (max-width: 767px)').matches){ if(!jQuery(this).hasClass("active")){ jQuery("#manager_components_videos_tabs > div").removeClass("active"); jQuery(this).addClass("active"); var index = jQuery(this).attr("id"); jQuery("#manager_components_videos_content video").each(function() { jQuery(this).get(0).currentTime = 0; jQuery(this).get(0).pause(); }); tenweb_play_video(index); } } }); 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, headers:{ "Authorization":"Bearer "+tenweb.auth_header, "Accept": "application/x.10webmanager.v1+json" }, data: { domain_id: tenweb.domain_id, }, 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(); }); jQuery("#video_container").on('click',function(a){ jQuery(this).hide(); jQuery('.iframe-container iframe').remove(); jQuery('.iframe-container').html("
"); }); /*Show Video*/ jQuery(".manager_watch_video").on('click',function () { if(jQuery("#manager_section_1 div#manager_components_videos_tabs").length){ jQuery("#manager_section_1 div#manager_components_videos_tabs > div").css("z-index","1"); } var tenWebPluginVideoId = jQuery(this).attr("data-id"); var tenwebplayer = new YT.Player('iframe-container', { height: '675', width: '1200', videoId: tenWebPluginVideoId, playerVars: { autoplay: 1, modestbranding: 1, vq: 'hd2160', rel: 0, showinfo: 0, cc_load_policy: 0, iv_load_policy: 3, } }); jQuery("#video_container").show(); }); if(jQuery('#manager_components_videos').length) { videoIndex = 0; if (typeof jQuery().swiperight !== 'undefined') { if (jQuery.isFunction(jQuery().swiperight)) { jQuery('#manager_components_videos').swiperight(function () { if (videoIndex > 0 && videoIndex < 4) { videoIndex--; swipeVideos(videoIndex); return false; } videoIndex--; if (videoIndex < 0) { videoIndex = 2; swipeVideos(videoIndex); return false; } }); } } if (typeof jQuery().swipeleft !== 'undefined') { if (jQuery.isFunction(jQuery().swipeleft)) { jQuery('#manager_components_videos').swipeleft(function () { if (videoIndex == 2) { videoIndex = 0; swipeVideos(videoIndex); } else if (videoIndex >= 0 && videoIndex < 2) { videoIndex++; swipeVideos(videoIndex); } return false; }); } } } /*Image Optimizer*/ jQuery("#image_optimizer_content").on( "mousemove", function(event){ v = event.pageX - jQuery(this).offset().left + 1; if (v > 20 && v < (jQuery(this).width() - 20)) { jQuery("#separator").css("left", v + "px"); jQuery("#horizon-original").css("clip", "rect(0px " + v + "px 405px 0px)"); } }); jQuery("#image_optimizer").on( "touchmove", function(event){ v = event.originalEvent.touches[0].clientX - jQuery(this).offset().left + 1; if (v > 20 && v < (jQuery(this).width() - 20)) { jQuery("#separator").css("left", v + "px"); jQuery("#horizon-original").css("clip", "rect(0px " + v + "px 405px 0px)"); } }); if(matchMedia('screen and (max-width: 1024px)').matches){ jQuery("div#tenweb_menu.photo-gallery #speed .floating-img1 img").attr("src",tenweb.plugin_url + "/assets/images/plugins_from/img1_768.png"); jQuery("div#tenweb_menu.photo-gallery #speed .floating-img2 img").attr("src",tenweb.plugin_url + "/assets/images/plugins_from/img2_768.png"); } if(matchMedia('screen and (max-width: 767px)').matches){ jQuery("div#tenweb_menu.photo-gallery #speed .floating-img1 img").attr("src",tenweb.plugin_url + "/assets/images/plugins_from/img1_320.png"); jQuery("div#tenweb_menu.photo-gallery #speed .floating-img2 img").attr("src",tenweb.plugin_url + "/assets/images/plugins_from/img2_320.png"); } }); function tenwebstopCycle(event) { if(event.data === 0) { setTimeout( function(){ jQuery("#video_container").fadeOut(800); jQuery('.iframe-container iframe').remove(); jQuery('.iframe-container').html(""); },1000); } }