Co to jest jQuery dla Document.createElementNS()?Co to jest jQuery dla Document.createElementNS()?
function emleGraphicToSvg(aGraphicNode) {
var lu = function luf(aPrefix){
switch (aPrefix){
case 'xhtml': return 'http://www.w3.org/1999/xhtml';
case 'math': return 'http://www.w3.org/1998/Math/MathML';
case 'svg': return 'http://www.w3.org/2000/svg';
}
return '';
};
var svg = document.evaluate("svg:svg",
aGraphicNode, lu, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
singleNodeValue;
$(svg).children().remove();
rect = document.createElementNS(lu('svg'), "rect");
rect.setAttribute("x", "35");
rect.setAttribute("y", "25");
rect.setAttribute("width", "200");
rect.setAttribute("height", "50");
rect.setAttribute("class", "emleGraphicOutline");
svg.appendChild(rect);
}
Kod jest uproszczony fragment Emle - Electronic Mathematics Laboratory Equipment plik JavaScript emle_lab.js.
Funkcja wyszukiwania, luf()
, odwzorowuje kompletne odniesienie do skróconej nazwy obszaru nazw w ciągu XPath i createElementNS()
. Istniejący svg:svg
znajduje się, usuwa i zastępuje nowym prostokątem.
Muszę również wiedzieć, co robi createElementNS(). Oto moje pokrewne pytanie w svg-edit: http://pl.google.com/p/svg-edit/issues/detail?id=574 – marknt15