| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616 | /*The MIT License (MIT)Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)*/    /*     * Cell widgets      */    class Widgets {        constructor() {          console.log("widget constructor")        }        get divider(){            return {                $cell: true,                $type: "hr",                class: "mdc-list-divider"            }        }        get emptyDiv(){            return {                $type: "div",                style: "padding-bottom: 30px;"            }        }        get break(){            return {                $type: "br"            }        }        get space() {           return {                $type: "span",                $text: " "            }        }        get p(){            return {                $type: "p"            }        }            inputTextFieldOutlined(obj){                function initFunc() {                    new mdc.textField.MDCTextField.attachTo(this);                }                let inputType = obj.type ? obj.type: 'text';                let init = obj.init ? obj.init: initFunc;                let style = obj.style ? obj.style: "";                let fieldStyle = obj.fieldStyle ? obj.fieldStyle: "";                return {                    $cell: true,                    $type: "div",                    class: "mdc-text-field mdc-text-field--outlined mdc-text-field--dense",                    style: style,                    $init: init,                    $components:[                        {                            $type: "input",                            type: inputType,                            id: obj.id,                            class: "mdc-text-field__input",                            value: obj.value,                            onchange: obj.change,                            style: obj.fieldStyle                        },                        {                            $type: "span",                            class: "mdc-notched-outline",                            $components:[                                {                                    $type: "span",                                    class: "mdc-notched-outline__leading"                                },                                {                                    $type: "span",                                    class: "mdc-notched-outline__notch",                                    $components:[                                        {                                            $type: "span",                                            class: "mdc-floating-label",                                            for: obj.id,                                            $text: obj.label                                        }                            ]                                },                                {                                    $type: "span",                                    class: "mdc-notched-outline__trailing"                                }                            ]                        }                                                                                         ]                    //onclick: obj.onclick                }            }            inputTextFieldStandart(obj){                var propValue = obj.value;                if (_app.helpers.testJSON(obj.value)){                    propValue = JSON.parse(obj.value);                }  else {                propValue = obj.value;            }                return {                    $cell: true,                    $type: "div",                    class: "mdc-text-field mdc-text-field--filled",                    _mdc: null,                    $init: function(){                    //new mdc.mdc.notchedOutline.MDCNotchedOutline(document.querySelector('.mdc-notched-outline'));                       this._mdc = new mdc.textField.MDCTextField.attachTo(this);                    },                    $components:[                        {                            $type: "span",                            class: "mdc-text-field__ripple",                        },                        {                            $type: "input",                            type: "text",                            id: obj.id,                            class: "mdc-text-field__input",                            value: propValue,                            onchange: obj.change                        },                        {                            $type: "span",                            class: "mdc-floating-label",                            for: obj.id,                            $text: obj.label                        },                        {                            $type: "span",                            class: "mdc-line-ripple"                        }                                            ]                    //onclick: obj.onclick                }            }        headerH3(headertype, label, cssclass) {            return  {                $cell: true,                $type: headertype,                class: cssclass,                $text: label            }        }        simpleCard(obj){            let style =  'background-image: url(' + obj.imgSrc + '); background-size: cover; background-repeat: no-repeat; height:' + obj.imgHeight + ';';            var addonClass = obj.addonClass;            if (!addonClass){                addonClass = ''            }            return  {                $cell: true,                $type: "div",                $components:[                    {                        $cell: true,                        $type: "div",                        class: "mdc-card" +' '+ addonClass,                        onclick: obj.onclickfunc,                        $components:[                            {                                $cell: true,                                $type: "section",                                class: "mdc-card__media",                                style:  style                            },                            {                                $cell: true,                                $type: "section",                                class: "mdc-card__supporting-text",                                $text: obj.text                            }                        ]                    }                ]            }        }        listDivider() {            return {                $cell: true,                $type: "hr",                class: "mdc-list-divider mdc-list-divider--inset"            }        }        createListItem(obj) {            return {                $cell: true,                $type: "li",                class: "mdc-list-item",                $components: [                    {                        $cell: true,                        $type: "span",                        class: "mdc-list-item__graphic",                        $components: [                            {                            $cell: true,                            class: "createItems",                            $type: "img",                            src: obj.imgSrc,                            onclick: obj.onclickfunc                            }                        ]                    },                    {                        $cell: true,                        $type: "span",                        class: "mdc-list-item__text",                        $text: obj.title                        // $components: [                        //     {                        //         $text: obj.title                        //     },                        //     {                        //     $cell: true,                        // $type: "span",                        // class: "mdc-list-item__secondary-text",                        // $text: obj.subTitle                        //     }                        // ]                    }                ]            }        }        createCard(obj){            return {                $cell: true,                $type: "div",                $components:[                    {                        $cell: true,                        $type: "div",                        class: "mdc-card",                        $components:[                            {                                $cell: true,                                $type: "div",                                class: "mdc-card__horizontal-block",                                $components:[                                    {                                        $cell: true,                                        $type: "section",                                        class: "mdc-card__primary",                                        $components:[                                            {                                                $cell: true,                                                $type: "h1",                                                class: "mdc-card__title mdc-card__title--large",                                                $text: obj.title                                            },                                            {                                                $cell: true,                                                $type: "h2",                                                class: "mdc-card__subtitle",                                                $text: obj.subTitle                                            }                                        ]                                    },                                    {                                                                                    $cell: true,                                            $type: "img",                                            class: "",                                            src: obj.imgSrc                                                                            }                                ]                            },                            {                                $cell: true,                                $type: "section",                                class: "mdc-card__actions",                                $components:[                                    {                                        $cell: true,                                        $type: "button",                                        class: "mdc-button mdc-button--compact mdc-card__action",                                        $text: obj.actionLabel                                    }                                ]                            }                        ]                    }                ]            }        }        buttonStroked(obj){            let initFun = obj.init ? obj.init: function(){}            return {                $cell: true,                $type: "button",                class: "mdc-button mdc-button--outlined",                $text: obj.label,                onclick: obj.onclick,                $init: initFun            }        }        buttonRaised(obj){            let initFun = obj.init ? obj.init: function(){}            return {                $cell: true,                $type: "button",                class: "mdc-button mdc-button--raised mdc-ripple-upgraded",                $text: obj.label,                onclick: obj.onclick,                $init: initFun            }        }        buttonSimple(obj){            return {                $cell: true,                $type: "button",                class: "mdc-button",                $components: [                    {                        $type: "span",                        class: "mdc-button__label",                        $text: obj.label                    }                ],                onclick: obj.onclick            }        }        sliderDiscrete(obj) {            return {                $cell: true,                $type: "div",                class: "mdc-slider mdc-slider--discrete",                role: "slider",                'aria-valuemin': obj.min,                'aria-valuemax': obj.max,                'aria-label': obj.label,                $init: obj.init,                $components: [                    {                        $cell: true,                        $type: "div",                        class: "mdc-slider__track-container",                        $components: [                            {                                $cell: true,                                $type: "div",                                class: "mdc-slider__track",                                                            }                        ]                    },                    {                        $cell: true,                        $type: "div",                        class: "mdc-slider__thumb-container",                        $components: [                            {                                $cell: true,                                $type: "div",                                class: "mdc-slider__pin",                                $components: [                                    {                                        $cell: true,                                        $type: "span",                                        class: "mdc-slider__pin-value-marker",                                    }                                ]                                                            },                            {                                $cell: true,                                $type: "svg",                                class: "mdc-slider__thumb",                                width: 21,                                height: 21,                                $components: [                                    {                                        $cell: true,                                        $type: "circle",                                        cx: 10.5,                                        cy: 10.5,                                        r: 7.875                                    }                                ]                            },                            {                                $cell: true,                                $type: "div",                                class: "mdc-slider__focus-ring"                            }                        ]                    }                ]            }        }        sliderContinuous(obj) {            return {                $cell: true,                $type: "div",                class: "mdc-slider",                role: "slider",                tabindex: 0,                'id': obj.id,                'aria-valuemin': obj.min,                'aria-valuemax': obj.max,                'aria-label': obj.label,                'aria-valuenow': obj.value,                'data-step': obj.step,                $init: obj.init,                $components: [                    {                        $cell: true,                        $type: "div",                        class: "mdc-slider__track-container",                        $components: [                            {                                $cell: true,                                $type: "div",                                class: "mdc-slider__track",                                                            }                        ]                    },                    {                        $cell: true,                        $type: "div",                        class: "mdc-slider__thumb-container",                        $components: [                            {                                $cell: true,                                $type: "svg",                                class: "mdc-slider__thumb",                                width: 21,                                height: 21,                                $components: [                                    {                                        $cell: true,                                        $type: "circle",                                        cx: 10.5,                                        cy: 10.5,                                        r: 7.875                                    }                                ]                            },                            {                                $cell: true,                                $type: "div",                                class: "mdc-slider__focus-ring"                            }                        ]                    }                ]            }        }        textField(obj) {            return {                class: "mdc-text-field",                style: "width: 100%",                $cell: true,                $type: "div",                $components: [                    {                        class: "mdc-text-field__input prop-text-field-input",                        id: obj.id,                        $cell: true,                        $type: "input",                        type: "text",                        value: obj.value,                        onchange: obj.funconchange                    }                ]            }        }        icontoggle(obj) {            var addClass = "";            if (obj.styleClass){                addClass = obj.styleClass;            }            return {                $type: "button",                class: addClass + " mdc-icon-button",                //$text: obj.label,                id: obj.id,                //'data-toggle-on': obj.on,               // 'data-toggle-off': obj.off,                'aria-pressed': obj.state,                'aria-hidden': true,                $init: obj.init,                $components:[                    {                    $type: "i",                    class: "material-icons mdc-icon-button__icon mdc-icon-button__icon--on",                    $text: JSON.parse(obj.on).content                },                {                    $type: "i",                    class: "material-icons mdc-icon-button__icon",                    $text: JSON.parse(obj.off).content                  },                ]            }        }        floatActionButton(obj) {            var addClass = "";            if (obj.styleClass){                addClass = obj.styleClass;            }            return {                    $cell: true,                    $type: "button",                    class: "mdc-fab material-icons " + addClass,                    onclick: obj.onclickfunc,                    $components:[                        {                            $cell: true,                            $type: "span",                            class: "mdc-fab__icon",                            $text: obj.label                        }                    ]                }        }        iconButton(obj) {            var addClass = "";            if (obj.styleClass){                addClass = obj.styleClass;            }            return {                    $cell: true,                    $type: "button",                    class: "mdc-button " + addClass,                    onclick: obj.onclick,                    $components:[                        {                            $cell: true,                            $type: "i",                            class: "material-icons mdc-button__icon",                            $text: obj.label                        }                    ]                }        }        imageButton(obj){            return {                $cell: true,                $type: "button",                class: "mdc-button mdc-button--compact",                onclick: obj.onclickfunc,                $components:[                    {                        $cell: true,                        class: obj.styleClass,                        $type: "img",                        src: obj.imgSrc                     }                ]            }                    }        listTitle(obj){            return {                $type: "div",                class: "mdc-layout-grid__inner",                $components: [                    {                        $type: "div",                        class: "mdc-layout-grid__cell",                        $components: [                            {                                $type: "h3",                                class: "",                                $text: obj.text                            }                        ]                    }                ]            }        }        gridListItem(obj) {            return {                $type: "div",                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2 tooltip " + obj.styleClass,                $components:[                    {                        class: "tooltiptext",                        $type: "span",                        $text: obj.title                    },                    {                        $type: "div",                        style: "background-color: transparent;",                        $components:[                            {                                class: "",                                $type: "div",                                'aria-label': obj.title,                                alt: obj.title,                                style: "background-image: url("+ obj.imgSrc + "); background-size: cover; background-repeat: no-repeat; height: "+ obj.imgSize + "; width: " + obj.imgSize + ";",                                onclick: obj.onclickfunc,                              }                        ]                    }                ]            }        }        switch(obj) {            return   {                $cell: true,                $type: "div",                class: "mdc-switch",                _switch: null,                id: obj.id,                $init: obj.init,                 //function(){                //     new mdc.switchControl.MDCSwitch(this);                // },                $components: [                    {                        $type: "div",                        class: "mdc-switch__track",                    },                    {                        $type: "div",                        class: "mdc-switch__thumb-underlay",                        $components:[                            {                                $type: "div",                                class: "mdc-switch__thumb",                                $components:[                                    {                                        $type: "input",                                        type: "checkbox",                                        class: "mdc-switch__native-control",                                        id: 'input-' + obj.id,                                        //$init: obj.init,                                        //id: "basic-switch",                                        onchange: obj.onchange,                                        role: "switch"                                    }                                ]                            }                        ]                    }                                        // {                    //     $type: "div",                    //     class: "mdc-switch__background",                    //     $components: [                    //         {                    //             $type: "div",                    //             class: "mdc-switch__knob"                    //         }                    //     ]                    // }                ]            }        }        connectionSettingsGUI() {            let connectionSettings = {                id: 'connectionSettings',                $type: 'div',                $components: [                 _app.widgets.emptyDiv,                window._app.widgets.buttonRaised(                    {                        "label": 'Settings',                        "onclick": function (e) {                            e.preventDefault();                            window.location.pathname = '/settings';                        }                    }), _app.widgets.emptyDiv                ]            }            return connectionSettings                    }        debugGUI() {            let self = this;            let debug6DoF = {                $cell: true,                $components: [                  {                    $type: "p",                    class: "mdc-typography--headline5",                    $text: "Debug 6DoF mode (for using with WebXR emulator)"                  },                  {                    $type: 'p'                  },                  _app.widgets.switch({                    'id': 'forceDebug6DoF',                    'init': function () {                      this._switch = new mdc.switchControl.MDCSwitch(this);                      let config = localStorage.getItem('lcs_config');                      this._switch.checked = JSON.parse(config).d6DoF;                                           // this._replaceSwitch = this._switch;                                          },                    'onchange': function (e) {                            if (this._switch) {                            let chkAttr = this._switch.checked;//this.getAttribute('checked');                            if (chkAttr) {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.d6DoF = true;                                localStorage.setItem('lcs_config', JSON.stringify(config));                                //this._switch.checked = false;                            } else {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.d6DoF = false;                                localStorage.setItem('lcs_config', JSON.stringify(config));                            }                        }                    }                  }                  ),                  {                    $type: 'label',                    for: 'input-forceDebug6DoF',                    $text: 'On / Off'                  }                    ]              }              let debug3DoF = {                $cell: true,                $components: [                  {                    $type: "p",                    class: "mdc-typography--headline5",                    $text: "Debug 3DoF mode (for using with WebXR emulator)"                  },                  {                    $type: 'p'                  },                  _app.widgets.switch({                    'id': 'forceDebug3DoF',                    'init': function () {                      this._switch = new mdc.switchControl.MDCSwitch(this);                      let config = localStorage.getItem('lcs_config');                      this._switch.checked = JSON.parse(config).d3DoF;                                           // this._replaceSwitch = this._switch;                                          },                    'onchange': function (e) {                            if (this._switch) {                            let chkAttr = this._switch.checked;//this.getAttribute('checked');                            if (chkAttr) {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.d3DoF = true;                                localStorage.setItem('lcs_config', JSON.stringify(config));                                //this._switch.checked = false;                            } else {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.d3DoF = false;                                localStorage.setItem('lcs_config', JSON.stringify(config));                            }                        }                    }                  }                  ),                  {                    $type: 'label',                    for: 'input-forceDebug3DoF',                    $text: 'On / Off'                  }                    ]              }              let allGUI =              {                  $type: "div",                  id: "allGUI",                  //style:"background-color: #efefef",                  class: "mdc-layout-grid mdc-layout-grid--align-left",                  _d3DoF: null,                  _d6DoF: null,                  _initData: function () {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                if (config.d3DoF) {                          this._d3DoF = config.d3DoF                      }                      if (config.d6DoF) {                          this._d6DoF =config.d6DoF                      }                                          this._refresh();                 },                  $init: function () {                      this._initData();                  },                  _refresh: function () {                                this.$components = [                          {                              $type: "div",                              class: "mdc-layout-grid__inner",                              $components: [                                  {                                      $type: "div",                                      class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                      $components: [                                      {                                          $type: "h4",                                          class: "mdc-typography--headline4",                                          $text: "Debug settings"                                      }                                  ]                                  },                                 {                                   $type: "div",                                  class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                  $components: [debug6DoF ]                                 },                                 {                                   $type: "div",                                  class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                  $components: [_app.widgets.divider]                                 },                                 {                                   $type: "div",                                  class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                  $components: [debug3DoF]                                 },                                  {                                      $type: "div",                                      class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                      $components: [                                        //   window._app.widgets.buttonRaised(                                        //       {                                        //           "label": 'Update',                                        //           "onclick": function (e) {                                        //               e.preventDefault();                                                  //               let config = JSON.parse(localStorage.getItem('lcs_config'));                                                  //               config.reflector = this._refHostField.value;                                        //               config.dbhost = this._dbHostField.value;                                        //               config.luminaryPath = this._lpathField.value;                                        //               config.luminaryGlobalHBPath = this._hbpathField.value;                                                  //               localStorage.setItem('lcs_config', JSON.stringify(config));                                        //               window.location.reload(true);                                        //           }                                        //       }),                                              {                                                $type: 'span',                                                $text: " "                                              },                                              {                                                $type: "button",                                                class: "mdc-button mdc-button--raised",                                                $text: "Close",                                                onclick: function (e) {                                                      window.history.back();                                                    //window.location.pathname = '/'                                                }                                              }                                      ]                                  }                                        ]                          }                      ]                  }                        }                        document.querySelector("#appGUI").$cell({                  id: "appGUI",                  $cell: true,                  $type: "div",                  $components: [allGUI]              }              );            }        reflectorGUI() {            let self = this;            let webrtcConnection = {                $cell: true,                $components: [                  {                    $type: "p",                    class: "mdc-typography--headline5",                    $text: "Use WebRTC for connection"                  },                  {                    $type: 'p'                  },                  _app.widgets.switch({                    'id': 'forceWebRTC',                    'init': function () {                      this._switch = new mdc.switchControl.MDCSwitch(this);                      let config = localStorage.getItem('lcs_config');                      this._switch.checked = JSON.parse(config).webrtc;                                           // this._replaceSwitch = this._switch;                                          },                    'onchange': function (e) {                            if (this._switch) {                            let chkAttr = this._switch.checked;//this.getAttribute('checked');                            if (chkAttr) {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.webrtc = true;                                localStorage.setItem('lcs_config', JSON.stringify(config));                                //this._switch.checked = false;                            } else {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.webrtc = false;                                localStorage.setItem('lcs_config', JSON.stringify(config));                            }                        }                    }                  }                  ),                  {                    $type: 'label',                    for: 'input-forceWebRTC',                    $text: 'On / Off'                  }                    ]              }            let streamMsgConfig = {                $cell: true,                _streamMsgConfig: null,                $components: [                  {                    $type: "p",                    class: "mdc-typography--headline5",                    $text: "Use Stream of Messages"                  },                  {                    $type: 'p'                  },                  _app.widgets.switch({                    'id': 'streamMsgConfig',                    'init': function () {                      this._switch = new mdc.switchControl.MDCSwitch(this);                      let config = localStorage.getItem('lcs_config');                      this._switch.checked = JSON.parse(config).streamMsg;                                           // this._replaceSwitch = this._switch;                                          },                    'onchange': function (e) {                            if (this._switch) {                            let chkAttr = this._switch.checked;//this.getAttribute('checked');                            if (chkAttr) {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.streamMsg = true;                                localStorage.setItem('lcs_config', JSON.stringify(config));                                //this._switch.checked = false;                            } else {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.streamMsg = false;                                localStorage.setItem('lcs_config', JSON.stringify(config));                            }                        }                    }                  }                  ),                  {                    $type: 'label',                    for: 'input-streamMsgConfig',                    $text: 'On / Off'                  }                    ]            }              let multiSocket = {                $cell: true,                $components: [                  {                    $type: "p",                    class: "mdc-typography--headline5",                    $text: "Use Rooms & Gun DB MultiSocket (no mem)"                  },                  {                    $type: 'p'                  },                  _app.widgets.switch({                    'id': 'multisocket',                    'init': function () {                      this._switch = new mdc.switchControl.MDCSwitch(this);                      let config = localStorage.getItem('lcs_config');                      this._switch.checked = JSON.parse(config).multisocket;                                           // this._replaceSwitch = this._switch;                                          },                    'onchange': function (e) {                            if (this._switch) {                            let chkAttr = this._switch.checked;//this.getAttribute('checked');                            if (chkAttr) {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.multisocket = true;                                localStorage.setItem('lcs_config', JSON.stringify(config));                                //this._switch.checked = false;                            } else {                                let config = JSON.parse(localStorage.getItem('lcs_config'));                                config.multisocket = false;                                localStorage.setItem('lcs_config', JSON.stringify(config));                            }                        }                    }                  }                  ),                  {                    $type: 'label',                    for: 'input-multisocket',                    $text: 'On / Off'                  }                    ]              }            // let luminaryGlobalHB = {            //     $cell: true,            //     $components: [            //       {            //         $type: "p",            //         class: "mdc-typography--headline5",            //         $text: "Use Global Heartbeat"            //       },            //       {            //         $type: 'p'            //       },            //       _app.widgets.switch({            //         'id': 'forceLuminary',            //         'init': function () {            //           this._switch = new mdc.switchControl.MDCSwitch(this);            //           let config = localStorage.getItem('lcs_config');            //           this._switch.checked = JSON.parse(config).luminaryGlobalHB;                                  //          // this._replaceSwitch = this._switch;                                  //         },            //         'onchange': function (e) {                //             if (this._switch) {            //                 let chkAttr = this._switch.checked;//this.getAttribute('checked');            //                 if (chkAttr) {            //                     let config = JSON.parse(localStorage.getItem('lcs_config'));            //                     config.luminaryGlobalHB = true;            //                     localStorage.setItem('lcs_config', JSON.stringify(config));            //                     //this._switch.checked = false;            //                 } else {            //                     let config = JSON.parse(localStorage.getItem('lcs_config'));            //                     config.luminaryGlobalHB = false;            //                     localStorage.setItem('lcs_config', JSON.stringify(config));            //                 }            //             }            //         }            //       }            //       ),            //       {            //         $type: 'label',            //         for: 'input-forceLuminary',            //         $text: 'On / Off'            //       }                //     ]            //   }              let luminaryFeature = {                $type: 'div',                $components: [                    {                        $type: "p",                        class: "mdc-typography--headline4",                        $text: "Use Krestianstvo Luminary (experimental)"                    },                    {                        $type: 'p'                    },                    _app.widgets.switch({                        'id': 'forceLuminary',                        'init': function () {                            this._switch = new mdc.switchControl.MDCSwitch(this);                            let config = localStorage.getItem('lcs_config');                            this._switch.checked = JSON.parse(config).luminary;                                // this._replaceSwitch = this._switch;                            },                        'onchange': function (e) {                                if (this._switch) {                                let chkAttr = this._switch.checked;//this.getAttribute('checked');                                if (chkAttr) {                                    let config = JSON.parse(localStorage.getItem('lcs_config'));                                    config.luminary = true;                                    localStorage.setItem('lcs_config', JSON.stringify(config));                                    window.location.reload(true);                                    //this._switch.checked = false;                                } else {                                    let config = JSON.parse(localStorage.getItem('lcs_config'));                                    config.luminary = false;                                    localStorage.setItem('lcs_config', JSON.stringify(config));                                    window.location.reload(true);                                }                            }                        }                    }                    ),                    {                        $type: 'label',                        for: 'input-forceLuminary',                        $text: 'Off / On'                    },                    _app.widgets.p                    ]            }                let reflectorGUI =            {                $type: "div",                id: "reflectorGUI",                //style:"background-color: #efefef",                class: "mdc-layout-grid mdc-layout-grid--align-left",                _reflectorHost: null,                _dbHost: null,                _refHostField: null,                _dbHostField: null,                _lpath: null,                _lpathField: null,                _hbpath: null,                _hbpathField: null,                //_debug: null,                _initData: function () {                    this._reflectorHost = '';                    this._dbHost = '';                            let config = JSON.parse(localStorage.getItem('lcs_config'));                            if (config.reflector) {                        this._reflectorHost = config.reflector                    }                    if (config.dbhost) {                        this._dbHost =config.dbhost                    }                    if (config.luminaryPath) {                        this._lpath = config.luminaryPath                    }                    // if (config.luminaryGlobalHBPath) {                    //     this._hbpath = config.luminaryGlobalHBPath                    // }                    // if (config.debug) {                    //     this._debug = config.debug                    // }                },                $init: function () {                    this._initData();                },                $update: function () {                            this.$components = [                        {                            $type: "div",                            class: "mdc-layout-grid__inner",                            $components: [                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                    {                                        $type: "h4",                                        class: "mdc-typography--headline4",                                        $text: "Gun DB settings"                                    }                                ]                                },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        {                                            $type: "span",                                            class: "mdc-typography--headline5",                                            $text: "DB Host: "                                        },                                        window._app.widgets.inputTextFieldOutlined({                                            "id": 'dbhostInput',                                            "label": "DB Host",                                            "value": this._dbHost,                                            "type": "text",                                            "init": function() {                                                this._dbHostField = new mdc.textField.MDCTextField(this);                                            },                                            "style": 'width: 400px;'                                        }),                                    ]                                },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                    {                                        $type: "h4",                                        class: "mdc-typography--headline4",                                        $text: "Reflector settings"                                    }                                ]                                },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        {                                            $type: "span",                                            class: "mdc-typography--headline5",                                            $text: "Reflector: "                                        },                                        window._app.widgets.inputTextFieldOutlined({                                            "id": 'reflectorInput',                                            "label": "Reflector",                                            "value": this._reflectorHost,                                            "type": "text",                                            "init": function() {                                                        this._refHostField = new mdc.textField.MDCTextField(this);                                                    },                                            "style": 'width: 400px;'                                        }),                                    ]                                },                                {                                     $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [webrtcConnection ]                                   },                                   {                                     $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [_app.widgets.divider]                                   },                                                                  // {                                //     $type: "div",                                //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                //     $components: [                                //     {                                //         $type: "h4",                                //         class: "mdc-typography--headline4",                                //         $text: "Krestianstvo Luminary settings (experimental)"                                //     }                                // ]                                // },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        luminaryFeature                                ]                                },                                {                                     $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [multiSocket]                                   },                                                                                               {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        {                                            $type: "span",                                            class: "mdc-typography--headline5",                                            $text: "Multisocket Rooms Host: "                                        },                                        window._app.widgets.inputTextFieldOutlined({                                            "id": 'lpathInput',                                            "label": "Multisocket Rooms Host",                                            "value": this._lpath,                                            "type": "text",                                            "init": function() {                                                this._lpathField = new mdc.textField.MDCTextField(this);                                            },                                            "style": 'width: 400px;'                                        }),                                    ]                                },                                // {                                //     $type: "div",                                //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                //     $components: [                                //         {                                //             $type: "span",                                //             class: "mdc-typography--headline5",                                //             $text: "Global Heartbeat Path: "                                //         },                                //         window._app.widgets.inputTextFieldOutlined({                                //             "id": 'hbpathInput',                                //             "label": "Global Heartbeat Path",                                //             "value": this._hbpath,                                //             "type": "text",                                //             "init": function() {                                //                 this._hbpathField = new mdc.textField.MDCTextField(this);                                //             },                                //             "style": 'width: 400px;'                                //         }),                                //     ]                                // },                            //    {                             //     $type: "div",                            //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                            //     $components: [luminaryGlobalHB ]                            //    },                               {                                 $type: "div",                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                $components: [_app.widgets.divider]                               },                               {                                 $type: "div",                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                $components: [streamMsgConfig ]                               },                            //    {                             //     $type: "div",                            //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                            //     $components: [debugGUI]                            //    },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        window._app.widgets.buttonRaised(                                            {                                                "label": 'Update',                                                "onclick": function (e) {                                                    e.preventDefault();                                                            let config = JSON.parse(localStorage.getItem('lcs_config'));                                                            config.reflector = this._refHostField.value;                                                    config.dbhost = this._dbHostField.value;                                                    config.luminaryPath = this._lpathField.value;                                                    //config.luminaryGlobalHBPath = this._hbpathField.value;                                                            localStorage.setItem('lcs_config', JSON.stringify(config));                                                    window.location.reload(true);                                                }                                            }),                                            {                                              $type: 'span',                                              $text: " "                                            },                                            {                                              $type: "button",                                              class: "mdc-button mdc-button--raised",                                              $text: "Close",                                              onclick: function (e) {                                                    window.history.back();                                                  //window.location.pathname = '/'                                              }                                            }                                    ]                                }                                    ]                        }                    ]                }                    }                    document.querySelector("#appGUI").$cell({                id: "appGUI",                $cell: true,                $type: "div",                $components: [reflectorGUI]            }            );                }        getLoginGUI(){            let loginGUI =            {                $type: "div",                id: "loginGUI",                //style:"background-color: #efefef",                class: "mdc-layout-grid mdc-layout-grid--align-left",                _alias: null,                _pass: null,                _passField: null,                _aliasField: null,                _initData: function () {                    this._alias = '';                    this._pass = '';                    // if (window.sessionStorage.getItem('alias')) {                    //     this._alias = window.sessionStorage.getItem('alias')                    // }                    // if (window.sessionStorage.getItem('tmp')) {                    //     this._pass = window.sessionStorage.getItem('tmp')                    // }                },                $init: function () {                    this._initData();                },                $update: function () {                        this.$components = [                        {                            $type: "div",                            class: "mdc-layout-grid__inner",                            $components: [                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        {                                            $type: "span",                                            class: "mdc-typography--headline5",                                            $text: _l.t("login") + ": "                                        },                                        window._app.widgets.inputTextFieldOutlined({                                            "id": 'aliasInput',                                            "label": _l.t("login"),                                            "value": this._alias,                                            "type": "text",                                            "init": function () {                                                this._aliasField = new mdc.textField.MDCTextField(this);                                            }                                        }),                                    ]                                },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        {                                            $type: "span",                                            class: "mdc-typography--headline5",                                            $text: _l.t("password") + ": "                                        },                                        window._app.widgets.inputTextFieldOutlined({                                            "id": 'passwordInput',                                            "label": _l.t("password"),                                            "value": this._pass,                                            "type": "password",                                            "init": function () {                                                this._passField = new mdc.textField.MDCTextField(this);                                            }                                        }),                                    ]                                },                                {                                    $type: "div",                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",                                    $components: [                                        window._app.widgets.buttonRaised(                                            {                                                "label": _l.t("sign up"),                                                "onclick": function (e) {                                                    e.preventDefault();                                                        let alias = this._aliasField.value;                                                    let pass = this._passField.value                                                        if (pass.length < 7) {                                                        new Noty({                                                            text: "Your passphrase needs to be longer than 7 letters",                                                            timeout: 2000,                                                            theme: 'mint',                                                            layout: 'bottomRight',                                                            type: 'error'                                                        }).show();                                                    } else {                                                        //                                                        _LCSDB.user().create(alias, pass,                                                            function (ack) {                                                                if (!ack.wait) { }                                                                if (ack.err) {                                                                    console.log(ack.err)                                                                    return ack.err                                                                };                                                                if (ack.pub) {                                                                    let userObj = {                                                                        'alias': alias,                                                                        'pub': ack.pub                                                                    };                                                                    _LCSDB.get('users').get(alias).put(userObj);                                                                    }                                                                _LCSDB.user().auth(alias, pass);                                                            });                                                        }                                                }                                            }),                                        _app.widgets.space,                                        window._app.widgets.buttonRaised(                                            {                                                "label": _l.t("sign in"),                                                "onclick": function (e) {                                                    e.preventDefault();                                                    let alias = this._aliasField.value;                                                    let pass = this._passField.value                                                    _app.helpers.authUser(alias, pass);                                                    // _LCSDB.user().auth.call(_LCSDB, alias, pass                                                    // //     , function(ack) {                                                        // //     if (ack.err) {                                                    // //         new Noty({                                                    // //             text: ack.err,                                                    // //             timeout: 2000,                                                    // //             theme: 'mint',                                                    // //             layout: 'bottomRight',                                                    // //             type: 'error'                                                    // //         }).show();                                                        // //     }                                                    //  //}                                                    //  );                                                }                                            })                                                ]                                }                                ]                        }                    ]                }                }            return loginGUI        }      }   export { Widgets }
 |