Tighter client side integrations for uploads.
This commit is contained in:
parent
41e27cdffa
commit
12d40e69a5
17 changed files with 277 additions and 220 deletions
assets/common.js
36
assets/common.js/meta.js
Normal file
36
assets/common.js/meta.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include html.js
|
||||
|
||||
const $meta = (() => {
|
||||
return {
|
||||
get(name, prefixed=true) {
|
||||
if(!name) return;
|
||||
if(prefixed) name = `msz-${name}`;
|
||||
|
||||
const elem = $query(`meta[name="${name}"]`);
|
||||
if(elem instanceof HTMLMetaElement && typeof elem.content === 'string')
|
||||
return elem.content;
|
||||
|
||||
return null;
|
||||
},
|
||||
set(name, value, prefixed=true) {
|
||||
if(!name) return;
|
||||
if(prefixed) name = `msz-${name}`;
|
||||
|
||||
let elem = $query(`meta[name="${name}"]`);
|
||||
if(elem instanceof HTMLMetaElement) {
|
||||
if(typeof value === 'string')
|
||||
elem.content = value;
|
||||
else
|
||||
elem.remove();
|
||||
} else {
|
||||
if(typeof value !== 'string')
|
||||
return;
|
||||
|
||||
elem = document.createElement('meta');
|
||||
elem.name = name;
|
||||
elem.content = value;
|
||||
document.head.appendChild(elem);
|
||||
}
|
||||
},
|
||||
};
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue