diff --git a/index.html b/index.html index 18902f0..92dc762 100644 --- a/index.html +++ b/index.html @@ -32,6 +32,38 @@ then target position=" -0.3 1.35 0" rotation="0 40 0" scale="0.1 0.1 0.1"> */ +var library +AFRAME.registerComponent('library-load', { + init: function(){ + //fetch("../content/library-acm22.json").then( res => res.json() ).then( res => { + fetch("https://webdav.benetou.fr/fotsave/test_newfot.json").then( res => res.json() ).then( res => { + library = res + console.log(res) + res.documents.map( (doc,i) => { + if (doc.customData[0].position) + addNewNote( doc.title, doc.customData[0].position ) + else + addNewNote( doc.title, '.5 '+(1+i/50)+' -.5' ) + .setAttribute("onreleased", "updateDatasetThenSave(e.detail.element)") + }) + + }) + } +}) + +function updateDatasetThenSave(element){ + if (!library) return + let pos = element.getAttribute('position') + let title = element.getAttribute('value') + console.log(pos, title) + library.documents.filter( el => el.title == title ).map( found => found.customData[0].position = pos ) + //library.documents.filter( el => el.title == title ).map( found => console.log( found.customData[0] ) ) + const webdavurl = "https://webdav.benetou.fr"; + const client = window.WebDAV.createClient(webdavurl) + async function w(path, data){ return await client.putFileContents(path, data); } + w("/fotsave/test_newfot.json", JSON.stringify(library) ) + setFeedbackHUD( "file saved" ) +} function cloneTarget(target){ let el = target.cloneNode(true) @@ -184,7 +216,7 @@ AFRAME.registerComponent('teleporter', { - +