This commit is contained in:
2021-08-31 15:30:03 +03:00
parent 9b29d56786
commit dc85b0571f
10 changed files with 86 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ function Редактор(имяОбласти)
this.создать = function()
{
this.установитьAce();
this.улавливатьРедактирование();
};
this.установитьAce = function()
@@ -12,6 +13,63 @@ function Редактор(имяОбласти)
this.ace.session.setMode("ace/mode/javascript");
}
this.улавливатьРедактирование = function()
{
var тут = this;
this.ace.session.on("change", function(дельта) {
const билет = тут.uuid();
тут.билет = билет;
setTimeout(
function()
{
if (билет == тут.билет)
{
тут.проверитьКорректностьКода();
}
},
1000
);
});
};
this.проверитьКорректностьКода = function()
{
try
{
eval(this.ace.session.getValue());
/**/console.debug("ИГР Редактор.проверитьКК OK");
}
catch (ошибка)
{
/**/console.debug("ИГР Редактор.проверитьКК ОШИБКА: ", ошибка);
}
};
this.в64 = function(строка)
{
var байты = new TextEncoder("utf-8").encode(строка);
return base64js.fromByteArray(байты);
};
this.из64 = function(строка)
{
var байты = base64js.toByteArray(строка);
return new TextDecoder("utf-8").decode(байты);
};
this.uuid = function()
{
// https://stackoverflow.com/a/2117523
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);
}
);
};
// Конструктор.
this.создать();
}

View File

@@ -0,0 +1 @@
https://github.com/ajaxorg/ace-builds/tree/master/src-min-noconflict

View File

@@ -14,4 +14,4 @@
}
});
})();

View File

@@ -0,0 +1 @@
https://github.com/beatgammit/base64-js/blob/master/base64js.min.js

View File

@@ -0,0 +1 @@
(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?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.base64js=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({"/":[function(a,b,c){'use strict';function d(a){var b=a.length;if(0<b%4)throw new Error("Invalid string. Length must be a multiple of 4");var c=a.indexOf("=");-1===c&&(c=b);var d=c===b?0:4-c%4;return[c,d]}function e(a,b,c){return 3*(b+c)/4-c}function f(a){var b,c,f=d(a),g=f[0],h=f[1],j=new m(e(a,g,h)),k=0,n=0<h?g-4:g;for(c=0;c<n;c+=4)b=l[a.charCodeAt(c)]<<18|l[a.charCodeAt(c+1)]<<12|l[a.charCodeAt(c+2)]<<6|l[a.charCodeAt(c+3)],j[k++]=255&b>>16,j[k++]=255&b>>8,j[k++]=255&b;return 2===h&&(b=l[a.charCodeAt(c)]<<2|l[a.charCodeAt(c+1)]>>4,j[k++]=255&b),1===h&&(b=l[a.charCodeAt(c)]<<10|l[a.charCodeAt(c+1)]<<4|l[a.charCodeAt(c+2)]>>2,j[k++]=255&b>>8,j[k++]=255&b),j}function g(a){return k[63&a>>18]+k[63&a>>12]+k[63&a>>6]+k[63&a]}function h(a,b,c){for(var d,e=[],f=b;f<c;f+=3)d=(16711680&a[f]<<16)+(65280&a[f+1]<<8)+(255&a[f+2]),e.push(g(d));return e.join("")}function j(a){for(var b,c=a.length,d=c%3,e=[],f=16383,g=0,j=c-d;g<j;g+=f)e.push(h(a,g,g+f>j?j:g+f));return 1===d?(b=a[c-1],e.push(k[b>>2]+k[63&b<<4]+"==")):2===d&&(b=(a[c-2]<<8)+a[c-1],e.push(k[b>>10]+k[63&b>>4]+k[63&b<<2]+"=")),e.join("")}c.byteLength=function(a){var b=d(a),c=b[0],e=b[1];return 3*(c+e)/4-e},c.toByteArray=f,c.fromByteArray=j;for(var k=[],l=[],m="undefined"==typeof Uint8Array?Array:Uint8Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,p=n.length;o<p;++o)k[o]=n[o],l[n.charCodeAt(o)]=o;l[45]=62,l[95]=63},{}]},{},[])("/")});

View File

@@ -3,6 +3,17 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>M-3.0</title>
<script src="ace/ace.js"></script>
<script src="ace/mode-javascript.js"></script>
<script src="ace/worker-javascript.js"></script>
<script src="base64-js/base64js.min.js"></script>
<link rel="stylesheet" type="text/css" href="uikit/uikit.min.css" />
<script src="uikit/uikit.min.js"></script>
<script src="uikit/uikit-icons.min.js"></script>
<style>
#редактор
{
@@ -21,8 +32,7 @@
width: 4em;
display: flex;
justify-content: center;
padding-top: 1em;
background: snow;
border: 1px dashed gainsboro;
}
#воспроизведение
{
@@ -34,6 +44,7 @@
}
</style>
<style>
/*
.кнопка {
border-radius: 50%;
width: 3em;
@@ -44,17 +55,16 @@
justify-content: center;
background: white;
}
*/
</style>
</head>
<body>
<div id="редактор"></div>
<div id="пульт">
<a class="кнопка" id="пуск">&#9658;</a>
<a id="пуск" class="uk-icon-button uk-margin-top uk-margin-bottom" uk-icon="play" uk-tooltip="Пуск"></a>
</div>
<div id="воспроизведение"></div>
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/worker-javascript.js" type="text/javascript" charset="utf-8"></script>
<script src="100.редактор.js"></script>
<script src="200.пульт.js"></script>
<script src="700.муром.js"></script>

View File

@@ -0,0 +1 @@
https://getuikit.com/download

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long