Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
Name: orgviz-js/lib/worker.js
1: | var orgfile = "http://cpee.org/~demo/orgviz/organisation_informatik.xml"; |
2: | |
3: | var GraphWorker = function(file,xpath,subjects,nopts){ |
4: | this.nodes = []; |
5: | this.subjects = []; |
6: | |
7: | function handler(response) { |
8: | if(this.status == 200 && this.responseXML != null ) |
9: | { |
10: | console.log(this.responseXML); |
11: | processData(this.responseXML); |
12: | } else { |
13: | console.log("schas") |
14: | } |
15: | } |
16: | |
17: | var client = new XMLHttpRequest(); |
18: | var response; |
19: | client.onload = handler(response); |
20: | client.open("GET", orgfile, true); |
21: | client.send(null); |
22: | |
23: | function nsResolver(prefix) { |
24: | return prefix == 'o' ? "http://cpee.org/ns/organisation/1.0" : null ; |
25: | } |
26: | |
27: | function processData(data) { |
28: | var evalue = data.evaluate('/o:organisation/o:units/o:unit|/o:organisation/o:roles/o:role', |
29: | data, |
30: | nsResolver, |
31: | XPathResult.ORDERED_NODE_ITERATOR_TYPE, |
32: | null); |
33: | // Nodes //{{{ |
34: | var node = evalue.iterateNext(); |
35: | for(; node && !node.invalidIteratorState; ) { |
36: | var type = node.prefix ? node.prefix + ":" : "" + node.localName |
37: | var id = node.id |
38: | var curr = new Node(id, type, nopts); |
39: | var numsubjects = data.evaluate('count(' + subjects.replace(/\/*$/,'') + '[o:relation[@' + type + '="' + id + '"]])', |
40: | data, |
41: | nsResolver, |
42: | XPathResult.NUMBER_TYPE, |
43: | null); |
44: | curr.numsubjects = numsubjects.numberValue; |
45: | |
46: | for(var i = 0; i < node.childNodes.length; ++i) { |
47: | var child = node.childNodes[i]; |
48: | if(child.nodeName == "parent") { |
49: | var pa = child.textContent; |
50: | for(var j = 0; j < node.parentNode.childNodes.length; ++j) { |
51: | var pid = node.parentNode.childNodes[j]; |
52: | if(pid.id == pa) { |
53: | curr.parents.push([type, pa]); |
54: | } |
55: | } |
56: | } |
57: | } |
58: | |
59: | nodes.push(curr); |
60: | node = evalue.iterateNext() |
61: | } |
62: | } //}}} |
63: | |
64: | // Subjects |
65: | |
66: | |
67: | } |