This commit is contained in:
2021-11-22 19:06:53 +03:00
parent cafa01c3a5
commit 5bd7b5ffb7
3 changed files with 58 additions and 49 deletions
+3 -3
View File
@@ -5,9 +5,9 @@ __PluginManager__.register('loggerService', function(module, exports, require, g
var Logger = require('Logger'); var Logger = require('Logger');
var lightMap = [ var lightMap = [
{class: '', keys: []}, {class: 'kit-logger-row--success', keys: ['pass', 'success']},
{class: 'text-danger', keys: []}, {class: 'kit-logger-row--warning', keys: ['warn', 'warning']},
{class: 'text-secondary', keys: []}, {class: 'kit-logger-row--error', keys: ['fail', 'error', 'errors']},
]; ];
var getLightClass = function(key) { var getLightClass = function(key) {
key = ''+key; key = ''+key;
+48 -29
View File
@@ -4,7 +4,7 @@
<div style="display: flex; flex-direction: column; align-items: center;"> <div style="display: flex; flex-direction: column; align-items: center;">
<script> <script>
var iframeList = [], iframe, i; var iframeList = [], iframe;
</script> </script>
<?php <?php
$arFilesItems = glob(__DIR__ . '/*Test.php'); $arFilesItems = glob(__DIR__ . '/*Test.php');
@@ -14,32 +14,21 @@
//echo "<a href=\"$file\"><b>$clName</b></a>"; //echo "<a href=\"$file\"><b>$clName</b></a>";
?> ?>
<script> <script>
iframe = document.createElement("frame"); iframe = document.createElement("frame");
iframe.src = '<?=$file?>'; iframe.src = '<?=$file?>';
i = iframeList.push({ iframeList.push({
fileName: '<?=$file?>', fileName: '<?=$file?>',
clName: '<?=$clName?>', clName: '<?=$clName?>',
iframe: iframe, iframe: iframe,
// contentWindow: iframe.contentWindow,
//document: iframe.contentWindow.document
}); });
// if (iframeDoc.readyState == 'complete') {
// iframeDoc.body.style.backgroundColor = 'green';
// }
// iframe.onload = function() {
// var iframeDoc2 = iframe.contentWindow.document;
// iframeDoc2.body.style.backgroundColor = 'orange';
// }
</script> </script>
<? <?
} }
?> ?>
</div> </div>
<div class="kit-wrapper">
<div class="kit-logger"></div>
</div>
<script> <script>
kit.ready(['Collection', 'flexKit', 'loggerService'], function () { kit.ready(['Collection', 'flexKit', 'loggerService'], function () {
@@ -56,29 +45,59 @@
console.log(frameList); console.log(frameList);
frameList.map(function (data) { frameList.map(function (data) {
data.iframe.onload = function() { data.iframe.onload = function() {
data.kit = data.iframe.contentWindow.kit; data.window = data.iframe.contentWindow;
//console.log('kit',kit); data.document = data.iframe.contentWindow.document;
data.kit = data.window.kit;
if(!data.kit) {
return;
}
data.kit.ready([], function () { data.kit.ready([], function () {
setTimeout(function () { setTimeout(function () {
var log = []; var log = [], result = {};
if(!data.kit.service.logger){
return;
}
function pr(key, log){
if(!result[key]) {
result[key] = new kit.Collection();
}
if(log.message[key]){
result[key].push(log);
}
}
data.kit.service.logger.collection.map(function (log) {
pr('pass', log);
pr('warn', log);
pr('fail', log);
});
kit.service.logger.info(data.clName); kit.service.logger.info(data.clName);
if(data.kit.service.logger){ if(result.pass.count()){
log = data.kit.service.logger.collection.map(function (log) { kit.service.logger.log(1, {
pass: result.pass.count(),
});
}
if(result.warn.count()) {
kit.service.logger.log(1, {
warn: result.warn.count(),
});
result.warn.map(function (log) {
log.lvl++;
kit.service.logger.log(log);
});
}
if(result.fail.count()) {
kit.service.logger.log(1, {
fail: result.fail.count(),
});
result.fail.map(function (log) {
log.lvl++; log.lvl++;
kit.service.logger.__log(log); kit.service.logger.__log(log);
}); });
} }
}, 1000); }, 1000);
}); });
}; };
document.body.appendChild(data.iframe); document.body.appendChild(data.iframe);
data.window = data.iframe.contentWindow;
data.document = data.iframe.contentWindow.document;
data.kit = data.window.kit;
}) })
}); });
</script> </script>
<div class="kit-wrapper">
<div class="kit-logger"></div>
</div>
+7 -17
View File
@@ -26,29 +26,21 @@ kit.ready(['collection', 'testing', 'flexKit'], function () {
var unit = new kit.testing.Unit(); var unit = new kit.testing.Unit();
unit.logger.info('Коллекции by php collection: Array ( [10] => 10 [1] => 1 )'); unit.logger.info('Коллекции by php collection: Array ( [10] => 10 [1] => 1 )');
unit.logger.notice(' ');
unit.logger.info('ARRAY');
unit.logger.notice(' ');
var assertSame = unit.assertSame.bind(unit); var assertSame = unit.assertSame.bind(unit);
var arr = []; var arr = [];
arr[10] = 100; arr[10] = 100;
var collection = new kit.Collection(arr); var collection = new kit.Collection(arr);
assertSame(1, collection.count(), 'Количество'); assertSame(1, collection.count(), 'type array: Количество');
assertSame(true, collection.has(10), 'has (int) 10'); assertSame(true, collection.has(10), 'type array: has (int) 10');
assertSame(true, collection.has('10'), 'has 10'); assertSame(true, collection.has('10'), 'type array: has 10');
assertSame(false, collection.has('5'), 'has 5'); assertSame(false, collection.has('5'), 'type array: has 5');
assertSame(2, collection.get(3, 2), 'get'); assertSame(2, collection.get(3, 2), 'type array: get');
assertSame(100, collection.get(10, 2), 'get'); assertSame(100, collection.get(10, 2), 'type array: get');
assertSame(undefined, collection.get(11), 'get'); assertSame(undefined, collection.get(11), 'type array: get');
unit.logger.info(' ');
unit.logger.info('Object');
unit.logger.info(' ');
var ob = { var ob = {
a: 1, a: 1,
b: 2, b: 2,
@@ -232,8 +224,6 @@ kit.ready(['collection', 'testing', 'flexKit'], function () {
y = x.pluck('age'); y = x.pluck('age');
assertSame('20-19-18', y.toArray().join('-'), 'pluck с проверкой сохранения порядка'); assertSame('20-19-18', y.toArray().join('-'), 'pluck с проверкой сохранения порядка');
assertSame('10', 20, 'Спец ошибка');
}); });
</script> </script>