From e302f2587a28e39cbe4a9a181380f85d1d03f35a Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Thu, 6 Oct 2022 12:20:31 +0200 Subject: [PATCH] sorting fixed, saving back to dedicated page --- index.html | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 5d08c0c..9268e9c 100644 --- a/index.html +++ b/index.html @@ -1329,21 +1329,29 @@ AFRAME.registerComponent('glossary', { AFRAME.registerComponent('fossxr', { init:function(){ - }, - tick: function(){ let generatorName = this.attrName fetch("https://fabien.benetou.fr/Testing/FOSSXR2022?action=source#" + Date.now()).then(res => res.text() ).then(res => { - res.split("\n").filter(e => (e[0] && e[0] == "*")).slice(0,maxItemsFromSources).map( (n,i) => { + res.split("\n").filter(e => (e.match(/^\* /))).slice(0,maxItemsFromSources).map( (n,i) => { found = added.find((str) => str === n) if (typeof found === 'undefined'){ added.push(n) - addNewNote( n, "-1 "+(1+i/10)+" -2.5", ".1 .1 .1", null, generatorName ) + addNewNote( n, "-.1 "+(1+i/10)+" -.5", ".1 .1 .1", null, generatorName ) } }) }) } }); +function saveBackList(){ + data = Array.from( document.querySelectorAll(".fossxr") ).sort((a, b) => a.object3D.position.y - b.object3D.position.y ).map( e => e.getAttribute("value")).join("%0a") + configurableURL="https://fabien.benetou.fr/PIMVRdata/FOSSXR?action=" + fetch(configurableURL+'edit', { + method: 'POST', + headers: {'Content-Type':'application/x-www-form-urlencoded'}, + body: "post=1&author=PIMVR&authpw=edit_password&text="+JSON.stringify( data ) + }).then(res => res).then(res => setFeedbackHUD("saved remotely"+ res)) +} + AFRAME.registerComponent('fot', { init:function(){ }, @@ -1472,8 +1480,9 @@ fetch('./templates.json') ] links = [] //fetch("commands.json").then(res => res.json() ).then(res => { - var commandsURL = "https://fabien.benetou.fr/PIMVRdata/CabinCommands?action=source" - commandsURL = "https://fabien.benetou.fr/PIMVRdata/EngineSequentialTutorialCommands?action=source" // new default + var commandsURL = "https://fabien.benetou.fr/PIMVRdata/CabinCommands?action=source" // should become a global parameter + // commandsURL = "https://fabien.benetou.fr/PIMVRdata/EngineSequentialTutorialCommands?action=source" // new default + commandsURL = "https://fabien.benetou.fr/PIMVRdata/EngineFOSSXRCommands?action=source" // new default var src = AFRAME.utils.getUrlParameter('commands-url') if (src && src != "") commandsURL = src fetch(commandsURL).then(res => res.json() ).then(res => { @@ -1493,7 +1502,7 @@ fetch('./templates.json') }, }); -function save(){ +function save(classname=null){ var data = targets.map( e => { return { localname: e.localName, src: e.getAttribute("src"), @@ -1533,8 +1542,9 @@ function remoteLoad(){ // both might not be ideal directly in the original JSON but could be attachement as URLs } -function remoteSave(){ - fetch(url+'edit', { +function remoteSave(configurableURL="https://fabien.benetou.fr/PIMVRdata/CabinData?action="){ + // targets could be filtered down, e.g .fossxr only + fetch(configurableURL+'edit', { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: "post=1&author=PIMVR&authpw=edit_password&text="+JSON.stringify( cabin ) @@ -1620,6 +1630,8 @@ function switchSide(){ + +