משתמש:קיפודנחש/common.js/virtkb.js
< משתמש:קיפודנחש | common.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
var allkeys = [
[["\u05b0", "\u05d9\u05b0","שוא"],["\u05b1", "\u05d9\u05b1","חטף-סגול"],["\u05b2", "\u05d9\u05b2", "חטף-פתח"],["\u05b3", "\u05d9\u05b3", "חטף-קמץ"],
["\u05b4", "\u05d9\u05b4", "חיריק"],["\u05b5", "\u05d9\u05b5", "צירה"],["\u05b6", "\u05d9\u05b6", "סגול"],["\u05b7", "\u05d9\u05b7", "פתח"],
["\u05b8", "\u05d9\u05b8", "קמץ"],["\u05b9", "\u05d5\u05b9", "חולם"],["\u05bb", "\u05d9\u05bb", "קֻבוץ"],["\u05bc", "\u05d9\u05bc", "דגש, שורוק, מפיק"],
["\u05e9\u05c1",,"שין ימנית"],["\u05e9\u05c2",,"שין שמאלית, סין"]
],
[,"/", "'", "\u05e7","\u05e8","\u05d0","\u05d8","\u05d5","\u05df","\u05dd","\u05e4","[","]","\\"
],
[,"\u05e9","\u05d3","\u05d2","\u05db","\u05e2","\u05d9","\u05d7","\u05dc","\u05da","\u05e3",",",["\n", "Enter",,2]
],
[,,"\u05d6","\u05e1","\u05d1","\u05d4","\u05e0","\u05de","\u05e6","\u05ea","\u05e5",".","\u20aa"
],
[
[,"-->","Text Entry direction: left to right(english)",2,,function(){this.textarea.dir = "ltr";this.textarea.focus();}],
[" ",,,12],
[,"<--","Text Entry direction: right to left (Hebrew)",2,,function(){this.textarea.dir = "rtl";this.textarea.focus();}]
]
];
function createButtonInCell(key, textarea, cell) {
if ((typeof key != 'string' && typeof key != 'object') || key.length == 0)
return;
if (typeof key == 'string')
var str = key;
var button = document.createElement("input");
button.type = 'button';
button.character = str || key[0];
button.value = str || key[1] || key[0];
button.title= str || key[2] || key[1] || key[0];
button.style.padding = 3;
button.textarea = textarea;
button.onclick = str ? setSelectedText : key[5] || setSelectedText;
if (!str && key[3])
button.style.width = 25 * (cell.colSpan = key[3]);
cell.appendChild(button);
cell.align = "center";
}
// snippett taken from MorrissonSchwartz at http://www.ms-inc.net/ViewThread.aspx?ThreadID=169
function setSelectedText() {
var ta = this.textarea, text = this.character;
if( typeof(ta.selectionStart) != "undefined" ) { // Netscape, Mozilla, Firefox
var start_selection = Math.min(ta.selectionStart, ta.selectionEnd),
end_selection = Math.max(ta.selectionStart, ta.selectionEnd),
scrollTop = ta.scrollTop;
ta.value = ta.value.slice(0, start_selection) + text + ta.value.slice(end_selection);
ta.selectionStart = ta.selectionEnd = start_selection + text.length;
ta.focus();
ta.scrollTop = scrollTop;
} else if( ta.createTextRange ) {
ta.focus( ta.caretPos );
ta.caretPos = document.selection.createRange().duplicate();
ta.caretPos.text = text;
ta.caretPos.moveStart( "character", text.length);
document.selection.setRange(ta.caretPos);
} else
ta.value += text;
}
function buildKeyboard(TextArea_id, div_id) {
var table = document.createElement("table");
var textarea = document.getElementById(TextArea_id);
document.getElementById(div_id).appendChild(table);
for (var i = 0; i < allkeys.length; i++) {
var row = table.insertRow(i);
for (var j = 0; j < allkeys[i].length; j++) // i like better "for (j in allkeys[i]), but ie has difficulty with it.
createButtonInCell(allkeys[i][j], textarea, row.insertCell(j));
}
}