Skip to content

Commit

Permalink
Fixing JS interface: const -> constants, i18n -> i18n()
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jun 8, 2022
1 parent c0ba5ce commit 0082bb1
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 35 deletions.
4 changes: 2 additions & 2 deletions js/core-clipboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

Luwrain.addHook("luwrain.area.region.point.set", function(arg){
Luwrain.speak("Отметка установлена", Luwrain.const.SOUND_REGION_POINT);//FIXME:
Luwrain.speak("Отметка установлена", Luwrain.constants.SOUND_REGION_POINT);//FIXME:
return true;
});

Luwrain.addHook("luwrain.clipboard.copy.all", function(arg){
Luwrain.speak("Скопировано полное содержимое в буфер обмена", Luwrain.const.SOUND_COPIED);//FIXME:
Luwrain.speak("Скопировано полное содержимое в буфер обмена", Luwrain.constants.SOUND_COPIED);//FIXME:
return true;
});
4 changes: 2 additions & 2 deletions js/core-clock-ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Luwrain.addWorker("luwrain-clock-hourly", 5, 1, ()=>{
default:
return;
}
Luwrain.speak(text, Luwrain.const.SOUND_GENERAL_TIME);
Luwrain.speak(text, Luwrain.constants.SOUND_GENERAL_TIME);
});

Luwrain.addCommand("hot-info", ()=>{
Expand Down Expand Up @@ -152,5 +152,5 @@ Luwrain.addCommand("hot-info", ()=>{
text += 'минуты';
text += ', ' + DAY_OF_MONTH[now.dayOfMonth] + ' ' + MONTH[now.month];
text += ', ' + DAY_OF_WEEK[now.dayOfWeek];
Luwrain.speak(text, Luwrain.const.SOUND_GENERAL_TIME);
Luwrain.speak(text, Luwrain.constants.SOUND_GENERAL_TIME);
});
28 changes: 28 additions & 0 deletions js/core-commander.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2019-2022 Michael Pozhidaev <[email protected]>
This file is part of LUWRAIN.
LUWRAIN is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
LUWRAIN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/

Luwrain.addHook("luwrain.commander.panel.actions", ()=>{
return {name: "gpg-decrypt", title: "Расшифровать", action: (selected, marked)=>{
const passwd = Luwrain.popups.text("Расшифровка файла", "Введите пароль:", "");
if (!passwd)
return true;
Luwrain.newJob("sys", ["eject"], null, (ok, exitCode)=>{
Luwrain.message("privet " + exitCode);
});
return true;
}
};
});
14 changes: 7 additions & 7 deletions js/core-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Luwrain.addHook("luwrain.edit.input", (area, event)=>{
return false;
const deleted = line.substring(area.hotPoint.x);
area.lines[area.hotPoint.y] = line.substring(0, area.hotPoint.x);
Luwrain.speak(deleted, Luwrain.const.SOUND_DELETED);
Luwrain.speak(deleted, Luwrain.constants.SOUND_DELETED);
return true;
});

Expand All @@ -55,15 +55,15 @@ Luwrain.addHook("luwrain.edit.multiline.input", function(event, args){
if (lines.length == 0)
{
Luwrain.sounds.emptyLine();
Luwrain.speak(Luwrain.i18n.static.EmptyLine);
Luwrain.speak(Luwrain.i18n().static.EmptyLine);
return true;
}
var hotPoint = args.hotPoint;
var line = lines[hotPoint.y];
if (line.length == 0)
{
Luwrain.sounds.emptyLine();
Luwrain.speak(Luwrain.i18n.static.EmptyLine);
Luwrain.speak(Luwrain.i18n().static.EmptyLine);
return true;
}
for(var i = 0;i < line.length;i++)
Expand All @@ -72,7 +72,7 @@ Luwrain.addHook("luwrain.edit.multiline.input", function(event, args){
hotPoint.x = i;
if (i > 0)
Luwrain.message('' + i + " пробелов от начала строки"); else //FIXME:
Luwrain.message(Luwrain.i18n.static.BeginOfLine);
Luwrain.message(Luwrain.i18n().static.BeginOfLine);
return true;
}
hotPoint.x = line.length();
Expand All @@ -90,15 +90,15 @@ Luwrain.addHook("luwrain.edit.multiline.input", function(event, args){
if (lines.length == 0)
{
Luwrain.sounds.emptyLine();
Luwrain.speak(Luwrain.i18n.static.EmptyLine);
Luwrain.speak(Luwrain.i18n().static.EmptyLine);
return true;
}
var hotPoint = args.hotPoint;
var line = lines[hotPoint.y];
if (line.length == 0)
{
Luwrain.sounds.emptyLine();
Luwrain.speak(Luwrain.i18n.static.EmptyLine);
Luwrain.speak(Luwrain.i18n().static.EmptyLine);
return true;
}
for(var i = line.length - 1;i >= 0;i--)
Expand All @@ -107,7 +107,7 @@ Luwrain.addHook("luwrain.edit.multiline.input", function(event, args){
hotPoint.x = i + 1;
if (i + 1 < line.length)
Luwrain.message('' + line.length - i - 1 + " пробелов до конца строки"); else //FIXME:
Luwrain.message(Luwrain.i18n.static.EndOfLine);
Luwrain.message(Luwrain.i18n().static.EndOfLine);
return true;
}
hotPoint.x = 0;
Expand Down
18 changes: 9 additions & 9 deletions js/core-edu-chemistry-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ function MendeleevApp(args) {
this.x = j;
this.y = i;
this.updateHotPoint();
Luwrain.speak(item.id + ' ' + item.name, Luwrain.const.SOUND_REGION_POINT);
Luwrain.speak(item.id + ' ' + item.name, Luwrain.constants.SOUND_REGION_POINT);
return true;
}
return false;
Expand All @@ -461,7 +461,7 @@ function MendeleevApp(args) {
this.x = j;
this.y = i;
this.updateHotPoint();
Luwrain.speak(item.id + ' ' + item.name, Luwrain.const.SOUND_REGION_POINT);
Luwrain.speak(item.id + ' ' + item.name, Luwrain.constants.SOUND_REGION_POINT);
return true;
}
return false;
Expand All @@ -471,7 +471,7 @@ function MendeleevApp(args) {
}
switch(event.special)
{
case Luwrain.const.KEY_ENTER:
case Luwrain.constants.KEY_ENTER:
if (TABLE[this.y][this.x] == null)
return false;
{
Expand All @@ -481,22 +481,22 @@ function MendeleevApp(args) {
Luwrain.launchApp("reader", [WIKIPEDIA[id]]);
}
return true;
case Luwrain.const.KEY_MOVE_LEFT:
case Luwrain.constants.KEY_MOVE_LEFT:
if (this.x == 0)
return false;
this.x--;
break;
case Luwrain.const.KEY_MOVE_RIGHT:
case Luwrain.constants.KEY_MOVE_RIGHT:
if (this.x + 1 >= TABLE[this.y].length)
return false;
this.x++;
break;
case Luwrain.const.KEY_MOVE_UP:
case Luwrain.constants.KEY_MOVE_UP:
if (this.y == 0)
return false;
this.y--;
break;
case Luwrain.const.KEY_MOVE_DOWN:
case Luwrain.constants.KEY_MOVE_DOWN:
if (this.y + 1 >= TABLE.length)
return false;
this.y++;
Expand All @@ -510,8 +510,8 @@ function MendeleevApp(args) {
this.searchOffset = 0;
this.updateHotPoint();
if (TABLE[this.y][this.x] != null)
Luwrain.speak(TABLE[this.y][this.x].name, Luwrain.const.SOUND_REGION_POINT); else
Luwrain.speak(MSG_EMPTY_CELL, Luwrain.const.SOUND_REGION_POINT);
Luwrain.speak(TABLE[this.y][this.x].name, Luwrain.constants.SOUND_REGION_POINT); else
Luwrain.speak(MSG_EMPTY_CELL, Luwrain.constants.SOUND_REGION_POINT);
return true;
};

Expand Down
30 changes: 15 additions & 15 deletions js/core-edu-chemistry-solubility.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,26 +229,26 @@ function SolubilityApp(args)
if (!event.special)
return false;
switch(event.special) {
case Luwrain.const.KEY_MOVE_LEFT:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_left:
case Luwrain.constants.KEY_MOVE_LEFT:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_left:
if (this.x == 0)
return false;
this.x--;
break;
case Luwrain.const.KEY_MOVE_RIGHT:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_RIGHT:
case Luwrain.constants.KEY_MOVE_RIGHT:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_RIGHT:
if (this.x + 1 >= TABLE[this.y].length)
return false;
this.x++;
break;
case Luwrain.const.KEY_MOVE_UP:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_UP:
case Luwrain.constants.KEY_MOVE_UP:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_UP:
if (this.y == 0)
return false;
this.y--;
break;
case Luwrain.const.KEY_MOVE_DOWN:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_DOWN:
case Luwrain.constants.KEY_MOVE_DOWN:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_DOWN:
if (this.y + 1 >= TABLE.length)
return false;
this.y++;
Expand All @@ -259,18 +259,18 @@ function SolubilityApp(args)
this.updateHotPoint();
if (!!event.special.match("_alternative_"))
switch(event.special) {
case Luwrain.const.KEY_ALTERNATIVE_MOVE_left:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_right:
Luwrain.speak('анион ' + TOP_NAMES[this.x], Luwrain.const.SOUND_REGION_POINT);
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_left:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_right:
Luwrain.speak('анион ' + TOP_NAMES[this.x], Luwrain.constants.SOUND_REGION_POINT);
return true;
case Luwrain.const.KEY_ALTERNATIVE_MOVE_up:
case Luwrain.const.KEY_ALTERNATIVE_MOVE_down:
Luwrain.speak('катион ' + LEFT_NAMES[this.y], Luwrain.const.SOUND_REGION_POINT);
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_up:
case Luwrain.constants.KEY_ALTERNATIVE_MOVE_down:
Luwrain.speak('катион ' + LEFT_NAMES[this.y], Luwrain.constants.SOUND_REGION_POINT);
return true;
default:
return false;
}
Luwrain.speak(constructMessage(this.x, this.y), Luwrain.const.SOUND_REGION_POINT);
Luwrain.speak(constructMessage(this.x, this.y), Luwrain.constants.SOUND_REGION_POINT);
return true;
};

Expand Down

0 comments on commit 0082bb1

Please sign in to comment.