Answer the question
In order to leave comments, you need to log in
How to get elements from an array that contain def. characters?
There are arrays like:
[ "Hawaii mvc_mcycle_Data-Summary0812a.html", "bg1.png", "compatibility.js", "f1.woff", "f2.woff", "f3.woff", "f4.woff", "f5.woff", "pdf2htmlEX-64x64.png", "pdf2htmlEX.min.js" ]
function infoJSON(myURL) {
$.ajax({
url: myURL,
dataType: "text",
success: function(data) {
var v = $.parseJSON(data);
var arrayFiles = v.output.files;
var png = $(arrayFiles':not([.png$])').splice();
$(".class").html(png);
}
});
}
Answer the question
In order to leave comments, you need to log in
Everything is allowed. But you have to do it manually. In opencart, a lot of scripts are written in the middle of the desired template (module or page), for example, all sorts of sliders, lightboxes, etc. And they will stop working if you transfer the library necessary for them, owl carousel or jQuery in general, from the header to the footer. If you are doing all this to please google page speed insight, I would not advise doing this. Win a couple of points and break the site.. it's not worth it
function filterFiles(arr, extensions, ignore) {
extensions = extensions || [];
ignore = ignore || [];
var getFileExt = function (filename) {
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename)[0] : undefined;
}
return arr.filter(function (item) {
return -1 === ignore.indexOf(item) && -1 !== extensions.indexOf(getFileExt(item));
});
}
// usage
var files = filterFiles([ "Hawaii mvc_mcycle_Data-Summary0812a.html", "bg1.png", "compatibility.js", "f1.woff", "f2.woff", "f3.woff", "f4.woff", "f5.woff", "pdf2htmlEX-64x64.png", "pdf2htmlEX.min.js" ], ['png'], ['pdf2htmlEX-64x64.png']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question