mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2025-07-17 20:33:48 +02:00
Added some semi good docs
This commit is contained in:
518
docs/docco.css
Normal file
518
docs/docco.css
Normal file
@ -0,0 +1,518 @@
|
|||||||
|
/*--------------------- Typography ----------------------------*/
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'aller-light';
|
||||||
|
src: url('public/fonts/aller-light.eot');
|
||||||
|
src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('public/fonts/aller-light.woff') format('woff'),
|
||||||
|
url('public/fonts/aller-light.ttf') format('truetype');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'aller-bold';
|
||||||
|
src: url('public/fonts/aller-bold.eot');
|
||||||
|
src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('public/fonts/aller-bold.woff') format('woff'),
|
||||||
|
url('public/fonts/aller-bold.ttf') format('truetype');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'roboto-black';
|
||||||
|
src: url('public/fonts/roboto-black.eot');
|
||||||
|
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
|
||||||
|
url('public/fonts/roboto-black.woff') format('woff'),
|
||||||
|
url('public/fonts/roboto-black.ttf') format('truetype');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------- Layout ----------------------------*/
|
||||||
|
html { height: 100%; }
|
||||||
|
body {
|
||||||
|
font-family: "aller-light";
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 18px;
|
||||||
|
color: #30404f;
|
||||||
|
margin: 0; padding: 0;
|
||||||
|
height:100%;
|
||||||
|
}
|
||||||
|
#container { min-height: 100%; }
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
b, strong {
|
||||||
|
font-weight: normal;
|
||||||
|
font-family: "aller-bold";
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 15px 0 0px;
|
||||||
|
}
|
||||||
|
.annotation ul, .annotation ol {
|
||||||
|
margin: 25px 0;
|
||||||
|
}
|
||||||
|
.annotation ul li, .annotation ol li {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 18px;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #112233;
|
||||||
|
line-height: 1em;
|
||||||
|
font-weight: normal;
|
||||||
|
font-family: "roboto-black";
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin: 30px 0 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 1.26em;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 0;
|
||||||
|
background: 1px #ddd;
|
||||||
|
height: 1px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre, tt, code {
|
||||||
|
font-size: 12px; line-height: 16px;
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
||||||
|
margin: 0; padding: 0;
|
||||||
|
}
|
||||||
|
.annotation pre {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
padding: 7px 10px;
|
||||||
|
background: #fcfcfc;
|
||||||
|
-moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
.annotation pre code {
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
border-left: 5px solid #ccc;
|
||||||
|
margin: 0;
|
||||||
|
padding: 1px 0 1px 1em;
|
||||||
|
}
|
||||||
|
.sections blockquote p {
|
||||||
|
font-family: Menlo, Consolas, Monaco, monospace;
|
||||||
|
font-size: 12px; line-height: 16px;
|
||||||
|
color: #999;
|
||||||
|
margin: 10px 0 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections {
|
||||||
|
list-style: none;
|
||||||
|
padding:0 0 5px 0;;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Force border-box so that % widths fit the parent
|
||||||
|
container without overlap because of margin/padding.
|
||||||
|
|
||||||
|
More Info : http://www.quirksmode.org/css/box.html
|
||||||
|
*/
|
||||||
|
ul.sections > li > div {
|
||||||
|
-moz-box-sizing: border-box; /* firefox */
|
||||||
|
-ms-box-sizing: border-box; /* ie */
|
||||||
|
-webkit-box-sizing: border-box; /* webkit */
|
||||||
|
-khtml-box-sizing: border-box; /* konqueror */
|
||||||
|
box-sizing: border-box; /* css3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------- Jump Page -----------------------------*/
|
||||||
|
#jump_to, #jump_page {
|
||||||
|
margin: 0;
|
||||||
|
background: white;
|
||||||
|
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
||||||
|
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
||||||
|
font: 16px Arial;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: right;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_to a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_to a.large {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#jump_to a.small {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #676767;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_to, #jump_wrapper {
|
||||||
|
position: fixed;
|
||||||
|
right: 0; top: 0;
|
||||||
|
padding: 10px 15px;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_wrapper {
|
||||||
|
display: none;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_to:hover #jump_wrapper {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_page_wrapper{
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_page {
|
||||||
|
padding: 5px 0 3px;
|
||||||
|
margin: 0 0 25px 25px;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_page .source {
|
||||||
|
display: block;
|
||||||
|
padding: 15px;
|
||||||
|
text-decoration: none;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_page .source:hover {
|
||||||
|
background: #f5f5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump_page .source:first-child {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------- Low resolutions (> 320px) ---------------------*/
|
||||||
|
@media only screen and (min-width: 320px) {
|
||||||
|
.pilwrap { display: none; }
|
||||||
|
|
||||||
|
ul.sections > li > div {
|
||||||
|
display: block;
|
||||||
|
padding:5px 10px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.content {
|
||||||
|
overflow-x:auto;
|
||||||
|
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
|
||||||
|
box-shadow: inset 0 0 5px #e5e5ee;
|
||||||
|
border: 1px solid #dedede;
|
||||||
|
margin:5px 10px 5px 10px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation pre {
|
||||||
|
margin: 7px 0 7px;
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation p tt, .annotation code {
|
||||||
|
background: #f8f8ff;
|
||||||
|
border: 1px solid #dedede;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 0 0.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------- (> 481px) ---------------------*/
|
||||||
|
@media only screen and (min-width: 481px) {
|
||||||
|
#container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: #F5F5FF;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 21px;
|
||||||
|
}
|
||||||
|
pre, tt, code {
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
p, ul, ol {
|
||||||
|
margin: 0 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#jump_to {
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
#jump_wrapper {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
#jump_to, #jump_page {
|
||||||
|
font: 10px Arial;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
#jump_page .source {
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
#jump_to a.large {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#jump_to a.small {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#background {
|
||||||
|
position: absolute;
|
||||||
|
top: 0; bottom: 0;
|
||||||
|
width: 350px;
|
||||||
|
background: #fff;
|
||||||
|
border-right: 1px solid #e5e5ee;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
|
||||||
|
padding-left: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation {
|
||||||
|
max-width: 350px;
|
||||||
|
min-width: 350px;
|
||||||
|
min-height: 5px;
|
||||||
|
padding: 13px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
white-space: normal;
|
||||||
|
vertical-align: top;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
ul.sections > li > div.annotation pre {
|
||||||
|
margin: 15px 0 15px;
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.content {
|
||||||
|
padding: 13px;
|
||||||
|
vertical-align: top;
|
||||||
|
border: none;
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pilwrap {
|
||||||
|
position: relative;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pilcrow {
|
||||||
|
font: 12px Arial;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #454545;
|
||||||
|
position: absolute;
|
||||||
|
top: 3px; left: -20px;
|
||||||
|
padding: 1px 2px;
|
||||||
|
opacity: 0;
|
||||||
|
-webkit-transition: opacity 0.2s linear;
|
||||||
|
}
|
||||||
|
.for-h1 .pilcrow {
|
||||||
|
top: 47px;
|
||||||
|
}
|
||||||
|
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow {
|
||||||
|
top: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.sections > li > div.annotation:hover .pilcrow {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------- (> 1025px) ---------------------*/
|
||||||
|
@media only screen and (min-width: 1025px) {
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#background {
|
||||||
|
width: 525px;
|
||||||
|
}
|
||||||
|
ul.sections > li > div.annotation {
|
||||||
|
max-width: 525px;
|
||||||
|
min-width: 525px;
|
||||||
|
padding: 10px 25px 1px 50px;
|
||||||
|
}
|
||||||
|
ul.sections > li > div.content {
|
||||||
|
padding: 9px 15px 16px 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------- Syntax Highlighting -----------------------------*/
|
||||||
|
|
||||||
|
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
||||||
|
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
||||||
|
/*
|
||||||
|
|
||||||
|
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
pre code {
|
||||||
|
display: block; padding: 0.5em;
|
||||||
|
color: #000;
|
||||||
|
background: #f8f8ff
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-comment,
|
||||||
|
pre .hljs-template_comment,
|
||||||
|
pre .hljs-diff .hljs-header,
|
||||||
|
pre .hljs-javadoc {
|
||||||
|
color: #408080;
|
||||||
|
font-style: italic
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-keyword,
|
||||||
|
pre .hljs-assignment,
|
||||||
|
pre .hljs-literal,
|
||||||
|
pre .hljs-css .hljs-rule .hljs-keyword,
|
||||||
|
pre .hljs-winutils,
|
||||||
|
pre .hljs-javascript .hljs-title,
|
||||||
|
pre .hljs-lisp .hljs-title,
|
||||||
|
pre .hljs-subst {
|
||||||
|
color: #954121;
|
||||||
|
/*font-weight: bold*/
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-number,
|
||||||
|
pre .hljs-hexcolor {
|
||||||
|
color: #40a070
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-string,
|
||||||
|
pre .hljs-tag .hljs-value,
|
||||||
|
pre .hljs-phpdoc,
|
||||||
|
pre .hljs-tex .hljs-formula {
|
||||||
|
color: #219161;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-title,
|
||||||
|
pre .hljs-id {
|
||||||
|
color: #19469D;
|
||||||
|
}
|
||||||
|
pre .hljs-params {
|
||||||
|
color: #00F;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-javascript .hljs-title,
|
||||||
|
pre .hljs-lisp .hljs-title,
|
||||||
|
pre .hljs-subst {
|
||||||
|
font-weight: normal
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-class .hljs-title,
|
||||||
|
pre .hljs-haskell .hljs-label,
|
||||||
|
pre .hljs-tex .hljs-command {
|
||||||
|
color: #458;
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-tag,
|
||||||
|
pre .hljs-tag .hljs-title,
|
||||||
|
pre .hljs-rules .hljs-property,
|
||||||
|
pre .hljs-django .hljs-tag .hljs-keyword {
|
||||||
|
color: #000080;
|
||||||
|
font-weight: normal
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-attribute,
|
||||||
|
pre .hljs-variable,
|
||||||
|
pre .hljs-instancevar,
|
||||||
|
pre .hljs-lisp .hljs-body {
|
||||||
|
color: #008080
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-regexp {
|
||||||
|
color: #B68
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-class {
|
||||||
|
color: #458;
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-symbol,
|
||||||
|
pre .hljs-ruby .hljs-symbol .hljs-string,
|
||||||
|
pre .hljs-ruby .hljs-symbol .hljs-keyword,
|
||||||
|
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
|
||||||
|
pre .hljs-lisp .hljs-keyword,
|
||||||
|
pre .hljs-tex .hljs-special,
|
||||||
|
pre .hljs-input_number {
|
||||||
|
color: #990073
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-builtin,
|
||||||
|
pre .hljs-constructor,
|
||||||
|
pre .hljs-built_in,
|
||||||
|
pre .hljs-lisp .hljs-title {
|
||||||
|
color: #0086b3
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-preprocessor,
|
||||||
|
pre .hljs-pi,
|
||||||
|
pre .hljs-doctype,
|
||||||
|
pre .hljs-shebang,
|
||||||
|
pre .hljs-cdata {
|
||||||
|
color: #999;
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-deletion {
|
||||||
|
background: #fdd
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-addition {
|
||||||
|
background: #dfd
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-diff .hljs-change {
|
||||||
|
background: #0086b3
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-chunk {
|
||||||
|
color: #aaa
|
||||||
|
}
|
||||||
|
|
||||||
|
pre .hljs-tex .hljs-formula {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
531
docs/index.html
Normal file
531
docs/index.html
Normal file
@ -0,0 +1,531 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>index.js</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||||
|
<link rel="stylesheet" media="all" href="docco.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<div id="background"></div>
|
||||||
|
|
||||||
|
<ul class="sections">
|
||||||
|
|
||||||
|
<li id="title">
|
||||||
|
<div class="annotation">
|
||||||
|
<h1>index.js</h1>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-1">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-1">¶</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">const</span> {
|
||||||
|
app,
|
||||||
|
BrowserWindow,
|
||||||
|
screen,
|
||||||
|
ipcMain,
|
||||||
|
BrowserView,
|
||||||
|
} = <span class="hljs-built_in">require</span>(<span class="hljs-string">"electron"</span>);
|
||||||
|
<span class="hljs-keyword">var</span> Config = <span class="hljs-built_in">require</span>(<span class="hljs-string">"config-js"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> fs = <span class="hljs-built_in">require</span>(<span class="hljs-string">"fs"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> { win32 } = <span class="hljs-built_in">require</span>(<span class="hljs-string">"path"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> sysInf = <span class="hljs-built_in">require</span>(<span class="hljs-string">"systeminformation"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> dgram = <span class="hljs-built_in">require</span>(<span class="hljs-string">"dgram"</span>);
|
||||||
|
<span class="hljs-keyword">var</span> server = dgram.createSocket(<span class="hljs-string">"udp4"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">"express"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> { time } = <span class="hljs-built_in">require</span>(<span class="hljs-string">"console"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> { nanoid } = <span class="hljs-built_in">require</span>(<span class="hljs-string">"nanoid"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> restApp = express();
|
||||||
|
|
||||||
|
<span class="hljs-keyword">const</span> restPort = <span class="hljs-number">33334</span>;
|
||||||
|
<span class="hljs-keyword">const</span> PORT = <span class="hljs-number">33333</span>;
|
||||||
|
<span class="hljs-keyword">const</span> MULTICAST_ADDR = <span class="hljs-string">"192.168.178.50"</span>;
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> aWin2 = <span class="hljs-literal">undefined</span>;
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> preLoadedAmount = <span class="hljs-number">0</span>;
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> networkInterfaces = [];</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-2">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-2">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>/ !!!———–!!!
|
||||||
|
/ PAGE LOOKUP TABLE</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">var</span> preloadedPageLookup = {};
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> pageLookup = {};
|
||||||
|
pageLookup[<span class="hljs-string">"index"</span>] = <span class="hljs-string">"index.html"</span>;
|
||||||
|
pageLookup[<span class="hljs-string">"session"</span>] = <span class="hljs-string">"sessions.html"</span>;
|
||||||
|
pageLookup[<span class="hljs-string">"header"</span>] = <span class="hljs-string">"header.html"</span>;</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-3">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-3">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>/ !!!———–!!!
|
||||||
|
Session state data
|
||||||
|
-1 Unset/Unknown
|
||||||
|
0 Not connected
|
||||||
|
1 Connecting
|
||||||
|
2 Connected as host
|
||||||
|
3 Connected as Client
|
||||||
|
4 Connection failed</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre>
|
||||||
|
<span class="hljs-keyword">var</span> sessionState = -<span class="hljs-number">1</span>;
|
||||||
|
<span class="hljs-keyword">var</span> sessionStateGoal = -<span class="hljs-number">1</span>;
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> mySession = {
|
||||||
|
<span class="hljs-attr">name</span>: <span class="hljs-string">"Unnamed Session"</span>,
|
||||||
|
<span class="hljs-attr">joinable</span>: <span class="hljs-literal">false</span>,
|
||||||
|
<span class="hljs-attr">passwordProtected</span>: <span class="hljs-literal">false</span>,
|
||||||
|
<span class="hljs-attr">passwordHash</span>: <span class="hljs-string">""</span>,
|
||||||
|
<span class="hljs-attr">members</span>: <span class="hljs-number">1</span>,
|
||||||
|
<span class="hljs-attr">memberList</span>: [],
|
||||||
|
<span class="hljs-attr">usedUIDs</span>: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> mainConn = <span class="hljs-string">""</span>;
|
||||||
|
<span class="hljs-keyword">var</span> mainNetworkInterface = <span class="hljs-literal">undefined</span>;
|
||||||
|
|
||||||
|
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> [key, value] <span class="hljs-keyword">of</span> <span class="hljs-built_in">Object</span>.entries(pageLookup)) {</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-4">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-4">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>check if the property/key is defined in the object itself, not in parent</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (pageLookup.hasOwnProperty(key)) {
|
||||||
|
fs.readFile(<span class="hljs-string">"ui_templates/"</span> + value, <span class="hljs-string">"utf8"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">err, data</span>) </span>{
|
||||||
|
preLoadedAmount++;
|
||||||
|
<span class="hljs-keyword">if</span> (err) {
|
||||||
|
<span class="hljs-keyword">return</span> <span class="hljs-built_in">console</span>.log(err);
|
||||||
|
}
|
||||||
|
preloadedPageLookup[key] = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">prepBroadcast</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
server.bind(PORT, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
|
||||||
|
server.setBroadcast(<span class="hljs-literal">true</span>);
|
||||||
|
server.setMulticastTTL(<span class="hljs-number">128</span>);
|
||||||
|
server.addMembership(MULTICAST_ADDR);
|
||||||
|
});
|
||||||
|
runy = <span class="hljs-literal">true</span>;
|
||||||
|
<span class="hljs-keyword">while</span> (runy) {</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-5">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-5">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>console.log(“INTERFACE EMPTY”, networkInterfaces)</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (networkInterfaces.length >= <span class="hljs-number">1</span>) {
|
||||||
|
runy = <span class="hljs-literal">false</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Waiting done"</span>);
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> Ibroad = <span class="hljs-number">0</span>;
|
||||||
|
<span class="hljs-keyword">var</span> names = [];
|
||||||
|
<span class="hljs-keyword">while</span> (Ibroad < networkInterfaces.length) {
|
||||||
|
names.push(networkInterfaces[Ibroad].ifaceName);
|
||||||
|
Ibroad++;
|
||||||
|
}
|
||||||
|
last = fs.readFileSync(<span class="hljs-string">"usrStore/lastNetwork.data"</span>);
|
||||||
|
mainConn = last.toString();
|
||||||
|
ind = names.indexOf(mainConn);
|
||||||
|
mainNetworkInterface = networkInterfaces[ind];</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-6">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-6">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>console.info(“!!!!!!!!!!!!!!!!!!!!!”, mainConn, names, mainNetworkInterface)</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre>}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">broadcastNew</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">var</span> message = <span class="hljs-keyword">new</span> Buffer(
|
||||||
|
<span class="hljs-string">"ENLIGHT_NEW_SESSION$"</span> + <span class="hljs-built_in">String</span>(mainNetworkInterface.ip4)
|
||||||
|
);
|
||||||
|
server.send(message, <span class="hljs-number">0</span>, message.length, PORT, MULTICAST_ADDR);
|
||||||
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Sent "</span> + message + <span class="hljs-string">" to the wire..."</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">loadPage</span>(<span class="hljs-params">name</span>) </span>{
|
||||||
|
load = preloadedPageLookup[name];
|
||||||
|
<span class="hljs-keyword">if</span> (load == <span class="hljs-literal">undefined</span>) {
|
||||||
|
load = fs.readFileSync(<span class="hljs-string">"ui_templates/"</span> + pageLookup[name]).toString();
|
||||||
|
<span class="hljs-built_in">console</span>.warn(<span class="hljs-string">"Loading fallback for page "</span> + name);
|
||||||
|
}
|
||||||
|
<span class="hljs-keyword">return</span> load;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createWindow</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">const</span> win = <span class="hljs-keyword">new</span> BrowserWindow({
|
||||||
|
<span class="hljs-attr">width</span>: screen.getPrimaryDisplay().size.width,
|
||||||
|
<span class="hljs-attr">height</span>: screen.getPrimaryDisplay().size.height,
|
||||||
|
<span class="hljs-attr">webPreferences</span>: {
|
||||||
|
<span class="hljs-attr">nodeIntegration</span>: <span class="hljs-literal">true</span>,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
win.setFullScreen(<span class="hljs-literal">true</span>);
|
||||||
|
win.setMenuBarVisibility(<span class="hljs-literal">false</span>);
|
||||||
|
win.setAutoHideMenuBar(<span class="hljs-literal">true</span>);
|
||||||
|
|
||||||
|
main = loadPage(<span class="hljs-string">"index"</span>);
|
||||||
|
header = loadPage(<span class="hljs-string">"header"</span>);</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-7">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-7">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>header = fs.readFileSync(“ui_templates/header.html”).toString();</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> toLoad = header + main;
|
||||||
|
fs.writeFileSync(<span class="hljs-string">"ui_templates/temp.html"</span>, toLoad);</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-8">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-8">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>win.loadURL(“data:text/html;charset=utf-8,” + encodeURI(toLoad));</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> win.loadFile(<span class="hljs-string">"ui_templates/temp.html"</span>);
|
||||||
|
<span class="hljs-keyword">return</span> win;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createStartupInfo</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">const</span> win2 = <span class="hljs-keyword">new</span> BrowserWindow({
|
||||||
|
<span class="hljs-attr">width</span>: <span class="hljs-number">400</span>,
|
||||||
|
<span class="hljs-attr">height</span>: <span class="hljs-number">200</span>,
|
||||||
|
<span class="hljs-attr">frame</span>: <span class="hljs-literal">false</span>,
|
||||||
|
<span class="hljs-attr">webPreferences</span>: {
|
||||||
|
<span class="hljs-attr">nodeIntegration</span>: <span class="hljs-literal">true</span>,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
win2.setFullScreen(<span class="hljs-literal">false</span>);
|
||||||
|
win2.setAlwaysOnTop(<span class="hljs-literal">true</span>);
|
||||||
|
win2.loadFile(<span class="hljs-string">"ui_templates/startUp.html"</span>);
|
||||||
|
win2.show();
|
||||||
|
<span class="hljs-keyword">return</span> win2;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">doneLoading</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">var</span> fadeOutI = <span class="hljs-number">1</span>;
|
||||||
|
<span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>.keys(pageLookup).length == preLoadedAmount) {
|
||||||
|
aWin2.webContents.executeJavaScript(
|
||||||
|
<span class="hljs-string">"document.getElementById('current').innerHTML = 'Done';"</span>
|
||||||
|
);
|
||||||
|
<span class="hljs-keyword">var</span> fadeIntervall = <span class="hljs-built_in">setInterval</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-keyword">if</span> (fadeOutI < <span class="hljs-number">0</span>) {
|
||||||
|
<span class="hljs-built_in">clearInterval</span>(fadeIntervall);
|
||||||
|
aWin2.webContents.executeJavaScript(<span class="hljs-string">"window.close()"</span>);
|
||||||
|
} <span class="hljs-keyword">else</span> {
|
||||||
|
aWin2.setOpacity(fadeOutI);
|
||||||
|
fadeOutI = fadeOutI - <span class="hljs-number">0.05</span>;
|
||||||
|
}
|
||||||
|
} <span class="hljs-keyword">catch</span> (e) {
|
||||||
|
<span class="hljs-built_in">console</span>.warn(<span class="hljs-string">"Startup window got destroyed!"</span>);
|
||||||
|
<span class="hljs-built_in">clearInterval</span>(fadeIntervall);
|
||||||
|
}
|
||||||
|
}, <span class="hljs-number">20</span>);
|
||||||
|
} <span class="hljs-keyword">else</span> {
|
||||||
|
<span class="hljs-built_in">console</span>.warn(<span class="hljs-string">"Had to reschedule load finish"</span>);
|
||||||
|
<span class="hljs-built_in">setTimeout</span>(doneLoading, <span class="hljs-number">200</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">init</span>(<span class="hljs-params"></span>) </span>{
|
||||||
|
win = createWindow();
|
||||||
|
aWin2 = createStartupInfo();
|
||||||
|
<span class="hljs-built_in">setInterval</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
|
||||||
|
sysInf.networkInterfaces(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
|
||||||
|
networkInterfaces = data;
|
||||||
|
});
|
||||||
|
}, <span class="hljs-number">2</span> * <span class="hljs-number">60</span> * <span class="hljs-number">1000</span>); <span class="hljs-comment">// Update network interface every 2 mins</span>
|
||||||
|
|
||||||
|
sysInf.networkInterfaces(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
|
||||||
|
networkInterfaces = data;
|
||||||
|
});
|
||||||
|
|
||||||
|
<span class="hljs-keyword">var</span> langs = <span class="hljs-keyword">new</span> Config(<span class="hljs-string">"./lang/langs_v1.js"</span>);
|
||||||
|
|
||||||
|
sessionState = <span class="hljs-number">0</span>; <span class="hljs-comment">// Init with no connection</span>
|
||||||
|
<span class="hljs-built_in">setTimeout</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Starting restfulServer API interface"</span>);
|
||||||
|
restApp.listen(restPort, <span class="hljs-function">() =></span> {
|
||||||
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Restful is running on http://localhost:<span class="hljs-subst">${restPort}</span>`</span>);
|
||||||
|
});
|
||||||
|
|
||||||
|
restApp.get(<span class="hljs-string">"/"</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =></span> {
|
||||||
|
res.send(<span class="hljs-string">"Hello World! The RestFul API of Enlight is up and working!"</span>);
|
||||||
|
});
|
||||||
|
|
||||||
|
restApp.get(<span class="hljs-string">"/api/v1/ping"</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =></span> {
|
||||||
|
res.json({ <span class="hljs-attr">state</span>: <span class="hljs-string">"Succes"</span>, <span class="hljs-attr">uptime</span>: time.time() });
|
||||||
|
});
|
||||||
|
|
||||||
|
restApp.get(<span class="hljs-string">"/api/v1/session/info"</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =></span> {
|
||||||
|
res.json({
|
||||||
|
<span class="hljs-attr">state</span>: <span class="hljs-string">"Succes"</span>,
|
||||||
|
<span class="hljs-attr">name</span>: mySession.name,
|
||||||
|
<span class="hljs-attr">joinAble</span>: mySession.joinable,
|
||||||
|
<span class="hljs-attr">passwordProtected</span>: mySession.passwordProtected,
|
||||||
|
<span class="hljs-attr">memberAmount</span>: mySession.members,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
restApp.get(<span class="hljs-string">"/api/v1/session/join"</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =></span> {
|
||||||
|
<span class="hljs-keyword">if</span> (mySession.joinable) {
|
||||||
|
<span class="hljs-keyword">if</span> (mySession.passwordProtected == <span class="hljs-literal">false</span>) {
|
||||||
|
uid = nanoid();
|
||||||
|
<span class="hljs-keyword">while</span> (mySession.usedUIDs.includes(uid)) {
|
||||||
|
uid = nanoid();
|
||||||
|
}
|
||||||
|
|
||||||
|
mySession.usedUIDs.push(uid);
|
||||||
|
dev = {
|
||||||
|
<span class="hljs-attr">type</span>: <span class="hljs-string">"client"</span>,
|
||||||
|
<span class="hljs-attr">ip</span>: req.connection.remoteAddress,
|
||||||
|
<span class="hljs-attr">uid</span>: uid,
|
||||||
|
};
|
||||||
|
mySession.memberList.push();
|
||||||
|
mySession.members++;
|
||||||
|
res.json({ <span class="hljs-attr">state</span>: <span class="hljs-string">"Succes"</span>, <span class="hljs-attr">uid</span>: uid });
|
||||||
|
} <span class="hljs-keyword">else</span> {
|
||||||
|
res.json({
|
||||||
|
<span class="hljs-attr">state</span>: <span class="hljs-string">"Failed"</span>,
|
||||||
|
<span class="hljs-attr">message</span>: <span class="hljs-string">"Passwords are not yet implemented"</span>,
|
||||||
|
<span class="hljs-attr">code</span>: -<span class="hljs-number">1</span>,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} <span class="hljs-keyword">else</span> {
|
||||||
|
res.json({
|
||||||
|
<span class="hljs-attr">state</span>: <span class="hljs-string">"Failed"</span>,
|
||||||
|
<span class="hljs-attr">message</span>: <span class="hljs-string">"Session is not joinable."</span>,
|
||||||
|
<span class="hljs-attr">code</span>: <span class="hljs-number">1</span>,
|
||||||
|
});
|
||||||
|
}</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-9">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-9">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>name: mySession.name, joinAble: mySession.joinable, passwordProtected: mySession.passwordProtected});</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> });
|
||||||
|
}, <span class="hljs-number">20</span>);</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-10">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-10">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>Handling sessioning</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> <span class="hljs-built_in">setInterval</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
|
||||||
|
<span class="hljs-keyword">if</span> (sessionStateGoal == <span class="hljs-number">2</span>) {
|
||||||
|
broadcastNew();
|
||||||
|
sessionState = <span class="hljs-number">2</span>;
|
||||||
|
}
|
||||||
|
}, <span class="hljs-number">400</span>);
|
||||||
|
|
||||||
|
<span class="hljs-built_in">setTimeout</span>(doneLoading, <span class="hljs-number">2000</span>);
|
||||||
|
ipcMain.on(<span class="hljs-string">"asynchronous-message"</span>, <span class="hljs-function">(<span class="hljs-params">event, arg</span>) =></span> {
|
||||||
|
<span class="hljs-built_in">console</span>.log(arg);
|
||||||
|
<span class="hljs-keyword">if</span> (arg == <span class="hljs-string">"hasBattery"</span>) {
|
||||||
|
event.reply(<span class="hljs-string">"asynchronous-reply"</span>, sysInf.battery().hasbattery);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on(<span class="hljs-string">"synchronous-message"</span>, <span class="hljs-function">(<span class="hljs-params">event, arg</span>) =></span> {
|
||||||
|
<span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"hasBattery"</span>)) {
|
||||||
|
sysInf.battery(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
|
||||||
|
event.returnValue = data.hasbattery;
|
||||||
|
});
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"getBatteryLevel"</span>)) {
|
||||||
|
sysInf.battery(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
|
||||||
|
event.returnValue = data.percent;
|
||||||
|
});
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"loadOverride"</span>)) {
|
||||||
|
event.returnValue = <span class="hljs-literal">false</span>;
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"getNetworks"</span>)) {
|
||||||
|
event.returnValue = networkInterfaces;
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"set:newNetwork"</span>)) {
|
||||||
|
fs.writeFile(
|
||||||
|
<span class="hljs-string">"usrStore/lastNetwork.data"</span>,
|
||||||
|
<span class="hljs-built_in">String</span>(arg).split(<span class="hljs-string">"|"</span>)[<span class="hljs-number">1</span>],
|
||||||
|
<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">err</span>) </span>{
|
||||||
|
<span class="hljs-keyword">if</span> (err) <span class="hljs-keyword">return</span> <span class="hljs-built_in">console</span>.log(err);
|
||||||
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Saved new main network"</span>);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
event.returnValue = <span class="hljs-string">""</span>;
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"getMainNetwork"</span>)) {
|
||||||
|
<span class="hljs-keyword">try</span> {
|
||||||
|
last = fs.readFileSync(<span class="hljs-string">"usrStore/lastNetwork.data"</span>);</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-11">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-11">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>console.log(last.toString())</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> event.returnValue = last.toString();
|
||||||
|
mainConn = last.toString();
|
||||||
|
} <span class="hljs-keyword">catch</span> (e) {
|
||||||
|
sysInf.networkInterfaces(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">data</span>) </span>{
|
||||||
|
fs.writeFileSync(<span class="hljs-string">"usrStore/lastNetwork.data"</span>, data[<span class="hljs-number">0</span>].ifaceName);
|
||||||
|
event.returnValue = data[<span class="hljs-number">0</span>].ifaceName;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"PAGE:change"</span>)) {
|
||||||
|
newPage = <span class="hljs-built_in">String</span>(arg).split(<span class="hljs-string">"."</span>)[<span class="hljs-number">1</span>];
|
||||||
|
main = header = loadPage(newPage);
|
||||||
|
|
||||||
|
header = loadPage(<span class="hljs-string">"header"</span>);
|
||||||
|
toLoad = header + main;
|
||||||
|
<span class="hljs-keyword">const</span> timestamp = <span class="hljs-built_in">Date</span>.now();
|
||||||
|
fs.writeFileSync(<span class="hljs-string">"ui_templates/temp.html"</span>, toLoad);
|
||||||
|
<span class="hljs-keyword">const</span> timestamp2 = <span class="hljs-built_in">Date</span>.now();
|
||||||
|
win.loadFile(<span class="hljs-string">"ui_templates/temp.html"</span>);
|
||||||
|
<span class="hljs-keyword">const</span> timestamp3 = <span class="hljs-built_in">Date</span>.now();</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
<li id="section-12">
|
||||||
|
<div class="annotation">
|
||||||
|
|
||||||
|
<div class="pilwrap ">
|
||||||
|
<a class="pilcrow" href="#section-12">¶</a>
|
||||||
|
</div>
|
||||||
|
<p>win.loadFile(“ui_templates/header.html”)</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content"><div class='highlight'><pre> event.returnValue = <span class="hljs-string">""</span>;
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"SESSION:get.state"</span>)) {
|
||||||
|
event.returnValue = sessionState;
|
||||||
|
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">String</span>(arg).includes(<span class="hljs-string">"SESSION:createNew"</span>)) {
|
||||||
|
<span class="hljs-built_in">setTimeout</span>(prepBroadcast, <span class="hljs-number">5</span>);
|
||||||
|
mySession.name = <span class="hljs-built_in">String</span>(arg).split(<span class="hljs-string">"|"</span>)[<span class="hljs-number">1</span>];
|
||||||
|
mySession.joinable = <span class="hljs-literal">true</span>;
|
||||||
|
sessionState = <span class="hljs-number">1</span>;
|
||||||
|
sessionStateGoal = <span class="hljs-number">2</span>;
|
||||||
|
event.returnValue = <span class="hljs-string">""</span>;
|
||||||
|
} <span class="hljs-keyword">else</span> {
|
||||||
|
event.returnValue = <span class="hljs-string">"ERR:UNKNOW_CMD"</span>;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
app.whenReady().then(init);
|
||||||
|
|
||||||
|
app.on(<span class="hljs-string">"window-all-closed"</span>, <span class="hljs-function">() =></span> {
|
||||||
|
<span class="hljs-keyword">if</span> (process.platform !== <span class="hljs-string">"darwin"</span>) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on(<span class="hljs-string">"activate"</span>, <span class="hljs-function">() =></span> {
|
||||||
|
<span class="hljs-keyword">if</span> (BrowserWindow.getAllWindows().length === <span class="hljs-number">0</span>) {
|
||||||
|
createWindow();
|
||||||
|
}
|
||||||
|
});</pre></div></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
docs/public/fonts/aller-bold.eot
Normal file
BIN
docs/public/fonts/aller-bold.eot
Normal file
Binary file not shown.
BIN
docs/public/fonts/aller-bold.ttf
Normal file
BIN
docs/public/fonts/aller-bold.ttf
Normal file
Binary file not shown.
BIN
docs/public/fonts/aller-bold.woff
Normal file
BIN
docs/public/fonts/aller-bold.woff
Normal file
Binary file not shown.
BIN
docs/public/fonts/aller-light.eot
Normal file
BIN
docs/public/fonts/aller-light.eot
Normal file
Binary file not shown.
BIN
docs/public/fonts/aller-light.ttf
Normal file
BIN
docs/public/fonts/aller-light.ttf
Normal file
Binary file not shown.
BIN
docs/public/fonts/aller-light.woff
Normal file
BIN
docs/public/fonts/aller-light.woff
Normal file
Binary file not shown.
BIN
docs/public/fonts/roboto-black.eot
Normal file
BIN
docs/public/fonts/roboto-black.eot
Normal file
Binary file not shown.
BIN
docs/public/fonts/roboto-black.ttf
Normal file
BIN
docs/public/fonts/roboto-black.ttf
Normal file
Binary file not shown.
BIN
docs/public/fonts/roboto-black.woff
Normal file
BIN
docs/public/fonts/roboto-black.woff
Normal file
Binary file not shown.
375
docs/public/stylesheets/normalize.css
vendored
Normal file
375
docs/public/stylesheets/normalize.css
vendored
Normal file
@ -0,0 +1,375 @@
|
|||||||
|
/*! normalize.css v2.0.1 | MIT License | git.io/normalize */
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
HTML5 display definitions
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Corrects `block` display not defined in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
article,
|
||||||
|
aside,
|
||||||
|
details,
|
||||||
|
figcaption,
|
||||||
|
figure,
|
||||||
|
footer,
|
||||||
|
header,
|
||||||
|
hgroup,
|
||||||
|
nav,
|
||||||
|
section,
|
||||||
|
summary {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Corrects `inline-block` display not defined in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
audio,
|
||||||
|
canvas,
|
||||||
|
video {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevents modern browsers from displaying `audio` without controls.
|
||||||
|
* Remove excess height in iOS 5 devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
audio:not([controls]) {
|
||||||
|
display: none;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses styling for `hidden` attribute not present in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Base
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Sets default font family to sans-serif.
|
||||||
|
* 2. Prevents iOS text size adjust after orientation change, without disabling
|
||||||
|
* user zoom.
|
||||||
|
*/
|
||||||
|
|
||||||
|
html {
|
||||||
|
font-family: sans-serif; /* 1 */
|
||||||
|
-webkit-text-size-adjust: 100%; /* 2 */
|
||||||
|
-ms-text-size-adjust: 100%; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes default margin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Links
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses `outline` inconsistency between Chrome and other browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
a:focus {
|
||||||
|
outline: thin dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Improves readability when focused and also mouse hovered in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
a:active,
|
||||||
|
a:hover {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Typography
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses `h1` font sizes within `section` and `article` in Firefox 4+,
|
||||||
|
* Safari 5, and Chrome.
|
||||||
|
*/
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses styling not present in IE 8/9, Safari 5, and Chrome.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abbr[title] {
|
||||||
|
border-bottom: 1px dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
|
||||||
|
*/
|
||||||
|
|
||||||
|
b,
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses styling not present in Safari 5 and Chrome.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dfn {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses styling not present in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
mark {
|
||||||
|
background: #ff0;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Corrects font family set oddly in Safari 5 and Chrome.
|
||||||
|
*/
|
||||||
|
|
||||||
|
code,
|
||||||
|
kbd,
|
||||||
|
pre,
|
||||||
|
samp {
|
||||||
|
font-family: monospace, serif;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Improves readability of pre-formatted text in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pre {
|
||||||
|
white-space: pre;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets consistent quote types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
q {
|
||||||
|
quotes: "\201C" "\201D" "\2018" "\2019";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses inconsistent and variable font size in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sub,
|
||||||
|
sup {
|
||||||
|
font-size: 75%;
|
||||||
|
line-height: 0;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup {
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
bottom: -0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Embedded content
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes border when inside `a` element in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
img {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Corrects overflow displayed oddly in IE 9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
svg:not(:root) {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Figures
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses margin not present in IE 8/9 and Safari 5.
|
||||||
|
*/
|
||||||
|
|
||||||
|
figure {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Forms
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define consistent border, margin, and padding.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
border: 1px solid #c0c0c0;
|
||||||
|
margin: 0 2px;
|
||||||
|
padding: 0.35em 0.625em 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Corrects color not being inherited in IE 8/9.
|
||||||
|
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
|
||||||
|
*/
|
||||||
|
|
||||||
|
legend {
|
||||||
|
border: 0; /* 1 */
|
||||||
|
padding: 0; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Corrects font family not being inherited in all browsers.
|
||||||
|
* 2. Corrects font size not being inherited in all browsers.
|
||||||
|
* 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font-family: inherit; /* 1 */
|
||||||
|
font-size: 100%; /* 2 */
|
||||||
|
margin: 0; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Addresses Firefox 4+ setting `line-height` on `input` using `!important` in
|
||||||
|
* the UA stylesheet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
input {
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
|
||||||
|
* and `video` controls.
|
||||||
|
* 2. Corrects inability to style clickable `input` types in iOS.
|
||||||
|
* 3. Improves usability and consistency of cursor style between image-type
|
||||||
|
* `input` and others.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
html input[type="button"], /* 1 */
|
||||||
|
input[type="reset"],
|
||||||
|
input[type="submit"] {
|
||||||
|
-webkit-appearance: button; /* 2 */
|
||||||
|
cursor: pointer; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Re-set default cursor for disabled elements.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button[disabled],
|
||||||
|
input[disabled] {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Addresses box sizing set to `content-box` in IE 8/9.
|
||||||
|
* 2. Removes excess padding in IE 8/9.
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="checkbox"],
|
||||||
|
input[type="radio"] {
|
||||||
|
box-sizing: border-box; /* 1 */
|
||||||
|
padding: 0; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome.
|
||||||
|
* 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome
|
||||||
|
* (include `-moz` to future-proof).
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="search"] {
|
||||||
|
-webkit-appearance: textfield; /* 1 */
|
||||||
|
-moz-box-sizing: content-box;
|
||||||
|
-webkit-box-sizing: content-box; /* 2 */
|
||||||
|
box-sizing: content-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes inner padding and search cancel button in Safari 5 and Chrome
|
||||||
|
* on OS X.
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="search"]::-webkit-search-cancel-button,
|
||||||
|
input[type="search"]::-webkit-search-decoration {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Removes inner padding and border in Firefox 4+.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button::-moz-focus-inner,
|
||||||
|
input::-moz-focus-inner {
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Removes default vertical scrollbar in IE 8/9.
|
||||||
|
* 2. Improves readability and alignment in all browsers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
overflow: auto; /* 1 */
|
||||||
|
vertical-align: top; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Tables
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove most spacing between table cells.
|
||||||
|
*/
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
Reference in New Issue
Block a user