You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
spasca-fot-sloan-q2/data/selfcontained_test.html

46 lines
1.9 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://fabien.benetou.fr/pub/home/future_of_text_demo/engine/dependencies/webdav.js"></script>
<head>
<script src="https://aframe.io/releases/1.7.0/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
<button style="position:absolute; z-index:42; top:0;" onclick="save()">save</button>
<script>
const webdavURL = "https://webdav.benetou.fr";
const subdirWebDAV = "/fotsave/fot_sloan_companion_public/"
var webdavClient = window.WebDAV.createClient(webdavURL)
const hmdURL = "https://hmd.link/?https://companion.benetou.fr"
function save(){
async function r(path = "/file.txt"){ return await webdavClient.getFileContents(path, { format: "text" }) }
r(subdirWebDAV+"selfcontained_test.html").then( file => {
let newContent = file.replace("#FFC65D",'#' + Math.floor(Math.random()*16777215).toString(16) ) // random in order to repeat few times
let filename = "selfcontained_test_saved_"+Date.now()+".html"
saveJSONToWebDAV( filename, newContent )
let url = webdavURL+subdirWebDAV+filename
setTimeout( _ => window.open(url, '_blank'), 1000 )
// delay to avoid opening a URL that needs .1 s to be actually available
})
}
function saveJSONToWebDAV(filename, content){
async function w(path = "/file.txt"){ return await webdavClient.putFileContents(path, content) }
written = w(subdirWebDAV+filename)
}
</script>
</body>
</html>