Log Message write in the logs/{date}.log file, Now there are a lot of different state (alert, failed, warning, console, info etc.). It use byCode (RSD1000X etc.) which make easier. There is a console display window now when it starts and logging there as well. There is now the opportunity to choose the debug level, turn on or of the debug and event displays. Added an admin template into the admin

main
Balazs Birtalan 2023-11-02 19:17:25 +00:00
parent fc576a32f5
commit ce145b8203
59 changed files with 458 additions and 759 deletions

View File

@ -0,0 +1,19 @@
<link rel="stylesheet" type="text/css" href="content/logs/style.css">
<script>
$(document).ready(function(){
//getData("name", true);
});
function message(label,data) {
/* DON'T PUT ANY WINDOW.SIGHT.CONSOLE function or other one which call the logs because causing infinity loop */
if(label === "logs") {
//alert(data)
var data = JSON.parse(data);
var div = document.getElementById('display_logs');
div.innerHTML += "["+data.type+"]"+" ("+data.event_code+") "+data.msg+" ("+data.date+")<br\>";
}
}
</script>
<div id="display_logs"></div>

View File

@ -0,0 +1,3 @@
#display_logs {
font-size: 10pt;
}

View File

@ -0,0 +1,3 @@
<a href="#" id="screate" data-page="other" data-id="other">Create an "Other" sight!</a>
<a href="#" id="screate" data-page="other">Create an "Other" no id sight!</a>

View File

@ -0,0 +1,15 @@
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
<div id="example">This is a sentence.</div>
<button onclick="h()">JE</button>
<script>
window.sight.console("This appear in the console from the content/main_text. The content files reach the window.sight.")
</script>
<script>
window.sight.console("2")
function h(){
alert("hello2")
}
</script>

View File

@ -1,6 +1,10 @@
body {
background-color: white;
}
#sight {
background-color: #26324d;
color: white;
}
#sight #stitlebar {
background-color: #4f9af3;
}
@ -12,8 +16,8 @@ body {
font-size: larger;
float: left;
}
#sight {
border: 4px solid #4f9af3;
#sight[display="show"]{
border: 4px solid #4f9af3;
}
#sight #content {
padding: 5px;

View File

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 775 B

View File

Before

Width:  |  Height:  |  Size: 571 B

After

Width:  |  Height:  |  Size: 571 B

View File

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 535 B

View File

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 689 B

52
admin/base/main.html Normal file
View File

@ -0,0 +1,52 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../core/template_files/css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="template.js"></script>
<script src="../../core/template_files/js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script>
var init_sight={
'width' : 700,
'height' : 400,
'pos_x' : 50,
'pos_y': 50
}
</script>
<script src="../../core/template_files/js/sight.js"></script>
<script>
$(document).ready(function(){
/*addData("name", "Balazs", true);
getData("name");*/
});
function message(label, data) {
if(label === "price_change") {
sendMessage("changed_now")
return "I update my price - "+label+"; DATA - "+data
}
if(label === "test") {
return "MAIN GOT TEST MESSAGE"+"; DATA - "+data
}
}
</script>
</head>
<body>
<main id="sight">
<div id="stitlebar">
<div id="stitle">Main Template</div>
<div id="sclose"></div>
<div id="stoggled"></div>
<div id="sminimize"></div>
</div>
<div id="content">
<div id="logs" scontent="logs"></div>
</div>
<div id="sresize"></div>
</main>
</body>
</html>

6
admin/base/template.js Normal file
View File

@ -0,0 +1,6 @@
var s_template={
'name' : "Admin",
'author' : 'Balazs Birtalan',
'URL' : '/admin/base',
'created': '2023'
}

41
base.py
View File

@ -2,6 +2,12 @@ import sys
import os
import platform
import configparser
from log import Log
log = Log(3)
log.debugOn()
log.debug_level = 3
log.eventOff()
from mouseevents import MouseEvents
from pynput import mouse
from sightfactory import SightFactory
@ -10,15 +16,16 @@ from pynput.mouse import Controller
import subprocess
def init():
global data, sights, mousectrl, app
global sights, mousectrl, app, data
data = {}
#init the basic values
app = QApplication(sys.argv)
mousectrl = Controller()
sights = SightFactory()
data = {}
data["move"] = False
data["active_sight"] = "main"
data["platform"] = {}
data["platform"]["system"] = platform.system()
data["mouse_distance_x"] = 0
@ -30,6 +37,8 @@ def init():
data["display_server"] = result.decode('ascii')
data["base_dir"]=os.path.abspath(os.getcwd())+os.path.sep
data["template_dir"]=data["base_dir"]+"place"+os.path.sep+"templates"+os.path.sep
data["admin_template"] = data["base_dir"] + "admin" +os.path.sep + "base"+os.path.sep
#LOAD the template config.ini file's content
loadConfigTemplate()
@ -42,20 +51,6 @@ def frameSupported():
return False
return True
def where():
# for current func name, specify 0 or no argument.
# for name of caller of current func, specify 1.
# for name of caller of caller of current func, specify 2. etc.
currentFuncName = lambda n=0: sys._getframe(n + 1).f_code.co_name
try:
currentClassName = sys._getframe(1).f_locals["self"].__class__.__name__
except KeyError:
currentClassName = None
return str(currentClassName) + " -> " + currentFuncName(1)
def loadConfigTemplate():
config = configparser.ConfigParser()
config.sections()
@ -65,18 +60,18 @@ def loadConfigTemplate():
data["default_template_page"] = config["DEFAULT"]["default_template_page"]
data["default_template_dir"] = data["template_dir"]+data["default_template"]+os.path.sep
data["sight_mode"] = config["DEFAULT"]["sight_mode"]
logMsg("LOADED","CONFIG.INI file", where())
log.byCode("CFL1000S","CONFIG.INI file")
else:
logMsg("ERROR", "Missing 'DEFAULT' data from the templates config.ini folder. It can't start!", where())
log.byCode( "CFL1000F", "Missing 'DEFAULT' data from the templates config.ini folder. It can't start!")
def start():
# Creating admin sight
sights.create("sight-admin", "main")
sights.show("sight-admin")
# Creating the main Sight
sights.create("main", data["default_template_page"])
sights.show("main")
app.exec()
def logMsg(status, msg, where = ""):
if len(str(where)) > 0:
where = "("+where+")"
print("["+status+"]", str(msg), where, sep='\t')
app.exec()

View File

@ -1,4 +1,5 @@
import base
from base import *
from PyQt6.QtWebChannel import QWebChannel
from PyQt6.QtWebEngineWidgets import QWebEngineView
@ -16,4 +17,8 @@ class Browser(QWebEngineView):
def loadContent(self, page):
self.load(QUrl.fromLocalFile(base.data["default_template_dir"]+page+".html"))
base.logMsg("LOADED", base.data["default_template_dir"]+page+".html", base.where())
log.byCode("BLC1000S", base.data["default_template_dir"]+page+".html")
def loadAdminContent(self, page):
self.load(QUrl.fromLocalFile(base.data["admin_template"] + page + ".html"))
log.byCode("BLC1001S", base.data["admin_template"] + page + ".html")

View File

@ -1,6 +1,7 @@
import base
import json
import random
import base
from base import log
from PyQt6.QtCore import QObject, pyqtSlot
@ -11,7 +12,7 @@ class CallHandler(QObject):
@pyqtSlot(str)
def console(self, msg):
base.logMsg("CONSOLE", msg)
log.console(msg)
@pyqtSlot(str, result=str)
def test2(self, t):
@ -34,6 +35,14 @@ class CallHandler(QObject):
def setHeight(self, height):
self.sight.resize(self.sight.width(), height);
@pyqtSlot(int, int)
def setSize(self, width, height):
self.sight.resize(width,height);
@pyqtSlot(int,int)
def setPosition(self, x, y):
self.sight.move(x,y)
@pyqtSlot(result=str)
def system(self):
return base.data["platform"]["system"]
@ -105,6 +114,8 @@ class CallHandler(QObject):
def endmove(self):
base.data["move"] = False
@pyqtSlot()
def resize(self):
new_height = base.mousectrl.position[1] - self.sight.pos().y()
@ -119,7 +130,6 @@ class CallHandler(QObject):
def message(self, label, sight_id_json, data):
sight_list = json.loads(sight_id_json)
base.logMsg("MESSAGE",label, base.where())
if len(sight_list) == 0:
for sight in base.sights.getSights().values():
sight.browser.page().runJavaScript("message('" + label + "', '"+data+"')", self.ready)

View File

@ -1 +0,0 @@
<a href="#" id="screate" data-type="other" data-id="other">Create an "Other" sight!</a>

View File

@ -1 +0,0 @@
<a href="#" id="screate" data-type="other">Create an "Other" sight!</a>

View File

@ -1,6 +0,0 @@
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
<div id="example">This is a sentence.</div>
<script>
window.sight.test("This appear in the console from the content/main_text. The content files reach the window.sight.")
</script>

View File

@ -1,6 +0,0 @@
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
<div id="example">This is a sentence.</div>
<script>
window.sight.test("This appear in the console. The content files reach the window.sight.")
</script>

View File

@ -1,40 +0,0 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="template.js"></script>
<script src="../../js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script>
var init_sight={
'width' : 300,
'height' : 300
}
</script>
<script src="../../js/sight.js"></script>
<script>
$(document).ready(function(){
/*addData("name", "Balazs", true);
getData("name");*/
});
</script>
</head>
<body>
<main id="sight">
<div id="stitlebar">
<div id="stitle">Main Template</div>
<div id="sclose"></div>
<div id="stoggled"></div>
<div id="sminimize"></div>
</div>
<div id="content">
<div id="main_content"></div>
MAIN
<div id="main_text"></div>
</div>
<div id="sresize"></div>
</main>
</body>
</html>

View File

@ -1,40 +0,0 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="template.js"></script>
<script src="../../js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script>
var init_sight={
'width' : 300,
'height' : 300
}
</script>
<script src="../../js/sight.js"></script>
<script>
$(document).ready(function(){
addData("name", "Balazs", true);
getData("name");
});
</script>
</head>
<body>
<main id="sight">
<div id="stitlebar">
<div id="stitle">Main Template</div>
<div id="sclose"></div>
<div id="stoggled"></div>
<div id="sminimize"></div>
</div>
<div id="content">
<div id="main_content"></div>
MAIN
<div id="main_text"></div>
</div>
<div id="sresize"></div>
</main>
</body>
</html>

View File

@ -1,30 +0,0 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="../../js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script src="../../js/sight.js"></script>
<script>
$(document).ready(function(){
getData("name", true);
});
</script>
</head>
<body>
<main id="sight">
<div id="stitlebar">
<div id="stitle">TITLE</div>
<div id="sclose"></div>
<div id="stoggled"></div>
<div id="sminimize"></div>
</div>
<div id="content">
OTHER
<a href="main.html">Open the main inside this sight!</a>
</div>
<div id="sresize"></div>
</main>
</body>
</html>

View File

@ -1,13 +0,0 @@
var s_template={
'name' : "Base",
'author' : 'Balazs Birtalan',
'URL' : '/template/base',
'created': '2023'
}
// first element: "key" is the ID where the content html will be embedded
// second element: "value" is the folder name of that content folder where the content.html file's contents will be embedded
var s_contents={
'main_content':"main",
'main_text':"main_text",
}

View File

@ -1,13 +0,0 @@
var s_template={
'name' : "Base",
'author' : 'Balazs Birtalan',
'URL' : '/template/base',
'created': '2023'
}
// first element "key" is the ID where the content html will be embedded
// second element "value" is the folder name of that content folder where the content.html file's contents will be embedded
var s_contents={
'main_content':"main",
'main_text':"main_text",
}

View File

@ -1,3 +0,0 @@
[DEFAULT]
default_template = base
sight_mode = single

View File

@ -1,3 +0,0 @@
[DEFAULT]
default_template = base
sight_mode = multiple

View File

@ -188,8 +188,7 @@ $(document).ready(function(){
// INIT the Sight from init_sight variable
if (typeof init_sight !== 'undefined') {
for ( const [key,value] of Object.entries( init_sight ) ) {
/*for ( const [key,value] of Object.entries( init_sight ) ) {
window.sight.console(key + " - " + value)
switch(key) {
case 'width':
@ -199,7 +198,12 @@ $(document).ready(function(){
window.sight.setHeight(value)
break;
}
}
}*/
if(init_sight["width"]!== 'undefined' && init_sight["height"]!== 'undefined')
window.sight.setSize(init_sight["width"],init_sight["height"])
if(init_sight["pos_x"]!== 'undefined' && init_sight["pos_y"]!== 'undefined')
window.sight.setPosition(init_sight["pos_x"], init_sight["pos_y"])
}
// INIT
/*window.sight.getDefaultTemplate(function(default_template) {

View File

@ -0,0 +1,3 @@
<a href="#" id="screate" data-page="other" data-id="other">Create an "Other" sight!</a>
<a href="#" id="screate" data-page="other">Create an "Other" no id sight!</a>

View File

@ -0,0 +1,15 @@
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
<div id="example">This is a sentence.</div>
<button onclick="h()">JE</button>
<script>
window.sight.console("This appear in the console from the content/main_text. The content files reach the window.sight.")
</script>
<script>
window.sight.console("2")
function h(){
alert("hello2")
}
</script>

View File

@ -0,0 +1,3 @@
#example {
background-color: yellow;
}

View File

@ -1,6 +1,10 @@
body {
background-color: white;
}
#sight {
background-color: #26324d;
color: white;
}
#sight #stitlebar {
background-color: #4f9af3;
}
@ -12,17 +16,8 @@ body {
font-size: larger;
float: left;
}
#sight #sresize {
width: 15px;
height: 15px;
background-color: none;
right: 0;
float: right;
bottom: 0;
position: absolute;
}
#sight {
border: 4px solid #4f9af3;
#sight[display="show"]{
border: 4px solid #4f9af3;
}
#sight #content {
padding: 5px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

View File

@ -0,0 +1,51 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../core/template_files/css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="template.js"></script>
<script src="../../core/template_files/js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script>
var init_sight={
'width' : 500,
'height' : 300,
'pos_x' : 50,
'pos_y': 50
}
</script>
<script>
$(document).ready(function(){
/*addData("name", "Balazs", true);
getData("name");*/
});
function message(label, data) {
if(label === "price_change") {
sendMessage("changed_now")
return "I update my price - "+label+"; DATA - "+data
}
if(label === "test") {
return "MAIN GOT TEST MESSAGE"+"; DATA - "+data
}
}
</script>
</head>
<body>
<main id="sight" display="show">
<div id="stitlebar" display="show">
<div id="stitle">Main Template</div>
<div id="sclose"></div>
<div id="stoggled"></div>
<div id="sminimize"></div>
</div>
<div id="content">
ADMIN
</div>
<div id="sresize" display="show"></div>
</main>
</body>
</html>

View File

@ -9,7 +9,23 @@
<script>
$(document).ready(function(){
//getData("name", true);
sendMessage("price_change")
dict = {}
dict["account_id"] = 10227;
dict["account_name"] = "Test Bank";
dict["details"] = {};
dict["details"]["phone"] = 123456789
dict["details"]["place"] = "New York"
sendMessage("test", ["other","main"], dict)
});
function message(label,data) {
if(label === "test") {
data_dict = JSON.parse(data)
return "DATA - "+data_dict["account_name"] + " - " + data_dict["details"]["place"]
}
}
</script>
</head>
<body>

View File

@ -0,0 +1,6 @@
var s_template={
'name' : "Admin",
'author' : 'Balazs Birtalan',
'URL' : '/admin/base',
'created': '2023'
}

123
log.py Normal file
View File

@ -0,0 +1,123 @@
import sys
import os.path
import datetime
import html
from log_event_codes import loge_codes
import base
class Log():
def __init__(self, specify=1):
loge_codes.addEventCode("LOG0001X", "The event code is not exist!")
self.specify = specify
self.debug = False
self.debug_level = 1
self.event_on = True
self.debug_modes = {}
self.debug_modes[0] = ["info", "console", "message", "success"]
self.debug_modes[1] = ["alert", "warning", "event"]
self.debug_modes[2] = ["failed", "error"]
self.debug_modes[3] = ["all"]
print("--- LOG STARTED ----")
def debugOn(self):
self.debug = True
def debugOff(self):
self.debug = False
def eventOn(self):
self.event_on = True
def eventOff(self):
self.event_on = False
def debugLevel(self, number):
if number < 1:
self.debug_level = 1
elif number > 3:
self.debug_level = 3
else:
self.debug_level = number
def whereis(self):
# for current func name, specify 0 or no argument.
# for name of caller of current func, specify 1.
# for name of caller of caller of current func, specify 2. etc.
# self.specify
currentFuncName = lambda n=0: sys._getframe(n + 1).f_code.co_name
try:
currentClassName = sys._getframe(self.specify).f_locals["self"].__class__.__name__
except KeyError:
currentClassName = None
if currentClassName is None:
currentClassName = "No Class"
return str(currentClassName) + " -> " + currentFuncName(self.specify)
def byCode(self, event_code, msg = "", wheres = ""):
code_data = loge_codes.getEventCode(event_code)
if code_data is not None:
if event_code[:3].upper() == "LOG":
self.msg(code_data["type"], event_code, msg, wheres, True)
else:
self.msg(code_data["type"], event_code, msg, wheres)
else:
self.byCode("LOG0001X", event_code + " is not exist!")
def msg(self, type, event_code, msg="", wheres="", serious_error=False):
dnow = datetime.datetime.now()
if serious_error is True:
type = "SERIOUS"
code_data = loge_codes.getEventCode(event_code)
event_state = ""
if code_data is not None:
if len(code_data["event_state"]) > 0:
event_state = code_data["event_state"]
msg = event_state+" "+code_data["details"] + " " + msg
if len(wheres) == 0:
wheres = self.whereis()
""" LOG FILE WRITING """
if type not in self.debug_modes[0] and type.upper() != "EVENT":
filename = str(dnow.strftime("%d"))+"-"+str(dnow.strftime("%m"))+"-"+str(dnow.year)+".log"
directory = '.'+os.path.sep+"logs"+os.path.sep
file_path = os.path.join(directory, filename)
if not os.path.isdir(directory):
os.mkdir(directory)
content = "["+type.upper()+"]\t{"+event_code+"}\t"+str(msg)+"\t("+wheres+")\t"+"<"+str(dnow)+">\n"
if os.path.exists(file_path):
with open(file_path, 'a') as file:
file.write(content)
file.close()
else:
f = open(file_path, "w")
f.write(content)
f.close()
""" END LOG FILE WRITING """
""" LOG DISPLAY """
if serious_error is False:
if type.upper() == "EVENT" and self.event_on is False:
return
if type not in self.debug_modes[0] and self.debug_level != 3:
if self.debug is True and type not in self.debug_modes[self.debug_level]:
return
dict = {}
dict["type"] = type.upper()
dict["event_code"] = str(event_code)
dict["msg"] = msg.replace('\\', '\\\\')
dict["event_state"] = str(event_state)
dict["date"] = str(dnow)
base.sights.sendMessage("logs", ["sight-admin"], dict)
print("["+type.upper()+"]",event_code, str(msg), wheres, "["+str(dnow)+"]", sep='\t')
""" END LOG DISPLAY """
def console(self, msg, wheres = ""):
self.msg("console", "", msg, wheres)
def message(self, msg, wheres = ""):
self.msg("message", "", msg, wheres)

41
log_event_codes.py Normal file
View File

@ -0,0 +1,41 @@
class LogEventCodes():
def __init__(self, specify=1):
self.code_list = {}
def addEventCode(self, code, details, event_state=""):
self.code_list[code] = {}
self.code_list[code]["details"] = details
self.code_list[code]["event_state"] = event_state
last_letter = code[len(code)-1]
type = "info"
match last_letter.upper():
case 'S': type = "success"
case 'F': type = "failed"
case 'W': type = "warning"
case 'E': type = "event"
case 'X': type = "error"
case 'A': type = "alert"
self.code_list[code]["type"] = type
def getEventCode(self, code):
if code in self.code_list:
return self.code_list[code]
return None
loge_codes = LogEventCodes()
loge_codes.addEventCode("CFL1000S", "The Config File loaded and the [DEFAULT] datablock is loaded.")
loge_codes.addEventCode("CFL1000X", "The [DEFAULT] datablock isn't loaded or founded, but the config file loaded.")
loge_codes.addEventCode("BLC1000S", "The html file content is loaded in the browser")
loge_codes.addEventCode("BLC1001S", "The admin html file content is loaded in the browser")
loge_codes.addEventCode("SF1000E", "The sight is being created.","CREATING")
loge_codes.addEventCode("SF1000W", "The sight is already exist with that ID. It can't be create a new one with that id.s")
loge_codes.addEventCode("SF1001W", "The sight ID is not exist. It can't be shown!")
#EVENT BASED
loge_codes.addEventCode("MES1000E", "Mouse dragged the Sight and move to other position.", "MOVING")
loge_codes.addEventCode("MES1001E", "Mouse pressed on that windows which was in the background and it is become now active.", "PRESSED")
loge_codes.addEventCode("MES1002E", "Mouse released", "RELEASED")
loge_codes.addEventCode("MES1003E", "Mouse scrolling down", "SCROLLING_DOWN")
loge_codes.addEventCode("MES1004E", "Mouse scrolling up", "SCROLLING_UP")

2
logs/02-11-2023.log Normal file
View File

@ -0,0 +1,2 @@
[SERIOUS] {LOG0001X} The event code is not exist! SF1001E is not exist! (Log -> byCode) <2023-11-02 15:22:48.165720>
[WARNING] {SF1001W} The sight ID is not exist. It can't be shown! This 'sight-admin-main' id isn't exist to show! (SightFactory -> show) <2023-11-02 16:34:22.302591>

View File

@ -1,4 +1,5 @@
import base
from base import log
from pynput import mouse
class MouseEvents():
@ -12,7 +13,6 @@ class MouseEvents():
# MOUSE EVENTS/LISTENER
def on_move(x, y):
if base.data["move"]:
print("MOVING")
if base.data["mouse_distance_x"] == 0:
base.data["mouse_distance_x"] = base.sights.get(base.data["active_sight"]).pos().x()-x
@ -22,20 +22,20 @@ def on_move(x, y):
x_point = x+base.data["mouse_distance_x"]
y_point = y+base.data["mouse_distance_y"]
print( str(x_point) + " x " + str(y_point))
log.byCode("MES1000E",str(x_point) + " x " + str(y_point))
base.sights.get(base.data["active_sight"]).move(x_point, y_point)
def on_click(x, y, button, pressed):
if pressed:
print("pressed on " +base.data["active_sight"])
log.byCode("MES1001E", base.data["active_sight"])
else:
print("released")
log.byCode("MES1002E", base.data["active_sight"])
base.data["mouse_distance_x"] = 0
base.data["mouse_distance_y"] = 0
base.data["move"] = False
def on_scroll(x, y, dx, dy):
print('Scrolled {0} at {1}'.format(
'down' if dy < 0 else 'up',
(x, y)))
if dy < 0:
log.byCode("MES1003E", 'Scrolled {0} at {1}'.format('down',(x, y)))
else:
log.byCode("MES1004E", 'Scrolled {0} at {1}'.format('up',(x, y)))

View File

@ -1,34 +0,0 @@
body {
background-color: white;
}
* {
cursor: default;
}
a {
cursor: pointer;
}
body {
margin: 0px;
display: flex;
}
#sight #smove, #sight #sresize {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by any browser but < IE9 */
}
#sight #sresize {
cursor: nw-resize;
}
#sight {
border: 4px solid grey;
display: block;
width: 100%;
}
#sight #stitlebar {
width: 100%;
height: 25px;
background-color: grey;
}

View File

@ -1,267 +0,0 @@
if(navigator.userAgent.indexOf("QtWebEngine") > 0) {
new QWebChannel(qt.webChannelTransport, function (channel) {
// now I retrieve my object
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() {
event.preventDefault();
window.sight.create($(this).data("id"), $(this).data("type"), function(sight_id) {
});
})
};*/
$.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);
}
$(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 ) ) {
/*$("#"+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) {
});
});
});
});
}
}
// 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
/*$( "#screate" ).s_create();*/
$( "#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();
});

View File

@ -1,82 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="styles.css" />
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<title>jQuery xtr.js plugin Demo</title>
<style>
body { font-family:'Roboto'; background-color:#333; color:#fafafa;}
#wrapper {
margin: 150px auto;
width: 400px;
text-align: center
}
#wrapper div {
color:#fff;
}
</style>
</head>
<body>
<div id="jquery-script-menu">
<div class="jquery-script-center">
<ul>
<li><a href="http://www.jqueryscript.net/text/jQuery-Client-side-Translation-xtr/">Download This Plugin</a></li>
<li><a href="http://www.jqueryscript.net/">Back To jQueryScript.Net</a></li>
</ul>
<div class="jquery-script-ads"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2783044520727903";
/* jQuery_demo */
google_ad_slot = "2780937993";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div class="jquery-script-clear"></div>
</div>
</div>
<div id="wrapper">
<h1>jQuery xtr.js plugin Demo</h1>
<div xtr>Welcome</div>
<div xtr>Hello</div>
<div data-xtr-key="bye">Good Bye</div>
<label for="lang">Current language</label>
<select name="lang" id="lang">
<option value="reset">EN</option>
<option value="de">DE</option>
<option value="fr">FR</option>
<option value="es">ES</option>
</select>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="../jquery.xtr.min.js"></script>
<script>
$('body').xtr({t: data});
$('#lang').on('change', function() {
$('body').data('plugin_xtr').lang($(this).val());
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

View File

@ -1,27 +0,0 @@
#wrapper {
font: 16px/18px Calibri;
margin: 0 auto;
width: 200px;
text-align: center
}
#wrapper div {
background: #28b7ff;
padding: 15px;
margin: 10px;
text-align: center
}
label {
font-weight: 700;
margin: 25px 0 5px;
display: block
}
select {
width: 100%;
height: 30px;
outline: 0;
cursor: pointer
}

View File

@ -1,23 +0,0 @@
#wrapper {
font: 16px / 18px Calibri;
margin: 0 auto;
width: 200px;
text-align: center;
div {
background: #28b7ff;
padding: 15px;
margin: 10px;
text-align: center;
}
}
label {
font-weight: bold;
margin: 25px 0 5px;
display: block;
}
select {
width: 100%;
height: 30px;
outline: none;
cursor: pointer;
}

View File

@ -1,8 +0,0 @@
var data = {
"close": {
en: "close",
hu: "Bezar",
it: "Vicino"
},
};

View File

@ -1,88 +0,0 @@
/*!
* July 2017
* xtr 1.0.0
* @author Mario Vidov
* @url http://vidov.it
* @twitter MarioVidov
* MIT license
*/
(function($) {
var pluginName = 'xtr';
var settings = {
default: 'en',
lang: 'en',
regExp: {
'': /\s/g,
'_': /[&<>"'`\/=]/g
}
};
var config = {
defaultClass: 'data-xtr-default',
langClass: 'data-xtr-lang',
langKey : 'data-xtr-key',
langOrig : 'data-xtr-original'
};
function Plugin(element, options) {
options = options || {};
this.$element = $(element);
this.options = $.extend(true, {}, settings, options);
this.selector = '[xtr]';
this.regExp = this.options.regExp;
this.default = this.options.default;
this.t = this.options.t;
this.l = this.options.lang;
this.$element.attr(config.langClass, this.l)
.attr(config.defaultClass, this.default);
this.init();
}
Plugin.prototype.lang = function(l) {
if (l && l === 'reset') {
this.l = this.default;
} else if (l) {
this.l = l;
}
this.init();
};
Plugin.prototype.set = function(index) {
var $el = $('[' + config.langKey + '="' + index + '"]');
var original = $el && $el.attr(config.langOrig) || index;
return (this.t && this.t[index] && this.t[index][this.l]) ? this.t[index][this.l] : original;
};
Plugin.prototype.init = function() {
var self = this;
this.$element.attr(config.langClass, this.l);
$(self.selector).add('[' + config.langKey + ']').each(function () {
var $this = $(this);
var key = $this.attr(config.langKey);
var original = $this.attr(config.langOrig);
var text = $this.text();
if (!key) {
key = text;
for (var i in self.regExp) {
key = key.replace(self.regExp[i], i);
}
$this.attr(config.langKey, key);
}
if (!original) {
$this.attr(config.langOrig, text);
}
$this.html(self.set(key));
});
};
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
}
});
};
})(jQuery);

View File

@ -1 +0,0 @@
(function(t){var i="xtr";var a={"default":"en",lang:"en",regExp:{"":/\s/g,_:/[&<>"'`\/=]/g}};var e={defaultClass:"data-xtr-default",langClass:"data-xtr-lang",langKey:"data-xtr-key",langOrig:"data-xtr-original"};function s(i,s){s=s||{};this.$element=t(i);this.options=t.extend(true,{},a,s);this.selector="[xtr]";this.regExp=this.options.regExp;this.default=this.options.default;this.t=this.options.t;this.l=this.options.lang;this.$element.attr(e.langClass,this.l).attr(e.defaultClass,this.default);this.init()}s.prototype.lang=function(t){if(t&&t==="reset"){this.l=this.default}else if(t){this.l=t}this.init()};s.prototype.set=function(i){var a=t("["+e.langKey+'="'+i+'"]');var s=a&&a.attr(e.langOrig)||i;return this.t&&this.t[i]&&this.t[i][this.l]?this.t[i][this.l]:s};s.prototype.init=function(){var i=this;this.$element.attr(e.langClass,this.l);t(i.selector).add("["+e.langKey+"]").each(function(){var a=t(this);var s=a.attr(e.langKey);var n=a.attr(e.langOrig);var r=a.text();if(!s){s=r;for(var l in i.regExp){s=s.replace(i.regExp[l],l)}a.attr(e.langKey,s)}if(!n){a.attr(e.langOrig,r)}a.html(i.set(s))})};t.fn[i]=function(a){return this.each(function(){if(!t.data(this,"plugin_"+i)){t.data(this,"plugin_"+i,new s(this,a))}})}})(jQuery);

View File

@ -1,21 +1,23 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
<link rel="stylesheet" type="text/css" href="../../../core/template_files/css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="template.js"></script>
<script src="../../js/jquery-3.6.4.min.js"></script>
<script src="../../../core/template_files/js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script>
var init_sight={
'width' : 300,
'height' : 300
'height' : 300,
'pos_x' : 450,
'pos_y': 450
}
</script>
<script src="../../js/sight.js"></script>
<script src="../../../core/template_files/js/sight.js"></script>
<script>
$(document).ready(function(){
/*addData("name", "Balazs", true);

View File

@ -1,11 +1,11 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
<link rel="stylesheet" type="text/css" href="../../../core/template_files/css/sight.css">
<link rel="stylesheet" type="text/css" href="css/template.css">
<script src="../../js/jquery-3.6.4.min.js"></script>
<script src="../../../core/template_files/js/jquery-3.6.4.min.js"></script>
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script src="../../js/sight.js"></script>
<script src="../../../core/template_files/js/sight.js"></script>
<script>
$(document).ready(function(){
//getData("name", true);

View File

@ -23,7 +23,12 @@ class Sight(QWidget):
self.browser = Browser()
self.browser.addObject('handler', CallHandler(self) )
self.browser.loadContent(page)
#self.browser.loadAdminContent(page)
if "sight-admin" in id:
self.browser.loadAdminContent(page)
else:
self.browser.loadContent(page)
self.layout = QVBoxLayout()
self.layout.addWidget(self.browser)

View File

@ -1,4 +1,6 @@
import base
from base import log
import json
import random
from sight import Sight
@ -8,10 +10,9 @@ class SightFactory():
self.data = {} #Global data(s) for the sight(s)
def create(self, id, page):
base.logMsg("CREATING","The page '" + str(page) + "' with '"+str(id)+"' id.",base.where())
log.byCode("SF1000E","The page '" + str(page) + "' with '"+str(id)+"' id.")
if str(id) == "main" and self.checkKey(id):
base.logMsg("WARNING", "The '"+str(id)+"' window already exist! You can't create more than one 'main' page sight!", base.where())
log.warning("SF1000W", "The '"+str(id)+"' window already exist! You can't create more than one 'main' page sight!")
return None
if base.data["sight_mode"] == "unique":
@ -39,9 +40,9 @@ class SightFactory():
def show(self, id):
if self.checkKey(id):
self.list[id].show()
base.logMsg("SHOWED","The '"+str(id)+"' sight is showed!", base.where())
log.byCode("SF1000E","The '"+str(id)+"' sight is showed!")
return True
base.logMsg("MISSING", "This '"+str(id)+"' id isn't exist to show!", base.where())
log.byCode("SF1001W", "This '"+str(id)+"' id isn't exist to show!")
return False
def getSights(self):
@ -79,19 +80,25 @@ class SightFactory():
self.list[id].deleteLater()
del self.list[id]
"""print("The '"+str(id)+"' is closed now!")"""
self.eventMessage("CLOSED", "sight", id)
return True
else:
print("The '"+str(id)+"' isn't exist'")
return False
def eventMessage(self, label, where, data):
for sight in self.list.values():
sight.browser.page().runJavaScript("eventMsg('" + label + "', '" + where + "', '" + data + "')", self.ready)
def sendMessage(self, label, sight_list, data):
data = json.dumps(data)
print(data)
if len(sight_list) == 0:
for sight in self.list.values():
sight.browser.page().runJavaScript("message('" + label + "', '"+str(data)+"')", self.ready)
else:
for sight_id in sight_list:
if base.sights.checkKey(sight_id):
base.sights.get(sight_id).browser.page().runJavaScript("message('" + label + "', '" + str(data) + "')", self.ready)
def ready(self, returnValue):
if returnValue is not None:
print(returnValue)
print("RETURN "+returnValue)
def processes(self):
if len(self.list) > 0: