Commit f6f9aeab authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed regexp method

parent 50279b60
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
newElement.classList.add("query"); newElement.classList.add("query");
newElement.classList.add("card"); newElement.classList.add("card");
newElement.innerHTML = el; newElement.innerHTML = el;
document.getElementById("queries").appendCHild(newElement); document.getElementById("queries").appendChild(newElement);
}); });
lastUpdate = Date.now(); lastUpdate = Date.now();
checkRegexp(); checkRegexp();
...@@ -158,14 +158,16 @@ ...@@ -158,14 +158,16 @@
function checkRegexp() { function checkRegexp() {
var val = $("#regexp").val(); var val = document.getElementById("regexp").value;
var queries = []; var queries = [];
$("#queries > .query").each(function(index, el){ document.querySelectorAll("#queries > .query").forEach((el, index) => {
queries.push($(el).html()); queries.push(el.innerHTML);
}); });
queries.push($("#check-against").val());
queries.push(document.getElementById("check-against").value)
var url = "{{ url('admin/spam/queryregexp') }}"; var url = "{{ url('admin/spam/queryregexp') }}";
var options = { var options = {
...@@ -182,17 +184,18 @@ ...@@ -182,17 +184,18 @@
fetch(url, options) fetch(url, options)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
$("#queries > .query").each(function(index, el){ document.querySelectorAll("#queries > .query").forEach((el, index) => {
if(data[index]["matches"]){ if(data[index]["matches"]){
$(el).addClass("matches"); el.classList.add("matches");
}else{ }else{
$(el).removeClass("matches"); elclassList.remove("matches");
} }
}); });
if(data[data.length-1]["matches"]){ if(data[data.length-1]["matches"]){
$("#check-against").addClass("matches"); document.getElementById("check-against").classList.add("matches");
}else{ }else{
$("#check-against").removeClass("matches"); document.getElementById("check-against").classList.remove("matches");
} }
}); });
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment