Skip to content

Commit

Permalink
Hledani v prekladech
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Kocourek committed Jun 6, 2019
1 parent 0eba771 commit 9aaec01
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/l10nNetteTranslator/Templates/panel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
#l10nNTP-remove:hover {
background-color: #e77676 !important;
}

#l10nNTP-filter {
border: 1px solid gray;
background: white;
}

</style>
<script>
var l10nNTP = {
Expand Down Expand Up @@ -283,6 +289,11 @@
language: language,
namespace: namespace
});

var self = this;
this.getById('l10nNTP-filter').addEventListener("keyup", function() {
self.filterList(this.value);
});
},
showMsg: function (msg) {
this.getById('l10nNTP-right_panel-msg').innerHTML = msg;
Expand Down Expand Up @@ -358,7 +369,29 @@
var obj = this.getById(response.select);
obj && this.click(obj);
obj && obj.scrollIntoView();
}
},
filterList: function(key) {
var list = this.getById('l10nNTP-list').getElementsByTagName('li');

if(key.length == 0) {
for(let item of list) {
item.style.display = "block";
}
} else {
for(let item of list) {
key = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
var keyReg = new RegExp('"key":"[^"]*'+key+'[^"]*"','i');
var textsReg = new RegExp('"texts":\\[[^\\]]*'+key+'[^\\]]*\\]*"','i')
if(item.dataset.json.match(keyReg) || item.dataset.json.match(textsReg)) {
item.style.display = "block";
} else {
item.style.display = "none";
}
}
}
}


};
</script>
<div id="l10nNTP">
Expand All @@ -372,6 +405,7 @@
<td id="l10nNTP-left_panel">
<div id="l10nNTP-langs_wrapper">
<select id="l10nNTP-langs" onchange="l10nNTP.changeLanguage(this)"></select>
<input type="text" id="l10nNTP-filter" placeholder="Search" size="10">
</div>
<div id="l10nNTP-list_wrapper">
<ul id="l10nNTP-list"></ul>
Expand Down

0 comments on commit 9aaec01

Please sign in to comment.