mirror of
https://gitlab.com/octospacc/octospacc.gitlab.io
synced 2025-06-05 21:59:15 +02:00
Update site structure, update global js to add domain warning, update SpiderADB
This commit is contained in:
32
source/SpiderADB/util.js
Normal file
32
source/SpiderADB/util.js
Normal file
@@ -0,0 +1,32 @@
|
||||
(function(){
|
||||
|
||||
function arrayFrom (items) {
|
||||
var itemsArray = [];
|
||||
for (var i=0; i<items.length; i++) {
|
||||
itemsArray.push(items[i]);
|
||||
}
|
||||
return itemsArray;
|
||||
}
|
||||
|
||||
function domSelector (query, tree=document) {
|
||||
query = query.trim();
|
||||
return (query.startsWith('::')
|
||||
? arrayFrom(tree.querySelectorAll(domSpecialQuery(query.slice(2).trim())))
|
||||
: tree.querySelector(domSpecialQuery(query))
|
||||
);
|
||||
}
|
||||
|
||||
function domSpecialQuery (query) {
|
||||
query = query.trim();
|
||||
if (query.endsWith('$')) {
|
||||
query = query.split('$');
|
||||
return `${query.slice(0, -2).join('$')}[name="${query.slice(-2)[0]}"]`;
|
||||
} else {
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
||||
window.arrayFrom = arrayFrom;
|
||||
window.$ = domSelector;
|
||||
|
||||
})();
|
Reference in New Issue
Block a user