/** * Created by Atomic 1 on 8/7/2015. */ jQuery(document).ready(function ($) { // ATOMIC REACH SCORE REMINDER $("#awAdminNoticeSignup").click(function (e) { e.preventDefault(); $('html, body').animate({ scrollTop: $("#aranalyzer_metabox").offset().top }, 1000, function () { // Animation complete. $("#aranalyzer_metabox .inside").addClass('aw-glow'); setTimeout(function () { $("#aranalyzer_metabox .inside").removeClass('aw-glow'); }, 1000) }); }); (function () { var s = $("#aranalyzer_metabox .inside #awScoreReminder"); $.ajax({ type: 'POST', url: ajaxurl, data: {'action': 'awCheckScoreFreq_ajax'}, success: function (arScoreReminder) { if (typeof arScoreReminder == 'undefined') return; /* * 20 = activated for more than a day but never scored any post. * 22 = Last time user scored any post is more than 4 days. * */ if (arScoreReminder == 20) { s.find('h2').html("Don't forget to edit your article with AtomicWriter!"); showReminderMessage(); } else if (arScoreReminder == 22) { s.find('h2').html("See how you can quickly edit your article for your audience."); showReminderMessage(); } } }) function showReminderMessage(){ //hide after 10 seconds. //@todo: temporary hidden s.slideToggle('slow', function () { $("#aranalyzer_metabox .inside").addClass('aw-glow'); setTimeout(function () { s.slideToggle("slow", function(){ $("#aranalyzer_metabox .inside").removeClass('aw-glow'); }); }, 4000) }) } })(); // ATOMIC REACH SCORE REMINDER $("#aw-goTosignUpForm").click(function (e) { e.preventDefault(); $("#aw-signIn").fadeOut(function () { // Animation complete. $("#aw-signUp").fadeIn(); }); }); $("#aw-goTosignInForm").click(function (e) { e.preventDefault(); $("#aw-signUp").fadeOut(function () { // Animation complete. $("#aw-signIn").fadeIn(); }); }); $("#aw-signUpForm").submit(function (e) { e.preventDefault(); var email = $("#aw-signUpEmail").val(); var pass = $("#aw-signUpPassword").val(); var pass2 = $("#aw-signUpPasswordReType").val(); if (pass != pass2) { $("#aw-API-Error").html("Password do not match!").show().delay(5000).fadeOut("slow", function () { $(this).empty() }); return; } if (!jQuery("#tos").is(":checked")) { $("#aw-API-Error").html("Unfortunately you cannot set up an account without accepting our Terms of Use. Please feel free to use our" + " Web App.").show().delay(9000).fadeOut("slow", function () { $(this).empty() }); return; } // var newtab = window.open('', '', "width=600, height=800, menubar=0, status=0, titlebar=0, toolbar=0"); //var newtab = window.open('','_blank') ; $(".awloadingIcon").show(); var data = { 'action': 'awSignUpEmail_ajax', 'email': email, 'test': 'test', 'pass': pass }; $.post(ajaxurl, data, function (response) { console.log(response); if (!response.match(/ok/g)) { // newtab.close(); var value = JSON.parse(response); if (typeof value.data.email !== 'undefined') { emailMessages = Object.keys(value.data.email); $.map(emailMessages, function (val, i) { $("#aw-API-Error").append("
Create Account - Email Error: " + value.data.email[val] + "
"); }); } if (typeof value.data.password !== 'undefined') { passwordMessages = Object.keys(value.data.password); $.map(passwordMessages, function (val, i) { $("#aw-API-Error").append("Create Account - Password Error: " + value.data.password[val] + "
"); }); } $("#aw-API-Error").show().delay(5000).fadeOut("slow", function () { $(this).empty() }); } else { var x = response.split("-"); // newtab.location = 'https://www.atomicreach.com/wordpress-signup/?accountId=' + x[1]; $("#aw-atomicAdminNotice").fadeOut(); $("#AW-StandBy").load("../wp-content/plugins/atomic-reach-audience-engager/custom/html/audSlider-score.html", function () { $("#AW-notLoggedIn").slideUp("slow", function () { $("#AW-StandBy").slideDown("slow"); createTooltipsyForTheI(); }); }); } $(".awloadingIcon").hide(); }).done(function () { }).always(function () { }); }); $("#aw-signInFormSubmit").click(function (e) { e.preventDefault(); var email = $("#aw-signInEmail").val(); var pass = $("#aw-signInPassword").val(); var data = { 'action': 'awSignInEmail_ajax', 'email': email, 'test': 'test', 'pass': pass }; $(".awloadingIcon").show(); $.ajax({ type: 'POST', url: ajaxurl, data: data, async: false, success: function (response) { if (response != 'ok') { //clearTimeout(myVar); $("#aw-API-Error").html(response).fadeIn().delay(5000).fadeOut("slow"); } else if (response == 'ok') { $("#aw-atomicAdminNotice").fadeOut(); $("#AW-StandBy").load("../wp-content/plugins/atomic-reach-audience-engager/custom/html/audSlider-score.html", function () { $("#AW-notLoggedIn").slideUp("slow", function () { $("#AW-StandBy").slideDown("slow"); createTooltipsyForTheI(); }); }); } $(".awloadingIcon").hide(); }, done: function () { }, always: function () { } }); }); var audBand = 5; // change audience slider $("#aranalyzer_metabox").on("change", '.ar-aud-slider_WP', function (e) { var audnum = $(this).val(); var audText = ''; if (audnum == 1) { audText = 'General'; audBand = 5; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Beginner Novice Basic") } else if (audnum == 2) { audText = 'Knowledgeable'; audBand = 4; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Aware Familiar Informed"); } else if (audnum == 3) { audText = 'Specialist'; audBand = 3; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Advanced Trained Well-versed") } else if (audnum == 4) { audText = 'Academic'; audBand = 2; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Scholarly Collegiate Masterful") } else if (audnum == 5) { audText = 'Genius'; audBand = 1; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Expert Brilliant Intellectual") } $('#arSelectedAud_WP, #arSelectedAud2').text(audText).removeClass().addClass(audText + "ColorText"); $('#ar_desc-aud_WP, #ar_desc-aud_WP2').removeClass().addClass(audText + "ColorText"); targetAud = audText.toUpperCase(); }); // Click Score button $("#aranalyzer_metabox").on("click", "#arScore_WP", function (e) { e.preventDefault(); var title = $("#title").val(); var content = tinyMCE.activeEditor.getContent(); if (title == "") { $("#right-score").html("ERROR! : Title is missing. Please write your title and try again.").fadeIn().delay(5000).fadeOut(); return; } if (content == "") { $("#right-score").html("ERROR! : Content is missing. Please write some content and try again.").fadeIn().delay(5000).fadeOut(); return; } var STARTTIME,ENDTIME; var data = { 'action': 'aranalyzer_ajax', 'arTitle': title, 'arContent': content, 'segmentId': audBand }; var quote = displayQuote(); $.ajax({ type: "POST", url: ajaxurl, data: data, beforeSend: function () { STARTTIME = +new Date(); if ($("#right-score").is(":visible")) { $("#right-score").slideUp(function () { $("#AW-staticBlock").fadeOut(function () { $("#awloadingBlock").fadeIn(); $(".ar-selectAudSlider_WP").show(); $("#arAudDetails").hide(); }); }); } else { $("#AW-staticBlock").fadeOut(function () { $("#awloadingBlock").fadeIn(); }); } $('.randomQuote').find('p').html(quote[0]) $('.randomQuote').find('.quoteFooter').html(quote[1]); clearAllhighlighting(); }, success: function (response) { jQuery("#right-score").html(response).hide(); ARTabs(); ar_tips(); ar_tipsread(); ar_scoreDisplay(); sortTitleMeasure(); ENDTIME = +new Date(); $("#scoreTime small").html( "(" + Math.round(((ENDTIME - STARTTIME)/1000)) + " Seconds)").css('color', '#777;'); //OnSuccessFeedback(response) }, error: function (response) { }, complete: function () { $("#awloadingBlock").fadeOut(function () { $(".ar-selectAudSlider_WP").hide(); $("#arAudDetails").show(); $("#AW-staticBlock").fadeIn(function () { $("#right-score").slideDown("slow"); }) }); $("#arScore_WP").text("RESCORE") // Show audience box when click $('#changeAudience').unbind('click').bind('click', function (e) { e.preventDefault(); console.log(e); //$('#scoreButton').remove(); $('.ar-selectAudSlider_WP').slideToggle(); }); } }); }); /********************************/ /**** Score Button & new-meta.php Tabs ui ****/ /********************************/ $("#right-score").on("load", "ul.AR-tabs", ARTabs()); function ARTabs() { $('ul.AR-tabs').each(function () { // For each set of tabs, we want to keep track of // which tab is active and it's associated content var $active, $content, $links = $(this).find('a'); // If the location.hash matches one of the links, use that as the active tab. // If no match is found, use the first link as the initial active tab. $active = $($links.filter('[href="' + location.hash + '"]')[0] || $links[2]); $active.addClass('active'); $content = $($active[0].hash); // Hide the remaining content $links.not($active).each(function () { $(this.hash).hide(); }); // Bind the click event handler $(this).on('click', 'a', function (e) { // Make the old tab inactive. $active.removeClass('active'); $content.hide(); // Update the variables with the new link and content $active = $(this); $content = $(this.hash); // Make the tab active. $active.addClass('active'); $content.show(); // Prevent the anchor's default click action e.preventDefault(); }); }); } function ar_scoreDisplay(){ $('#scoreBubble').css('margin-left', (ARTICLESCORE - 12) + '%'); $('#scoreBubble > span').text(ARTICLESCORE); $('#scoreBar').css('width', ARTICLESCORE + '%'); if (ARTICLESCORE > ATOMICSCORE) { $('#notHIT').hide(); $('#HIT').show(); }else{ $('#notHIT').show(); $('#HIT').hide(); } if (ATOMICSCORE > 0) { $('div#atomicScoreIndicator').show(); $('#atomicScoreIndicator').css('margin-left', (ATOMICSCORE - 4) + '%'); $('#atomicScoreIndicator strong').html(ATOMICSCORE); } else { $('div#atomicScoreIndicator').hide(); } var so = soHL; if(so.state == 10) { so.state == 'green' ? $('#audienceWrapper p.so-actual').hide() : $('#audienceWrapper p.so-actual').show(); $('#audienceWrapper p.so-target > span').html(so.detail.toLowerCase()); $('#audienceWrapper p.so-target > strong').html(typeof so.target == 'undefined' ? so.actual : so.target); $('#audienceWrapper p.so-actual > strong').html(so.actual); //$('i.so-actual').addClass("color-aud-"+val.data.analysis.so.actual); $('#audienceWrapper p.so-target > strong, i.so-target').removeClass(function (index, css) { return (css.match(/\bcolor-aud-\S+/g) || []).join(' '); }).addClass("color-aud-" + so.target); $('#audienceWrapper p.so-actual > strong, i.so-actual').removeClass(function (index, css) { return (css.match(/\bcolor-aud-\S+/g) || []).join(' '); }).addClass("color-aud-" + so.actual); }else if(so.state == 14){ noAccessDisplay(); }else{ console.error("something went wrong",so); } } function noAccessDisplay(){ var LockIconHTML = ''; $("#scoreBubble > span") .html(LockIconHTML) .css({ 'top': '16px' ,'left': '23px' ,'color': '#ddd' }); $("#notHIT, #HIT, .text-center.so-target, .text-center.so-actual").hide(); $("#targetandactual").addClass('ar-feature-lock'); $("#targetandactual").find("i.fa-circle").removeClass("fa-circle").addClass("fa-lock fa-lock-background"); if(ARBELOW50) { $('#scoreBubble').css('margin-left', (19 - 12) + '%'); $("#BELOW50").show(); $("#ABOVE50").hide(); } if(AROVER50){ $('#scoreBubble').css('margin-left', (51 - 12) + '%'); $("#ABOVE50").show(); $("#BELOW50").hide(); } $("#ar-WCbtn").find(".onoffswitch").html(''); $(".ar-feature-lock").tooltipsy({ offset: [-4, 0], className: 'arTooltipsy arlockedTooltip', content: 'Please upgrade your account to use this locked feature. ' }); } function ar_tips() { if (titleKeywordState.toLowerCase() != 'green') { $("#ar-kword").tooltipsy({ offset: [-10, 0], className: 'arTooltipsy', content: 'Your Keywords:' + tgKeywords + '
' }); } if (lengthState == 'red' || 'yellow') { $("#ar-ln").tooltipsy({ offset: [-10, 0], className: 'arTooltipsy', content: 'Tip:The knowledge levels to choose from are:
" +
"General - your audience has a basic understanding of the content topic or theme.
" +
"Knowledgeable - your audience has an advanced understanding of content or theme.
" +
"Specialist - your audience has a superior understanding of content or theme.
" +
"Academic - your audience has a proficient understanding of content or theme.
" +
"Genius - your audience has an expert understanding of content or theme.