This commit is contained in:
Dmitry Borisenko
2021-10-18 21:12:42 +08:00
parent 810f7a436d
commit ba41171df1
2 changed files with 14 additions and 46 deletions

View File

@@ -4,6 +4,6 @@
"svelteBracketNewLine": false, "svelteBracketNewLine": false,
"svelteAllowShorthand": false, "svelteAllowShorthand": false,
"svelteIndentScriptAndStyle": true, "svelteIndentScriptAndStyle": true,
"printWidth": 60, "printWidth": 600,
"sxBracketSameLine": true "sxBracketSameLine": true
} }

View File

@@ -24,23 +24,15 @@
} catch (e) { } catch (e) {
return json; return json;
} }
json = json json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
.replace(/&/g, "&amp;") json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
.replace(/</g, "&lt;") return match;
.replace(/>/g, "&gt;"); });
json = json.replace(
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
function (match) {
return match;
}
);
return json; return json;
}; };
function wigetsUpdate() { function wigetsUpdate() {
wigets = JSON.parse( wigets = JSON.parse(document.getElementById("text1").value);
document.getElementById("text1").value
);
findNewPage(); findNewPage();
} }
@@ -97,14 +89,9 @@
let pages = []; let pages = [];
function findNewPage() { function findNewPage() {
pages = []; pages = [];
const newPage = Array.from( const newPage = Array.from(new Set(Array.from(wigets, ({ page }) => page)));
new Set(Array.from(wigets, ({ page }) => page))
);
newPage.forEach(function (item, i, arr) { newPage.forEach(function (item, i, arr) {
pages = [ pages = [...pages, JSON.parse(JSON.stringify({ page: item }))];
...pages,
JSON.parse(JSON.stringify({ page: item })),
];
}); });
pages.sort(function (a, b) { pages.sort(function (a, b) {
if (a.page < b.page) { if (a.page < b.page) {
@@ -133,16 +120,13 @@
<a class="menu__item" href="/">{"Управление"}</a> <a class="menu__item" href="/">{"Управление"}</a>
</li> </li>
<li> <li>
<a class="menu__item" href="/config" <a class="menu__item" href="/config">{"Конфигуратор"}</a>
>{"Конфигуратор"}</a>
</li> </li>
<li> <li>
<a class="menu__item" href="/connection" <a class="menu__item" href="/connection">{"Подключение"}</a>
>{"Подключение"}</a>
</li> </li>
<li> <li>
<a class="menu__item" href="/utilities" <a class="menu__item" href="/utilities">{"Утилиты"}</a>
>{"Утилиты"}</a>
</li> </li>
<li> <li>
<a class="menu__item" href="/log">{"Лог"}</a> <a class="menu__item" href="/log">{"Лог"}</a>
@@ -161,9 +145,7 @@
{#each wigets as widget, i} {#each wigets as widget, i}
{#if widget.page === pagesName.page} {#if widget.page === pagesName.page}
{#if widget.widget === "input"} {#if widget.widget === "input"}
<Input <Input bind:value={widget.status} widget={widget} />
bind:value={widget.status}
widget={widget} />
{/if} {/if}
{/if} {/if}
{/each} {/each}
@@ -171,14 +153,7 @@
{/each} {/each}
<Card title="Редактор JSON"> <Card title="Редактор JSON">
<textarea <textarea on:input={wigetsUpdate} rows="10" class="json-input w-full" id="text1">{syntaxHighlight(JSON.stringify(wigets))}</textarea>
on:input={wigetsUpdate}
rows="10"
class="json-input w-full"
id="text1"
>{syntaxHighlight(
JSON.stringify(wigets)
)}</textarea>
</Card> </Card>
</div> </div>
</Route> </Route>
@@ -198,14 +173,7 @@
<Route path="/utilities"> <Route path="/utilities">
<div class="cards-grid"> <div class="cards-grid">
<Card title="Редактор JSON"> <Card title="Редактор JSON">
<textarea <textarea on:input={wigetsUpdate} rows="10" class="json-input w-full" id="text1">{syntaxHighlight(JSON.stringify(wigets))}</textarea>
on:input={wigetsUpdate}
rows="10"
class="json-input w-full"
id="text1"
>{syntaxHighlight(
JSON.stringify(wigets)
)}</textarea>
</Card> </Card>
</div> </div>
</Route> </Route>