File: /home/dtptviut/public_html/wp-content/plugins/comparisonfeed-wp/js/dist/compare-admin.min.js
function initTpl(){var e=jQuery("select#compare-account option:selected").val(),r=jQuery("select#compare-account option:selected").data("country"),t=jQuery("select#compare-account option:selected").data("accountname"),a=jQuery("select#compare-template option:selected").val(),o=jQuery("select#compare-account option:selected").data("country"),i=jQuery("select#compare-account option:selected").data("countryname"),d=jQuery("select#compare-template option#creditcard"),n=jQuery("select#compare-template option#quickloan"),s=jQuery("select#compare-template option#socialSecurity"),l=jQuery("select#compare-template option#loan"),c=jQuery("select#compare-template option#allLoans"),u=jQuery("select#compare-template option#dating"),p=jQuery("select#compare-template option#hosting"),m=jQuery("select#compare-template option#broadband"),y=jQuery("select#compare-template option#casino"),h=jQuery("select#compare-template option#magazine"),f=jQuery("select#compare-template option#mobileSubscription");filterAvailable=!1,"180,147"===a||"180"===a||"147"===a||"167"===a||"153"===a?(filterAvailable=!0,usingIframe||jQuery("#adservice-comparison-feed .categoryFilter").hide()):jQuery("#adservice-comparison-feed .categoryFilter").slideUp();var j=jQuery("#adservice-comparison-feed #feed-id").val();""!==r&&"0"!==a?(void 0!==j&&j.length>0?(jQuery("#export-feed-completed-section").find("span:eq(0)").text(j),jQuery("#export-feed-completed-section").find("span:eq(1)").text(t),jQuery("#export-feed-completed-section").find("span:eq(2)").text(i),jQuery("#export-feed-completed-section").find("code").text("[adservice-comparison-feed feed="+j+"]"),jQuery("#adservice-comparison-feed #export-feed-completed-section").slideDown(),jQuery("#adservice-comparison-feed .code-generated").slideUp(),jQuery("#adservice-comparison-feed .legal-notice").slideUp()):(jQuery("#adservice-comparison-feed #export-feed-section").slideDown(),jQuery("#adservice-comparison-feed .code-generated").slideDown(),jQuery("#adservice-comparison-feed .legal-notice").slideDown()),jQuery("#adservice-comparison-feed .change-order").prop("disabled",!1),jQuery("#adservice-comparison-feed .change-order").removeClass("disabled"),renderTpl(e,a),initConditions(e,a)):r>0&&"0"!==a?(void 0!==j&&j.length>0?(jQuery("#export-feed-completed-section").find("span:eq(0)").text(j),jQuery("#export-feed-completed-section").find("span:eq(1)").text(t),jQuery("#export-feed-completed-section").find("span:eq(2)").text(i),jQuery("#export-feed-completed-section").find("code").text("[adservice-comparison-feed feed="+j+"]"),jQuery("#adservice-comparison-feed #export-feed-completed-section").slideDown(),jQuery("#adservice-comparison-feed .code-generated").slideUp(),jQuery("#adservice-comparison-feed .legal-notice").slideUp()):(jQuery("#adservice-comparison-feed #export-feed-section").slideDown(),jQuery("#adservice-comparison-feed .code-generated").show(),jQuery("#adservice-comparison-feed .legal-notice").show()),jQuery("#adservice-comparison-feed .change-order").prop("disabled",!1),jQuery("#adservice-comparison-feed .change-order").removeClass("disabled"),renderTpl(e,a),initConditions(e,a)):(jQuery("#adservice-comparison-feed .code-generated").slideUp(),jQuery("#adservice-comparison-feed .legal-notice").slideUp(),jQuery("#adservice-comparison-feed #try-feed-builder-section").slideDown(),jQuery("#adservice-comparison-feed .change-order").prop("disabled",!0),jQuery("#adservice-comparison-feed .change-order").addClass("disabled")),"dk"===o?(d.show(),l.show(),c.show(),n.show(),s.show(),p.show(),u.show(),m.show(),y.show(),h.show(),f.show()):"fi"===o?(d.show(),n.show(),l.show(),c.show(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.show(),f.show()):"no"===o?(n.hide(),d.show(),l.show(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.show()):"se"===o?(n.show(),d.show(),l.show(),c.show(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.show()):"pl"===o?(n.show(),d.hide(),l.hide(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.hide()):"es"===o?(n.show(),d.hide(),l.hide(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.hide()):"mx"===o?(n.show(),d.hide(),l.hide(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.hide()):"de"===o?(n.hide(),d.hide(),l.show(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.hide()):(n.hide(),d.hide(),l.hide(),c.hide(),s.hide(),p.hide(),u.hide(),m.hide(),y.hide(),h.hide(),f.hide())}function renderTpl(e,r){if(jQuery("#adminTableHolder").attr("data-publisherId",e),jQuery("#adminTableHolder").attr("data-categoryId",r),Number(e)>0&&(Number(r)>0||r.toString().trim().length>0)){var t=getDisabledItems(),a=getCustomOrder();Object.keys(a).length>0&&(usingCustomOrder=!0,jQuery("#using-custom-order").removeClass("hidden")),jQuery("#adminTableHolder").adserviceFeed({reload:!0}),jQuery("#adminTableHolder").off().on("renderedTemplate",function(){markAsDisabled(t,a),jQuery("#sortable").disableSelection();var e=jQuery("#sortable li").length;makeSortable(e),createRating(e),resetData(".bottom-bar .button.reset"),jQuery(".bottom-bar .button.update").click(function(e){e.preventDefault(),jQuery("#publish").length>0?jQuery("#publish").click():jQuery(".components-button.editor-post-publish-button").click()}),jQuery('input[type="rating"]').rating({showClear:!1,showCaption:!1}),removeOrAddCampaign(),markAsLowEPC()})}}function initConditions(e,r){feedFieldsCache[e]&&feedFieldsCache[e][r]&&feedFieldsCache[e][r].length>0?renderConditions(feedFieldsCache[e][r]):jQuery.getJSON("https://feedcontentcloud.com/cgi-bin/publisher/API/ComparisonFeed/Data.pl/fields?pid="+e+"&cid="+r,function(t){"OK"===t.status?(void 0===feedFieldsCache[e]&&(feedFieldsCache[e]={}),feedFieldsCache[e][r]=t.fields,renderConditions(t.fields)):(jQuery("#as-conditions-error").removeClass("hidden"),jQuery("#as-create-condition").attr("onclick",""))}).fail(function(){jQuery("#as-conditions-error").removeClass("hidden"),jQuery("#as-create-condition").attr("onclick","")})}function renderConditions(e){feedFields=e;for(var r=getConditions(),t=0;t<r.length;t++)for(var a=0;a<e.length;a++)if(e[a].name===r[t].name){r[t].fieldType=e[a].fieldType;var o=e[a].potentialValues;try{o=JSON.parse(o)}catch(e){}r[t].potentialValues=o}var i=[{conditions:r,fields:e,operators:feedOperators}],d=jQuery("#conditions-table-template").render(i);jQuery("#as-conditions-table").html(d),r.length>0?jQuery("#conditions-applied").removeClass("hidden"):jQuery("#conditions-applied").addClass("hidden")}function createCondition(){var e={fields:feedFields,operators:feedOperators},r=jQuery("#condition-template").render(e);jQuery("#as-conditions-table").append(r)}function deleteCondition(e){jQuery(e).closest("tr").remove()}function changeConditionField(e){var r=jQuery(e).find(":selected"),t=r.attr("data-type"),a=[];try{a=JSON.parse(r.attr("data-values"))}catch(e){}var o=jQuery(e).closest("tr").find(".as-condition-operator");o.html("");var i=jQuery(e).closest("tr").find(".as-condition-value");i.html("");var d=jQuery("<select>").attr("name","condition-operator").appendTo(o);if("ENUM"===t){d.append(jQuery("<option>").attr("value","equals").text("equal to")),d.append(jQuery("<option>").attr("value","notEquals").text("not equal to"));var n=jQuery("<select>").attr("name","condition-value").appendTo(i);a.forEach(function(e){n.append(jQuery("<option>").attr("value",e).text(e))})}else if("NUMBER"===t)feedOperators.forEach(function(e){"contains"!==e.operator&&"notContains"!==e.operator&&d.append(jQuery("<option>").attr("value",e.operator).text(e.name))}),jQuery("<input>").attr("name","condition-value").attr("type","text").attr("title","Please enter numbers like this: 1000, 75.50, 4.2").appendTo(i);else if("BOOLEAN"===t){d.append(jQuery("<option>").attr("value","equals").text("equal to")),d.append(jQuery("<option>").attr("value","notEquals").text("not equal to"));var s=jQuery("<select>").attr("name","condition-value").appendTo(i);s.append(jQuery("<option>").attr("value",0).text("No")),s.append(jQuery("<option>").attr("value",1).text("Yes"))}else feedOperators.forEach(function(e){d.append(jQuery("<option>").attr("value",e.operator).text(e.name))}),jQuery("<input>").attr("name","condition-value").attr("type","text").appendTo(i)}function resetConditions(){initConditions(jQuery("select#compare-account option:selected").val(),jQuery("select#compare-template option:selected").val())}function saveConditions(e){var r=[],t=!1;jQuery("#as-conditions-table .as-condition-row").each(function(){var e=jQuery(this),a=e.find("[name='condition-field'] option:selected").attr("data-type"),o=e.find("[name='condition-value']"),i=o.val().toString().replace("'","").replace('"',"");if("NUMBER"===a){var d=Number(i);isNaN(d)?(t=!0,o.css("border","1px solid red")):(i=d,o.css("border",""))}o.val(i);var n={name:e.find("[name='condition-field']").val(),operator:e.find("[name='condition-operator']").val(),value:i};r.push(n)}),t?alert("An invalid number was entered. Please enter numbers like this: 1000, 75.50, 4.2"):(jQuery("#conditions").html(JSON.stringify(r)),jQuery("#adminTableHolder").attr("data-conditions",JSON.stringify(r)),jQuery("#adminTableHolder").adserviceFeed({reload:!0}),r.length>0?jQuery("#conditions-applied").removeClass("hidden"):jQuery("#conditions-applied").addClass("hidden"),e.tb_remove())}function getDisabledItems(){var e=[];try{e=JSON.parse(jQuery("#removed-items").html())}catch(r){try{e=JSON.parse("["+jQuery("#removed-items").html()+"]")}catch(e){}}return e}function getCustomOrder(){var e={};try{e=JSON.parse(jsonFix(jQuery("#custom-order").html()))}catch(r){try{e=JSON.parse(jsonFix("{"+jQuery("#custom-order").html()+"}"))}catch(e){}}return e}function getCustomRating(){var e={};try{e=JSON.parse(jsonFix(jQuery("#custom-rating").html()))}catch(r){try{e=JSON.parse(jsonFix("{"+jQuery("#custom-rating").html()+"}"))}catch(e){}}return e}function getConditions(){var e=[];try{e=JSON.parse(jQuery("#conditions").html())}catch(e){}return e}function showLoadingIcon(){jQuery("#TB_ajaxContent #loading").removeClass("hide").addClass("show")}function hideLoadingIcon(){jQuery("#TB_ajaxContent #loading").removeClass("show").addClass("hide")}function resetData(e){jQuery(e).click(function(e){e.preventDefault(),usingCustomOrder=!1,jQuery("#custom-rating").html(""),jQuery("#custom-order").html(""),jQuery("#removed-items").html(""),jQuery("#include-new-campaigns").val("true"),jQuery("#include-new-campaigns").prop("checked",!0),jQuery("#new-campaign-available").addClass("hidden"),jQuery("#using-custom-order").addClass("hidden"),jQuery("#adminTableHolder").attr("data-customRating",""),jQuery("#adminTableHolder").attr("data-customOrder",""),jQuery("#adminTableHolder").adserviceFeed({reload:!0}),jQuery("#adminTableHolder").off().on("renderedTemplate",function(){jQuery("#sortable").disableSelection();var e=jQuery("#sortable li").length;makeSortable(e),createRating(e),jQuery('input[type="rating"]').rating({showClear:!1,showCaption:!1}),removeOrAddCampaign(),markAsLowEPC()})})}function createRating(e){jQuery('input[type="rating"]').on("rating.change",function(e,r,t){var a=r,o=r/5*100;jQuery(this).attr("value",a),jQuery(this).parent().parent().parent().find("input.amount").attr("value",o);var i="";jQuery("#sortable li").each(function(e){var r=jQuery(this).data("id"),t=jQuery(this).find(".three-up input.amount").val();i+=r+":"+t+", "}),i=i.substr(0,i.length-2),jQuery("#custom-rating").html("{"+i+"}"),usingCustomOrder||updateOrder()})}function makeSortable(){jQuery("#sortable").sortable({items:"> li",handle:".move",opacity:".7",placeholder:"ui-state-highlight",update:function(e,r){updateOrder()}})}function updateOrder(){var e=jQuery("#sortable li").length,r="",t=[];jQuery("#sortable li").each(function(a){var o=jQuery(this).data("id");r+=o+":"+(e-a)+", ",jQuery(this).hasClass("disabled")&&t.push(o),jQuery(this).find(".new-tag").addClass("hidden")}),r=r.substr(0,r.length-2),jQuery("#custom-order").html("{"+r+"}"),jQuery("#removed-items").html(JSON.stringify(t)),usingCustomOrder=!0,jQuery("#using-custom-order").removeClass("hidden"),jQuery("#new-campaign-available").addClass("hidden")}function removeOrAddCampaign(){jQuery(".ui-state-default .removeOrAddCampaign").click(function(){var e=[];jQuery(this).parent().find(".three-up").toggleClass("removed"),jQuery(this).find("i").toggleClass("fa-check"),jQuery(this).find("i").toggleClass("fa-trash-o"),jQuery(this).parent().toggleClass("disabled"),jQuery("#sortable li").each(function(r){var t=jQuery(this).data("id");jQuery(this).hasClass("disabled")&&e.push(t)}),jQuery("#removed-items").html(JSON.stringify(e))})}function markAsDisabled(e,r){var t=e,a=Object.keys(r),o="false"!==jQuery("#include-new-campaigns").val(),i=!1;jQuery("#sortable li").each(function(e){var r=parseInt(jQuery(this).attr("data-id"));-1!==jQuery.inArray(r,t)?(jQuery(this).addClass("disabled"),jQuery(this).find(".three-up").addClass("removed"),jQuery(this).find(".removeOrAddCampaign i").addClass("fa-check"),jQuery(this).find(".removeOrAddCampaign i").removeClass("fa-trash-o")):a.length>0&&-1===a.indexOf(r.toString())&&(jQuery(this).find(".new-tag").removeClass("hidden"),i=!0,o?(jQuery(this).removeClass("disabled"),jQuery(this).find(".three-up").removeClass("removed"),jQuery(this).find(".removeOrAddCampaign i").removeClass("fa-check"),jQuery(this).find(".removeOrAddCampaign i").addClass("fa-trash-o")):(jQuery(this).addClass("disabled"),jQuery(this).find(".three-up").addClass("removed"),jQuery(this).find(".removeOrAddCampaign i").addClass("fa-check"),jQuery(this).find(".removeOrAddCampaign i").removeClass("fa-trash-o")))}),i?jQuery("#new-campaign-available").removeClass("hidden"):jQuery("#new-campaign-available").addClass("hidden")}function markAsLowEPC(){jQuery("#sortable li").each(function(e){var r=parseFloat(jQuery(this).attr("data-campEpc")),t=parseFloat(jQuery(this).attr("data-epcLimit"));r>=0&&t>0&&r<t&&jQuery(this).find(".low-epc-tag").removeClass("hidden")})}function updateMinRating(e){var r=jQuery(e).val();jQuery("#adminTableHolder").attr("data-minRating",r),jQuery("#adminTableHolder").adserviceFeed({reload:!0})}function updateUseIframe(e){var r=jQuery(e);r.prop("checked")?(usingIframe=!0,r.val("1"),jQuery("#adservice-comparison-feed .categoryFilter").slideUp(),jQuery("#as-iframe-options").slideDown(),jQuery("#as-feed-shortcode").html("[adservice-comparison-feed-iframe]")):(usingIframe=!1,r.val("0"),filterAvailable&&jQuery("#adservice-comparison-feed .categoryFilter").slideDown(),jQuery("#as-iframe-options").slideUp(),jQuery("#as-feed-shortcode").html("[adservice-comparison-feed]"))}function updateShowFilter(e){var r=jQuery(e);r.prop("checked")?r.val("1"):r.val("0")}function updateIncludeNewCampaigns(e){var r=jQuery(e);r.prop("checked")?r.val("true"):(r.val("false"),usingCustomOrder||updateOrder());markAsDisabled(getDisabledItems(),getCustomOrder())}function updateLazyLoading(e){var r=jQuery(e);r.prop("checked")?r.val("true"):r.val("false")}function jsonFix(e){return e.replace(/(\d*\.*\d+):/gm,'"$1":')}function exportFeed(e,r){var t=jQuery("#feedName").val().trim(),a=jQuery("#feedID").val().trim();if(jQuery("#feedName").css("border",""),jQuery("#feedID").css("border",""),t.length<4||t.length>32)return jQuery("#feedName").css("border","1px solid red"),jQuery("#export-feed-error").find("span").text("Name must be between 4 and 32 characters."),void jQuery("#export-feed-error").css("display","");if(a.length<4||a.length>32)return jQuery("#feedID").css("border","1px solid red"),jQuery("#export-feed-error").find("span").text("Feed ID must be between 4 and 32 characters."),void jQuery("#export-feed-error").css("display","");if(null===new RegExp(/(^[a-z])([a-z]|\-|\d)*([a-z\d]$)/g).exec(a))return jQuery("#feedID").css("border","1px solid red"),jQuery("#export-feed-error").find("span").text("Feed ID can have lowercase letters (no special characters), digits, or hyphens. It must start with a lowercase letter and end with a letter or number."),void jQuery("#export-feed-error").css("display","");var o={PID:e,LoginToken:r};jQuery.getJSON("https://feedcontentcloud.com/cgi-bin/publisher/API/ComparisonFeed/Feed.pl/"+a+"/available",o,function(e){if(e&&!1===e.available)return jQuery("#feedID").css("border","1px solid red"),jQuery("#export-feed-error").find("span").text("Feed ID is already in use."),void jQuery("#export-feed-error").css("display","");if(e&&e.error)return jQuery("#feedID").css("border","1px solid red"),jQuery("#export-feed-error").find("span").text("Checking feed ID availability failed."),void jQuery("#export-feed-error").css("display","");jQuery("#feedID").css("border",""),jQuery("#export-feed-error").find("span").text(""),jQuery("#export-feed-error").css("display","none");var r=jQuery("select#compare-account option:selected").data("accountname"),i=jQuery("select#compare-account option:selected").data("countryname"),d={id:a,name:t,agentId:parseInt(jQuery("select#compare-account option:selected").val()),categoryId:jQuery("select#compare-template option:selected").val(),type:usingIframe?"IFRAME":"REGULAR",settings:{showFilter:1==jQuery("#using-filter-shortcode").val()||1==jQuery("#show-filter").val()&&usingIframe?1:0,includeNewCampaigns:"true"===jQuery("#include-new-campaigns").val(),lazyLoading:"true"===jQuery("#lazy-loading").val(),color:jQuery("#button-color").val().substr(1),hColor:jQuery("#button-hover-color").val().substr(1),fontUrl:jQuery("#font-url").val(),fontName:jQuery("#font-name").val(),removedItems:getDisabledItems(),conditions:getConditions(),customOrder:getCustomOrder(),customRating:getCustomRating(),initialRows:jQuery("#initial-rows").val(),maxRows:jQuery("#max-rows").val(),minRating:jQuery("#min-rating").val(),sub:jQuery("#subID").val(),media_id:Number(jQuery("#mediaID").val())}},n=jQuery.extend(!0,{},d,o);n.settings=JSON.stringify(n.settings),jQuery.ajax({method:"POST",url:"https://feedcontentcloud.com/cgi-bin/publisher/API/ComparisonFeed/Feed.pl/"+n.id,data:n}).done(function(e){e&&"OK"===e.status?(jQuery("#export-feed-completed-section").find("span:eq(0)").text(n.id),jQuery("#export-feed-completed-section").find("span:eq(1)").text(r),jQuery("#export-feed-completed-section").find("span:eq(2)").text(i),jQuery("#export-feed-completed-section").find("code").text("[adservice-comparison-feed feed="+n.id+"]"),jQuery("#export-feed-section").hide(),jQuery("#export-feed-completed-section").show(),jQuery("#feed-id").val(n.id),jQuery("#feed-id").attr("value",n.id),alert("Feed '"+n.id+"' was successfully exported."),jQuery("#publish")>0?jQuery("#publish").click():jQuery(".components-button.editor-post-publish-button").click()):e&&"ERROR"===e.status?alert("Received the following error when trying to export the feed: "+e.msg):alert("Something went wrong when trying to export the feed.")}).fail(function(e){alert("Request to export feed failed.")})})}var filterAvailable=!1,usingCustomOrder=!1,usingIframe=!1,feedOperators=[{operator:"lessThan",name:"less than or equal to"},{operator:"greaterThan",name:"greater than or equal to"},{operator:"equals",name:"equal to"},{operator:"notEquals",name:"not equal to"},{operator:"contains",name:"contains"},{operator:"notContains",name:"not contains"}],feedFields=[],feedFieldsCache={};jQuery(document).ready(function(){1==jQuery("#use-iframe").val()?(usingIframe=!0,jQuery("#use-iframe").prop("checked",!0),jQuery("#as-iframe-options").show()):jQuery("#use-iframe").prop("checked",!1),1==jQuery("#show-filter").val()?jQuery("#show-filter").prop("checked",!0):jQuery("#show-filter").prop("checked",!1),"true"===jQuery("#include-new-campaigns").val()?jQuery("#include-new-campaigns").prop("checked",!0):jQuery("#include-new-campaigns").prop("checked",!1),"true"===jQuery("#lazy-loading").val()?jQuery("#lazy-loading").prop("checked",!0):jQuery("#lazy-loading").prop("checked",!1),initTpl(),jQuery("#adservice-comparison-feed select#compare-account, #adservice-comparison-feed select#compare-template").change(function(){jQuery("#conditions").html(""),jQuery("#adminTableHolder").attr("data-conditions",""),initTpl()}),jQuery(".as-tab, .as-tab-link").click(function(){var e=jQuery(this).data("anchor");if(jQuery(".as-tab").removeClass("active"),jQuery(e+"-tab").addClass("active"),jQuery(".as-anchor").removeClass("active"),jQuery(e).addClass("active"),"#as-feed-builder"===e)jQuery("#adservice-comparison-feed .code-generated").hide(),jQuery("#adservice-comparison-feed .legal-notice").hide();else{var r=jQuery("select#compare-account option:selected").data("country"),t=jQuery("select#compare-template option:selected").val();(""!==r||r>0)&&"0"!==t&&(jQuery("#adservice-comparison-feed .code-generated").slideDown(),jQuery("#adservice-comparison-feed .legal-notice").slideDown())}})});