mirror of
https://github.com/alei1180/curlone.git
synced 2026-06-21 01:30:38 +02:00
Merge pull request #152 from Stivo182/feature/connector-http
Конвертация при изменении селектора, восстановление дефолтного результата
This commit is contained in:
@@ -316,13 +316,23 @@ input[type='radio']:checked {
|
|||||||
import { createHighlighterCore } from '/static/shiki/core.js';
|
import { createHighlighterCore } from '/static/shiki/core.js';
|
||||||
import { createOnigurumaEngine } from '/static/shiki/engine/oniguruma.js';
|
import { createOnigurumaEngine } from '/static/shiki/engine/oniguruma.js';
|
||||||
|
|
||||||
let outputText = 'Соединение = Новый HTTPСоединение("example.com", 80);\n'
|
let defaultOutputs = {
|
||||||
+ 'HTTPЗапрос = Новый HTTPЗапрос("/");\n\n'
|
'1c':
|
||||||
+ 'HTTPОтвет = Соединение.ВызватьHTTPМетод("GET", HTTPЗапрос);';
|
'Соединение = Новый HTTPСоединение("example.com", 80);\n'
|
||||||
|
+ 'HTTPЗапрос = Новый HTTPЗапрос("/");\n\n'
|
||||||
|
+ 'HTTPОтвет = Соединение.ВызватьHTTPМетод("GET", HTTPЗапрос);',
|
||||||
|
'connector':
|
||||||
|
'Результат = КоннекторHTTP.Get("http://example.com")'
|
||||||
|
};
|
||||||
|
|
||||||
|
let outputText = "";
|
||||||
let convertButton = document.getElementById("convert");
|
let convertButton = document.getElementById("convert");
|
||||||
let convertInput = document.getElementById("command");
|
let convertInput = document.getElementById("command");
|
||||||
|
|
||||||
function convert(command, lang) {
|
function convert() {
|
||||||
|
let command = getCommand();
|
||||||
|
let lang = getLang();
|
||||||
|
|
||||||
if (!isAllowedRequests()) return;
|
if (!isAllowedRequests()) return;
|
||||||
hideErrors();
|
hideErrors();
|
||||||
|
|
||||||
@@ -421,7 +431,7 @@ input[type='radio']:checked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLang() {
|
function getLang() {
|
||||||
let radios = document.getElementsByName('syntax');
|
let radios = document.getElementsByName('lang');
|
||||||
|
|
||||||
for (let i = 0; i < radios.length; i++) {
|
for (let i = 0; i < radios.length; i++) {
|
||||||
if (radios[i].checked) {
|
if (radios[i].checked) {
|
||||||
@@ -433,28 +443,42 @@ input[type='radio']:checked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
convertButton.addEventListener("click", function (e) {
|
convertButton.addEventListener("click", function (e) {
|
||||||
let command = getCommand();
|
convert();
|
||||||
let lang = getLang();
|
|
||||||
convert(command, lang);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("copy").addEventListener("click", function (e) {
|
document.getElementById("copy").addEventListener("click", function (e) {
|
||||||
copyToClipboard(outputText);
|
copyToClipboard(outputText);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
convertInput.addEventListener("input", function (e) {
|
||||||
|
if(!getCommand()) {
|
||||||
|
setOutput(defaultOutputs[getLang()]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
document.addEventListener("keyup", function (e) {
|
document.addEventListener("keyup", function (e) {
|
||||||
if (e.keyCode == 13 && e.ctrlKey) {
|
if (e.keyCode == 13 && e.ctrlKey) {
|
||||||
convertButton.click();
|
convertButton.click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementsByName("lang").forEach(function(e) {
|
||||||
|
e.addEventListener("change", function(e) {
|
||||||
|
if(getCommand()) {
|
||||||
|
convert();
|
||||||
|
} else {
|
||||||
|
setOutput(defaultOutputs[getLang()]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const highlighter = await createHighlighterCore({
|
const highlighter = await createHighlighterCore({
|
||||||
themes: [theme],
|
themes: [theme],
|
||||||
langs: [lang],
|
langs: [lang],
|
||||||
engine: createOnigurumaEngine(import('/static/shiki/wasm.js'))
|
engine: createOnigurumaEngine(import('/static/shiki/wasm.js'))
|
||||||
});
|
});
|
||||||
|
|
||||||
setOutput(outputText);
|
setOutput(defaultOutputs[getLang()]);
|
||||||
enableRequests();
|
enableRequests();
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@@ -479,12 +503,12 @@ input[type='radio']:checked {
|
|||||||
ontouchend="this.classList.remove('hoveredbutton')">
|
ontouchend="this.classList.remove('hoveredbutton')">
|
||||||
<div class="checkboxgroup" style="">
|
<div class="checkboxgroup" style="">
|
||||||
<div class="singlecheckbox">
|
<div class="singlecheckbox">
|
||||||
<input type="radio" id="onec" name="syntax" value="1c"
|
<input type="radio" id="onec" name="lang" value="1c"
|
||||||
checked="checked" />
|
checked="checked" />
|
||||||
<label for="onec">1С</label>
|
<label for="onec">1С</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="singlecheckbox last">
|
<div class="singlecheckbox last">
|
||||||
<input type="radio" id="connector" name="syntax" value="connector" />
|
<input type="radio" id="connector" name="lang" value="connector" />
|
||||||
<label for="connector">Connector</label>
|
<label for="connector">Connector</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user