'
);
};
$(".TTWForm").on("click", "[data-popup-field-name]", function (e) {
e.preventDefault();
if (
jQuery(this).attr("data-popup-field-name") != "" &&
jQuery("#camp_type").val() != "Feeds"
) {
// a specific field exists
var mySrc = jQuery(
'*[name="' + jQuery(this).attr("data-popup-field-name") + '"]'
).val();
} else {
var mySrc = jQuery(
"*[data-visual-selector-" + jQuery("#camp_type").val() + "]"
).val();
}
// Single page and multi-page cookie
var theCookie = jQuery('[name="cg_sn_cookie"]').val();
if (theCookie == "") {
theCookie = jQuery('[name="cg_ml_cookie"]').val();
}
var theTrigger = this;
if (mySrc.indexOf("http") == -1) {
// not valid URL
alert("Please add a valid source URL");
return;
}
var which = jQuery(theTrigger)
.parent()
.parent()
.find('input[type="text"]')
.attr("name");
var iframeUrl =
ajaxurl +
"?action=wp_automatic_iframe&address=" +
encodeURIComponent(mySrc) +
"&theCookie=" +
encodeURIComponent(theCookie) +
"&nonce=" + jQuery("#wp_automatic_nonce_field").val();
// Encoding
if (jQuery('input[value="OPT_FEED_ENCODING"]').prop("checked") == true) {
iframeUrl = iframeUrl + "&clean_encoding=yes";
}
console.log(which);
//JS support
if (which == "cg_ml_visual[]" || which == "cg_feed_visual[]") {
//single posts on feeds and multi-page scraper
if (jQuery('input[value="OPT_FEED_APIFY"]').prop("checked") == true) {
iframeUrl = iframeUrl + "&js_enabled=yes";
}
//read input with name cg_apify_wait_for and add it to the iframe url
var wait_for = jQuery('input[name="cg_apify_wait_for_single"]').val();
if (wait_for != "") {
iframeUrl = iframeUrl + "&wait_for=" + wait_for;
}
//read initial cookies field cg_ml_cookie
var initial_cookies = jQuery('input[name="cg_ml_cookie"]').val();
if (initial_cookies != "") {
//url encode the initial cookies
initial_cookies = encodeURIComponent(initial_cookies);
iframeUrl = iframeUrl + "&initial_cookies=" + initial_cookies;
}
} else if (which == "cg_ml_lnk_visual[]") {
if (jQuery('input[value="OPT_FEED_APIFY2"]').prop("checked") == true) {
iframeUrl = iframeUrl + "&js_enabled=yes";
}
//read input with name cg_apify_wait_for and add it to the iframe url
var wait_for = jQuery('input[name="cg_apify_wait_for"]').val();
if (wait_for != "") {
iframeUrl = iframeUrl + "&wait_for=" + wait_for;
}
} else {
//OPT_FEED_APIFY : single page scraper
if (
jQuery('input[value="OPT_FEED_APIFY"]').prop("checked") == true ||
jQuery('input[value="OPT_FEED_APIFY2"]').prop("checked") == true
) {
iframeUrl = iframeUrl + "&js_enabled=yes";
//read input with name cg_apify_wait_for and add it to the iframe url
var wait_for = jQuery('input[name="cg_apify_wait_for_single"]').val();
if (wait_for != "") {
iframeUrl = iframeUrl + "&wait_for=" + wait_for;
}
}
}
// SOURCE campaign type
iframeUrl = iframeUrl + "&sourse=" + jQuery("#camp_type").val();
// WHICH button
iframeUrl = iframeUrl + "&which=" + which;
$(".wmBox_overlay .wmBox_scaleWrap").append(
'