
Oprava JS kódu
Ahoj,
snažím se rozchodit tento kód v JS. Kód funguje správně, pokud již není spuštěn PSPad, po kliknutí otevře požadovaný název souboru i nastaví kurzor na potřebný řadek v editoru PSPad.
Pokud je již PSPad spuštěný, otevře krom požadovaného souboru taky samotný soubor PSPad.exe.
Nepomůže někdo? Předem moc děkuji.
ZDROJ:https://pla.nette.org/cs/jak-otevrit-soubor-z-debu ggeru-v-editoru
var editor = '"C:\\Program Files (x86)\\PSPad editor\\PSPad.exe" -%line% "%file%"';
var mappings = {
//
};
if (typeof editor === 'undefined') {
WScript.Echo('Create variable "editor" in ' + WScript.ScriptFullName);
WScript.Quit();
}
var url = WScript.Arguments(0);
var match = /^editor:\/\/open\/\?file=(.+)&line=(\d+)/.exec(url);
if (match) {
var file = decodeURIComponent(match[1]).replace(/\+/g, ' ');
for (var id in mappings) {
if (file.indexOf(id) === 0) {
file = mappings[id] + file.substr(id.length);
break;
}
}
var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file);
var shell = new ActiveXObject("WScript.Shell");
shell.Exec(command.replace(/\\/g, '\\\\'));
}