mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Fixed parsing.
This commit is contained in:
@@ -51,11 +51,17 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
// For each child of element, call handler defined in next
|
// For each child of element, call handler defined in next
|
||||||
function parseChildren(element, next) {
|
function parseChildren(element, next) {
|
||||||
|
|
||||||
var children = root.childNodes;
|
var children = element.childNodes;
|
||||||
for (var i=0; i<children.length; i++) {
|
for (var i=0; i<children.length; i++) {
|
||||||
|
|
||||||
// Get child node and corresponding handler
|
// Get child node
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
|
|
||||||
|
// Do not parse text nodes
|
||||||
|
if (!child.tagName)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get handler for node
|
||||||
var handler = next[child.tagName];
|
var handler = next[child.tagName];
|
||||||
|
|
||||||
// Call handler if defined
|
// Call handler if defined
|
||||||
@@ -64,7 +70,7 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
|
|
||||||
// Throw exception if no handler
|
// Throw exception if no handler
|
||||||
else
|
else
|
||||||
throw new Exception(
|
throw new Error(
|
||||||
"Unexpected " + child.tagName
|
"Unexpected " + child.tagName
|
||||||
+ " within " + element.tagName
|
+ " within " + element.tagName
|
||||||
);
|
);
|
||||||
@@ -111,6 +117,8 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
gap.style.width = gap.style.height =
|
gap.style.width = gap.style.height =
|
||||||
parseFloat(gap_size.value) + "em";
|
parseFloat(gap_size.value) + "em";
|
||||||
|
|
||||||
|
row.appendChild(gap);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"key": function parse_key(e) {
|
"key": function parse_key(e) {
|
||||||
@@ -118,6 +126,11 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
// Get attributes
|
// Get attributes
|
||||||
var key_size = e.attributes["size"];
|
var key_size = e.attributes["size"];
|
||||||
|
|
||||||
|
// Create element
|
||||||
|
var key = document.createElement("div");
|
||||||
|
key.className = "key";
|
||||||
|
key.textContent = "K";
|
||||||
|
|
||||||
parseChildren(e, {
|
parseChildren(e, {
|
||||||
"cap": function cap(e) {
|
"cap": function cap(e) {
|
||||||
|
|
||||||
@@ -127,10 +140,19 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
var keysym = e.attributes["keysym"];
|
var keysym = e.attributes["keysym"];
|
||||||
var sticky = e.attributes["sticky"];
|
var sticky = e.attributes["sticky"];
|
||||||
|
|
||||||
|
// Get content of key cap
|
||||||
|
var content = e.textContent;
|
||||||
|
|
||||||
|
// If no requirements, then show cap by default
|
||||||
|
if (!required) {
|
||||||
|
key.textContent = content;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
row.appendChild(key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -162,27 +184,23 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
|
|
||||||
|
|
||||||
// Parse document
|
// Parse document
|
||||||
parseChildren(xml.documentElement, {
|
var keyboard_element = xml.documentElement;
|
||||||
|
if (keyboard_element.tagName != "keyboard")
|
||||||
"keyboard": function parse_keyboard(e) {
|
throw new Error("Root element must be keyboard");
|
||||||
|
|
||||||
// Get attributes
|
|
||||||
var keyboard_size = e.attributes["size"];
|
|
||||||
|
|
||||||
parseChildren(e, {
|
|
||||||
|
|
||||||
"row": function(e) {
|
|
||||||
keyboard.appendChild(parse_row(e));
|
|
||||||
},
|
|
||||||
|
|
||||||
"column": function(e) {
|
|
||||||
keyboard.appendChild(parse_column(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
} // end keyboard
|
// Get attributes
|
||||||
|
var keyboard_size = keyboard_element.attributes["size"];
|
||||||
|
|
||||||
|
parseChildren(keyboard_element, {
|
||||||
|
|
||||||
|
"row": function(e) {
|
||||||
|
keyboard.appendChild(parse_row(e));
|
||||||
|
},
|
||||||
|
|
||||||
|
"column": function(e) {
|
||||||
|
keyboard.appendChild(parse_column(e));
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user