From cbebd6b572d89a9be247f17a9f03597f47451d9f Mon Sep 17 00:00:00 2001 From: Marcell Mars Date: Tue, 24 Aug 2021 17:31:22 +0200 Subject: [PATCH] not sandpoints key/values... --- app/c.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/c.js b/app/c.js index b11f32c..0890b89 100644 --- a/app/c.js +++ b/app/c.js @@ -6,13 +6,11 @@ function captureFrontMatterAndMarkdown() { if(key.endsWith('[]')){ let kie = key.slice(0, -2); (kie in formDataJSON) || (formDataJSON[kie] = []) - console.log("[]:", kie, value) formDataJSON[kie].push(value); } else if (key.endsWith('[j]')) { let kie = key.slice(0, -3); (kie in formDataJSON) || (formDataJSON[kie] = []) let vA = JSON.parse(value) - console.log("[j]:", kie, value, vA) if (Array.isArray(vA)) { vA.forEach(v => formDataJSON[kie].push(v)) } @@ -25,6 +23,20 @@ function captureFrontMatterAndMarkdown() { publishpath = `${location.pathname.split('/public')[0]}/public${value}index.html`; } else if (["protocol", "offline", "ignore"].includes(key)) { 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 { formDataJSON[key] = value } @@ -34,6 +46,7 @@ function captureFrontMatterAndMarkdown() { if (abstract) { formDataJSON['abstract'] = abstract.value } + const content = document.getElementById('pagecontent').value let publish = formData.get("publish") == "on" ? true : false let offline = formData.get("offline") == "on" ? true : false @@ -57,7 +70,7 @@ if (sb) { e.preventDefault() pageDict = captureFrontMatterAndMarkdown() chrome.runtime.sendMessage(pageDict) - }); + }); } chrome.runtime.onMessage.addListener((m, n)=> {