not sandpoints key/values...

This commit is contained in:
Marcell Mars 2021-08-24 17:31:22 +02:00
parent 34cc5f851b
commit cbebd6b572
1 changed files with 16 additions and 3 deletions

View File

@ -6,13 +6,11 @@ function captureFrontMatterAndMarkdown() {
if(key.endsWith('[]')){ if(key.endsWith('[]')){
let kie = key.slice(0, -2); let kie = key.slice(0, -2);
(kie in formDataJSON) || (formDataJSON[kie] = []) (kie in formDataJSON) || (formDataJSON[kie] = [])
console.log("[]:", kie, value)
formDataJSON[kie].push(value); formDataJSON[kie].push(value);
} else if (key.endsWith('[j]')) { } else if (key.endsWith('[j]')) {
let kie = key.slice(0, -3); let kie = key.slice(0, -3);
(kie in formDataJSON) || (formDataJSON[kie] = []) (kie in formDataJSON) || (formDataJSON[kie] = [])
let vA = JSON.parse(value) let vA = JSON.parse(value)
console.log("[j]:", kie, value, vA)
if (Array.isArray(vA)) { if (Array.isArray(vA)) {
vA.forEach(v => formDataJSON[kie].push(v)) vA.forEach(v => formDataJSON[kie].push(v))
} }
@ -25,6 +23,20 @@ function captureFrontMatterAndMarkdown() {
publishpath = `${location.pathname.split('/public')[0]}/public${value}index.html`; publishpath = `${location.pathname.split('/public')[0]}/public${value}index.html`;
} else if (["protocol", "offline", "ignore"].includes(key)) { } else if (["protocol", "offline", "ignore"].includes(key)) {
return return
} else if (key.startsWith("notsand")) {
if (key.startsWith("notsandkey")) {
let id = key.split("_")[1]
let vA = [];
if (formData.get(`notsandvalue_${id}`).startsWith("[")) {
vA = JSON.parse(formData.get(`notsandvalue_${id}`))
}
if (Array.isArray(vA) && vA.length != 0) {
(value in formDataJSON) || (formDataJSON[value] = [])
vA.forEach(v => formDataJSON[value].push(v))
} else {
formDataJSON[value] = formData.get(`notsandvalue_${id}`)
}
}
} else { } else {
formDataJSON[key] = value formDataJSON[key] = value
} }
@ -34,6 +46,7 @@ function captureFrontMatterAndMarkdown() {
if (abstract) { if (abstract) {
formDataJSON['abstract'] = abstract.value formDataJSON['abstract'] = abstract.value
} }
const content = document.getElementById('pagecontent').value const content = document.getElementById('pagecontent').value
let publish = formData.get("publish") == "on" ? true : false let publish = formData.get("publish") == "on" ? true : false
let offline = formData.get("offline") == "on" ? true : false let offline = formData.get("offline") == "on" ? true : false
@ -57,7 +70,7 @@ if (sb) {
e.preventDefault() e.preventDefault()
pageDict = captureFrontMatterAndMarkdown() pageDict = captureFrontMatterAndMarkdown()
chrome.runtime.sendMessage(pageDict) chrome.runtime.sendMessage(pageDict)
}); });
} }
chrome.runtime.onMessage.addListener((m, n)=> { chrome.runtime.onMessage.addListener((m, n)=> {