Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/aimogen-pro/scripts/footer.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + "use strict";
2 + jQuery(document).ready(function(){
3 + jQuery('span.wpaiomatic-delete').on('click', function(){
4 + var confirm_delete = confirm('Delete This Rule?');
5 + if (confirm_delete) {
6 + jQuery(this).parent().parent().remove();
7 + jQuery('#myForm').submit();
8 + }
9 + });
10 + });
11 + var unsaved = false;
12 + jQuery(document).ready(function () {
13 + jQuery(":input").on('change', function(){
14 + if(this !== undefined)
15 + {
16 + var classes = this.className;
17 + var classes = this.className.split(' ');
18 + var found = jQuery.inArray('actions', classes) > -1;
19 + if(this.id != 'select-shortcode' && this.id != 'PreventChromeAutocomplete' && this.id != 'editor_select_template' && this.className != 'sc_chat_form_field_prompt_text' && this.id != 'actions' && this.className != 'codemainfzr' && !found)
20 + {
21 + unsaved = true;
22 + }
23 + }
24 + });
25 + function unloadPage(){
26 + if(unsaved){
27 + return "You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?";
28 + }
29 + }
30 + window.onbeforeunload = unloadPage;
31 + });
32 +
33 + function deletePostsManual(number, type, typeId, uniquid)
34 + {
35 + if (confirm("Are you sure you want to delete all posts generated by this rule?") == true) {
36 + document.getElementById("run_img" + number).style.visibility = "visible";
37 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/running.gif";
38 + var data = {
39 + action: 'aiomatic_my_action',
40 + id: uniquid,
41 + how: type,
42 + type: typeId,
43 + nonce: mycustomsettings.nonce
44 + };
45 + jQuery.post(mycustomsettings.ajaxurl, data, function(response) {
46 + if(response.trim() == 'ok')
47 + {
48 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/ok.gif";
49 + }
50 + else
51 + {
52 + if(response.trim() == 'nochange')
53 + {
54 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/nochange.gif";
55 + }
56 + else
57 + {
58 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
59 + }
60 + }
61 + }).fail( function(xhr)
62 + {
63 + console.log('Error occured in processing: ' + xhr.statusText + ' - please check plugin\'s \'Activity and Logging\' menu for details.');
64 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
65 + });
66 + } else {
67 + return;
68 + }
69 + }
70 + function myAIGetDateTime() {
71 + var now = new Date();
72 + var year = now.getFullYear();
73 + var month = now.getMonth()+1;
74 + var day = now.getDate();
75 + var hour = now.getHours();
76 + var minute = now.getMinutes();
77 + var second = now.getSeconds();
78 + if(month.toString().length == 1) {
79 + month = '0'+month;
80 + }
81 + if(day.toString().length == 1) {
82 + day = '0'+day;
83 + }
84 + if(hour.toString().length == 1) {
85 + hour = '0'+hour;
86 + }
87 + if(minute.toString().length == 1) {
88 + minute = '0'+minute;
89 + }
90 + if(second.toString().length == 1) {
91 + second = '0'+second;
92 + }
93 + var dateTime = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
94 + return dateTime;
95 + }
96 + function runNowManual(number, typeId)
97 + {
98 + if (confirm("Are you sure you want to run this rule now?") == true) {
99 + document.getElementById("run_img" + number).style.visibility = "visible";
100 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/running.gif";
101 + var data = {
102 + action: 'aiomatic_run_my_action',
103 + id: number,
104 + type: typeId,
105 + nonce: mycustomsettings.nonce
106 + };
107 + var pollingInterval;
108 + function startPolling() {
109 + pollingInterval = setInterval(function()
110 + {
111 + jQuery.get(mycustomsettings.ajaxurl, { action: 'aiomatic_check_process_status', nonce: mycustomsettings.bulk_nonce }, function(response)
112 + {
113 + if (response.status === 'success')
114 + {
115 + var datetime = myAIGetDateTime();
116 + jQuery('#running_status_ai').html('<hr/><b>Activity Log:</b><br/><br/>' + datetime + ':<br/> ' + response.msg);
117 + }
118 + else
119 + {
120 + console.log('Failed to poll results: ' + response);
121 + clearInterval(pollingInterval);
122 + }
123 + }).fail(function(xhr)
124 + {
125 + clearInterval(pollingInterval);
126 + console.log('Exception in results polling: ' + JSON.stringify(xhr));
127 + });
128 + }, 3000);
129 + }
130 + jQuery.post(mycustomsettings.ajaxurl, data, function(response) {
131 + if(response.trim() == 'ok')
132 + {
133 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/ok.gif";
134 + }
135 + else
136 + {
137 + if(response.trim() == 'nochange')
138 + {
139 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/nochange.gif";
140 + }
141 + else
142 + {
143 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
144 + }
145 + }
146 + if(mycustomsettings.more_logs == '1')
147 + {
148 + clearInterval(pollingInterval);
149 + }
150 + }).fail( function(xhr)
151 + {
152 + console.log('Error occured in processing: ' + xhr.statusText + ' - please check plugin\'s \'Activity and Logging\' menu for details.');
153 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
154 + if(mycustomsettings.more_logs == '1')
155 + {
156 + clearInterval(pollingInterval);
157 + }
158 + });
159 + if(mycustomsettings.more_logs == '1')
160 + {
161 + startPolling();
162 + }
163 + } else {
164 + return;
165 + }
166 + }
167 +
168 + function duplicatePostsManual(number, type, typeId)
169 + {
170 + if (confirm("Are you sure you want to duplicate this rule?") == true) {
171 + document.getElementById("run_img" + number).style.visibility = "visible";
172 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/running.gif";
173 + var data = {
174 + action: 'aiomatic_my_action',
175 + id: number,
176 + how: type,
177 + type: typeId,
178 + nonce: mycustomsettings.nonce
179 + };
180 + jQuery.post(mycustomsettings.ajaxurl, data, function(response) {
181 + if(response.trim() == 'ok')
182 + {
183 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/ok.gif";
184 + location.reload();
185 + }
186 + else
187 + {
188 + if(response.trim() == 'nochange')
189 + {
190 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/nochange.gif";
191 + }
192 + else
193 + {
194 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
195 + }
196 + }
197 + }).fail( function(xhr)
198 + {
199 + console.log('Error occured in processing: ' + xhr.statusText + ' - please check plugin\'s \'Activity and Logging\' menu for details.');
200 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
201 + });
202 + } else {
203 + return;
204 + }
205 + }
206 + function movePostOrder(number, selectedValue, type, typeId)
207 + {
208 + document.getElementById("run_img" + number).style.visibility = "visible";
209 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/running.gif";
210 + var data = {
211 + action: 'aiomatic_my_action_move',
212 + id: number,
213 + how: selectedValue,
214 + type: type,
215 + nonce: mycustomsettings.nonce
216 + };
217 + jQuery.post(mycustomsettings.ajaxurl, data, function(response) {
218 + if(response.trim() == 'ok')
219 + {
220 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/ok.gif";
221 + location.reload();
222 + }
223 + else
224 + {
225 + if(response.trim() == 'nochange')
226 + {
227 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/nochange.gif";
228 + }
229 + else
230 + {
231 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
232 + }
233 + }
234 + }).fail( function(xhr)
235 + {
236 + console.log('Error occured in processing: ' + xhr.statusText + ' - please check plugin\'s \'Activity and Logging\' menu for details.');
237 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
238 + });
239 + }
240 + function eraseManual(number)
241 + {
242 + if (confirm("Are you sure you want to erase processed keywords by this rule?") == true) {
243 + document.getElementById("run_img" + number).style.visibility = "visible";
244 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/running.gif";
245 + var data = {
246 + action: 'aiomatic_erase_action',
247 + id: number,
248 + nonce: mycustomsettings.nonce
249 + };
250 + jQuery.post(mycustomsettings.ajaxurl, data, function(response) {
251 + if(response.trim() == 'ok')
252 + {
253 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/ok.gif";
254 + location.reload();
255 + }
256 + else
257 + {
258 + if(response.trim() == 'nochange')
259 + {
260 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/nochange.gif";
261 + }
262 + else
263 + {
264 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
265 + }
266 + }
267 + }).fail( function(xhr)
268 + {
269 + console.log('Error occured in processing: ' + xhr.statusText + ' - please check plugin\'s \'Activity and Logging\' menu for details.');
270 + document.getElementById("run_img" + number).src= mycustomsettings.plugin_dir_url + "images/failed.gif";
271 + });
272 + } else {
273 + return;
274 + }
275 + }
276 + function go_change_cats(sel, which)
277 + {
278 + var postType = sel && sel.value ? sel.value : 'post';
279 + var $select = jQuery('#default_category' + which);
280 + $select.prop('disabled', true);
281 + var prevSelected = $select.val() || [];
282 + jQuery.post(
283 + mycustomsettings.ajaxurl,
284 + {
285 + action: 'aiomatic_get_terms',
286 + nonce: mycustomsettings.nonce,
287 + post_type: postType
288 + }
289 + ).done(function(resp) {
290 + $select.empty();
291 + $select.append(
292 + jQuery('<option/>', {
293 + value: 'aiomatic_no_category_12345678',
294 + text: 'Do Not Add a Category',
295 + selected: prevSelected.length === 0 || prevSelected.includes('aiomatic_no_category_12345678')
296 + })
297 + );
298 + if (resp && resp.success && Array.isArray(resp.data)) {
299 + resp.data.forEach(function(t) {
300 + $select.append(
301 + jQuery('<option/>', {
302 + value: String(t.id),
303 + text: t.name + ' - ID ' + t.id,
304 + selected: prevSelected.includes(String(t.id))
305 + })
306 + );
307 + });
308 + }
309 + }).always(function() {
310 + $select.prop('disabled', false);
311 + $select.trigger('change');
312 + });
313 + }
314 + function actionsChangedManual(ruleId, selectedValue, typeId, uniquid)
315 + {
316 + if (selectedValue==='run')
317 + {
318 + if(unsaved){
319 + alert("You have unsaved changes on this page. Please save your changes before manually running rules!");
320 + return;
321 + }
322 + runNowManual(ruleId, typeId);
323 + }
324 + else
325 + {
326 + if (selectedValue==='erase')
327 + {
328 + if(unsaved){
329 + alert("You have unsaved changes on this page. Please save your changes before manually erasing the rule keywords list!");
330 + return;
331 + }
332 + eraseManual(ruleId);
333 + }
334 + else
335 + {
336 + if (selectedValue==='duplicate')
337 + {
338 + if(unsaved){
339 + alert("You have unsaved changes on this page. Please save your changes before manually erasing the rule keywords list!");
340 + return;
341 + }
342 + duplicatePostsManual(ruleId, 'duplicate', typeId);
343 + }
344 + else
345 + {
346 + if (selectedValue==='up' || selectedValue==='down')
347 + {
348 + if(unsaved){
349 + alert("You have unsaved changes on this page. Please save your changes before manually erasing the rule keywords list!");
350 + return;
351 + }
352 + movePostOrder(ruleId, selectedValue, typeId, uniquid);
353 + }
354 + else
355 + {
356 + if (selectedValue==='trash')
357 + {
358 + deletePostsManual(ruleId, 'trash', typeId, uniquid);
359 + }
360 + else
361 + {
362 + deletePostsManual(ruleId, 'delete', typeId, uniquid);
363 + }
364 + }
365 + }
366 + }
367 + }
368 + }
369 + function assistantSelected(ruleid)
370 + {
371 + var selected = jQuery('#assistant_id' + ruleid).val();
372 + if(selected == '' || selected == null)
373 + {
374 + jQuery('.hideAssistant' + ruleid).find('option').removeAttr('disabled');
375 + }
376 + else
377 + {
378 + var selectElement = jQuery('.hideAssistant' + ruleid);
379 + var selectedValue = selectElement.val();
380 + jQuery('.hideAssistant' + ruleid).find('option').attr('disabled', 'disabled');
381 + selectElement.find('option[value="' + selectedValue + '"]').removeAttr('disabled');
382 + }
383 + }
384 + jQuery(document).ready(function() {
385 +
386 + jQuery('.aiomatic_image_button').on('click', function(){
387 + tb_show('',"media-upload.php?type=image&TB_iframe=true");
388 + window.send_to_editor = function(html) {
389 + var url = jQuery(html).attr('src');
390 + jQuery('#cr_input_box').val(url);
391 + tb_remove();
392 + };
393 + });
394 + });
395 + function thisonChangeHandler(cb) {
396 + if(cb.checked == true)
397 + {
398 + jQuery("input.activateDeactivateClass:checkbox").each( function () {
399 + jQuery(this).prop('checked', true);
400 + });
401 + }
402 + else
403 + {
404 + jQuery("input.activateDeactivateClass:checkbox").each( function () {
405 + jQuery(this).prop('checked', false);
406 + });
407 + }
408 + }
409 + var codemodalfzr = document.getElementById('mymodalfzr');
410 + var btn = document.getElementById("mybtnfzr");
411 + var span = document.getElementById("aiomatic_close");
412 + var ok = document.getElementById("aiomatic_ok");
413 + if(btn != null)
414 + {
415 + btn.onclick = function() {
416 + codemodalfzr.style.display = "block";
417 + }
418 + }
419 + if(span != null)
420 + {
421 + span.onclick = function() {
422 + codemodalfzr.style.display = "none";
423 + }
424 + }
425 + if(ok != null)
426 + {
427 + ok.onclick = function() {
428 + codemodalfzr.style.display = "none";
429 + }
430 + }
431 + var codemodalauto = document.getElementById('mymodalauto');
432 + var btn = document.getElementById("mybtnauto");
433 + var span = document.getElementById("aiomatic_auto_close");
434 + var ok = document.getElementById("aiomatic_auto_ok");
435 + if(btn != null)
436 + {
437 + btn.onclick = function() {
438 + codemodalauto.style.display = "block";
439 + }
440 + }
441 + if(span != null)
442 + {
443 + span.onclick = function() {
444 + codemodalauto.style.display = "none";
445 + }
446 + }
447 + if(ok != null)
448 + {
449 + ok.onclick = function() {
450 + codemodalauto.style.display = "none";
451 + }
452 + }
453 + window.onclick = function(event) {
454 + if (codemodalauto != null && event.target == codemodalauto) {
455 + codemodalauto.style.display = "none";
456 + }
457 + else if (event.target == codemodalfzr) {
458 + codemodalfzr.style.display = "none";
459 + }
460 + }
461 + jQuery("#myForm").on('submit', function (e) {
462 + jQuery(this).on('submit', function() {
463 + return false;
464 + });
465 +
466 + e.preventDefault();
467 + var changedCheckboxes = [];
468 +
469 + var this_master = jQuery(this);
470 + jQuery('button[type=submit], input[type=submit]').prop('disabled',true);
471 + this_master.find('input[type="checkbox"]').each( function () {
472 + var checkbox_this = jQuery(this);
473 +
474 + if (checkbox_this.attr("id") !== "exclusion")
475 + {
476 + if( checkbox_this.is(":checked") == true ) {
477 + checkbox_this.attr('value','1');
478 + } else {
479 + checkbox_this.prop('checked',true);
480 + checkbox_this.attr('value','0');
481 + changedCheckboxes.push(checkbox_this);
482 + }
483 + }
484 + });
485 + if (typeof mycustomsettings.max_input_vars !== 'undefined' && jQuery('input, textarea, select, button').length >= mycustomsettings.max_input_vars) {
486 + this_master.append("<span style='color:red;'>Saving settings, please wait...</span>");
487 + var coderevolution_max_input_var_data = this_master.serialize();
488 + this_master.find("table").remove();
489 + this_master.append("<input type='hidden' class='coderevolution_max_input_var_data' name='coderevolution_max_input_var_data'/>");
490 + this_master.find("input.coderevolution_max_input_var_data").val(coderevolution_max_input_var_data);
491 + }
492 + setTimeout(() => {
493 + this.submit();
494 + changedCheckboxes.forEach(function(item) {
495 + item.prop('checked', false);
496 + });
497 + }, 10);
498 + });
499 + function createAdmin(i) {
500 + var modals = [];
501 + var btns = [];
502 + var spans = [];
503 + var oks = [];
504 + var btns = [];
505 + modals = document.getElementById("mymodalfzr" + i);
506 + btns = document.getElementById("mybtnfzr" + i);
507 + spans = document.getElementById("aiomatic_close" + i);
508 + oks = document.getElementById("aiomatic_ok" + i);
509 + btns.onclick = function(e) {
510 + modals.style.display = "block";
511 + }
512 + spans.onclick = function(e) {
513 + modals.style.display = "none";
514 + }
515 + oks.onclick = function(e) {
516 + modals.style.display = "none";
517 + }
518 + modals.addEventListener("click", function(e) {
519 + if (e.target !== this)
520 + return;
521 + modals.style.display = "none";
522 + }, false);
523 + }