Реализовать расширяемую платформу Муром 1.2 с панелью управления 1.0.0

This commit is contained in:
kornerr committed 2019-10-16 14:49:11 +03:00
1 parent 8752fdf1e8
commit 898981e9dd
9 files changed
+1124 -228

No files matched your search

+99
View File
@@ -0,0 +1,99 @@
/*
*
* UUID
*
*/
// Create GUID / UUID in JavaScript?
// https://stackoverflow.com/a/2117523
муром.uuid = function()
{
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
/[xy]/g,
function(c)
{
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
}
);
};
/*
*
* Уведомитель / Reporter
*
*/
// ReporterSubscription class.
function ReporterSubscription(id, callback, reporter)
{
this.id = id;
this.callback = callback;
this.reporter = reporter;
}
// Reporter class.
function Reporter(name)
{
this.name =
(typeof name !== "undefined") ?
name :
"";
this.subscriptions = [];
}
Reporter.prototype.report = function()
{
for (var id in this.subscriptions)
{
var subscription = this.subscriptions[id];
subscription.callback();
}
}
Reporter.prototype.subscribe = function(callback)
{
var id = murom.uuid();
var subscription = new ReporterSubscription(id, callback, this);
this.subscriptions.push(subscription);
return subscription;
}
Reporter.prototype.subscribeMany = function(funcs)
{
for (var i = 0; i < funcs.length; ++i)
{
var func = funcs[i];
this.subscribe(func);
}
}
var Уведомитель = Reporter;
Reporter.prototype.уведомить = function()
{
this.report();
};
Reporter.prototype.подписать = function(функция)
{
this.subscribe(функция);
};
Reporter.prototype.подписатьМного = function(funcs)
{
this.subscribeMany(funcs);
};
/*
*
* Пуск / Start
*
*/
муром.пуск = new Уведомитель();
// Can also be accessed as 'murom.run'.
Object.defineProperty(murom, "run", {
get: function()
{
return муром.пуск;
}
});
murom.start = function()
{
муром.пуск.уведомить();
};
@@ -0,0 +1,122 @@
/*
* NOTE Only ASCII is allowed in this loading module
* NOTE because it's deciphered with btoa() call,
* NOTE which can't handle Unicode.
* NOTE However, murom.atob/btoa functions (defined here)
* NOTE work fine with Unicode, so you are free
* NOTE to use Unicode in other modules
*/
murom.installLocalForage = function()
{
/*
localForage -- Offline Storage, Improved
Version 1.7.3
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.localforage=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){"use strict";function c(){k=!0;for(var a,b,c=l.length;c;){for(b=l,l=[],a=-1;++a<c;)b[a]();c=l.length}k=!1}function d(a){1!==l.push(a)||k||e()}var e,f=a.MutationObserver||a.WebKitMutationObserver;if(f){var g=0,h=new f(c),i=a.document.createTextNode("");h.observe(i,{characterData:!0}),e=function(){i.data=g=++g%2}}else if(a.setImmediate||void 0===a.MessageChannel)e="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){c(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(c,0)};else{var j=new a.MessageChannel;j.port1.onmessage=c,e=function(){j.port2.postMessage(0)}}var k,l=[];b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){"use strict";function d(){}function e(a){if("function"!=typeof a)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,a!==d&&i(this,a)}function f(a,b,c){this.promise=a,"function"==typeof b&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof c&&(this.onRejected=c,this.callRejected=this.otherCallRejected)}function g(a,b,c){o(function(){var d;try{d=b(c)}catch(b){return p.reject(a,b)}d===a?p.reject(a,new TypeError("Cannot resolve promise with itself")):p.resolve(a,d)})}function h(a){var b=a&&a.then;if(a&&("object"==typeof a||"function"==typeof a)&&"function"==typeof b)return function(){b.apply(a,arguments)}}function i(a,b){function c(b){f||(f=!0,p.reject(a,b))}function d(b){f||(f=!0,p.resolve(a,b))}function e(){b(d,c)}var f=!1,g=j(e);"error"===g.status&&c(g.value)}function j(a,b){var c={};try{c.value=a(b),c.status="success"}catch(a){c.status="error",c.value=a}return c}function k(a){return a instanceof this?a:p.resolve(new this(d),a)}function l(a){var b=new this(d);return p.reject(b,a)}function m(a){function b(a,b){function d(a){g[b]=a,++h!==e||f||(f=!0,p.resolve(j,g))}c.resolve(a).then(d,function(a){f||(f=!0,p.reject(j,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=new Array(e),h=0,i=-1,j=new this(d);++i<e;)b(a[i],i);return j}function n(a){function b(a){c.resolve(a).then(function(a){f||(f=!0,p.resolve(h,a))},function(a){f||(f=!0,p.reject(h,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=-1,h=new this(d);++g<e;)b(a[g]);return h}var o=a(1),p={},q=["REJECTED"],r=["FULFILLED"],s=["PENDING"];b.exports=e,e.prototype.catch=function(a){return this.then(null,a)},e.prototype.then=function(a,b){if("function"!=typeof a&&this.state===r||"function"!=typeof b&&this.state===q)return this;var c=new this.constructor(d);if(this.state!==s){g(c,this.state===r?a:b,this.outcome)}else this.queue.push(new f(c,a,b));return c},f.prototype.callFulfilled=function(a){p.resolve(this.promise,a)},f.prototype.otherCallFulfilled=function(a){g(this.promise,this.onFulfilled,a)},f.prototype.callRejected=function(a){p.reject(this.promise,a)},f.prototype.otherCallRejected=function(a){g(this.promise,this.onRejected,a)},p.resolve=function(a,b){var c=j(h,b);if("error"===c.status)return p.reject(a,c.value);var d=c.value;if(d)i(a,d);else{a.state=r,a.outcome=b;for(var e=-1,f=a.queue.length;++e<f;)a.queue[e].callFulfilled(b)}return a},p.reject=function(a,b){a.state=q,a.outcome=b;for(var c=-1,d=a.queue.length;++c<d;)a.queue[c].callRejected(b);return a},e.resolve=k,e.reject=l,e.all=m,e.race=n},{1:1}],3:[function(a,b,c){(function(b){"use strict";"function"!=typeof b.Promise&&(b.Promise=a(2))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;iLine truncated
};
murom.installUnicodeBase64 = function()
{
/*
https://github.com/solderjs/TextEncoderLite
Apache 2.0
*/
function TextEncoderLite(){}function TextDecoderLite(){}(function(){"use strict";function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end||Infinity);start=start||0;for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}TextEncoderLite.prototype.encode=function(str){var result;if("undefined"===typeof Uint8Array){result=utf8ToBytes(str)}else{result=new Uint8Array(utf8ToBytes(str))}return result};TextDecoderLite.prototype.decode=function(bytes){return utf8Slice(bytes,0,bytes.length)}})();if(typeof module==="object"&&module){module.exports.TextDecoderLite=TextDecoderLite;module.exports.TextEncoderLite=TextEncoderLite}
/*
https://github.com/beatgammit/base64-js
MIT
*/
(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,n;return function(){function r(e,n,t){function o(f,i){if(!n[f]){if(!e[f]){var u="function"==typeof require&&require;if(!i&&u)return u(f,!0);if(a)return a(f,!0);var v=new Error("Cannot find module '"+f+"'");throw v.code="MODULE_NOT_FOUND",v}var d=n[f]={exports:{}};e[f][0].call(d.exports,function(r){var n=e[f][1][r];return o(n||r)},d,d.exports,r,e,n,t)}return n[f].exports}for(var a="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}return r}()({"/":[function(r,e,n){"use strict";n.byteLength=d;n.toByteArray=h;n.fromByteArray=p;var t=[];var o=[];var a=typeof Uint8Array!=="undefined"?Uint8Array:Array;var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,u=f.length;i<u;++i){t[i]=f[i];o[f.charCodeAt(i)]=i}o["-".charCodeAt(0)]=62;o["_".charCodeAt(0)]=63;function v(r){var e=r.length;if(e%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function d(r){var e=v(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function c(r,e,n){return(e+n)*3/4-n}function h(r){var e;var n=v(r);var t=n[0];var f=n[1];var i=new a(c(r,t,f));var u=0;var d=f>0?t-4:t;for(var h=0;h<d;h+=4){e=o[r.charCodeAt(h)]<<18|o[r.charCodeAt(h+1)]<<12|o[r.charCodeAt(h+2)]<<6|o[r.charCodeAt(h+3)];i[u++]=e>>16&255;i[u++]=e>>8&255;i[u++]=e&255}if(f===2){e=o[r.charCodeAt(h)]<<2|o[r.charCodeAt(h+1)]>>4;i[u++]=e&255}if(f===1){e=o[r.charCodeAt(h)]<<10|o[r.charCodeAt(h+1)]<<4|o[r.charCodeAt(h+2)]>>2;i[u++]=e>>8&255;i[u++]=e&255}return i}function s(r){return t[r>>18&63]+t[r>>12&63]+t[r>>6&63]+t[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;a<n;a+=3){t=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255);o.push(s(t))}return o.join("")}function p(r){var e;var n=r.length;var o=n%3;var a=[];var f=16383;for(var i=0,u=n-o;i<u;i+=f){a.push(l(r,i,i+f>u?u:i+f))}if(o===1){e=r[n-1];a.push(t[e>>2]+t[e<<4&63]+"==")}else if(o===2){e=(r[n-2]<<8)+r[n-1];a.push(t[e>>10]+t[e>>4&63]+t[e<<2&63]+"=")}return a.join("")}},{}]},{},[])("/")});
/*
https://developer.mozilla.org/ru/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
*/
murom.btoa = function(str)
{
var bytes = new (TextEncoder || TextEncoderLite)("utf-8").encode(str);
return base64js.fromByteArray(bytes);
};
murom.atob = function(str)
{
var bytes = base64js.toByteArray(str);
return new (TextDecoder || TextDecoderLite)("utf-8").decode(bytes);
};
};
murom.moduleProperties = function(id)
{
var m = murom.modules[id];
return (typeof m[2] != "undefined") ? m[2] : {};
};
murom.moduleStatus = function(id)
{
var prop = murom.moduleProperties(id);
if ("status" in prop)
{
return prop["status"];
}
// Status == true if explicit record is absent.
return true;
};
murom.start = function()
{
console.debug("Override murom.start() function to be notified when all modules were loaded");
}
murom.loadModules = function()
{
// Skip `0` module because it's us.
for (var i = 1; i < murom.modules.length; ++i)
{
var module = murom.modules[i];
var name = module[0];
var code = murom.atob(module[1]);
if (murom.moduleStatus(i) == false)
{
console.warn("Skip loading '" + name + "' module because it's turned off");
}
else
{
try
{
eval(code);
}
catch (e)
{
console.error("Could not load '" + name + "' module: '" + e + "'");
}
}
}
murom.start();
};
murom.loadIndexedDBModules = function(completionHandler)
{
// See if IndexedDB has modules.
// IndexedDB modules override those coming from HTML.
localforage.config({ name: "murom" });
localforage.getItem("modules", function(error, modules) {
if (modules)
{
murom.modules = modules;
console.debug("Modules have been loaded from IndexedDB");
}
if (error)
{
console.error("Could not get modules from IndexedDB: '" + error + "'");
}
// Continue.
completionHandler();
});
};
murom.installLocalForage();
murom.installUnicodeBase64();
// IndexedDB modules override HTML ones.
murom.loadIndexedDBModules(murom.loadModules);
+18
View File
@@ -0,0 +1,18 @@
муром.создатьЛевуюПравуюОбласти = function()
{
// Левая область.
var ло = document.createElement("div");
ло.id="левая-область";
ло.style.cssText =
"position: fixed; left: 0; top: 0; bottom: 0; width: 50%;";
document.body.appendChild(ло);
// Правая область.
var по = document.createElement("div");
по.id="правая-область";
по.style.cssText =
"position: fixed; right: 0; top: 0; bottom: 0; width: 50%;";
document.body.appendChild(по);
return [ло, по];
};
+765
View File
@@ -0,0 +1,765 @@
/*
*
* Внешний вид
*
*/
function задатьВнешнийВид()
{
var вид = document.createElement("style");
document.head.appendChild(вид);
вид.innerHTML =
`
.муром-кнопка
{
padding: 0.5em 2em 0.5em 2em;
margin-right: 0.5em;
float: right;
color: #222;
font-family: sans-serif;
border: 1px solid #ddd;
background-color: transparent;
cursor: pointer;
text-transform: uppercase;
-webkit-transition-duration: 0.2s; /* Safari */
transition-duration: 0.2s;
}
.муром-кнопка:hover
{
border: 1px solid #222;
}
.муром-отступ-по-сторонам
{
margin-left: 0.5em;
margin-right: 0.5em;
}
`;
}
/*
*
* Список модулей
*
*/
function СписокМодулей()
{
var я = this;
this.создатьИнтерфейс();
this.задатьВид();
this.выбрали = new Уведомитель();
this.выбрали.подписать(function(){
я.отобразитьВыбор();
});
}
СписокМодулей.prototype.создатьИнтерфейс = function()
{
// Помещаем таблицу в div для реализации промотки.
this.иф = document.createElement("div");
this.таблица = document.createElement("table");
this.иф.appendChild(this.таблица);
};
СписокМодулей.prototype.задатьВид = function()
{
this.иф.style.cssText =
`
overflow: auto;
height: 18.5em;
border: 1px solid #ddd;
/*
padding: 0.5em;
margin: 0.5em;
*/
`;
this.таблица.style.cssText =
`
color: #666666;
font-family: sans-serif;
cursor: default;
border-collapse: collapse;
`;
};
СписокМодулей.prototype.очистить = function()
{
while (this.таблица.rows.length)
{
this.таблица.deleteRow(0);
};
};
СписокМодулей.prototype.добавитьЭлемент = function(статус, имя)
{
var статусHTML = "";
if (статус)
{
статусHTML = "checked";
}
var ряд = this.таблица.insertRow();
var ячейка = 0;
var номер = ряд.insertCell(ячейка++);
номер.innerHTML = this.таблица.rows.length - 1;
номер.style.cssText = "padding: 0.5em;";
var вкл = ряд.insertCell(ячейка++);
вкл.innerHTML = `<input type="checkbox" disabled ` + статусHTML + `></input>`;
var название = ряд.insertCell(ячейка++);
название.innerHTML = имя;
название.style.cssText = "padding: 0.5em; width: 100%;";
};
СписокМодулей.prototype.отобразитьСписок = function(список)
{
this.очистить();
for (var номер in список)
{
var элемент = список[номер];
var статус = элемент[0];
var имя = элемент[1];
this.добавитьЭлемент(статус, имя);
}
};
СписокМодулей.prototype.улавливатьВыборЭлемента = function(номер)
{
var я = this;
var ряд = this.таблица.rows[номер]
ряд.onclick = function()
{
я.выборРанее = я.выбор;
я.выбор = номер;
я.выбрали.уведомить();
};
};
СписокМодулей.prototype.улавливатьВыбор = function()
{
this.выборРанее = null;
this.выбор = null;
for (var номер = 0; номер < this.таблица.rows.length; ++номер)
{
this.улавливатьВыборЭлемента(номер);
}
};
СписокМодулей.prototype.отобразитьВыбор = function()
{
if (this.выборРанее != null)
{
var ряд = this.таблица.rows[this.выборРанее];
ряд.style.backgroundColor = null;
}
var ряд = this.таблица.rows[this.выбор];
ряд.style.backgroundColor = "#eee";
};
СписокМодулей.prototype.задатьСписок = function(список)
{
this.отобразитьСписок(список);
this.улавливатьВыбор();
};
СписокМодулей.prototype.выбрать = function(номер)
{
var ряд = this.таблица.rows[номер];
ряд.scrollIntoView();
ряд.onclick();
};
СписокМодулей.prototype.обновитьЭлемент = function(номер, статус, имя)
{
var ряд = this.таблица.rows[номер];
ряд.cells[1].childNodes[0].checked = статус;
ряд.cells[2].innerHTML = имя;
};
СписокМодулей.prototype.удалитьЭлемент = function(номер)
{
var ряд = this.таблица.rows[номер];
ряд.parentNode.removeChild(ряд);
}
/*
*
* Тест списка модулей
*
*/
function ТестСпискаМодулей()
{
this.создатьИнтерфейс();
}
ТестСпискаМодулей.prototype.создатьИнтерфейс = function()
{
var я = this;
this.иф = document.createElement("div");
this.список = new СписокМодулей();
this.иф.appendChild(this.список.иф);
var модули = [
[true, "муром.загрузка_1.0.0"],
[true, "муром.uuid_1.0.0"],
[true, "Уведомитель_1.0.0"],
[false, "uikit_3.2.0.css"],
[false, "uikit_3.2.0.js"],
[false, "ПанельУправления.UIKit"],
[false, "ПанельУправления_1.0.0"],
];
this.список.задатьСписок(модули);
this.список.выбрать(0);
this.создатьКнопку("Выбрать последний", function(){
console.log("выбрать");
я.список.выбрать(модули.length - 1);
});
this.создатьКнопку("Обновить последний", function(){
я.список.обновитьЭлемент(модули.length - 1, true, "Новое имя");
});
this.создатьКнопку("Удалить последний", function(){
я.список.удалитьЭлемент(модули.length - 1);
});
this.создатьКнопку("Добавить", function(){
я.список.добавитьЭлемент(true, "Новый-599");
var номер = я.список.таблица.rows.length - 1;
я.список.улавливатьВыборЭлемента(номер);
я.список.выбрать(номер);
});
};
ТестСпискаМодулей.prototype.создатьКнопку = function(имя, реакция)
{
var кнопка = document.createElement("button");
кнопка.innerHTML = имя;
this.иф.appendChild(кнопка);
кнопка.onclick = реакция;
};
/*
*
* Свойства модуля
*
*/
function СвойстваМодуля()
{
this.создатьИнтерфейс();
this.изменилиНомер = new Уведомитель();
this.настроитьНомер();
this.изменилиИмя = new Уведомитель();
this.настроитьИмя();
this.изменилиСтатус = new Уведомитель();
this.настроитьСтатус();
this.удалить = new Уведомитель();
this.настроитьУдаление();
}
СвойстваМодуля.prototype.создатьИнтерфейс = function()
{
this.иф = document.createElement("div");
this.иф.style.cssText =
`
border: 1px solid #ddd;
/*
padding: 0.5em;
margin: 0.5em;
*/
color: #666666;
font-family: sans-serif;
`;
this.таблица = document.createElement("table");
this.иф.appendChild(this.таблица);
};
Object.defineProperty(СвойстваМодуля.prototype, "номер", {
get: function()
{
return Number(this.полеНомер.value);
},
set: function(значение)
{
this.полеНомер.value = значение;
}
});
СвойстваМодуля.prototype.настроитьНомер = function()
{
var я = this;
var ряд = this.таблица.insertRow();
var ячейка = 0;
var ключ = ряд.insertCell(ячейка++);
ключ.innerHTML = "Номер:";
ключ.style.cssText = "padding: 0.5em;";
var значение = ряд.insertCell(ячейка++);
this.полеНомер = document.createElement("input");
this.полеНомер.type = "number";
this.полеНомер.min = 0;
значение.style.cssText = "width: 100%; padding: 0.5em;";
this.полеНомер.style.cssText = "width: 100%;";
значение.appendChild(this.полеНомер);
this.полеНомер.oninput = function()
{
я.изменилиНомер.уведомить();
};
};
Object.defineProperty(СвойстваМодуля.prototype, "имя", {
get: function()
{
return this.полеИмя.value;
},
set: function(значение)
{
this.полеИмя.value = значение;
}
});
СвойстваМодуля.prototype.настроитьИмя = function()
{
var я = this;
var ряд = this.таблица.insertRow();
var ячейка = 0;
var ключ = ряд.insertCell(ячейка++);
ключ.innerHTML = "Имя:";
ключ.style.cssText = "padding: 0.5em;";
var значение = ряд.insertCell(ячейка++);
this.полеИмя = document.createElement("input");
значение.style.cssText = "width: 100%; padding: 0.5em;";
this.полеИмя.style.cssText = "width: 100%;";
значение.appendChild(this.полеИмя);
this.полеИмя.oninput = function()
{
я.изменилиИмя.уведомить();
};
};
Object.defineProperty(СвойстваМодуля.prototype, "статус", {
get: function()
{
return this.переключатель.checked;
},
set: function(значение)
{
this.переключатель.checked = значение;
}
});
СвойстваМодуля.prototype.настроитьСтатус = function()
{
var я = this;
var ряд = this.таблица.insertRow();
var ячейка = 0;
var ключ = ряд.insertCell(ячейка++);
ключ.innerHTML = "Исполнять:";
ключ.style.cssText = "padding: 0.5em;";
var значение = ряд.insertCell(ячейка++);
this.переключатель = document.createElement("input");
this.переключатель.type = "checkbox";
this.переключатель.style.cssText = "padding: 0.5em;";
значение.appendChild(this.переключатель);
this.переключатель.onchange = function()
{
я.изменилиСтатус.уведомить();
};
ключ.onclick = function()
{
я.переключатель.checked = !я.переключатель.checked;
я.изменилиСтатус.уведомить();
};
};
СвойстваМодуля.prototype.настроитьУдаление = function()
{
var я = this;
var ряд = this.таблица.insertRow();
var ячейка = 0;
ряд.insertCell(ячейка++);
var значение = ряд.insertCell(ячейка++);
this.кнопкаУдалить = document.createElement("button");
this.кнопкаУдалить.innerHTML = "Удалить";
this.кнопкаУдалить.classList.add("муром-кнопка");
значение.appendChild(this.кнопкаУдалить);
this.кнопкаУдалить.onclick = function()
{
я.удалить.уведомить();
};
};
/*
*
* Тест свойства модуля
*
*/
function ТестСвойстваМодуля()
{
this.создатьИнтерфейс();
}
ТестСвойстваМодуля.prototype.создатьИнтерфейс = function()
{
var я = this;
this.иф = document.createElement("div");
this.свойства = new СвойстваМодуля();
this.иф.appendChild(this.свойства.иф);
this.свойства.изменилиНомер.подписать(function(){
console.log("номер: '" + я.свойства.номер + "'");
});
this.свойства.изменилиИмя.подписать(function(){
console.log("имя: '" + я.свойства.имя + "'");
});
this.свойства.изменилиСтатус.подписать(function(){
console.log("статус: '" + я.свойства.статус + "'");
});
this.свойства.удалить.подписать(function(){
console.log("удалить модуль '" + я.свойства.имя + "'");
});
};
/*
*
* Модули
*
*/
function Модули()
{
}
Модули.prototype.свойства = function(номер)
{
return murom.moduleProperties(номер);
};
Модули.prototype.задатьСвойства = function(номер, свойства)
{
var м = муром.модули[номер];
м[2] = свойства;
};
Модули.prototype.статус = function(номер)
{
return murom.moduleStatus(номер);
};
Модули.prototype.задатьСтатус = function(номер, статус)
{
var св = this.свойства(номер);
св["status"] = статус;
this.задатьСвойства(номер, св);
};
Модули.prototype.задатьИмя = function(номер, имя)
{
var м = муром.модули[номер];
м[0] = имя;
};
Модули.prototype.задатьНомер = function(старый, новый)
{
//console.log("задать номер. '" + старый + "' -> '" + новый + "'");
var модуль = муром.модули[старый];
// Удаляем старую запись.
муром.модули.splice(старый, 1);
// Добавляем модуль в новую позицию.
муром.модули.splice(новый, 0, модуль);
};
/*
*
* Панель управления
*
*/
function ПанельУправления()
{
this.модули = new Модули();
this.создатьОснову();
this.создатьСохранениеСкачиваниеДобавление();
this.создатьСписокМодулей();
this.создатьСвойстваМодуля();
}
ПанельУправления.prototype.создатьОбёрткуЯчейку = function()
{
var обёртка = document.createElement("table");
обёртка.style.cssText = "width: 100%;";
var ряд = обёртка.insertRow();
var ячейка = ряд.insertCell();
return [обёртка, ячейка];
};
ПанельУправления.prototype.создатьОснову = function()
{
this.иф = document.createElement("table");
this.иф.style.cssText = "width: 100%;";
var ряд = this.иф.insertRow();
this.лево = ряд.insertCell();
this.лево.style.cssText = "width: 100%;";
var право = ряд.insertCell();
право.style.cssText = "height: 100%;";
this.кнопки = document.createElement("table");
this.кнопки.style.cssText = "height: 100%;";
право.appendChild(this.кнопки);
ряд = this.иф.insertRow();
this.низ = ряд.insertCell();
this.низ.colSpan = 2;
};
ПанельУправления.prototype.создатьСписокМодулей = function()
{
this.список = new СписокМодулей();
this.список.задатьСписок(this.списокМодулей());
var оя = this.создатьОбёрткуЯчейку();
this.лево.appendChild(оя[0]);
оя[1].appendChild(this.список.иф);
};
ПанельУправления.prototype.создатьСвойстваМодуля = function()
{
this.свойства = new СвойстваМодуля();
оя = this.создатьОбёрткуЯчейку();
this.низ.appendChild(оя[0]);
оя[1].appendChild(this.свойства.иф);
};
ПанельУправления.prototype.списокМодулей = function()
{
var список = [];
for (var номер in муром.модули)
{
var м = муром.модули[номер];
var статус = this.модули.статус(номер);
var имя = м[0];
var элемент = [статус, имя];
список.push(элемент);
}
return список;
};
ПанельУправления.prototype.создатьКнопку = function(имя, уведомитель)
{
var кнопка = document.createElement("button");
кнопка.innerHTML = имя;
кнопка.style.cssText = "width: 100%;";
кнопка.classList.add("муром-кнопка");
кнопка.onclick = function()
{
уведомитель.уведомить();
};
return кнопка;
};
ПанельУправления.prototype.создатьСохранениеСкачиваниеДобавление = function()
{
var я = this;
var ряд = this.кнопки.insertRow();
var ячейка = ряд.insertCell();
this.сохранить = new Уведомитель();
this.кнопкаСохранить = this.создатьКнопку("Сохранить", this.сохранить);
ячейка.appendChild(this.кнопкаСохранить);
ряд = this.кнопки.insertRow();
ячейка = ряд.insertCell();
this.скачать = new Уведомитель();
this.кнопкаСкачать = this.создатьКнопку("Скачать", this.скачать);
ячейка.appendChild(this.кнопкаСкачать);
// Пробел.
ряд = this.кнопки.insertRow();
ячейка = ряд.insertCell();
ячейка.style.cssText = "height: 100%;";
ряд = this.кнопки.insertRow();
ячейка = ряд.insertCell();
this.добавить = new Уведомитель();
this.кнопкаДобавить = this.создатьКнопку("Добавить", this.добавить);
ячейка.appendChild(this.кнопкаДобавить);
};
ПанельУправления.prototype.имяФайла = function()
{
var путь = window.location.pathname;
var имя = путь.split("/").pop();
return decodeURI(имя);
};
function запуститьПУ()
{
var пу = new ПанельУправления();
муром.пу = пу;
var области = муром.создатьЛевуюПравуюОбласти();
var по = области[1];
по.appendChild(пу.иф);
муром.создатьРедакторВЛевойОбласти();
var список = пу.список;
var свойства = пу.свойства;
var модули = пу.модули;
function отобразитьКодВыбранногоМодуля()
{
var модуль = муром.модули[список.выбор];
var код = муром.atob(модуль[1]);
муром.редактор.session.setValue(код);
}
function отобразитьСвойстваВыбранногоМодуля()
{
var модуль = муром.модули[список.выбор];
свойства.номер = список.выбор;
свойства.имя = модуль[0];
свойства.статус = пу.модули.статус(список.выбор);
}
список.выбрали.подписатьМного([
отобразитьКодВыбранногоМодуля,
отобразитьСвойстваВыбранногоМодуля,
]);
function обновитьСтатусМодуля()
{
var номер = список.выбор;
var имя = свойства.имя;
var статус = свойства.статус;
модули.задатьСтатус(номер, статус);
список.обновитьЭлемент(номер, статус, имя);
}
свойства.изменилиСтатус.подписать(обновитьСтатусМодуля);
function обновитьИмяМодуля()
{
var номер = список.выбор;
var имя = свойства.имя;
var статус = свойства.статус;
модули.задатьИмя(номер, имя);
список.обновитьЭлемент(номер, статус, имя);
}
свойства.изменилиИмя.подписать(обновитьИмяМодуля);
function обновитьНомерМодуля()
{
var старый = список.выбор;
var новый = свойства.номер;
if (старый == новый)
{
return;
}
if (новый > муром.модули.length - 1)
{
новый = муром.модули.length - 1;
}
модули.задатьНомер(старый, новый);
список.задатьСписок(пу.списокМодулей());
список.выбрать(новый);
}
свойства.изменилиНомер.подписать(обновитьНомерМодуля);
function добавитьМодуль()
{
var число = Math.floor(Math.random() * Math.floor(1000));
var имя = "новый-" + число;
var код = `console.log("НАДО Добавить код в модуль '` + имя + `'");`;
var модуль = [имя, муром.btoa(код)];
муром.модули.push(модуль);
var модули = пу.списокМодулей();
список.задатьСписок(модули);
список.выбрать(модули.length - 1);
}
пу.добавить.подписать(добавитьМодуль);
function удалитьМодуль()
{
var номер = список.выбор;
var статус = пу.модули.статус(номер);
if (статус)
{
alert("ОШИБКА Удалить можно лишь неисполняемый модуль");
return;
}
// Удалить выбранный модуль.
муром.модули.splice(номер, 1);
--номер;
if (номер < 0)
{
номер = 0;
}
var модули = пу.списокМодулей();
список.задатьСписок(модули);
список.выбрать(номер);
}
свойства.удалить.подписать(удалитьМодуль);
function сохранитьВыбранныйМодуль()
{
var модуль = муром.модули[список.выбор];
var код = муром.редактор.session.getValue();
модуль[1] = муром.btoa(код);
}
function сохранить()
{
пу.кнопкаСохранить.disabled = true;
localforage.setItem("modules", муром.модули, function(ошибка, значение){
пу.кнопкаСохранить.disabled = false;
if (ошибка)
{
console.error("Не удалось сохранить модули: '" + ошибка + "'");
}
});
}
пу.сохранить.подписатьМного([
сохранитьВыбранныйМодуль,
сохранить,
]);
// How to create a file in memory for user to download, but not through server?
// https://stackoverflow.com/a/18197341
function скачать()
{
var содержимое = муром.файл.начало;
for (var номер in муром.модули)
{
var модуль = муром.модули[номер];
var имя = модуль[0];
var код64 = модуль[1];
var свойства = модули.свойства(номер);
содержимое +=
`
[
"` + имя + `",
"` + код64 + `",
`
+
JSON.stringify(свойства)
+
`
],
`
;
}
содержимое += муром.файл.конец;
содержимое = муром.btoa(содержимое);
var ссыль = document.createElement("a");
ссыль.setAttribute("href", "data:text/html;charset=utf-8;base64," + содержимое);
var имя = пу.имяФайла();
ссыль.setAttribute("download", имя);
ссыль.style.display = "none";
document.body.appendChild(ссыль);
ссыль.click();
document.body.removeChild(ссыль);
}
пу.скачать.подписать(скачать);
// При запуске.
список.выбрать(0);
}
/*
*
* Пуск
*
*/
if (window.location.search == "?0")
{
console.debug("Запуск панели управления");
задатьВнешнийВид();
запуститьПУ();
console.debug("Панель управления запущена")
}
@@ -0,0 +1,48 @@
муром.загрузитьACE = function()
{
// Редактор кода ACE.
// https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/ace.js
(function(){function o(n){var i=e;n&&(e[n]||(e[n]={}),i=e[n]);if(!i.define||!i.define.packaged)t.original=i.define,i.define=t,i.define.packaged=!0;if(!i.require||!i.require.packaged)r.original=i.require,i.require=r,i.require.packaged=!0}var ACE_NAMESPACE = "ace",e=function(){return this}();!e&&typeof window!="undefined"&&(e=window);if(!ACE_NAMESPACE&&typeof requirejs!="undefined")return;var t=function(e,n,r){if(typeof e!="string"){t.original?t.original.apply(this,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(r=n),t.modules[e]||(t.payloads[e]=r,t.modules[e]=null)};t.modules={},t.payloads={};var n=function(e,t,n){if(typeof t=="string"){var i=s(e,t);if(i!=undefined)return n&&n(),i}else if(Object.prototype.toString.call(t)==="[object Array]"){var o=[];for(var u=0,a=t.length;u<a;++u){var f=s(e,t[u]);if(f==undefined&&r.original)return;o.push(f)}return n&&n.apply(null,o)||!0}},r=function(e,t){var i=n("",e,t);return i==undefined&&r.original?r.original.apply(this,arguments):i},i=function(e,t){if(t.indexOf("!")!==-1){var n=t.split("!");return i(e,n[0])+"!"+i(e,n[1])}if(t.charAt(0)=="."){var r=e.split("/").slice(0,-1).join("/");t=r+"/"+t;while(t.indexOf(".")!==-1&&s!=t){var s=t;t=t.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return t},s=function(e,r){r=i(e,r);var s=t.modules[r];if(!s){s=t.payloads[r];if(typeof s=="function"){var o={},u={id:r,uri:"",exports:o,packaged:!0},a=function(e,t){return n(r,e,t)},f=s(a,o,u);o=f||u.exports,t.modules[r]=o,delete t.payloads[r]}s=t.modules[r]=o||s}return s};o(ACE_NAMESPACE)})(),ace.define("ace/lib/regexp",["require","exports","module"],function(e,t,n){"use strict";function o(e){return(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":"")}function u(e,t,n){if(Array.prototype.indexOf)return e.indexOf(t,n);for(var r=n||0;r<e.length;r++)if(e[r]===t)return r;return-1}var r={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},i=r.exec.call(/()??/,"")[1]===undefined,s=function(){var e=/^/g;return r.test.call(e,""),!e.lastIndex}();if(s&&i)return;RegExp.prototype.exec=function(e){var t=r.exec.apply(this,arguments),n,a;if(typeof e=="string"&&t){!i&&t.length>1&&u(t,"")>-1&&(a=RegExp(this.source,r.replace.call(o(this),"g","")),r.replace.call(e.slice(t.index),a,function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===undefined&&(t[e]=undefined)}));if(this._xregexp&&this._xregexp.captureNames)for(var f=1;f<t.length;f++)n=this._xregexp.captureNames[f-1],n&&(t[n]=t[f]);!s&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--}return t},s||(RegExp.prototype.test=function(e){var t=r.exec.call(this,e);return t&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--,!!t})}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(e,t,n){function r(){}function w(e){try{return Object.defineProperty(e,"sentinel",{}),"sentinel"in e}catch(t){}}function H(e){return e=+e,e!==e?e=0:e!==0&&e!==1/0&&e!==-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e))),e}function B(e){var t=typeof e;return e===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function j(e){var t,n,r;if(B(e))return e;n=e.valueOf;if(typeof n=="function"){t=n.call(e);if(B(t))return t}r=e.toString;if(typeof r=="function"){t=r.call(e);if(B(t))return t}throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(t){var n=this;if(typeof n!="function")throw new TypeError("Function.prototype.bind called on incompatible "+n);var i=u.call(arguments,1),s=function(){if(this instanceof s){var e=n.apply(this,i.concat(u.call(arguments)));return Object(e)===e?e:this}return n.apply(t,i.concat(u.call(arguments)))};return n.prototype&&(r.prototype=n.prototype,s.prototype=new r,r.prototype=null),s});var i=Function.prototype.call,s=Array.prototype,o=Object.prototype,u=s.slice,a=i.bind(o.toString),f=i.bind(o.hasOwnProperty),l,c,h,p,d;if(d=f(o,"__defineGetter__"))l=i.bind(o.__defineGetter__),c=i.bind(o.__defineSetter__),h=i.bind(o.__lookupGetter__),p=i.bind(o.__lookupSetter__);if([1,2].splice(0).length!=2)if(!function(){function e(e){var t=new Array(e+2);return t[0]=t[1]=0,t}var t=[],n;t.splice.apply(t,e(20)),t.splice.apply(t,e(26)),n=t.length,t.splice(5,0,"XXX"),n+1==t.length;if(n+1==t.length)return!0}())Array.prototype.splice=function(e,t){var n=this.length;e>0?e>n&&(e=n):e==void 0?e=0:e<0&&(e=Math.max(n+e,0)),e+t<n||(t=n-e);var r=this.slice(e,e+t),i=u.call(arguments,2),s=i.length;if(e===n)s&&this.push.apply(this,i);else{var o=Math.min(t,n-e),a=e+o,f=a+s-o,l=n-a,c=n-o;if(f<a)for(var h=0;h<l;++h)this[f+h]=this[a+h];else if(f>a)for(h=l;h--;)this[f+h]=this[a+h];if(s&&e===c)this.length=c,this.push.apply(this,i);else{this.length=c+s;for(h=0;h<s;++h)this[e+h]=i[h]}}return r};else{var v=Array.prototype.splice;Array.prototype.splice=function(e,t){return arguments.length?v.apply(thisLine truncated
ace.require(["ace/ace"], function(a) {
if (a) {
a.config.init(true);
a.define = ace.define;
}
if (!window.ace)
window.ace = a;
for (var key in a) if (a.hasOwnProperty(key))
window.ace[key] = a[key];
window.ace["default"] = window.ace;
if (typeof module == "object" && typeof exports == "object" && module) {
module.exports = window.ace;
}
});
})();
};
муром.загрузитьРежимACEJS = function()
{
// Режим JavaScript для ACE.
// https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/mode-javascript.js
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},s.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(s,i),s.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},s.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},s.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=s}),ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";function a(){var e=o.replace("\\d","\\d\\-"),t={onMatch:function(e,t,n){var r=e.charAt(1)=="/"?2:1;if(r==1)t!=this.nextState?n.unshift(this.next,this.nextState,0):n.unshift(this.next),n[2]++;else if(r==2&&t==this.nextState){n[1]--;if(!n[1]||n[1]<0)n.shift(),n.shift()}return[{type:"meta.tag.punctuation."+(r==1?"":"end-")+"tag-open.xml",value:e.slice(0,r)},{type:"meta.tag.tag-name.xml",value:e.substr(r)}]},regex:"</?"+e+"",next:"jsxAttributes",nextState:"jsx"};this.$rules.start.unshift(t);var n={regex:"{",token:"paren.quasi.start",push:"start"};this.$rules.jsx=[n,t,{include:"reference"},{defaultToken:"string"}],this.$rules.jsxAttributes=[{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",onMatch:function(e,t,n){return t==n[0]&&n.shift(),e.length==2&&(n[0]==this.nextState&&n[1]--,(!n[1]||n[1]<0)&&n.splice(0,2)),this.next=n[0]||"start",[{type:this.token,value:e}]},nextState:"jsx"},n,f("jsxAttributes"),{token:"entity.other.attribute-name.xml",regex:e},{token:"keyword.operator.attribute-equals.xml",regex:"="},{token:"text.tag-whitespace.xml",regex:"\\s+"},{token:"string.attribute-value.xml",regex:"'",stateName:"jsx_attr_q",push:[{token:"string.attribute-value.xml",regex:"'",next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},{token:"string.attribute-value.xml",regex:'"',stateName:"jsx_attr_qq",push:[{token:"string.attribute-value.xml",regex:'"',next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},t],this.$rules.reference=[{token:"constant.language.escape.reference.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}]}function f(e){return[{token:"comment",regex:/\/\*/,next:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]},{token:"comment",regex:"\\/\\/",next:[i.getTagRule(),{token:"comment",regex:"$|^",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]}]}var r=e("../lib/oop"),i=e("./doc_comment_highlight_rules").DocCommentHighlightRules,s=e("./text_highlight_rules").TextHighlightRules,o="[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*",u=function(e){var t=this.createKeywordMapper({"variable.language":"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Namespace|QName|XML|XMLList|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|JSON|Math|this|arguments|prototype|window|document",keyword:"const|yield|import|get|set|async|await|break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|__parent__|__count__|escape|unescape|with|__proto__|class|enum|extends|super|export|implements|private|public|interface|package|protected|static","storage.type":"const|let|var|function","constant.language":"null|Infinity|NaN|undefined","support.function":"alert","constant.language.boolean":"true|false"},"identifier"),n="case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void",r="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|u{[0-9a-fA-F]{1,6}}|[0-2][0-7]{0,2}|3[0-7][0-7]?|[4-7][0-7]?|.)";this.$rules={no_regex:[i.getStartRule("doc-start"),f("no_regex"),{token:"string",regex:"'(?=.)",next:"qstring"},{token:"string",regex:'"(?=.)',next:"qqstring"},{token:"constant.numeric",regex:/0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/},{token:"constant.numeric",regex:/(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/},{token:["storage.type","punctuation.operator","support.function","punctuation.operator","entity.name.function","text","keyword.operator"],regex:"("+o+")(\\.)(prototype)(\\.)("+o+")(\\s*)(=)",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"functionLine truncated
ace.require(["ace/mode/javascript"], function(m) {
if (typeof module == "object" && typeof exports == "object" && module) {
module.exports = m;
}
});
})();
};
муром.создатьРедакторВЛевойОбласти = function()
{
муром.загрузитьACE();
муром.загрузитьРежимACEJS();
var редактор = document.createElement("div");
редактор.id = "редактор";
редактор.style.cssText = "height: 100%;";
var область = document.getElementById("левая-область");
область.appendChild(редактор);
муром.редактор = window.ace.edit("редактор");
муром.редактор.session.setMode("ace/mode/javascript");
};
+36
View File
@@ -0,0 +1,36 @@
муром.файл = {};
муром.файл.начало =
`
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<body>
<script>
var муром = {};
var murom = муром;
муром.модули = [
`;
муром.файл.конец =
`
];
Object.defineProperty(murom, "modules", {
get: function()
{
return муром.модули;
},
set: function(значения)
{
муром.модули = значения;
}
});
var загрузочныйМодуль = муром.модули[0];
var код = atob(загрузочныйМодуль[1]);
eval(код);
</script>
</body>
</html>
`;