From 4f8325247eaa340094348cd091416aa888f37fcb Mon Sep 17 00:00:00 2001 From: progreccor Date: Thu, 17 Jun 2021 11:23:42 +0300 Subject: [PATCH] ver. 3.0.2 --- media/js/adminscript.js | 76 ++++++++++++++++++++++--------------- media/js/adminscript.min.js | 2 +- media/js/script.js | 12 +++--- media/js/script.min.js | 2 +- radicalform.php | 10 ++--- radicalform.xml | 6 +-- 6 files changed, 59 insertions(+), 49 deletions(-) diff --git a/media/js/adminscript.js b/media/js/adminscript.js index 1821c88..249d232 100644 --- a/media/js/adminscript.js +++ b/media/js/adminscript.js @@ -16,43 +16,57 @@ jQuery(document).ready(function () { page; currentGetParams = getUrlParams(location.search); - document.querySelector("#historyclear").addEventListener('click', function (event) { - $("#historyclear").html("Wait...") - .prop('disabled', true); - if ('page' in currentGetParams ) - { - page=currentGetParams.page; - } - else - { - page="0"; - } + var historyClear = document.querySelector("#historyclear"); + if(historyClear) + { + historyClear.addEventListener('click', function (event) { + historyClear.innerHTML = "Wait..."; + historyClear.disabled = true; + if ('page' in currentGetParams ) + { + page=currentGetParams.page; + } + else + { + page="0"; + } - $.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=2&page="+page, function (data) { - location.reload(); - }); + $.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=2&page="+page, function (data) { + location.reload(); + }); - event.preventDefault(); - }); + event.preventDefault(); + }); + } - document.querySelector("#numberclear").addEventListener('click', function (event) { - $("#numberclear").html("Wait...") - .prop('disabled', true); - $.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=3", function (data) { - location.reload(); + var numberClear = document.querySelector("#numberclear"); + if(numberClear) + { + numberClear.addEventListener('click', function (event) { + numberClear.innerHTML = "Wait..."; + numberClear.disabled = true; + $.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=3", function (data) { + location.reload(); + }); + event.preventDefault(); }); - event.preventDefault(); - }); + } - document.querySelector("#exportcsv").addEventListener('click', function (event) { - var t=document.querySelector("#exportcsv"); - var temp=t.outerHTML; - t.outerHTML=""; + var exportCSV = document.querySelector("#exportcsv"); + if(exportCSV) + { + exportCSV.addEventListener('click', function (event) { + var temp=exportCSV.innerHTML; + exportCSV.innerHTML = "Wait..."; + exportCSV.disabled = true; + + setTimeout(function () { + exportCSV.innerHTML = temp; + exportCSV.disabled = false; + }, 3000) + }); + } - setTimeout(function () { - document.querySelector("#exportcsv").outerHTML=temp; - }, 3000) - }); diff --git a/media/js/adminscript.min.js b/media/js/adminscript.min.js index af8a382..47c0b81 100644 --- a/media/js/adminscript.min.js +++ b/media/js/adminscript.min.js @@ -1 +1 @@ -jQuery(document).ready(function(){jQuery(function($){function getUrlParams(url){var regex=/[?&]([^=#]+)=([^&#]*)/g,params={},match;while(match=regex.exec(url)){params[match[1]]=match[2]}return params}var currentGetParams,page;currentGetParams=getUrlParams(location.search);document.querySelector("#historyclear").addEventListener("click",function(event){$("#historyclear").html("Wait...").prop("disabled",true);if("page"in currentGetParams){page=currentGetParams.page}else{page="0"}$.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=2&page="+page,function(data){location.reload()});event.preventDefault()});document.querySelector("#numberclear").addEventListener("click",function(event){$("#numberclear").html("Wait...").prop("disabled",true);$.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=3",function(data){location.reload()});event.preventDefault()});document.querySelector("#exportcsv").addEventListener("click",function(event){var t=document.querySelector("#exportcsv");var temp=t.outerHTML;t.outerHTML="";setTimeout(function(){document.querySelector("#exportcsv").outerHTML=temp},3e3)});[].forEach.call(document.querySelectorAll("#attrib-list label.btn"),function(el){el.addEventListener("click",function(e){if(!document.querySelector("#attrib-list .alert.alert-info.hidden"))return;document.querySelector("#attrib-list .alert.alert-info.hidden").classList.remove("hidden")})});document.querySelector("#radicalformcheck").addEventListener("click",function(event){var radicalformcheck=document.querySelector("#radicalformcheck"),temp=radicalformcheck.innerHTML;radicalformcheck.innerHTML="Wait...";radicalformcheck.disabled=true;var request=new XMLHttpRequest;request.open("GET","index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=1",true);request.onload=function(){if(this.status>=200&&this.status<400){var data=JSON.parse(this.response);if(data.data[0].ok){var output=data.data[0].chatids;if(output.length>0){for(var i=0;iThere are no messages to bot')}}else{document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Код ошибки '+data.data[0].error_code+"

"+data.data[0].description+"
")}}else{document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Error

'+this.response+"
")}radicalformcheck.disabled=false;radicalformcheck.innerHTML=temp};request.onerror=function(){document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Error

Error connection
');radicalformcheck.disabled=false;radicalformcheck.innerHTML=temp};request.send();event.preventDefault()})})}); \ No newline at end of file +jQuery(document).ready(function(){jQuery(function($){function getUrlParams(url){var regex=/[?&]([^=#]+)=([^&#]*)/g,params={},match;while(match=regex.exec(url)){params[match[1]]=match[2]}return params}var currentGetParams,page;currentGetParams=getUrlParams(location.search);var historyClear=document.querySelector("#historyclear");if(historyClear){historyClear.addEventListener("click",function(event){historyClear.innerHTML="Wait...";historyClear.disabled=true;if("page"in currentGetParams){page=currentGetParams.page}else{page="0"}$.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=2&page="+page,function(data){location.reload()});event.preventDefault()})}var numberClear=document.querySelector("#numberclear");if(numberClear){numberClear.addEventListener("click",function(event){numberClear.innerHTML="Wait...";numberClear.disabled=true;$.getJSON("index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=3",function(data){location.reload()});event.preventDefault()})}var exportCSV=document.querySelector("#exportcsv");if(exportCSV){exportCSV.addEventListener("click",function(event){var temp=exportCSV.innerHTML;exportCSV.innerHTML="Wait...";exportCSV.disabled=true;setTimeout(function(){exportCSV.innerHTML=temp;exportCSV.disabled=false},3e3)})}[].forEach.call(document.querySelectorAll("#attrib-list label.btn"),function(el){el.addEventListener("click",function(e){if(!document.querySelector("#attrib-list .alert.alert-info.hidden"))return;document.querySelector("#attrib-list .alert.alert-info.hidden").classList.remove("hidden")})});document.querySelector("#radicalformcheck").addEventListener("click",function(event){var radicalformcheck=document.querySelector("#radicalformcheck"),temp=radicalformcheck.innerHTML;radicalformcheck.innerHTML="Wait...";radicalformcheck.disabled=true;var request=new XMLHttpRequest;request.open("GET","index.php?option=com_ajax&plugin=radicalform&format=json&group=system&admin=1",true);request.onload=function(){if(this.status>=200&&this.status<400){var data=JSON.parse(this.response);if(data.data[0].ok){var output=data.data[0].chatids;if(output.length>0){for(var i=0;iThere are no messages to bot')}}else{document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Код ошибки '+data.data[0].error_code+"

"+data.data[0].description+"
")}}else{document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Error

'+this.response+"
")}radicalformcheck.disabled=false;radicalformcheck.innerHTML=temp};request.onerror=function(){document.querySelector("#radicalformcheck").insertAdjacentHTML("afterend",'

Error

Error connection
');radicalformcheck.disabled=false;radicalformcheck.innerHTML=temp};request.send();event.preventDefault()})})}); \ No newline at end of file diff --git a/media/js/script.js b/media/js/script.js index df4c9ef..d19aa5b 100644 --- a/media/js/script.js +++ b/media/js/script.js @@ -21,7 +21,7 @@ RadicalFormClass = function () { * @type {array} */ this.danger_classes = RadicalForm.DangerClass.trim().split(/\s+/); - RadicalForm.ErrorFile = RadicalForm.ErrorFile.trim().split(/\s+/); + this.error_file_classes = RadicalForm.ErrorFile.trim().split(/\s+/); if (RadicalForm.KeepAlive != 0) { window.setInterval(function() { @@ -476,18 +476,18 @@ RadicalFormClass = function () { response = JSON.parse(this.response); } catch (e) { console.error(request.status + ' ' + e.message + ' ' + this.response); - rf_filenames_list.insertAdjacentHTML('beforeend', "
Unknown Error. See Console.
"); + rf_filenames_list.insertAdjacentHTML('beforeend', "
Unknown Error. See Console.
"); response = false; return; } if (response.success) { - var el=rf_filenames_list.querySelector("." + RadicalForm.ErrorFile); + var el=rf_filenames_list.querySelector("." + selfClass.error_file_classes.join('.')); if (el) { el.parentNode.removeChild(el); } if ("error" in response.data[0]) { - rf_filenames_list.insertAdjacentHTML('beforeend', "
" + response.data[0].error + "
"); + rf_filenames_list.insertAdjacentHTML('beforeend', "
" + response.data[0].error + "
"); } else { if (rf_filenames_list.textContent.trim() === "") { rf_filenames_list.insertAdjacentHTML('beforeend', "
" + RadicalForm.thisFilesWillBeSend + "
"); @@ -517,13 +517,13 @@ RadicalFormClass = function () { }; } else { - var el=rf_filenames_list.querySelector("." + RadicalForm.ErrorFile); + var el=rf_filenames_list.querySelector("." + selfClass.error_file_classes.join('.')); if (el) { el.parentNode.removeChild(el); } - rf_filenames_list.insertAdjacentHTML('beforeend',"
" + RadicalForm.ErrorMax + "
"); // size is more than limit + rf_filenames_list.insertAdjacentHTML('beforeend',"
" + RadicalForm.ErrorMax + "
"); // size is more than limit } }; diff --git a/media/js/script.min.js b/media/js/script.min.js index 9e84d8f..9993236 100644 --- a/media/js/script.min.js +++ b/media/js/script.min.js @@ -1 +1 @@ -function ready(fn){if(document.readyState!="loading"){fn()}else{document.addEventListener("DOMContentLoaded",fn)}}RadicalFormClass=function(){var selfClass=this;this.uniq=(new Date).getTime()+Math.floor(Math.random()*100);this.danger_classes=RadicalForm.DangerClass.trim().split(/\s+/);RadicalForm.ErrorFile=RadicalForm.ErrorFile.trim().split(/\s+/);if(RadicalForm.KeepAlive!=0){window.setInterval(function(){var request=new XMLHttpRequest;request.open("POST",RadicalForm.Base+"/index.php?option=com_ajax&format=json",true);request.onload=function(){};request.send()},RadicalForm.TokenExpire)}this.init=function(container){if(typeof container==="string"){container=document.querySelector(container)}else{if(container===null||container===undefined){container=document.querySelector("body")}}var allForms=Array.from(container.querySelectorAll("form:not(.rf-form)")),filteredForms;filteredForms=allForms.filter(function(el){if(el.querySelector(".rf-form")){return false}return el.querySelector(".rf-button-send")});filteredForms.forEach(function(el){el.classList.add("rf-form")});var request1=new XMLHttpRequest;var AjaxFormDataforToken=new FormData;AjaxFormDataforToken.append("gettoken","1");request1.open("POST",RadicalForm.Base+"/index.php?option=com_ajax&plugin=radicalform&format=json&group=system",true);request1.onload=function(){if(this.status>=200&&this.status<400){var data=JSON.parse(this.response);[].forEach.call(container.querySelectorAll(".rf-form .rf-button-send"),function(el){el.insertAdjacentHTML("afterend",'')})}};request1.send(AjaxFormDataforToken);this.on(container,".rf-form ."+selfClass.danger_classes.join("."),"keypress",function(target,e){selfClass.danger_classes.forEach(function(item){target.target.classList.remove(item)})});this.on(container,".rf-form ."+selfClass.danger_classes.join("."),"change",function(target,e){selfClass.danger_classes.forEach(function(item){target.target.classList.remove(item)})});this.on(container,".rf-form .rf-button-delete","click",function(target,e){var request=new XMLHttpRequest;var filename=selfClass.closest(target.target,"div").querySelector("span").textContent,catalog=selfClass.closest(target.target,"div").dataset.name;request.open("POST",RadicalForm.Base+"/index.php?option=com_ajax&plugin=radicalform&format=json&group=system&deletefile="+filename+"&uniq="+selfClass.uniq+"&catalog="+catalog,true);request.onload=function(){if(this.status>=200&&this.status<400){var data=JSON.parse(this.response);selfClass.closest(target.target,"div").parentNode.removeChild(selfClass.closest(target.target,"div"))}else{}};request.send()});if(container.querySelectorAll(".rf-filenames-list").length!==container.querySelectorAll(".rf-form .rf-filenames-list").length){alert("ERROR!\r\nThere is \r\n.rf-filenames-list\r\n outside of form!\r\n Please move .rf-filenames-list inside the form. ")}[].forEach.call(container.querySelectorAll(".rf-form .rf-button-send"),function(el){el.addEventListener("click",selfClass.formSend)});[].forEach.call(container.querySelectorAll("input[type='file'].rf-upload-button"),function(el){el.addEventListener("change",selfClass.fileSend)})};this.formSend=function(e){var needReturn=false,field,form=selfClass.closest(this,".rf-form");var numberOfInputsWithNames=form.querySelectorAll("input[name], select[name], textarea[name]").length-form.querySelectorAll('input[type="file"]').length;if(numberOfInputsWithNames<2){alert("There is no input tags in your form with 'name' attribute!\r\n Please add 'name' attribute to your input tags!");needReturn=true}if(form.querySelectorAll("input[name]").length!==form.querySelectorAll("input").length){console.log("RadicalForm: there are inputs in your form without name! Please check ")}RadicalForm.FormFields=[];[].forEach.call(form.querySelectorAll("[name]"),function(el){selfClass.danger_classes.forEach(function(item){el.classList.remove(item)});if(el.classList.contains("required")&&el.value.trim()===""||el.classList.contains("required")&&!el.checked&&el.type==="checkbox"||!el.checkValidity()){RadicalForm.FormFields.push(el);needReturn=true}});setTimeout(function(){for(var i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'"));var elements=form.querySelectorAll("input[name], select[name], textarea[name]");var option,optValue;RadicalForm.Contacts={};for(var i=0;i';formData.append(this.name,this.files[0]);if(this.files[0].sizeUnknown Error. See Console.");response=false;return}if(response.success){var el=rf_filenames_list.querySelector("."+RadicalForm.ErrorFile);if(el){el.parentNode.removeChild(el)}if("error"in response.data[0]){rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.data[0].error+"
")}else{if(rf_filenames_list.textContent.trim()===""){rf_filenames_list.insertAdjacentHTML("beforeend","
"+RadicalForm.thisFilesWillBeSend+"
")}if(!form.querySelector("input[name=needToSendFiles]")){form.insertAdjacentHTML("beforeend",'')}rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.data[0].name+""+rfDelete+"
")}}else{rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.message+"
")}}else if(this.readyState===4&&this.status!==200){if(textForUploadButton){textForUploadButton.disabled=false;textForUploadButton.innerHTML=previousTextForUploadButton}try{rfCall_9(request.status+" "+request.message,buttonPressed)}catch(e){console.error("Radical Form JS Code: ",e)}console.error(request.status+" "+request.message)}}}else{var el=rf_filenames_list.querySelector("."+RadicalForm.ErrorFile);if(el){el.parentNode.removeChild(el)}rf_filenames_list.insertAdjacentHTML("beforeend","
"+RadicalForm.ErrorMax+"
")}};this.on=function(el,selector,event,cb){el.addEventListener(event,function(e){for(var target=e.target;target&&target!=this;target=target.parentNode){var matchesSelector=target.matches||target.webkitMatchesSelector||target.mozMatchesSelector||target.msMatchesSelector;if(matchesSelector.call(target,selector)){cb.call(target,e);break}}},false)};this.closest=function(el,selector){var matchesSelector=el.matches||el.webkitMatchesSelector||el.mozMatchesSelector||el.msMatchesSelector;while(el){if(matchesSelector.call(el,selector)){return el}else{el=el.parentElement}}return null};this.clearForm=function(formToClear){var elements=Array.from(formToClear.querySelectorAll("input[name], select[name], textarea[name]"));for(var i=0;i=200&&this.status<400){var data=JSON.parse(this.response);[].forEach.call(container.querySelectorAll(".rf-form .rf-button-send"),function(el){el.insertAdjacentHTML("afterend",'')})}};request1.send(AjaxFormDataforToken);this.on(container,".rf-form ."+selfClass.danger_classes.join("."),"keypress",function(target,e){selfClass.danger_classes.forEach(function(item){target.target.classList.remove(item)})});this.on(container,".rf-form ."+selfClass.danger_classes.join("."),"change",function(target,e){selfClass.danger_classes.forEach(function(item){target.target.classList.remove(item)})});this.on(container,".rf-form .rf-button-delete","click",function(target,e){var request=new XMLHttpRequest;var filename=selfClass.closest(target.target,"div").querySelector("span").textContent,catalog=selfClass.closest(target.target,"div").dataset.name;request.open("POST",RadicalForm.Base+"/index.php?option=com_ajax&plugin=radicalform&format=json&group=system&deletefile="+filename+"&uniq="+selfClass.uniq+"&catalog="+catalog,true);request.onload=function(){if(this.status>=200&&this.status<400){var data=JSON.parse(this.response);selfClass.closest(target.target,"div").parentNode.removeChild(selfClass.closest(target.target,"div"))}else{}};request.send()});if(container.querySelectorAll(".rf-filenames-list").length!==container.querySelectorAll(".rf-form .rf-filenames-list").length){alert("ERROR!\r\nThere is \r\n.rf-filenames-list\r\n outside of form!\r\n Please move .rf-filenames-list inside the form. ")}[].forEach.call(container.querySelectorAll(".rf-form .rf-button-send"),function(el){el.addEventListener("click",selfClass.formSend)});[].forEach.call(container.querySelectorAll("input[type='file'].rf-upload-button"),function(el){el.addEventListener("change",selfClass.fileSend)})};this.formSend=function(e){var needReturn=false,field,form=selfClass.closest(this,".rf-form");var numberOfInputsWithNames=form.querySelectorAll("input[name], select[name], textarea[name]").length-form.querySelectorAll('input[type="file"]').length;if(numberOfInputsWithNames<2){alert("There is no input tags in your form with 'name' attribute!\r\n Please add 'name' attribute to your input tags!");needReturn=true}if(form.querySelectorAll("input[name]").length!==form.querySelectorAll("input").length){console.log("RadicalForm: there are inputs in your form without name! Please check ")}RadicalForm.FormFields=[];[].forEach.call(form.querySelectorAll("[name]"),function(el){selfClass.danger_classes.forEach(function(item){el.classList.remove(item)});if(el.classList.contains("required")&&el.value.trim()===""||el.classList.contains("required")&&!el.checked&&el.type==="checkbox"||!el.checkValidity()){RadicalForm.FormFields.push(el);needReturn=true}});setTimeout(function(){for(var i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'"));var elements=form.querySelectorAll("input[name], select[name], textarea[name]");var option,optValue;RadicalForm.Contacts={};for(var i=0;i';formData.append(this.name,this.files[0]);if(this.files[0].sizeUnknown Error. See Console.");response=false;return}if(response.success){var el=rf_filenames_list.querySelector("."+selfClass.error_file_classes.join("."));if(el){el.parentNode.removeChild(el)}if("error"in response.data[0]){rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.data[0].error+"
")}else{if(rf_filenames_list.textContent.trim()===""){rf_filenames_list.insertAdjacentHTML("beforeend","
"+RadicalForm.thisFilesWillBeSend+"
")}if(!form.querySelector("input[name=needToSendFiles]")){form.insertAdjacentHTML("beforeend",'')}rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.data[0].name+""+rfDelete+"
")}}else{rf_filenames_list.insertAdjacentHTML("beforeend","
"+response.message+"
")}}else if(this.readyState===4&&this.status!==200){if(textForUploadButton){textForUploadButton.disabled=false;textForUploadButton.innerHTML=previousTextForUploadButton}try{rfCall_9(request.status+" "+request.message,buttonPressed)}catch(e){console.error("Radical Form JS Code: ",e)}console.error(request.status+" "+request.message)}}}else{var el=rf_filenames_list.querySelector("."+selfClass.error_file_classes.join("."));if(el){el.parentNode.removeChild(el)}rf_filenames_list.insertAdjacentHTML("beforeend","
"+RadicalForm.ErrorMax+"
")}};this.on=function(el,selector,event,cb){el.addEventListener(event,function(e){for(var target=e.target;target&&target!=this;target=target.parentNode){var matchesSelector=target.matches||target.webkitMatchesSelector||target.mozMatchesSelector||target.msMatchesSelector;if(matchesSelector.call(target,selector)){cb.call(target,e);break}}},false)};this.closest=function(el,selector){var matchesSelector=el.matches||el.webkitMatchesSelector||el.mozMatchesSelector||el.msMatchesSelector;while(el){if(matchesSelector.call(el,selector)){return el}else{el=el.parentElement}}return null};this.clearForm=function(formToClear){var elements=Array.from(formToClear.querySelectorAll("input[name], select[name], textarea[name]"));for(var i=0;iparams->get('glue')=="
" || $this->params->get('glue')=="
" ) { array_unshift($record," "); - $record=implode($this->params->get('glue'), $record); - } - else - { - $record=implode($this->params->get('glue'), $record); - } + } + $record=implode($this->params->get('glue'), $record); - } + } if($key=="phone") { $mainbody .= "

".JText::_($key) . ": " . $record . "

"; diff --git a/radicalform.xml b/radicalform.xml index a1afe15..6c98fef 100644 --- a/radicalform.xml +++ b/radicalform.xml @@ -4,10 +4,10 @@ Progreccor info@hika.su https://hika.su - Copyright (C) 2020 Progreccor. All rights reserved. + Copyright (C) 2021 Progreccor. All rights reserved. GNU General Public License version 2 or later; - 3.0.1 - 2020-12-20 + 3.0.2 + 2021-06-17 PLG_RADICALFORM_DESC script.php