Добавить муром.файл_1.0.0
This commit is contained in:
File diff suppressed because one or more lines are too long
54
модули/Уведомитель_1.0.0.js
Normal file
54
модули/Уведомитель_1.0.0.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// 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);
|
||||||
|
};
|
||||||
13
модули/муром.uuid_1.0.0.js
Normal file
13
модули/муром.uuid_1.0.0.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// 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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
23
модули/муром.файл_1.0.0.js
Normal file
23
модули/муром.файл_1.0.0.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
муром.файл = {};
|
||||||
|
муром.файл.начало =
|
||||||
|
`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
var муром = {};
|
||||||
|
var murom = муром;
|
||||||
|
муром.модули = [
|
||||||
|
`;
|
||||||
|
муром.файл.конец =
|
||||||
|
`
|
||||||
|
];
|
||||||
|
murom.modules = муром.модули;
|
||||||
|
var загрузочныйМодуль = муром.модули[0];
|
||||||
|
var код = atob(загрузочныйМодуль[1]);
|
||||||
|
eval(код);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
Reference in New Issue
Block a user