1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| function qmlToLookup(fichierXML)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = getLookup;
xmlDoc.load("test3.xml");
lookup=getLookup();
}
function getLookup()
{
//alert("OK");
var labelss = xmlDoc.getElementsByTagName('symbol');
var labels= xmlDoc.getElementsByTagName('lowervalue');
var strokecolors = xmlDoc.getElementsByTagName('outlinecolor');
var strokestyles = xmlDoc.getElementsByTagName('outlinestyle');
var strokewidths = xmlDoc.getElementsByTagName('outlinewidth');
var fillcolors = xmlDoc.getElementsByTagName('fillcolor');
var fillpatterns = xmlDoc.getElementsByTagName('fillpattern');
var lookup = new Object();
for (i=0; i < labelss.length; i++)
{
label=labels[i].firstChild.nodeValue
outlineColor_red=strokecolors[i].getAttribute('red');
outlineColor_green=strokecolors[i].getAttribute('green');
outlineColor_blue=strokecolors[i].getAttribute('blue');
strokewidth=strokewidths[i].firstChild.nodeValue;
fillColor_red=fillcolors[i].getAttribute('red');
fillColor_green=fillcolors[i].getAttribute('green');
fillColor_blue=fillcolors[i].getAttribute('blue');
fillPattern=fillpatterns[i].firstChild.nodeValue;
var outlineColor = RGBtoHex(outlineColor_red,outlineColor_green,outlineColor_blue);
var fillColor = RGBtoHex(fillColor_red,fillColor_green,fillColor_blue);
var lookupOptions=new Object();
lookupOptions["outlineColor"]=outlineColor;
lookupOptions['strokewidth']=strokewidth;
lookupOptions['fillColor']=fillColor;
lookupOptions['fillPattern']=fillPattern;
lookup[label]=lookupOptions;
document.write(lookup[label].fillColor+"<br>");
}
return lookup;
}
function RGBtoHex(R,G,B) {return "#"+toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
if (N==null) return "00";
N=parseInt(N); if (N==0 || isNaN(N)) return "00";
N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
return "0123456789ABCDEF".charAt((N-N%16)/16)
+ "0123456789ABCDEF".charAt(N%16);
} |
Partager