File size: 4,087 Bytes
c0bb696 d790501 c0bb696 d790501 c0bb696 d790501 c0bb696 d790501 988e84f c0bb696 d790501 c0bb696 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
/** @format */
// function show() {
// const log = document.getElementById("id_log");
// if (log.classList.contains("active")) return;
// log.classList.add("active");
// }
// function hide() {
// const log = document.getElementById("id_log");
// if (!log.classList.contains("active")) return;
// log.classList.remove("active");
// }
// jshint esversion: 8
// release 09-'6-24
// utilizzare l'ultima versione di UaWindowAdm
// setXY con vw ,vh
var UaLog = {
callHide: function () {},
callShow: function () {},
active: false,
wind: null,
x: null,
y: null,
z: null,
max_length: 2000,
msg_id: "ualogmsg_",
new: function () {
if (this.wind == null) {
this.wind = UaWindowAdm.create("ualog_");
this.wind.drag();
}
const h = `
<button type="button" onclick="javascript:UaLog.cls();">Clear</button>
<button type="button" onclick="javascript:UaLog.close();">Close</button>
<div id="ualogmsg_"></div>`;
this.wind.setHtml(h);
this.wind.setStyle({
width: "auto",
minWidth: "300px",
maxWidth: "400px",
height: "auto",
textAlign: "center",
padding: "2px 2px 2px 2px",
margin: "5px 0 0 0",
// background: "#111111",
background: "#333333",
color: "#ffffff",
fontSize: "15px",
fontWeight: "normal",
borderRadius: "9px",
border: "1px solid #999999",
});
const msg = document.getElementById(this.msg_id);
const msg_css = {
width: "auto",
textAlign: "left",
fontSize: "16px",
fontFamily:"monospace",
paddingTop: "2px ",
marginTop: "2px",
color:"#ffffff",
background: "#000000",
maxHeight: "400px",
overflow: "auto",
// scrollbarColor: "#ab3205 #ffffff",
scrollbarColor: "#027876 #454444",
scrollbarWidth: "auto",
};
for (const k in msg_css) msg.style[k] = msg_css[k];
const btn_css = {
background: "#444444",
color: "#ffffff",
padding: "5px 5px 5px 5px",
margin: "0 5px 0 5px",
fontSize: "16px",
fontWeight: "bold",
border: "1px solid #ffffff",
borderRadius: "10px",
};
const btns = document.querySelectorAll("#ualog_ button");
for (const b of btns) {
for (const k in btn_css) b.style[k] = btn_css[k];
b.addEventListener("mouseover", (e) => {
e.target.style.cursor = "pointer";
e.target.style.color = "#000000";
e.target.style.background = "#aaaaaa";
});
b.addEventListener("mouseout", (e) => {
for (const k in btn_css) e.target.style[k] = btn_css[k];
});
}
if (!!this.x) this.wind.vw_vh().setXY(this.x, this.y, -1);
else this.wind.setCenter(-1);
if (!!this.z) this.wind.setZ(this.z);
return this;
},
setXY(x, y) {
this.x = x;
this.y = y;
return this;
},
setZ(z) {
this.z = z;
return this;
},
prn_(...args) {
let s = args.join("<br/>");
let e = document.getElementById(this.msg_id);
let h = e.innerHTML + s + "<br/>";
// TODO if (h.length > this.max_length) h = h.slice(-this.max_length);
e.innerHTML = h;
},
print(...args) {
if (this.wind == null) return;
if (!this.active) return;
this.prn_(...args);
},
log(...args) {
if (this.wind == null) return;
this.prn_(...args);
},
log_show(...args) {
if (this.wind == null) return;
if (!this.active) this.toggle();
this.prn_(...args);
},
cls() {
if (this.wind == null) return;
document.getElementById(this.msg_id).innerHTML = "";
return this;
},
close() {
if (this.wind == null) return;
this.wind.hide();
this.active = false;
this.callHide();
},
// open() {
// if (this.wind == null) return;
// this.wind.show();
// this.active = true;
// },
toggle() {
if (this.wind == null) return;
if (!this.active) {
this.active = true;
this.wind.show();
this.callShow();
} else {
this.active = false;
this.wind.hide();
this.callHide();
}
},
};
|