| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | if(navigator.userAgent.indexOf("QtWebEngine") > 0) { | 
					
						
							|  |  |  | 	new QWebChannel(qt.webChannelTransport, function (channel) { | 
					
						
							|  |  |  | 		// now I retrieve my object
 | 
					
						
							|  |  |  | 		window.sight = channel.objects.handler; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | /* | 
					
						
							|  |  |  | 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;*/ | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | (function ( $ ) { | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | /*	$.fn.s_create = function() { | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 		 $(document).on( "click", "#screate", function() { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | 			window.sight.create($(this).data("id"), $(this).data("type"), function(sight_id) { | 
					
						
							|  |  |  | 				 | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		})    | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  |     };*/ | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 	$.fn.s_close = function() { | 
					
						
							|  |  |  | 		$("body").on( "click", "#sclose", function() { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			window.sight.close(); | 
					
						
							|  |  |  | 		})    | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_exit = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_exit", function (event) { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			window.sight.exit(); | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_toggled = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_toggled", function (event) { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			$(this).empty(); | 
					
						
							|  |  |  | 			if($(this).attr('state') != "maximized") { 	// set to the maximized
 | 
					
						
							|  |  |  | 				window.sight.setMaximized(); | 
					
						
							|  |  |  | 				$(this).attr("state", "maximized"); | 
					
						
							|  |  |  | 				$(this).prepend('<img src="img/restoredown.png" height="20px" />') | 
					
						
							|  |  |  | 			} else { 									// set to the restore down
 | 
					
						
							|  |  |  | 				window.sight.restoreDown(); | 
					
						
							|  |  |  | 				$(this).attr("state", "restoredown"); | 
					
						
							|  |  |  | 				$(this).prepend('<img src="img/maximized.png" height="20px" />') | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_maximized = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_maximized", function (event) { | 
					
						
							|  |  |  | 			if($(this).attr('state') != "maximized") { | 
					
						
							|  |  |  | 				event.preventDefault(); | 
					
						
							|  |  |  | 				$("#stoggled").empty(); | 
					
						
							|  |  |  | 				window.sight.setMaximized() | 
					
						
							|  |  |  | 				$("#stoggled").prepend('<img src="img/restoredown.png" height="20px" />') | 
					
						
							|  |  |  | 				$("#stoggled").attr("state", "maximized"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_restoredown = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_restoredown", function (event) { | 
					
						
							|  |  |  | 			if($(this).attr('state') != "restoredown") { | 
					
						
							|  |  |  | 				event.preventDefault(); | 
					
						
							|  |  |  | 				$("#stoggled").empty(); | 
					
						
							|  |  |  | 				window.sight.restoreDown(); | 
					
						
							|  |  |  | 				$("#stoggled").attr("state", "restoredown"); | 
					
						
							|  |  |  | 				$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />') | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_minimize = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_minimize", function (event) { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			window.sight.setMinimize(); | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_fullscreen = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_fullscreen", function (event) { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			window.sight.setFullscreen(); | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_title = function() { | 
					
						
							|  |  |  | 		$(this).text(window.sight.getTitle());   | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_titlebar = function() { | 
					
						
							|  |  |  | 		/* DISABLE TEXT SELECT */ | 
					
						
							|  |  |  | 		$( this ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false); | 
					
						
							|  |  |  |         $( this ).mousedown(function() { | 
					
						
							|  |  |  | 			/*$( "body" ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false);*/ | 
					
						
							|  |  |  | 			if($(this).children("#stoggled").attr('state') == "restoredown") | 
					
						
							|  |  |  | 				window.sight.move(); | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		.mouseup(function() { | 
					
						
							|  |  |  | 			/*$( "body" ).attr('unselectable', 'off').css('user-select', 'yes').on('selectstart dragstart', true);*/ | 
					
						
							|  |  |  | 			window.sight.endmove(); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$.fn.s_global_add = function() { | 
					
						
							|  |  |  | 		this.bind("click.s_global_add", function (event) { | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			//window.sight.global($(this));
 | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 	$(document).mousemove(function(e){ | 
					
						
							|  |  |  | 		if(resizing) | 
					
						
							|  |  |  | 			window.sight.resize(); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	$(document).mouseup(function(e){ | 
					
						
							|  |  |  | 		resizing = false | 
					
						
							|  |  |  | 	});	 | 
					
						
							|  |  |  | 	$(document).mousedown(function(e){ | 
					
						
							|  |  |  | 		window.sight.activeSight(); | 
					
						
							|  |  |  | 	});	 | 
					
						
							|  |  |  | 	var resizing = false; | 
					
						
							|  |  |  | 	$.fn.s_resize = function() { | 
					
						
							|  |  |  | 		$(this).mousemove(function(e){ | 
					
						
							|  |  |  | 			event.preventDefault(); | 
					
						
							|  |  |  | 			if(e.buttons==1) | 
					
						
							|  |  |  | 				resizing = true | 
					
						
							|  |  |  | 		});     | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | }( jQuery )); | 
					
						
							|  |  |  | function addData(key, value, is_global = false) { | 
					
						
							|  |  |  | 	window.sight.addData(key,value, is_global); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | function getData(key, is_global = false) { | 
					
						
							|  |  |  | 	window.sight.getData(key, is_global, function(result) { | 
					
						
							|  |  |  | 		alert(result) | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | function sclose() { | 
					
						
							|  |  |  | 	window.sight.close(); | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | function setTitle(title) { | 
					
						
							|  |  |  | 	$("#stitle").text(title); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | $(document).ready(function(){ | 
					
						
							|  |  |  | 	// LOAD the contents into the Sight
 | 
					
						
							|  |  |  | 	if (typeof s_contents !== 'undefined') { | 
					
						
							|  |  |  | 		for ( const [id_name,content_folder] of Object.entries( s_contents ) ) { | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | 			/*$("#"+id_name).load("content/"+content_folder+"/content.html");*/ | 
					
						
							|  |  |  | 			$("#"+id_name).load("content/"+content_folder+"/content.html", function() { | 
					
						
							|  |  |  | 				document.querySelectorAll('#screate').forEach(link => { | 
					
						
							|  |  |  | 					link.addEventListener("click", (e) => { | 
					
						
							|  |  |  | 						e.preventDefault(); | 
					
						
							|  |  |  | 						window.sight.create(e.target.dataset.id, e.target.dataset.type, function(sight_id) { | 
					
						
							|  |  |  | 							 | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 	// INIT the Sight from init_sight variable
 | 
					
						
							|  |  |  | 	if (typeof init_sight !== 'undefined') { | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		for ( const [key,value] of Object.entries( init_sight ) ) { | 
					
						
							|  |  |  | 			window.sight.test(key + " - " + value) | 
					
						
							|  |  |  | 			switch(key) { | 
					
						
							|  |  |  | 				case 'width':  | 
					
						
							|  |  |  | 					window.sight.setWidth(value) | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				case 'height':  | 
					
						
							|  |  |  | 					window.sight.setHeight(value) | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	// INIT
 | 
					
						
							|  |  |  | 	/*window.sight.getDefaultTemplate(function(default_template) { | 
					
						
							|  |  |  | 		$('a[href]:not([href^="http://"]), a[href]:not([href^="https://"]), a[href]:not([href^="#"])').each(function(){ | 
					
						
							|  |  |  | 			if(!$(this).hasClass( "nav-link" )) { | 
					
						
							|  |  |  | 				window.sight.test($(this).attr("href") + " je1"); | 
					
						
							|  |  |  | 				var newUrl = './templates/'+default_template+'/'+$(this).attr("href"); | 
					
						
							|  |  |  | 				$(this).attr("href", newUrl); | 
					
						
							|  |  |  | 				window.sight.test(newUrl + " je2"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		});  | 
					
						
							|  |  |  | 	});*/ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	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" | 
					
						
							|  |  |  | 			$("#stoggled").prepend('<img src="img/'+png_button+'.png" height="20px" />'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if(attr == "maximized") | 
					
						
							|  |  |  | 				window.sight.setMaximized(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$("#stoggled").attr("state", "restoredown"); | 
					
						
							|  |  |  | 			$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />'); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if($("#sclose").length) { | 
					
						
							|  |  |  | 		$("#sclose:not([except])").empty(); | 
					
						
							|  |  |  | 		$("#sclose:not([except])").prepend('<img src="img/close.png" height="20px" />'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if($("#sminimize").length) { | 
					
						
							|  |  |  | 		$("#sminimize").empty(); | 
					
						
							|  |  |  | 		$("#sminimize").prepend('<img src="img/minimize.png" height="20px" />'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/*window.sight.getTitle(function(result) { | 
					
						
							|  |  |  | 		setTitle(result); | 
					
						
							|  |  |  | 	});*/ | 
					
						
							|  |  |  | 	// INIT END
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-26 08:30:47 +00:00
										 |  |  | 	/*$( "#screate" ).s_create();*/ | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | 	$( "#sclose" ).s_close(); | 
					
						
							|  |  |  | 	$( "#sexit" ).s_exit();	 | 
					
						
							|  |  |  | 	$( "#smaximized" ).s_maximized(); | 
					
						
							|  |  |  | 	$( "#sminimize" ).s_minimize(); | 
					
						
							|  |  |  | 	$( "#sresize" ).s_resize(); | 
					
						
							|  |  |  | 	$( "#srestoredown" ).s_restoredown(); | 
					
						
							|  |  |  | 	$( "#sfullscreen" ).s_fullscreen(); | 
					
						
							|  |  |  | 	$( "#stitlebar" ).s_titlebar(); | 
					
						
							|  |  |  | 	$( "#stoggled" ).s_toggled(); | 
					
						
							|  |  |  | });  |