| 1 |
window.onload = function () { |
| 2 |
var __tagembed__plugin_deactivate_btn = document.querySelector('[data-slug="tagembed-widget"] .deactivate a'); |
| 3 |
if (__tagembed__plugin_deactivate_btn) { |
| 4 |
__tagembed__plugin_deactivate_btn.addEventListener('click', function (event) { |
| 5 |
event.preventDefault(); |
| 6 |
let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`; |
| 7 |
elemHTML = `${elemHTML} <button onclick="__tagembed__hidePluginDeactivePopup();" type="button" class="__tagembed__closebtn"></button>`; |
| 8 |
elemHTML = `${elemHTML} <div class="__tagembed__popupinn">`; |
| 9 |
elemHTML = `${elemHTML} <div class="__tagembed__header"><h2>Feedback</h2></div>`; |
| 10 |
elemHTML = `${elemHTML} <hr class="__tagembed__horizontaborder">`; |
| 11 |
elemHTML = `${elemHTML} <div class="__tagembed__formwbody">`; |
| 12 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow">`; |
| 13 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero" >`; |
| 14 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason1">I found a better plugin</label> `; |
| 15 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason1" onclick="__tagembed__pluginDeactivateReason(1);" type="radio" name="__tagembed__pluginDeactivateReason" value="I found a better plugin"> `; |
| 16 |
elemHTML = `${elemHTML} </div>`; |
| 17 |
elemHTML = `${elemHTML} <div id="__tagembed__betterPluginDiv" class="__tagembed__formwrow" style="display:none;margin-left: 25px;">`; |
| 18 |
elemHTML = `${elemHTML} <input type="text" id="__tagembed__better_plugin_input" name="__tagembed__betterPluginInputInput" placeholder="What's the plugin's name?"> `; |
| 19 |
elemHTML = `${elemHTML} </div>`; |
| 20 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 21 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason2">I only needed the plugin for a short period</label> `; |
| 22 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason2" onclick="__tagembed__pluginDeactivateReason(2);" type="radio" name="__tagembed__pluginDeactivateReason" value="I only needed the plugin for a short period"> `; |
| 23 |
elemHTML = `${elemHTML} </div>`; |
| 24 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 25 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason3">The plugin broke my site</label> `; |
| 26 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason3" onclick="__tagembed__pluginDeactivateReason(3);" type="radio" name="__tagembed__pluginDeactivateReason" value="The plugin broke my site"> `; |
| 27 |
elemHTML = `${elemHTML} </div>`; |
| 28 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 29 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason4">I no longer need the plugin</label> `; |
| 30 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason4" onclick="__tagembed__pluginDeactivateReason(4);" type="radio" name="__tagembed__pluginDeactivateReason" value="I no longer need the plugin"> `; |
| 31 |
elemHTML = `${elemHTML} </div>`; |
| 32 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 33 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason5">The plugin suddenly stopped working</label> `; |
| 34 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason5" onclick="__tagembed__pluginDeactivateReason(5);" type="radio" name="__tagembed__pluginDeactivateReason" value="The plugin suddenly stopped working"> `; |
| 35 |
elemHTML = `${elemHTML} </div>`; |
| 36 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 37 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason6">It's a temporary deactivation. I'm just debugging an issue</label> `; |
| 38 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason6" onclick="__tagembed__pluginDeactivateReason(6);" type="radio" name="__tagembed__pluginDeactivateReason" value="It is a temporary deactivation. I am just debugging an issue"> `; |
| 39 |
elemHTML = `${elemHTML} </div>`; |
| 40 |
elemHTML = `${elemHTML} <div class="__tagembed__formwrow __tagembed__checkboxrow __tagembed__mbzero">`; |
| 41 |
elemHTML = `${elemHTML} <label for="__tagembed__pluginDeactivateReason7">Other</label> `; |
| 42 |
elemHTML = `${elemHTML} <input id="__tagembed__pluginDeactivateReason7" onclick="__tagembed__pluginDeactivateReason(7);" type="radio" name="__tagembed__pluginDeactivateReason" value="Other"> `; |
| 43 |
elemHTML = `${elemHTML} </div>`; |
| 44 |
elemHTML = `${elemHTML} <div id="__tagembed__otherReasonDiv" class="__tagembed__formwrow" style="display:none;margin-left: 25px;">`; |
| 45 |
elemHTML = `${elemHTML} <input id="__tagembed__other_reason_input" type="text" name="__tagembed__OtherReasonInput" placeholder="Kindly Tell Us The Reason So We Can Improve"> `; |
| 46 |
elemHTML = `${elemHTML} </div>`; |
| 47 |
elemHTML = `${elemHTML} </div></div>`; |
| 48 |
elemHTML = `${elemHTML} <div class = "__tagembed__btnwrap text-center">`; |
| 49 |
elemHTML = `${elemHTML} <button id="__tagembed__pluginDeactivateBtn" onclick="__tagembed__deactivatePlugin();" class="__tagembed__okaybtn __tagembed__bg-danger">Skip & Deactivate</button>`; |
| 50 |
elemHTML = `${elemHTML} <button class="__tagembed__okaybtn" onclick="__tagembed__hidePluginDeactivePopup();">Cencel</button>`; |
| 51 |
elemHTML = `${elemHTML} </div></div></div>`; |
| 52 |
let __tagembed__deactivatePopupNode = document.createElement('div'); |
| 53 |
__tagembed__deactivatePopupNode.setAttribute("id", "__tagembed__plugin_deactivate_popup"); |
| 54 |
__tagembed__deactivatePopupNode.setAttribute("class", "__tagembed__overlay"); |
| 55 |
__tagembed__deactivatePopupNode.innerHTML = elemHTML; |
| 56 |
document.body.appendChild(__tagembed__deactivatePopupNode); |
| 57 |
}); |
| 58 |
} |
| 59 |
} |
| 60 |
function __tagembed__hidePluginDeactivePopup() { |
| 61 |
let __tagembed__plugin_deactivate_popup = document.querySelector("#__tagembed__plugin_deactivate_popup"); |
| 62 |
__tagembed__plugin_deactivate_popup.remove(); |
| 63 |
} |
| 64 |
function __tagembed__pluginDeactivateReason(__tagembed__pluginDeactivateReason) { |
| 65 |
document.querySelector("#__tagembed__other_reason_input").value = ""; |
| 66 |
document.querySelector("#__tagembed__better_plugin_input").value = ""; |
| 67 |
let __tagembed__pluginDeactivateBtn = document.querySelector("#__tagembed__pluginDeactivateBtn"); |
| 68 |
__tagembed__pluginDeactivateBtn.innerHTML = "Submit & Deactivate"; |
| 69 |
let __tagembed__betterPluginDiv = document.querySelector("#__tagembed__betterPluginDiv"); |
| 70 |
__tagembed__betterPluginDiv.style.display = "none"; |
| 71 |
let __tagembed__otherReasonDiv = document.querySelector("#__tagembed__otherReasonDiv"); |
| 72 |
__tagembed__otherReasonDiv.style.display = "none"; |
| 73 |
if (__tagembed__pluginDeactivateReason == 7) |
| 74 |
__tagembed__otherReasonDiv.style.display = "block"; |
| 75 |
if (__tagembed__pluginDeactivateReason == 1) |
| 76 |
__tagembed__betterPluginDiv.style.display = "block"; |
| 77 |
} |
| 78 |
function __tagembed__deactivatePlugin() { |
| 79 |
__tagembed__open_loader(); |
| 80 |
let __tagembed__ajax_call_url = window.location.href; |
| 81 |
__tagembed__ajax_call_url = __tagembed__ajax_call_url.replace("plugins.php", "admin-ajax.php"); |
| 82 |
let __tagembed__other_reason_input = document.querySelector("#__tagembed__other_reason_input").value; |
| 83 |
let __tagembed__better_plugin_input = document.querySelector("#__tagembed__better_plugin_input").value; |
| 84 |
let __tagembed__pluginDeactivateReason = document.querySelector('input[name="__tagembed__pluginDeactivateReason"]:checked'); |
| 85 |
if (__tagembed__pluginDeactivateReason) { |
| 86 |
__tagembed__pluginDeactivateReason = __tagembed__pluginDeactivateReason.value; |
| 87 |
} else { |
| 88 |
__tagembed__pluginDeactivateReason = ""; |
| 89 |
} |
| 90 |
let formData = new FormData(); |
| 91 |
formData.append('action', 'data'); |
| 92 |
formData.append('__tagembed__ajax_action', '__tagembed__plugin_deactivate'); |
| 93 |
formData.append('betterPlugin', __tagembed__better_plugin_input); |
| 94 |
formData.append('otherReason', __tagembed__other_reason_input); |
| 95 |
formData.append('pluginDeactivateReason', __tagembed__pluginDeactivateReason); |
| 96 |
fetch(__tagembed__ajax_call_url, { |
| 97 |
method: 'POST', |
| 98 |
headers: { |
| 99 |
'x-requested-with': 'XMLHttpRequest', |
| 100 |
}, |
| 101 |
body: formData, |
| 102 |
}).then(response => { |
| 103 |
return response.json() |
| 104 |
}).then(response => { |
| 105 |
if (response.status == true) { |
| 106 |
location.reload(); |
| 107 |
} else { |
| 108 |
__tagembed__close_loader(); |
| 109 |
console.log(error); |
| 110 |
} |
| 111 |
}).catch((error) => { |
| 112 |
__tagembed__close_loader(); |
| 113 |
console.log(error); |
| 114 |
}); |
| 115 |
} |
| 116 |
|