diff --git a/app.js b/app.js
index 75560ba..edb98cf 100644
--- a/app.js
+++ b/app.js
@@ -921,6 +921,14 @@ io.on('connection', function (socket) {
db.addConnection(handle)
Functions.log({ action: "connect", handle: handle });
+ socket.emit('broadcast', {
+ type: 'log',
+ data: {
+ data: 'lol',
+ type: 'server'
+ }
+ })
+
socket.on('disconnect', function () {
db.removeConnection(handle)
Functions.log({ action: "disconnect", handle: handle });
@@ -969,6 +977,22 @@ io.on('connection', function (socket) {
});
+ socket.on('silent', function (data) {
+ function reply(rep) {
+ socket.emit('silent', {
+ rep: rep,
+ id: data.id
+ })
+ }
+ var actions = {
+ 'size': () => {
+ reply('lol')
+ }
+ }
+ if (actions[data.query])
+ actions[data.query]()
+ })
+
});
app.get('/', function (req, res) {
diff --git a/commands.js b/commands.js
index 40111c9..4e1f8cb 100644
--- a/commands.js
+++ b/commands.js
@@ -10,6 +10,7 @@ module.exports = {
test: {
f: com => {
com.insert(['whatever', [1,2]], {flag: 1});
+ com.insert(['whatever', [1,3]], {flag: 1});
com.end();
},
desc: "block test",
diff --git a/public/index.html b/public/index.html
index 712e923..f15afe9 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2,7 +2,6 @@
-
@@ -10,37 +9,19 @@
smart-home
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
-
-
-
-
-
diff --git a/public/packages/Download.js b/public/packages/Download.js
new file mode 100644
index 0000000..b129b4b
--- /dev/null
+++ b/public/packages/Download.js
@@ -0,0 +1,34 @@
+function download(content, filename) {
+ /**
+ * Download variable as file
+ * @param {mixed} content any variable
+ * @param {string} filename name of downloaded file
+ *
+ * @returns {undefined}
+ */
+
+ var createObjectURL = (window.URL || window.webkitURL || {}).createObjectURL || function () { };
+ var blob = null;
+ var mimeString = "application/octet-stream";
+ window.BlobBuilder = window.BlobBuilder ||
+ window.WebKitBlobBuilder ||
+ window.MozBlobBuilder ||
+ window.MSBlobBuilder;
+
+
+ if (window.BlobBuilder) {
+ var bb = new BlobBuilder();
+ bb.append(content);
+ blob = bb.getBlob(mimeString);
+ } else {
+ blob = new Blob([content], { type: mimeString });
+ }
+ var url = createObjectURL(blob);
+ var a = document.createElement("a");
+ a.href = url
+ a.download = filename;
+ a.innerHTML = "";
+ document.body.appendChild(a);
+ a.click()
+ a.remove()
+}
\ No newline at end of file
diff --git a/public/packages/Essentials.js b/public/packages/Essentials.js
index bd34349..66d792d 100644
--- a/public/packages/Essentials.js
+++ b/public/packages/Essentials.js
@@ -1,6 +1,28 @@
export var type = "command"
export default {
+ 'settings': com =>{
+ var actions = {
+ 'set': () => {
+ com.con.settings[com.arg[1]] = eval(com.arg[2])
+ Storage.Local.set('settings', com.con.settings)
+ com._end()
+ }
+ }
+ actions[com.arg[0]]()
+ },
+ 'mod': com => {
+ var actions = {
+ 'get': ()=>{
+ com.con.prompt(`Install ${com.arg[1]} module? [y\\n]`)
+ .then(()=>{
+ com.con._requires(com.arg[1])
+ .then(()=>com._end())
+ })
+ }
+ }
+ actions[com.arg[0]]()
+ },
'clear': com => {
com.con.clear()
},
@@ -12,6 +34,7 @@ export default {
} catch (error) {
com.log(error, "error");
}
+ com._end()
})
}
}
\ No newline at end of file
diff --git a/public/packages/Font.js b/public/packages/Font.js
new file mode 100644
index 0000000..3567247
--- /dev/null
+++ b/public/packages/Font.js
@@ -0,0 +1,30 @@
+export var type = 'sub'
+
+export default class Font{
+ constructor(con){
+ this.con = con
+ this.fonts = {}
+ }
+
+ set(name){
+ if(this.fonts[name]){
+ $(':root').css('--font', name)
+ } else {
+ this.con.log(`Font ${name} is not installed`, 'error')
+ }
+ }
+
+ install(url, name, prop){
+ this.fonts[name] = new FontFace(name, `url(${url})`, prop);
+ this._load(name)
+ }
+
+ _load(name){
+ this.fonts[name].load().then(face => {
+ document.fonts.add(face)
+ }).catch(err => {
+ this.con.log(`Loading font ${name} failed: ${err}`)
+ throw err
+ });
+ }
+}
\ No newline at end of file
diff --git a/public/packages/Fontello.js b/public/packages/Fontello.js
new file mode 100644
index 0000000..3ef4cea
--- /dev/null
+++ b/public/packages/Fontello.js
@@ -0,0 +1,9 @@
+export var type = 'Class'
+
+export var requires = {
+ styles: ['res/fontello.css']
+}
+
+export default class Fontello{
+
+}
\ No newline at end of file
diff --git a/public/packages/Graph.js b/public/packages/Graph.js
new file mode 100644
index 0000000..dcb118e
--- /dev/null
+++ b/public/packages/Graph.js
@@ -0,0 +1,14 @@
+function toGraph(data, x, y) {
+ /**
+ * Create chart.js graph
+ * @param {object} data chart.js configuration object
+ * @param {number} x graph width
+ * @param {number} y grap height
+ *
+ * @returns {H} chart.js html element with init script
+ */
+
+ var id = makeID(6);
+
+ return ``
+}
\ No newline at end of file
diff --git a/public/packages/Json.js b/public/packages/Json.js
new file mode 100644
index 0000000..820739d
--- /dev/null
+++ b/public/packages/Json.js
@@ -0,0 +1,33 @@
+export var type = 'sub'
+
+export var commands = {
+
+}
+
+export default class Json{
+
+// .append(
+// $("")
+// .addClass("jsonl")
+// .prop("type", "file")
+// .hide()
+// )
+// this.elements.$jsonl[0].addEventListener('chsange', this.readJson, false);
+ // readJson(data) {
+ // var file = data.target.files[0];
+ // var reader = new FileReader();
+
+ // reader.con = $(this).closest(".wind").data("con");
+ // reader.onload = function (event) {
+ // try {
+ // this.con.jsond = JSON.parse(event.target.result);
+ // this.con.log("JSON loaded", "ok");
+ // } catch (error) {
+ // this.con.log(`JSON parsing error: ${error}`, "error");
+ // }
+
+ // }
+ // reader.readAsText(file, "UTF-8");
+
+ // }
+}
\ No newline at end of file
diff --git a/public/packages/Messenger.js b/public/packages/Messenger.js
new file mode 100644
index 0000000..c4c25a9
--- /dev/null
+++ b/public/packages/Messenger.js
@@ -0,0 +1,276 @@
+// function mesparse(data, amount, con) { // parse mesenger chat information
+// var response = "";
+// var perf = performance.now();
+
+// // check if json is loaded\
+// if (typeof data != "undefined") {
+
+// // check if participants are defined\
+// if (typeof data.participants != "undefined") {
+
+// l = []; // links
+// p = 0; // pics
+// a = []; // unique words
+// ac = []; // unique words counter
+// w = 0; // word counter
+// d = [0, 0, 0, 0, 0, 0, 0] // weekdays
+// h = new Array(24).fill(0);
+
+// // unique words by participant
+// for (let key in data.participants) {
+// data.participants[key].w = [];
+// }
+
+// // check if messages are defined\
+// if (typeof data.messages != "undefined") {
+
+// // parse every message in file
+// for (let key in data.messages) {
+
+// // check if content is present
+// if (typeof data.messages[key].content != "undefined") {
+
+// let x = new Date();
+// x.setTime(data.messages[key].timestamp_ms);
+// d[x.getDay()] += 1;
+// h[x.getHours()] += 1;
+
+// // check if message is a photo
+// if (data.messages[key].photos) {
+// p++;
+// continue;
+// }
+
+// data.messages[key].content = data.messages[key].content.replace(/ +(?= )/g, '');
+// words = data.messages[key].content.split(" ");
+
+// for (let word in words) {
+
+// let i = a.indexOf(words[word]);
+// if (i == -1) {
+// a.push(words[word]);
+// ac.push(1);
+// } else {
+// ac[i] += 1;
+// }
+
+// for (let p in data.participants) {
+// if (data.messages[key].sender_name == data.participants[p].name)
+// data.participants[p].w.push(words[word])
+// }
+// // if(data.messages[key].sender_name == "Sebastian Fudalej") s.push(words[word]);
+// // else if(data.messages[key].sender_name == "Mateusz Pstrucha") m.push(words[word]);
+// w++;
+// }
+// }
+
+// // break if requested amount is parsed
+// if (typeof amount != "undefined")
+// if (amount > 0)
+// if (key == amount) break;
+// }
+
+// // merging words and count arrays
+// b = [];
+// for (let key in a) {
+// b.push([a[key], ac[key]]);
+// }
+
+// // sorting words by count
+// b.sort(function (a, b) {
+// if (a[1] === b[1]) {
+// return 0;
+// }
+// else {
+// return (a[1] > b[1]) ? -1 : 1;
+// }
+// });
+
+// response += "
" + con.returnError("Done", "ok");
+// response += "
#### " + data.title + ": ####"
+
+// // top #10 words
+// let v = b.slice(0, 10);
+// var tp = [];
+// for (let key in v) {
+// tp.push(["" + decodeURIComponent(escape(v[key][0])) + "", v[key][1]]);
+// }
+// response += toTable(tp);
+
+// // words by participant
+// var partic = [];
+// for (let key in data.participants) {
+// partic.push(["" + decodeURIComponent(escape(data.participants[key].name)) + "", data.participants[key].w.length])
+// // response += "
"+decodeURIComponent(escape(data.participants[key].name))+" words: "+data.participants[key].w.length;
+// }
+// response += toTable(partic);
+
+// // response += toTable([
+// // ["Monday", d[0]],
+// // ["Tuesday", d[1]],
+// // ["Wednesday", d[2]],
+// // ["Thursday", d[3]],
+// // ["Friday", d[4]],
+// // ["Saturday", d[5]],
+// // ["Sunday", d[6]]
+// // ])
+
+// // let hrs = [];
+// // for(let hours in h){
+// // hrs.push([hours+":00", h[hours]]);
+// // }
+
+// response += toGraph({
+// type: 'line',
+// data: {
+// labels: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
+// datasets: [{
+// label: '# per hour of day',
+// data: h,
+// backgroundColor: "#ffffff66",
+// borderColor: "#ffffff66",
+// borderWidth: 1
+// }]
+// },
+// options: {
+// maintainAspectRatio: false,
+// responsive: false,
+// scales: {
+// yAxes: [{
+// ticks: {
+// beginAtZero: true
+// }
+// }]
+// }
+// }
+// }, 400, 200);
+
+// response += toGraph({
+// type: 'line',
+// data: {
+// labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
+// datasets: [{
+// label: '# per weekday',
+// data: d,
+// backgroundColor: "#ffffff66",
+// borderColor: "#ffffff66",
+// borderWidth: 1
+// }]
+// },
+// options: {
+// maintainAspectRatio: false,
+// responsive: false,
+// scales: {
+// yAxes: [{
+// ticks: {
+// beginAtZero: true
+// }
+// }]
+// }
+// }
+// }, 400, 200);
+
+// response += toTable([
+// ["Total messages", data.messages.length],
+// ["Total words", w],
+// ["Unique words", a.length],
+// ["Total photos", p],
+
+// ["Parsing time", (performance.now() - perf) + "ms"]
+// ])
+
+// // response += "
"+"Unique words: "+a.length;
+// // response += "
"+"Total photos: "+p;
+// // response += "
"+"Total words: "+w;
+// // response += "
"+"Parsing time: "+(performance.now()-perf)+"ms";
+
+// } else {
+// response += "
" + con.returnError("JSON structure invalid", "error");
+// }
+// } else {
+// response += "
" + con.returnError("Invalid message file", "error");
+// }
+// } else {
+// response += "
" + con.returnError("No json data loaded", "error");
+// }
+
+// return response;
+// }
+
+// function mesall(data, amount, con) { // parse mesenger chat information
+// var response = "";
+// var perf = performance.now();
+
+// // check if json is loaded
+// response += "
" + con.returnError("Checking data", "info");
+// if (typeof data != "undefined") {
+
+// // check if participants are defined
+// response += "
" + con.returnError("Loading participants", "info");
+// if (typeof data.participants != "undefined") {
+
+// response += "
" + con.returnError("Initializing variables", "info");
+// var colors = {};
+
+// // unique words by participant
+// for (let key in data.participants) {
+// switch (key) {
+// case "0":
+// colors[data.participants[key].name] = "txgrn";
+// break;
+// case "1":
+// colors[data.participants[key].name] = "txblu";
+// break;
+// case "2":
+// colors[data.participants[key].name] = "txcya";
+// break;
+// case "3":
+// colors[data.participants[key].name] = "txyel";
+// break;
+// case "4":
+// colors[data.participants[key].name] = "txorn";
+// break;
+// case "5":
+// colors[data.participants[key].name] = "txred";
+// break;
+// case "6":
+// colors[data.participants[key].name] = "txpnk";
+// break;
+// case "7":
+// colors[data.participants[key].name] = "txred";
+// break;
+// default:
+// colors[data.participants[key].name] = "txblk";
+// break;
+// }
+
+// }
+
+// // check if messages are defined
+// response += "
" + con.returnError("Parsing messages", "info");
+// if (typeof data.messages != "undefined") {
+
+// // parse every message in file
+// var messages = data.messages.slice().reverse()
+// for (let key in messages) {
+// let col = colors[messages[key].sender_name] ? colors[messages[key].sender_name] : "txblk";
+// con.log("<" + col + ">" + decodeURIComponent(escape(messages[key].sender_name)) + "" + col + ">: " + decodeURIComponent(escape(messages[key].content)));
+
+// // break if requested amount is parsed
+// if (typeof amount != "undefined")
+// if (amount > 0)
+// if (key == amount) break;
+// }
+
+// } else {
+// response += "
" + con.returnError("JSON structure invalid", "error");
+// }
+// } else {
+// response += "
" + con.returnError("Invalid message file", "error");
+// }
+// } else {
+// response += "
" + con.returnError("No json data loaded", "error");
+// }
+
+// return null;
+// }
\ No newline at end of file
diff --git a/public/packages/Syntax.js b/public/packages/Syntax.js
new file mode 100644
index 0000000..2c06ab7
--- /dev/null
+++ b/public/packages/Syntax.js
@@ -0,0 +1,55 @@
+function toSyntax(data, lang) {
+ /**
+ * Text syntax highlighting
+ * @param {string} data text to highlight
+ * @param [lang] syntax language
+ */
+
+ if (lang) {
+ var langs = [];
+ langs.push(lang)
+ }
+ var hl = hljs.highlightAuto(data, lang);
+ var out = "";
+
+ var r = /(\<.*?\>)(.*?)(\<\/[\S]*?\>)/g;
+
+ out = hl.value.replace(r, function (match, beg, mid, end) {
+ // console.log(beg+"|"+mid+"|"+end);
+ // console.log(beg+ mid.replace(/\n/g, `[\n]`) +end)
+ return beg + mid.replace(/\n/g, `${end}\n${beg}`) + end
+ })
+
+ // var match = r.exec(hl.value);
+ // while (match != null) {
+ // console.log(match[0])
+ // out += match[1] + match[2].replace("\n", `${match[3]}\n${match[2]}`) + match[3]
+ // match = r.exec(hl.value);
+ // }
+
+
+ var lines = out.split("\n");
+ var code = $("")
+ .append(``)
+
+ /*for(let index in lines){
+ code.append(
+ $("")
+ .addClass('hljs-newline')
+ .append(lines[index])
+ // .prop( "data-int", " ".repeat( (lines.length.toString().length) - ((parseInt(index)+1).toString().length) ) + (parseInt(index)+1) )
+ )
+ .append("\n")
+ }*/
+ code.append(hl.value)
+
+ return $("").append(code)
+
+ /*for(let index in lines){
+ indexed+=`${lines[index]}\n`
+ }
+
+ return `${indexed}
`*/
+}
diff --git a/public/packages/Table.js b/public/packages/Table.js
new file mode 100644
index 0000000..620cb56
--- /dev/null
+++ b/public/packages/Table.js
@@ -0,0 +1,23 @@
+function toTable(content) {
+ /**
+ * Creates html table from 2D array
+ * @param {array} content 2d array
+ *
+ * @returns {H} html table from array
+ */
+
+ var $table = $("")
+
+ for (let row of content) {
+ let tr = $("
")
+ for (let col of row) {
+ tr.append(
+ $(" | ").append(col + "")
+ )
+ }
+ $table.append(tr)
+ }
+
+ return $table
+
+}
\ No newline at end of file
diff --git a/public/packages/Themes.js b/public/packages/Themes.js
new file mode 100644
index 0000000..54a984b
--- /dev/null
+++ b/public/packages/Themes.js
@@ -0,0 +1,58 @@
+export var type = 'sub'
+
+export var commands = {
+ 'theme': com => {
+ var actions = {
+ 'set': () => {
+ if (com.con.Themes.check(com.arg[1])){
+ com.con.Themes.change(com.arg[1])
+ com.log(`Theme ${com.arg[1]} applied`, 'ok')
+ } else {
+ com.log(`Theme ${com.arg[1]} not found`, 'error')
+ }
+ com._end()
+ }
+ }
+ if (actions[com.arg[0]])
+ actions[com.arg[0]]()
+ }
+}
+
+export default class Themes{
+ constructor(con){
+ this.con = con
+ this.list = {
+ 'default': {
+ blk: '#1f1f1f',
+ red: '#d25252',
+ grn: '#7fe173',
+ yel: '#ffc66d',
+ blu: '#4099ff',
+ prp: '#f680ff',
+ cya: '#bed6ff',
+ wht: '#eeeeec',
+ xblk: '#535353',
+ xred: '#f07070',
+ xgrn: '#9dff91',
+ xyel: '#ffe48b',
+ xblu: '#5eb7f7',
+ xprp: '#ff9dff',
+ xcya: '#dcf4ff',
+ xwht: '#ffffff'
+ }
+ }
+ }
+
+ check(name){
+ return true
+ }
+
+ add(theme){}
+
+ change(name){
+ var n = this.list[name]
+ for(let color in n){
+ $(':root').css(`--tx${color}`, n[color])
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/packages/Tree.js b/public/packages/Tree.js
index 9495e3e..f60a9ae 100644
--- a/public/packages/Tree.js
+++ b/public/packages/Tree.js
@@ -27,6 +27,7 @@ var colors = {
export default class Tree {
constructor(data) {
this.data = data
+ this.mdepth = 4
if (this._typeOf(data) != "array" && this._typeOf(data) != "object")
this.$ = $("").append(this._contentType(data)).append(": ").append(`${data}`)
@@ -112,7 +113,7 @@ export default class Tree {
_recur(obj, depth) {
- let m = this.mdepth || Config.treeDepth || 4
+ let m = this.mdepth || 4
const maxd = m <= 7 ? m : 7; // max depth
const maxn = 50; // max level length
const maxs = 150; // max string length
diff --git a/public/style.css b/public/style.css
index c248241..061852c 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1,10 +1,10 @@
-@font-face {
+/* @font-face {
font-family: 'Ubuntu Mono';
font-style: normal;
font-weight: 400;
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(res/ubuntu-mono.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
-}
+} */
:root{
--txblk: #1f1f1f;
@@ -24,19 +24,21 @@
--txxprp: #ff9dff;
--txxcya: #dcf4ff;
--txxwht: #ffffff;
+
+ --font: Courier New;
}
body{
height: 100vh;
font-size: 14px;
margin: 0px;
- font-family: Ubuntu Mono;
+ font-family: var(--font);
}
/* text inputs */
input,textarea{
color: white;
- font-family: Ubuntu Mono;
+ font-family: var(--font);
font-size: 14px;
}
@@ -87,7 +89,6 @@ txprp, .txprp {color: #AE00FF;} */
float: left;
padding: 0px 15px;
color: var(--txwht);
- /* font-family: Ubuntu Mono; */
overflow-y: scroll;
overflow-x: hidden;
box-sizing: border-box;