Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): Конвертация в зависимости от выбранного флага #151

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@
Возврат Токен;
КонецЕсли;

ДополнитьНакопительнуюСтроку(Токен.Значение());
Если Не Токен = Неопределено Тогда
ДополнитьНакопительнуюСтроку(Токен.Значение());
КонецЕсли;

КонецЦикла;

Expand Down
28 changes: 23 additions & 5 deletions src/interface/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
let convertButton = document.getElementById("convert");
let convertInput = document.getElementById("command");

function convert(command) {
function convert(command, lang) {
if (!isAllowedRequests()) return;
hideErrors();

Expand Down Expand Up @@ -354,7 +354,7 @@
enableRequests();
};
req.responseType = "json";
req.open("GET", "/convert?cmd=" + encodeURIComponent(command));
req.open("GET", "/convert?lang=" + lang + "&cmd=" + encodeURIComponent(command));
req.send();

disableRequests();
Expand Down Expand Up @@ -414,10 +414,28 @@
return !convertButton.disable;
}

convertButton.addEventListener("click", function (e) {
function getCommand() {
let formData = new FormData(document.forms.curl);
let command = formData.get("command");
convert(command);
return command;
}

function getLang() {
let radios = document.getElementsByName('syntax');

for (let i = 0; i < radios.length; i++) {
if (radios[i].checked) {
return radios[i].value;
}
}

return '1c';
}

convertButton.addEventListener("click", function (e) {
let command = getCommand();
let lang = getLang();
convert(command, lang);
});

document.getElementById("copy").addEventListener("click", function (e) {
Expand Down Expand Up @@ -461,7 +479,7 @@
ontouchend="this.classList.remove('hoveredbutton')">
<div class="checkboxgroup" style="">
<div class="singlecheckbox">
<input type="radio" id="onec" name="syntax" value="onec"
<input type="radio" id="onec" name="syntax" value="1c"
checked="checked" />
<label for="onec">1С</label>
</div>
Expand Down
21 changes: 21 additions & 0 deletions tests/ПарсерКонсольнойКоманды_test.os
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,25 @@
Ожидаем.Что(Результат[0][Инд]).Равно(Эталон[Инд]);
КонецЦикла;

КонецПроцедуры

&Тест
Процедура ТестДолжен_РаспарситьКомандуСОткрытойКавычкойВКонце() Экспорт

КоманднаяСтрока = "myapp -a """;

Эталон = Новый Массив;
Эталон.Добавить("myapp");
Эталон.Добавить("-a");

Парсер = Новый ПарсерКонсольнойКоманды();
Результат = Парсер.Распарсить(КоманднаяСтрока);

Ожидаем.Что(Результат).ИмеетДлину(1);
Ожидаем.Что(Результат[0]).ИмеетДлину(Эталон.Количество());

Для Инд = 0 По Результат[0].ВГраница() Цикл
Ожидаем.Что(Результат[0][Инд]).Равно(Эталон[Инд]);
КонецЦикла;

КонецПроцедуры
Loading