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

[Bugfix] "<" interpreted as html tag #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 9 additions & 11 deletions keyzen.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ layouts={};
layouts["qwerty"] = " jfkdlsahgyturieowpqbnvmcxz6758493021`-=[]\\;',./ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:\"<>?";
layouts["azerty"] = " jfkdlsmqhgyturieozpabnvcxw6758493021`-=[]\\;',./ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:\"<>?";
layouts["colemak"] = " ntesiroahdjglpufywqbkvmcxz1234567890'\",.!?:;/@$%&#*()_ABCDEFGHIJKLMNOPQRSTUVWXYZ~+-={}|^<>`[]\\";
layouts["b�po"] = " tesirunamc,�vodpl�jbk'.qxghyf�zw6758493021`-=[]\\;/ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:\"<>?";
layouts["bépo"] = " tesirunamc,èvodpléjbk'.qxghyfàzw6758493021`-=[]\\;/ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+{}|:\"<>?";
layouts["norman"] = " ntieosaygjkufrdlw;qbpvmcxz1234567890'\",.!?:;/@$%&#*()_ABCDEFGHIJKLMNOPQRSTUVWXYZ~+-={}|^<>`[]\\";
layouts["code-es6"] = " {}',;():.>=</_-|`!?#[]\\+\"@$%&*~^";

Expand Down Expand Up @@ -234,6 +234,10 @@ function render_level_bar() {

}

function escapeHTML(a){
return new Option(a).innerHTML;
}

function render_word() {
var word = "";
for (var i = 0; i < data.word.length; i++) {
Expand All @@ -253,25 +257,19 @@ function render_word() {
word += "<span class='" + sclass + "'>";
if(data.word[i] == " ") {
word += "&#9141;"
}
else if(data.word[i] == "&") {
word += "&amp;"
}
}
else {
word += data.word[i];
word += escapeHTML(data.word[i]);
}
word += "</span>";
}
var keys_hit = "<span class='keys-hit'>";
for(var d in data.keys_hit) {
if (data.keys_hit[d] == ' ') {
if (data.keys_hit[d] == " ") {
keys_hit += "&#9141;";
}
else if (data.keys_hit[d] == '&') {
keys_hit += "&amp;";
}
else {
keys_hit += data.keys_hit[d];
keys_hit += escapeHTML(data.keys_hit[d]);
}
}
for(var i = data.word_index; i < data.word_length; i++) {
Expand Down