diff --git a/.idea/sightplace-rep.iml b/.idea/sightplace-rep.iml index 766db97..e3d8eed 100644 --- a/.idea/sightplace-rep.iml +++ b/.idea/sightplace-rep.iml @@ -5,6 +5,13 @@ + + + + + + + diff --git a/place/js/sight.js b/place/js/sight.js index fea8d3f..d85b9aa 100644 --- a/place/js/sight.js +++ b/place/js/sight.js @@ -4,54 +4,10 @@ if(navigator.userAgent.indexOf("QtWebEngine") > 0) { window.sight = channel.objects.handler; }); } -/* -function docReady(fn) { - if(document.readyState === "complete" || document.readyState === "interactive") { - setTimeout(fn, 1); - } else { - setTimeout(fn, 2); - document.addEventListener("DOMContentLoaded", fn); - } -} - - - document.querySelectorAll('a').forEach(link => { - link.onclick = function() { alert("ss"); } - - link.addEventListener("click", (e) => { - e.preventDefault(); - alert("sds"); - }); - }); - -document.addEventListener('DOMContentLoaded', (event) => { - - - document.querySelectorAll('#screate').forEach(link => { - alert("1"); - link.addEventListener("click", (e) => { - alert("sds"); - }); - }); - - - const screate = document.getElementById("screate"); - screate.addEventListener("click",myFunc); - - document.getElementById("screate").onclick = e => { - alert("ss") - } -});*/ -/* -document.getElementById("screate").onclick = e => { - alert("ss") -}*/ - -/*const screate = document;*/ (function ( $ ) { $.fn.s_create = function() { - $(document).on( "click", "#screate", function() { + $(document).on( "click", "#screate", function(event) { event.preventDefault(); window.sight.create($(this).data("id"), $(this).data("type"), function(sight_id) { @@ -59,7 +15,7 @@ document.getElementById("screate").onclick = e => { }) }; $.fn.s_close = function() { - $("body").on( "click", "#sclose", function() { + $("body").on( "click", "#sclose", function(event) { event.preventDefault(); window.sight.close(); }) @@ -183,24 +139,68 @@ function setTitle(title) { ***/ function load(url, element) { - fetch(url).then(res => { + /*fetch(url,{ + method: "POST", + headers: {"Content-type": "application/javascript;charset=UTF-8"} + }).then(res => { return res.text(); }).then((html) => { element.innerHTML = html; - }); + });*/ +/* + const xhttp = new XMLHttpRequest(); + xhttp.open("GET", url, true);*/ + + /*xhttp.onreadystatechange = function() { + if (xhttp.readyState == XMLHttpRequest.DONE) { + if (xhttp.status == 200) { + // create a `div` elemenent, append response to `div` element + // get specific elements by `id`, append `script` element to `document.body` + var content = document.createElement("div"); + content.innerHTML = xhttp.responseText + var contentScript = content.querySelector("script"); + var script = document.createElement("script"); + script.textContent = contentScript.textContent; + element.innerHTML = content.innerHTML; + + //window.sight.console(script.textContent) + var rand = Math.random()*1000 + //script.setAttribute("script_run_"+rand) + document.body.appendChild(script); + + //document.body.removeChild(list.firstElementChild); + } + } + };*/ + +/* + xhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var doc = new DOMParser().parseFromString(this.responseText, "text/html"); + /*var fragmentElement = document.createDocumentFragment(); + var tempElement = fragmentElement.appendChild(doc.content.body); + alert(tempElement) + document.body.appendChild(tempElement);*/ + //element.innerHTML = this.responseText; + /* } + }; +*/ + /*xhttp.onload = function() { + element.innerHTML = this.responseText; + }*/ + + xhttp.send(); } $(document).ready(function(){ const scontent = document.querySelectorAll('[scontent]'); - scontent.forEach((element) => { - //$("[scontent="+element.getAttribute("scontent")+"]").load("content/"+element.getAttribute("scontent")+"/content.html"); - load("content/"+element.getAttribute("scontent")+"/content.html", document.querySelector("[scontent="+element.getAttribute("scontent")+"]")) + $("[scontent="+element.getAttribute("scontent")+"]").load("content/"+element.getAttribute("scontent")+"/content.html"); + //load("content/"+element.getAttribute("scontent")+"/content.html", document.querySelector("[scontent="+element.getAttribute("scontent")+"]")) }); // INIT the Sight from init_sight variable if (typeof init_sight !== 'undefined') { - for ( const [key,value] of Object.entries( init_sight ) ) { window.sight.console(key + " - " + value) switch(key) { @@ -228,7 +228,6 @@ $(document).ready(function(){ if($("#stoggled").length) { var attr = $("#stoggled").attr("state") if (typeof attr !== 'undefined' && attr !== false && (attr == "restoredown" || attr == "maximized")) { - png_button = "restoredown" if(attr == "restoredown") png_button = "maximized" diff --git a/place/templates/base/content/main_text/content.html b/place/templates/base/content/main_text/content.html index 1e61d87..cddb42e 100644 --- a/place/templates/base/content/main_text/content.html +++ b/place/templates/base/content/main_text/content.html @@ -1,6 +1,15 @@ This is a sentence. +JE + + \ No newline at end of file