qsos-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qsos-commits] qsos/apps/xuleditor/chrome/content Document.js


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/xuleditor/chrome/content Document.js
Date: Thu, 18 May 2006 22:04:09 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Branch:         
Changes by:     Raphaël Semeteys <address@hidden>      06/05/18 22:04:09

Modified files:
        apps/xuleditor/chrome/content: Document.js 

Log message:
        SVG chart functions: data collection

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/qsos/apps/xuleditor/chrome/content/Document.js.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: qsos/apps/xuleditor/chrome/content/Document.js
diff -u qsos/apps/xuleditor/chrome/content/Document.js:1.4 
qsos/apps/xuleditor/chrome/content/Document.js:1.5
--- qsos/apps/xuleditor/chrome/content/Document.js:1.4  Wed May 17 16:35:15 2006
+++ qsos/apps/xuleditor/chrome/content/Document.js      Thu May 18 22:04:09 2006
@@ -1,7 +1,7 @@
 /*
 **  Copyright (C) 2006 Atos Origin 
 **
-**  Author: Raphaël Semeteys <address@hidden>
+**  Author: Rapha� Semeteys <address@hidden>
 **
 **  This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -79,6 +79,8 @@
     this.getfilename = getfilename;
     this.setfilename = setfilename;
     this.getcomplextree = getcomplextree;
+    this.getChartData = getChartData;
+    this.getSubChartData = getSubChartData;
 
     ////////////////////////////////////////////////////////////////////
     // QSOS XML file functions
@@ -554,4 +556,73 @@
     function setlicensedesc(value) {
        return setkey("licensedesc", value);
     }
+ 
+    ////////////////////////////////////////////////////////////////////
+    // Chart functions
+    ////////////////////////////////////////////////////////////////////
+
+    function getChartData() {
+       var chartData = new Array();
+       var sections = sheet.evaluate("//section", sheet, null, 
XPathResult.ANY_TYPE,null);
+       var section = sections.iterateNext();
+       while (section) {
+               var criterion = new Object();
+               criterion.name = section.getAttribute("name");
+               criterion.title =  section.getAttribute("title");
+               criterion.children = getSubChartData(criterion.name);
+               criterion.score = renderScore(criterion.children);
+               chartData.push(criterion);
+               section = sections.iterateNext();
+       }
+       return chartData;
+    }
+
+    function getSubChartData(name) {
+       var chartData = new Array();
+       var elements = sheet.evaluate("//address@hidden'"+name+"']/element", 
sheet, null, XPathResult.ANY_TYPE,null);
+       var element = elements.iterateNext();
+       while (element) {
+               var criterion = new Object();
+               criterion.name = element.getAttribute("name");
+               criterion.title =  element.getAttribute("title");
+               
+               if (hassubelements(criterion.name)) {
+                       criterion.children = getSubChartData(criterion.name);
+                       criterion.score = renderScore(criterion.children);
+                       chartData.push(criterion);
+               }
+               else {
+                       criterion.children = null;
+                       criterion.score = getkeyscore(criterion.name);
+                       if (criterion.score == "") criterion.score = null;
+                       if (criterion.score != -1) {
+                               chartData.push(criterion);
+                       }
+               }
+               element = elements.iterateNext();
+       }
+       return chartData;
+    }
+    
+    function renderScore(chartData) {
+       var score = 0;
+       var sum = 0;
+       var totalWeight = 0
+       var isRenderable = true;
+       
+       for (i=0; i < chartData.length; i++) {
+               totalWeight++;
+               if (chartData[i].score == null) isRenderable = false;
+               sum += Math.round(chartData[i].score * 100)/100;
+       }
+       
+       if (isRenderable) {
+               score = Math.round((sum/totalWeight)*100)/100;
+       }
+       else {
+               score = null;
+       }
+       
+       return score;
+    }
 }
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]