Karima Rafes has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83227


Change subject: Fix warnings of JShint and fix a bug with loader JS
......................................................................

Fix warnings of JShint and fix a bug with loader JS

Change-Id: I205974a6f6c60ff764ec48755e97467fe9701965
---
A .jshintignore
M LinkedWiki.php
M js/FlintSparqlEditor/sparql/flint-editor.js
M js/FlintSparqlEditor/sparql/init-local.js
M js/bordercloud.js
M js/flowchart.js
M js/lwgraph.js
M js/table2CSV.js
M lib/sparql/Endpoint.php
M lib/sparql/ParserSparqlResult.php
10 files changed, 576 insertions(+), 442 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LinkedWiki 
refs/changes/27/83227/1

diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..5f49dd6
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+# third-party libs
+js/FlintSparqlEditor/
\ No newline at end of file
diff --git a/LinkedWiki.php b/LinkedWiki.php
index 62a039a..1564620 100644
--- a/LinkedWiki.php
+++ b/LinkedWiki.php
@@ -106,6 +106,11 @@
 $wgHooks['LanguageGetMagic'][]       = 'efSparqlParserFunction_Magic';
 
 function efSparqlParserFunction_Setup( &$parser ) {
+       //I can't put these lines in efLwgraphRender... bug ?
+       global $wgOut;
+       $wgOut->addModules('ext.LinkedWiki.table2CSV');
+       $wgOut->addModules('ext.LinkedWiki.flowchart');
+       
        $parser->setFunctionHook( 'sparql', 'efSparqlParserFunction_Render' );
        $parser->setFunctionHook( 'wsparql', 'efWsparqlParserFunction_Render' );
        $parser->setFunctionHook( 'properties', 
'efPropertiesParserFunction_Render' );
@@ -120,7 +125,7 @@
        # All remaining elements are synonyms for our parser function
        $magicWords['sparql'] = array( 0, 'sparql' );
        $magicWords['wsparql'] = array( 0, 'wsparql' );
-       $magicWords['properties'] = array( 0, 'properties' );
+       $magicWords['properties'] = array( 0, 'properties' );   
        # unless we return true, other parser functions extensions won't get 
loaded.
        return true;
 }
@@ -132,38 +137,39 @@
 }
 
 function efLwgraphRender( $input, array $args, Parser $parser, PPFrame $frame 
) {
-      global $wgOut;
+      //global $wgOut;
        $html = "";
         $width = isset($args["width"])?$args["width"]:"100%";
         $height = isset($args["height"])?$args["height"]:"150px";
         $border = isset($args["border"]) && $args["border"]>0 ? 
"border:".$args["border"]."px solid #000000;" : "" ;
         
-       if (isset($args["debug"]) && $args["debug"] == "true"){        
+       if (isset($args["debug"]) && $args["debug"] == "true"){
            $attr = array();    
            foreach( $args as $name => $value )
                    $attr[] =  $name . ' = ' .  $value ;
                    
-           $html .= "<div><b>lwgraph DEBUG :</b><br/>".implode( '<br/>', $attr 
)."</div>";
-            $html .= "<pre>".htmlspecialchars( $input )."</pre>";            
+                       $html .= "<div><b>lwgraph DEBUG :</b><br/>".implode( 
'<br/>', $attr )."</div>";
+            $html .= "<pre>".htmlspecialchars( $input )."</pre>";
            
         }
         
-        if (isset($args["type"]) == "flow"){ 
-           $wgOut->addModules('ext.LinkedWiki.flowchart');   
+        if (isset($args["type"]) && $args["type"] == "flow"){ 
+           // I put this addModules in efSparqlParserFunction_Setup
+              //$wgOut->addModules('ext.LinkedWiki.flowchart');
+        
+        
+               preg_match_all("/\[\[([^\]\|]*)(?:\|[^\]]*)?\]\]/U", 
$input,$out);
+               $arrayTitle = array_unique ($out[1]);
+               
+               $textGraph = $input;
+               foreach ($arrayTitle as $title) {
+                                 $titleObject = Title::newFromText( $title );
+                                 if ( !$titleObject->exists() ) 
+                                     $textGraph = str_replace("[[".$title, 
"~[[".$title, $textGraph);
+                                     $textGraph = str_replace("~~", "~", 
$textGraph);
+                               }
+               $html .= "<canvas  class=\"lwgraph-flow\" 
style=\"".$border."width: 
".$width.";height:".$height."\">".$textGraph."</canvas>";
         }
-        
-        preg_match_all("/\[\[([^\]\|]*)(?:\|[^\]]*)?\]\]/U", $input,$out);
-        $arrayTitle = array_unique ($out[1]);
-        
-        $textGraph = $input;
-        foreach ($arrayTitle as $title) {
-         $titleObject = Title::newFromText( $title );
-         if ( !$titleObject->exists() ) 
-             $textGraph = str_replace("[[".$title, "~[[".$title, $textGraph);
-             $textGraph = str_replace("~~", "~", $textGraph);
-       }
-        $html .= "<canvas  class=\"lwgraph-flow\" style=\"".$border."width: 
".$width.";height:".$height."\">".$textGraph."</canvas>";
-        
         return array($html, 'isHTML' => true);
 }
 
@@ -539,6 +545,8 @@
                        $str .= " bgcolor=\"#f5f5f5\" ";                
                $str .= ">\n";
                $lignegrise = !$lignegrise;
+               
+               
                foreach ( $variables as $variable) {
                      $str .= "<td>";
                      
diff --git a/js/FlintSparqlEditor/sparql/flint-editor.js 
b/js/FlintSparqlEditor/sparql/flint-editor.js
index c8eae2c..57b3820 100755
--- a/js/FlintSparqlEditor/sparql/flint-editor.js
+++ b/js/FlintSparqlEditor/sparql/flint-editor.js
@@ -58,7 +58,7 @@
                                        
$('#flint-dialog-okay-button').css('visibility', 'visible');
                                }
                                $('.flint-dialog-body').css('margin-top',
-                                               
($('#flint-editor').position().top + 200) + "px");
+                                               
($('#flint-editor').position().top + 200) + 'px');
                                $('#flint-dialog').css('visibility', 'visible');
                        }
                };
diff --git a/js/FlintSparqlEditor/sparql/init-local.js 
b/js/FlintSparqlEditor/sparql/init-local.js
index b5e06c2..4d877e4 100644
--- a/js/FlintSparqlEditor/sparql/init-local.js
+++ b/js/FlintSparqlEditor/sparql/init-local.js
@@ -4,11 +4,9 @@
   $(document)
                .ready(
                                function() {
-                                       var sampleQuery1 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\nPREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#>\nPREFIX frbr: 
<http://purl.org/vocab/frbr/core#>\nPREFIX dct: 
<http://purl.org/dc/terms/>\n\nSELECT ?work ?date ?title WHERE {\n\t?work a 
frbr:Work .\n\t?work dct:title ?title .\n\t?work dct:created ?date .\n\tFILTER 
(?date >= '2010-10-15'^^xsd:date)\n}\nORDER BY desc(?date)\nLIMIT 100";
-
-                                       var sampleQuery2 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\n\nCONSTRUCT {?s ?p ?o}\nWHERE 
{\n\tGRAPH <http://www.legislation.gov.uk/id/uksi/2010/2581>\n\t{?s ?p ?o}\n}";
-
-                                       var sampleQuery3 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\nPREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#>\nPREFIX gzt: 
<http://www.gazettes-online.co.uk/ontology#>\n\nSELECT ?n WHERE {\n\t?n a 
gzt:Notice .\n\t?n gzt:hasPublicationDate ?d .\n\tFILTER (?d >= 
'2010-09-01'^^xsd:date)\n}\nORDER BY ?d\nLIMIT 100";
+                                       var sampleQuery1 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\nPREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#>\nPREFIX frbr: 
<http://purl.org/vocab/frbr/core#>\nPREFIX dct: 
<http://purl.org/dc/terms/>\n\nSELECT ?work ?date ?title WHERE {\n\t?work a 
frbr:Work .\n\t?work dct:title ?title .\n\t?work dct:created ?date .\n\tFILTER 
(?date >= '2010-10-15'^^xsd:date)\n}\nORDER BY desc(?date)\nLIMIT 100",
+                                               sampleQuery2 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\n\nCONSTRUCT {?s ?p ?o}\nWHERE 
{\n\tGRAPH <http://www.legislation.gov.uk/id/uksi/2010/2581>\n\t{?s ?p ?o}\n}",
+                                               sampleQuery3 = "PREFIX rdf: 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: 
<http://www.w3.org/2000/01/rdf-schema#>\nPREFIX xsd: 
<http://www.w3.org/2001/XMLSchema#>\nPREFIX gzt: 
<http://www.gazettes-online.co.uk/ontology#>\n\nSELECT ?n WHERE {\n\t?n a 
gzt:Notice .\n\t?n gzt:hasPublicationDate ?d .\n\tFILTER (?d >= 
'2010-09-01'^^xsd:date)\n}\nORDER BY ?d\nLIMIT 100";
 
                                        var flintConfig = {
                                                "interface" : {
diff --git a/js/bordercloud.js b/js/bordercloud.js
index 38c33e6..aadde06 100644
--- a/js/bordercloud.js
+++ b/js/bordercloud.js
@@ -1,3 +1,6 @@
+/*global escape: true */
+/*exported bcValidateSPARQL */
+/*jshint -W061 */
 var imageObjWaiting = null;
 var canvas = null;
 var div = null;
@@ -7,32 +10,119 @@
 //
 var rotation = 0;
 var processusWaiting = null;
-var messageWaiting = "Waiting...";
+var messageWaiting = 'Waiting...';
 //
 //
 //var graph = null;
 //var datasetSelected = null;
 //
-//var doc_datasets = null;
+//var docDatasets = null;
 //var doc_links = null;
 //
 //var requestGetDatasetJson = null;
 //var requestGetLinksetJson = null;
 
+function makeTable(docDatasets){
+       var
+               table,
+               i,
+               i1,
+               ii;
+       
+       table = '<table class="wikitable sortable">';
+       table += '<tr>';
+       for(i in docDatasets.head.vars)
+       {
+               table += '<th>';
+               table += docDatasets.head.vars[i];
+               table += '</th>';
+       }
+       table += '</tr>';
+       
+       for(i1 in docDatasets.results.bindings)
+       {
+               table += '<tr>';
+               for(ii in docDatasets.results.bindings[i1])
+               {
+                       table += '<td>';
+                       table += docDatasets.results.bindings[i1][ii].value ;
+                       table += '</td>';
+               }
+               table += '</tr>';
+       }
+       
+       table += '</table>';
+       return table;
+}
+
+function downloadDatasets(endpoint,query){
+       //send request
+       var
+               req = new XMLHttpRequest(),
+               docDatasets;
+       
+       req.open('GET', endpoint + '/?output=json&query=' + 
escape(query.replace('\\n','')),
+                       true);
+       req.onreadystatechange = function () {
+               if (req.readyState === 4) {
+                       if(req.status === 200 || req.status === 0){
+                               if (req.responseText === ''){
+                                       messageWaiting = 'Error : The domain in 
the query is different of Web site...';
+                                       return;
+                               }
+                               docDatasets = eval('(' + req.responseText + 
')');
+                               //docDatasets = JSON.parse(json); // no with 
Chrome
+                               //messageWaiting = "Reading the datasets...";
+                               
+                               div.innerHTML =  makeTable(docDatasets);
+                               // download_links();    
+                       }else{
+                               messageWaiting = 'Error loading page';
+                       }
+               }
+       };
+       req.send(null);
+}
+
+function waiting(){
+       var
+               ctx = canvas.getContext('2d'),
+               xcenter = ctx.canvas.width/2,
+               ycenter = ctx.canvas.height/2,
+               sourceWidth = 65,
+               sourceHeight = 65;
+               //ximage = xcenter - sourceWidth/2,
+               //yimage = ycenter - sourceHeight/2;
+       
+       ctx.clearRect(0 ,0, ctx.canvas.width,ctx.canvas.height);
+
+       ctx.save();
+       ctx.translate(xcenter,ycenter); // to get it in the origin
+       rotation -=2;
+       ctx.rotate(rotation*Math.PI/64); //rotate in origin
+       ctx.drawImage(imageObjWaiting,-sourceWidth/2 ,-sourceHeight/2);
+       ctx.restore();
+
+       ctx.textAlign='center';
+       ctx.textBaseline = 'middle';
+       ctx.fillStyle ='#474754';
+       ctx.font = '30px arial';
+       ctx.fillText(messageWaiting, xcenter,ycenter + sourceHeight/2 + 50);
+}
 
 function bcValidateSPARQL(endpoint,query){
-       imageObjWaiting = document.getElementById("canvas-image-wait");
-       div =document.getElementById("bc_div");
+       imageObjWaiting = document.getElementById('canvas-image-wait');
+       div =document.getElementById('bc_div');
 
        if(canvas === null){
                div.innerHTML = '<canvas id="bc_canvas"></canvas>';
-               canvas =document.getElementById("bc_canvas");
+               canvas =document.getElementById('bc_canvas');
        }
 
        canvas.setAttribute('width', 300);
        canvas.setAttribute('height', 200);
        
-       ctx = canvas.getContext('2d');
+       //var ctx = canvas.getContext('2d');
        
        //Waiting logo
        processusWaiting = setInterval(waiting,20);
@@ -67,7 +157,7 @@
        
        //requestGetDatasetJson = requestGetSparqlDatasetJson;
 
-       download_datasets(endpoint,query);      
+       downloadDatasets(endpoint,query);
 }
 
 //function initDatasetJson(json){
@@ -144,82 +234,3 @@
 //     }
 //}
 //
-function download_datasets(endpoint,query){    
-       //send request
-       var req = new XMLHttpRequest();
-       req.open("GET", endpoint + '/?output=json&query=' + 
escape(query.replace('\\n','')),
-                       true); 
-       req.onreadystatechange = function (aEvt) {
-               if (req.readyState == 4) {
-                       if(req.status == 200 || req.status === 0){
-                                       if (req.responseText === "") { 
-                                               messageWaiting = "Error : The 
domain in the query is different of Web site...";
-                                               return;
-                                       }
-                                       doc_datasets = eval('(' + 
req.responseText + ')'); 
-                                       //doc_datasets = JSON.parse(json); // 
no with Chrome
-                               //messageWaiting = "Reading the datasets...";   
        
-                               
-                               div.innerHTML =  makeTable(doc_datasets);
-                               // download_links();    
-                       }else
-                               messageWaiting = "Error loading page";
-                       }
-                       };
-       req.send(null); 
-}
-
-function makeTable(doc_datasets){
-       table = '<table class="wikitable sortable">';
-       table += '<tr>';
-       for(var i in doc_datasets.head.vars)
-       {
-               table += '<th>';
-               table += doc_datasets.head.vars[i];
-               table += '</th>';
-       }
-       table += '</tr>';
-       
-       for(var i1 in doc_datasets.results.bindings)
-       {
-               table += '<tr>';
-               for(var ii in doc_datasets.results.bindings[i1])
-               {
-                       table += '<td>';
-                       table += doc_datasets.results.bindings[i1][ii].value ;
-                       table += '</td>';       
-               }
-               table += '</tr>';
-       }
-       
-       table += '</table>';
-       return table;
-}
-
-
-function waiting(){    
-    var xcenter = ctx.canvas.width/2;
-    var ycenter = ctx.canvas.height/2;
-    var sourceWidth = 65;
-    var sourceHeight = 65;
-    var ximage = xcenter - sourceWidth/2 ;
-    var yimage = ycenter - sourceHeight/2;
-    
-
-    
-    ctx.clearRect(0 ,0, ctx.canvas.width,ctx.canvas.height);
-
-       ctx.save();
-       ctx.translate(xcenter,ycenter); // to get it in the origin
-       rotation -=2;
-       ctx.rotate(rotation*Math.PI/64); //rotate in origin
-       ctx.drawImage(imageObjWaiting,-sourceWidth/2 ,-sourceHeight/2);
-       ctx.restore();
-
-       ctx.textAlign="center";
-       ctx.textBaseline = "middle";
-       ctx.fillStyle ="#474754";
-       ctx.font = "30px arial";
-       ctx.fillText(messageWaiting, xcenter,ycenter + sourceHeight/2 + 50);
-
-}
diff --git a/js/flowchart.js b/js/flowchart.js
index a994705..9a2c524 100644
--- a/js/flowchart.js
+++ b/js/flowchart.js
@@ -1,217 +1,13 @@
-function lwFlowChart($canvas,graphStr){
-       this.tabLines = [];
-       this.margemin = 10;
-       this.margex = 10;
-       this.margey = 10;
-       this.a = $canvas[0].getContext('2d');
-       this.ratio = 0;
-       
-       //BEGIN CONSTRUCTOR
-       var regLine = 
/(?:=(?:(~*)\[\[([^\]\|]*)(?:\|([^\]]*))?\]\])?=>)?(~*)\[\[([^\]\|]*)(?:\|([^\]]*))?\]\]/g;
-       
-       //Read shape arrow and rect
-       //console.log(graphStr);
-       var lines = graphStr.split("\n");  
-       for(var i1 in lines){
-               var line1  = lines[i1].trim();
-               //console.log(lines[i1]); 
-               if(line1 !== ''){
-                       var flowChartLine = new lwFlowChartLine();
-                       var first = true;
-                       while ((myArray = regLine.exec(line1)) !== null){
-                               //var msg = myArray[0]+"\n";
-                               //msg += "1 Exist property page: " +  
myArray[1] +"\n";
-                               //msg += "2 property title page: " +  
myArray[2] +"\n";
-                               //msg += "3 property label : " +  
myArray[3]+"\n";
-                               //msg += "4 Exist object page : " +  
myArray[4]+"\n";
-                               //msg += "5 object title page : " +  
myArray[5]+"\n";
-                               //msg += "6 object label : " +  myArray[6]+"\n";
-                               //console.log(msg);
-                               if(!first){
-                                       if(myArray[1] !== undefined){
-                                               flowChartLine.addShape(new 
lwFlowChartShape(myArray[2],myArray[3],myArray[1]!="~",true));
-                                       }else{
-                                               flowChartLine.addShape(new 
lwFlowChartShape(null,null,null,true));
-                                       }
-                               }
-                               flowChartLine.addShape(new 
lwFlowChartShape(myArray[5],myArray[6],myArray[4]!="~",false));
-                               first = false;
-                       }
-                       this.tabLines.push(flowChartLine);
-               }
-       }
-
-       //Calculate size
-       //console.log(this.tabLines);
-       var heightLine = 60;
-       var nbLine = 0;
-       for(var i2 in this.tabLines){
-               var line2 = this.tabLines[i2];     
-               for(var j in line2.shapes){
-                       var shape = line2.shapes[j];
-                       shape.label = shape.label === undefined ? shape.title : 
 shape.label;
-                       if(shape.isArrow){
-                               shape.width = 
$canvas.lwDrawLineArrow(shape.label,"red",0,0,0,0,false); 
-                       }else{
-                               shape.width = 
$canvas.lwDrawRect(shape.label,"red",0,0,false);  
-                       }
-                       shape.height = 40;
-                       shape.centery= heightLine*nbLine + heightLine/2;
-                       var beforex = 0;
-                       if(shape.pointerShapesBefore.length > 0){
-                               beforex = shape.pointerShapesBefore[0].rightx ;
-                       }
-                       shape.centerx= beforex + shape.width/2;
-                       
-                       shape.rightx= shape.centerx + shape.width/2;
-                       shape.righty= shape.centery;
-                       
-                       shape.leftx= shape.centerx - shape.width/2;
-                       shape.lefty= shape.centery;
-                       
-                       shape.topx=shape.centerx;
-                       shape.topy=shape.centery - heightLine/2;
-                       shape.downx=shape.centerx;
-                       shape.downy=shape.centery + heightLine/2;
-                       
-                       if(nbLine === 0)
-                               shape.fixed=true;
-               
-               }
-               nbLine++;
-       }
-//////////////
-
-       //Build array shape fixed and to link shapes 
-       var arrayShapeFixed = this.tabLines[0].shapes;
-       for(var iline = 1 ; iline < (this.tabLines.length) ; iline++){
-               for(var i3 = 0; i3 < arrayShapeFixed.length; i3++){
-                       var shapeFixed = arrayShapeFixed[i3];
-                       for(var l3 in this.tabLines){
-                               var line = this.tabLines[l3];     
-                               for(var j3 in line.shapes){
-                                       var shape3 = line.shapes[j3];
-                                       if(!shape3.fixed && !shape3.isArrow && 
shape3.title == shapeFixed.title){
-                                               for(var b = 0; b < 
shape3.pointerShapesAfter.length; b++){
-                                                       
shape3.pointerShapesAfter[b].leftx = shapeFixed.rightx;
-                                                       
shape3.pointerShapesAfter[b].lefty = shapeFixed.righty;
-                                                       
shape3.pointerShapesAfter[b].removeShapeBefore(shape3);
-                                                       
shape3.pointerShapesAfter[b].addShapeBefore(shapeFixed);
-                                                       
shapeFixed.addShapeAfter(shape3.pointerShapesAfter[b]);
-                                               }
-                                               for(var a = 0; a <  
shape3.pointerShapesBefore.length; a++){
-                                                       
shape3.pointerShapesBefore[a].rightx = shapeFixed.leftx;
-                                                       
shape3.pointerShapesBefore[a].righty = shapeFixed.lefty;
-                                                       
shape3.pointerShapesBefore[a].removeShapeAfter(shape3);
-                                                       
shape3.pointerShapesBefore[a].addShapeAfter(shapeFixed);
-                                                       
shapeFixed.addShapeBefore(shape3.pointerShapesBefore[a]);
-                                               }
-                                               line.shapes.splice(j3,1);
-                                       }
-                               }
-                       }
-               }
-       for(var s1 in this.tabLines[iline].shapes)
-               this.tabLines[iline].shapes[s1].fixed = true;
-               arrayShapeFixed = 
arrayShapeFixed.concat(this.tabLines[iline].shapes);
-               //console.log(arrayShapeFixed);
-       }
-
-       //Calculate the good position
-       for(var s2 in arrayShapeFixed){
-               var shape4 = arrayShapeFixed[s2];
-               shape4.checkPlace();
-       }
-
-       //calc size of the graph
-       var xmax = 0;
-       var ymax = 0;
-       for(var s in arrayShapeFixed){
-               var shape5 = arrayShapeFixed[s];
-               if(shape5.rightx > xmax)
-                       xmax = shape5.rightx;
-               if(shape5.downy > ymax)
-                       ymax = shape5.downy;
-               }
-
-       //resize the graph in the canvas
-       var ratiox = $canvas[0].width / (this.margemin*2 + xmax);
-       var ratioy = $canvas[0].height / (this.margemin*2 +ymax );
-       //console.log("ratiox"+ratiox);
-       //console.log("ratioy"+ratioy);
-       
-       this.a.save();
-       if(ratiox<ratioy){
-               this.ratio = ratiox;
-               this.a.scale(this.ratio,this.ratio);
-               this.margex = this.margemin;
-               this.margey = ($canvas[0].height - ymax*ratiox)/2;
-       }else{
-               this.ratio = ratioy;
-               this.a.scale(this.ratio,this.ratio);
-               this.margex = ($canvas[0].width - xmax*ratioy)/2 ;
-               this.margey = this.margemin;
-       }
-       
-       this.a.translate(this.margex ,this.margey );
-
-       // a.beginPath();
-       // a.rect(0, 0, xmax, ymax);
-       // a.lineWidth = 2;
-       // a.strokeStyle = 'red';
-       // a.stroke();  
-
-//////////////
-       
-       //draw the graph
-       for(var i6 in this.tabLines){
-               var line6 = this.tabLines[i6];
-               for(var j6 in line6.shapes){
-                       var shape6 = line6.shapes[j6];
-                       var color = shape6.isPageExist ? "black" : "red";
-                       if(shape6.isArrow){
-                               shape6.width = $canvas.lwDrawLineArrow(
-                                               shape6.label,
-                                               color,
-                                               shape6.leftx,
-                                               shape6.lefty,
-                                               shape6.rightx,
-                                               shape6.righty,
-                                               true); 
-                       }else{
-                               
$canvas.lwDrawRect(shape6.label,color,shape6.centerx,shape6.centery,true);     
-                       }
-               }
-       }
-       
-       this.a.restore();
-       
-       //END CONSTRUCTOR
-
-       //FUNCTION
-       //return the shape without the pointer
-       this.getShape= function (x,y){
-               for(var i in this.tabLines){
-                       var line = this.tabLines[i];     
-                       for(var j in line.shapes){
-                               var shape = line.shapes[j];
-                               var xmin = shape.leftx * this.ratio + 
this.margex ;
-                               var xmax = shape.rightx * this.ratio + 
this.margex ;
-                               var ymin = shape.topy * this.ratio + 
this.margey ;
-                               var ymax = shape.downy * this.ratio + 
this.margey ;
-                               if(x > xmin && x < xmax && y  > ymin && y < 
ymax )
-                                       return shape;
-                       }
-               }
-               return null;
-       };
-}
+/*global $:false */
+/*global mw:false */
+/*jshint -W055 */
 
 function lwFlowChartLine(){
+       var shapeBefore;
        this.shapes=[];
        this.addShape= function (shape){
                if(this.shapes[this.shapes.length-1]!==undefined){
-                       var shapeBefore =  this.shapes[this.shapes.length-1];
+                       shapeBefore =  this.shapes[this.shapes.length-1];
                        shape.addShapeBefore(shapeBefore);
                        shapeBefore.addShapeAfter(shape);
                }
@@ -267,7 +63,7 @@
        this.setLeftx= function (x){
                this.leftx = x ;
                this.rightx = x + this.width;
-               this.centerx = this.leftx + this.width/2;       
+               this.centerx = this.leftx + this.width/2;
                this.topx=this.centerx;
                this.downx=this.centerx;
        };
@@ -275,34 +71,302 @@
        this.setRightx= function (x){
                this.leftx = x - this.width;
                this.rightx = x ;
-               this.centerx = this.leftx + this.width/2;       
+               this.centerx = this.leftx + this.width/2;
                this.topx=this.centerx;
                this.downx=this.centerx;
        };
        
        this.checkPlace= function (){
+               var
+                       a1,
+                       b1,
+                       a2,
+                       b2;
                if(this.leftx > (this.rightx - this.width) ){
                        this.setLeftx(this.leftx);
                        
-                       for(var a1 in this.pointerShapesAfter){
+                       for(a1 in this.pointerShapesAfter){
                                this.pointerShapesAfter[a1].leftx = this.rightx;
                        }
-                       for(var b1 in this.pointerShapesBefore){
+                       for(b1 in this.pointerShapesBefore){
                                this.pointerShapesBefore[b1].rightx = 
this.leftx;
                        }
                        
-                       for(var a2 in this.pointerShapesAfter){
+                       for(a2 in this.pointerShapesAfter){
                                this.pointerShapesAfter[a2].checkPlace();
                        }
-                       for(var b2 in this.pointerShapesBefore){
+                       for(b2 in this.pointerShapesBefore){
                                this.pointerShapesBefore[b2].checkPlace();
                        }
                }
        };
 }
 
+function lwFlowChart($canvas,graphStr){
+       var
+               regLine = 
/(?:=(?:(~*)\[\[([^\]\|]*)(?:\|([^\]]*))?\]\])?=>)?(~*)\[\[([^\]\|]*)(?:\|([^\]]*))?\]\]/g,
+               lines,
+               i1,
+               line1,
+               i2,
+               line2,
+               j,
+               shape,
+               shape3,
+               shape4,
+               shape5,
+               shape6,
+               beforex,
+               flowChartLine,
+               first,
+               heightLine = 60,
+               nbLine,//for loop
+       arrayShapeFixed,
+       shapeFixed,
+       iline,
+       i3,
+       line,
+       j3,
+       l3,
+       a,
+       b,
+       myArray,
+       s,
+       s1,
+       s2,
+       xmax,
+       ymax,
+       ratiox,
+       ratioy,
+       i6,
+       line6,
+       j6,
+       color;
+       
+       this.tabLines = [];
+       this.margemin = 10;
+       this.margex = 10;
+       this.margey = 10;
+       this.a = $canvas[0].getContext('2d');
+       this.ratio = 0;
+       
+       //BEGIN CONSTRUCTOR
+       //Read shape arrow and rect
+       //console.log(graphStr);
+       lines = graphStr.split('\n');
+       for(i1 in lines){
+               line1  = lines[i1].trim();
+               //console.log(lines[i1]); 
+               if(line1 !== ''){
+                       flowChartLine = new lwFlowChartLine();
+                       first = true;
+                       while ((myArray = regLine.exec(line1)) !== null){
+                               //var msg = myArray[0]+"\n";
+                               //msg += "1 Exist property page: " +  
myArray[1] +"\n";
+                               //msg += "2 property title page: " +  
myArray[2] +"\n";
+                               //msg += "3 property label : " +  
myArray[3]+"\n";
+                               //msg += "4 Exist object page : " +  
myArray[4]+"\n";
+                               //msg += "5 object title page : " +  
myArray[5]+"\n";
+                               //msg += "6 object label : " +  myArray[6]+"\n";
+                               //console.log(msg);
+                               if(!first){
+                                       if(myArray[1] !== undefined){
+                                               flowChartLine.addShape(new 
lwFlowChartShape(myArray[2],myArray[3],myArray[1]!=='~',true));
+                                       }else{
+                                               flowChartLine.addShape(new 
lwFlowChartShape(null,null,null,true));
+                                       }
+                               }
+                               flowChartLine.addShape(new 
lwFlowChartShape(myArray[5],myArray[6],myArray[4]!=='~',false));
+                               first = false;
+                       }
+                       this.tabLines.push(flowChartLine);
+               }
+       }
+
+       //Calculate size
+       //console.log(this.tabLines);
+       nbLine = 0;
+       for(i2 in this.tabLines){
+               line2 = this.tabLines[i2];
+               for(j in line2.shapes){
+                       shape = line2.shapes[j];
+                       shape.label = shape.label === undefined ? shape.title : 
 shape.label;
+                       if(shape.isArrow){
+                               shape.width = 
$canvas.lwDrawLineArrow(shape.label,'red',0,0,0,0,false);
+                       }else{
+                               shape.width = 
$canvas.lwDrawRect(shape.label,'red',0,0,false);
+                       }
+                       shape.height = 40;
+                       shape.centery= heightLine*nbLine + heightLine/2;
+                       beforex = 0;
+                       if(shape.pointerShapesBefore.length > 0){
+                               beforex = shape.pointerShapesBefore[0].rightx ;
+                       }
+                       shape.centerx= beforex + shape.width/2;
+                       
+                       shape.rightx= shape.centerx + shape.width/2;
+                       shape.righty= shape.centery;
+                       
+                       shape.leftx= shape.centerx - shape.width/2;
+                       shape.lefty= shape.centery;
+                       
+                       shape.topx=shape.centerx;
+                       shape.topy=shape.centery - heightLine/2;
+                       shape.downx=shape.centerx;
+                       shape.downy=shape.centery + heightLine/2;
+                       
+                       if(nbLine === 0){
+                               shape.fixed=true;
+                       }
+               }
+               nbLine++;
+       }
+//////////////
+
+       //Build array shape fixed and to link shapes 
+       arrayShapeFixed = this.tabLines[0].shapes;
+       for(iline = 1 ; iline < (this.tabLines.length) ; iline++){
+               for(i3 = 0; i3 < arrayShapeFixed.length; i3++){
+                       shapeFixed = arrayShapeFixed[i3];
+                       for(l3 in this.tabLines){
+                               line = this.tabLines[l3];
+                               for(j3 in line.shapes){
+                                       shape3 = line.shapes[j3];
+                                       if(!shape3.fixed && !shape3.isArrow && 
shape3.title === shapeFixed.title){
+                                               for(b = 0; b < 
shape3.pointerShapesAfter.length; b++){
+                                                       
shape3.pointerShapesAfter[b].leftx = shapeFixed.rightx;
+                                                       
shape3.pointerShapesAfter[b].lefty = shapeFixed.righty;
+                                                       
shape3.pointerShapesAfter[b].removeShapeBefore(shape3);
+                                                       
shape3.pointerShapesAfter[b].addShapeBefore(shapeFixed);
+                                                       
shapeFixed.addShapeAfter(shape3.pointerShapesAfter[b]);
+                                               }
+                                               for(a = 0; a <  
shape3.pointerShapesBefore.length; a++){
+                                                       
shape3.pointerShapesBefore[a].rightx = shapeFixed.leftx;
+                                                       
shape3.pointerShapesBefore[a].righty = shapeFixed.lefty;
+                                                       
shape3.pointerShapesBefore[a].removeShapeAfter(shape3);
+                                                       
shape3.pointerShapesBefore[a].addShapeAfter(shapeFixed);
+                                                       
shapeFixed.addShapeBefore(shape3.pointerShapesBefore[a]);
+                                               }
+                                               line.shapes.splice(j3,1);
+                                       }
+                               }
+                       }
+               }
+               for(s1 in this.tabLines[iline].shapes){
+                       this.tabLines[iline].shapes[s1].fixed = true;
+               }
+               arrayShapeFixed = 
arrayShapeFixed.concat(this.tabLines[iline].shapes);
+               //console.log(arrayShapeFixed);
+       }
+
+       //Calculate the good position
+       for(s2 in arrayShapeFixed){
+               shape4 = arrayShapeFixed[s2];
+               shape4.checkPlace();
+       }
+
+       //calc size of the graph
+       xmax = 0;
+       ymax = 0;
+       for(s in arrayShapeFixed){
+               shape5 = arrayShapeFixed[s];
+               if(shape5.rightx > xmax){
+                       xmax = shape5.rightx;
+               }
+               if(shape5.downy > ymax){
+                       ymax = shape5.downy;
+               }
+       }
+
+       //resize the graph in the canvas
+       ratiox = $canvas[0].width / (this.margemin*2 + xmax);
+       ratioy = $canvas[0].height / (this.margemin*2 +ymax );
+       //console.log("ratiox"+ratiox);
+       //console.log("ratioy"+ratioy);
+       
+       this.a.save();
+       if(ratiox<ratioy){
+               this.ratio = ratiox;
+               this.a.scale(this.ratio,this.ratio);
+               this.margex = this.margemin;
+               this.margey = ($canvas[0].height - ymax*ratiox)/2;
+       }else{
+               this.ratio = ratioy;
+               this.a.scale(this.ratio,this.ratio);
+               this.margex = ($canvas[0].width - xmax*ratioy)/2 ;
+               this.margey = this.margemin;
+       }
+       
+       this.a.translate(this.margex ,this.margey );
+
+       // a.beginPath();
+       // a.rect(0, 0, xmax, ymax);
+       // a.lineWidth = 2;
+       // a.strokeStyle = 'red';
+       // a.stroke();  
+
+//////////////
+       
+       //draw the graph
+       for(i6 in this.tabLines){
+               line6 = this.tabLines[i6];
+               for(j6 in line6.shapes){
+                       shape6 = line6.shapes[j6];
+                       color = shape6.isPageExist ? 'black' : 'red';
+                       if(shape6.isArrow){
+                               shape6.width = $canvas.lwDrawLineArrow(
+                                               shape6.label,
+                                               color,
+                                               shape6.leftx,
+                                               shape6.lefty,
+                                               shape6.rightx,
+                                               shape6.righty,
+                                               true);
+                       }else{
+                               
$canvas.lwDrawRect(shape6.label,color,shape6.centerx,shape6.centery,true);
+                       }
+               }
+       }
+       
+       this.a.restore();
+       
+       //END CONSTRUCTOR
+
+       //FUNCTION
+       //return the shape without the pointer
+       this.getShape= function (x,y){
+               var
+                       i,
+                       line,
+                       j,
+                       shape,
+                       xmin,
+                       xmax,
+                       ymin,
+                       ymax;
+               for(i in this.tabLines){
+                       line = this.tabLines[i];
+                       for(j in line.shapes){
+                               shape = line.shapes[j];
+                               xmin = shape.leftx * this.ratio + this.margex ;
+                               xmax = shape.rightx * this.ratio + this.margex ;
+                               ymin = shape.topy * this.ratio + this.margey ;
+                               ymax = shape.downy * this.ratio + this.margey ;
+                               if(x > xmin && x < xmax && y  > ymin && y < 
ymax ){
+                                       return shape;
+                               }
+                       }
+               }
+               return null;
+       };
+}
+
+
+
 
 $( function () {
+       var
+               $elsCanvas= $('canvas.lwgraph-flow');
        
        function getMousePos(canvas, evt) {
                var rect = canvas.getBoundingClientRect();
@@ -312,33 +376,39 @@
                        };
        }
        
-       var $elsCanvas = $("canvas.lwgraph-flow");
-       
        $elsCanvas.each(function(index, canvas) {
+               var
+                       graphFlow,
+                       mousePos,
+                       shape,
+                       url;
                canvas.width = parseInt($(this).css('width'),10);
                canvas.height =  parseInt($(this).css('height'),10);
                
-               var graphFlow = new lwFlowChart($(this),$(this).text());
+               graphFlow = new lwFlowChart($(this),$(this).text());
                
                canvas.addEventListener('click', function(evt) {
-                               var mousePos = getMousePos(canvas, evt);
-                               var shape = graphFlow.getShape(mousePos.x 
,mousePos.y);
-                               if( shape !== null){
-                                       var url = mw.config.get( 'wgScript' ) + 
'?title=' + encodeURIComponent(shape.title) ;
-                                       if(shape.isPageExist)
-                                               window.location.href = url;
-                                       else
-                                               window.location.href = 
url+"&action=edit&redlink=1";
+                       mousePos = getMousePos(canvas, evt);
+                       shape = graphFlow.getShape(mousePos.x ,mousePos.y);
+                       if( shape !== null){
+                               url = mw.config.get( 'wgScript' ) + '?title=' + 
encodeURIComponent(shape.title) ;
+                               if(shape.isPageExist){
+                                       window.location.href = url;
+                               }else{
+                                       window.location.href = 
url+'&action=edit&redlink=1';
                                }
+                       }
                });
                
                canvas.addEventListener('mousemove', function(evt) {
-                       var mousePos = getMousePos(canvas, evt);
-                       var shape = graphFlow.getShape(mousePos.x ,mousePos.y);
-                       if( shape !== null)
+                       var
+                               mousePos = getMousePos(canvas, evt),
+                               shape = graphFlow.getShape(mousePos.x 
,mousePos.y);
+                       if( shape !== null){
                                $(this).css('cursor', 'pointer');
-                       else
+                       }else{
                                $(this).css('cursor', 'default');
+                       }
                }, false);
        });
-}); 
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/js/lwgraph.js b/js/lwgraph.js
index 9b904bb..eded3fe 100644
--- a/js/lwgraph.js
+++ b/js/lwgraph.js
@@ -1,10 +1,15 @@
+/*global $:false */
 jQuery.fn.lwDrawPolygon = function(shape) {
-       var a = $(this)[0].getContext('2d');
+       var
+               a = $(this)[0].getContext('2d'),
+               p ; //var loop for
        
        a.beginPath();
        a.moveTo(shape[0][0],shape[0][1]);
-       for(var p in shape){
-               if (p > 0) a.lineTo(shape[p][0],shape[p][1]);
+       for(p in shape){
+               if (p > 0){
+                       a.lineTo(shape[p][0],shape[p][1]);
+               }
        }
        a.lineTo(shape[0][0],shape[0][1]);
        a.fill();
@@ -12,8 +17,10 @@
 };
 
 function lwTranslateShape(shape,x,y) {
-       var rv = [];
-       for(var p in shape){
+       var
+               rv = [],
+               p; //var loop for
+       for(p in shape){
                rv.push([ shape[p][0] + x, shape[p][1] + y ]);
        }
        return rv;
@@ -21,16 +28,18 @@
 }
 
 function lwRotateShape(shape,ang) {
-
+       var
+               rv = [],
+               p; //var loop for
+       
        function rotatePoint(ang,x,y) {
-       return [
-               (x * Math.cos(ang)) - (y * Math.sin(ang)),
-               (x * Math.sin(ang)) + (y * Math.cos(ang))
-               ];
+               return [
+                       (x * Math.cos(ang)) - (y * Math.sin(ang)),
+                       (x * Math.sin(ang)) + (y * Math.cos(ang))
+                       ];
        }
 
-       var rv = [];
-       for(var p in shape){
+       for(p in shape){
                rv.push(rotatePoint(ang,shape[p][0],shape[p][1]));
        }
        return rv;
@@ -38,24 +47,30 @@
 }
 
 jQuery.fn.lwDrawLineArrow= function(text,color,x1,y1,x2,y2,draw) {
-       var a = $(this)[0].getContext('2d');
-       var arrow = [
-               [ 2, 0 ],
-               [ -10, -4 ],
-               [ -10, 4]
-               ];
-       var marge = 10 ;
-       var height = 14;
-       var width = 0;
+       var
+               a = $(this)[0].getContext('2d'),
+               arrow = [
+                                       [ 2, 0 ],
+                                       [ -10, -4 ],
+                                       [ -10, 4]
+                               ],
+               marge = 10,
+               height = 14,
+               width = 0,
+               metrics = 0,
+               cx = 0,
+               cy = 0,
+               ang = 0;
+       
        if(text !== null){
                a.save();
 
        a.font = '14px Arial';
-       var metrics = a.measureText(text);
+       metrics = a.measureText(text);
        width = metrics.width;
        
-       var cx = x1 > x2 ? x2 + x1 - x2 : x1 + x2 - x1;
-       var cy = y1 > y2 ? y2 + y1 - y2 : y1 + y2 - y1;
+       cx = x1 > x2 ? x2 + x1 - x2 : x1 + x2 - x1;
+       cy = y1 > y2 ? y2 + y1 - y2 : y1 + y2 - y1;
        //a.translate(x1 - width/2 - marge -5 + x2-x1,y1 - height/2 + y2-y1);
        a.translate(cx- width/2 - marge -5 ,cy - height/2 );
        a.textAlign = 'center';
@@ -69,7 +84,7 @@
                a.moveTo(x1,y1);
                a.lineTo(x2,y2);
                a.stroke();
-               var ang = Math.atan2(y2-y1,x2-x1);
+               ang = Math.atan2(y2-y1,x2-x1);
                
$(this).lwDrawPolygon(lwTranslateShape(lwRotateShape(arrow,ang),x2,y2));
        }
 
@@ -78,19 +93,24 @@
 
 
 jQuery.fn.lwDrawRect= function(text,color,x,y,draw) {
-       var a = $(this)[0].getContext('2d');
-       var rect = 
[[-30,30],[-30,-30],[30,-30],[30,30],[-28,30],[-28,28],[28,28],[28,-28],[-28,-28],[-28,30]];
-       var marge = 15;
+       var
+               a = $(this)[0].getContext('2d'),
+               rect = 
[[-30,30],[-30,-30],[30,-30],[30,30],[-28,30],[-28,28],[28,28],[28,-28],[-28,-28],[-28,30]],
+               marge = 15,
+               height = 20,
+               metrics = 0,
+               width = 0,
+               i;//var loop for
+       
        a.save();
 
        a.translate(x,y);
-       var height = 20;
        a.font = '20px Arial';
-       var metrics = a.measureText(text);
+       metrics = a.measureText(text);
        
-       var width = metrics.width;   
+       width = metrics.width;
        if(draw){
-               for(var i = 0; i < rect.length ; i++){
+               for(i = 0; i < rect.length ; i++){
                        //console.log(rect[i][0]);
                        //console.log(rect[i][1]);
                        rect[i][0] = rect[i][0]>0? rect[i][0] -(30-marge) + 
width/2: rect[i][0]+(30-marge) - width/2 ;
@@ -99,8 +119,8 @@
                $(this).lwDrawPolygon(lwTranslateShape(rect,0,0));
                a.textAlign = 'center';
                a.textBaseline = 'middle';
-               a.fillStyle = color;      
-               a.fillText(text, 0,0); 
+               a.fillStyle = color;
+               a.fillText(text, 0,0);
        }
        a.restore();
 
diff --git a/js/table2CSV.js b/js/table2CSV.js
index d405813..87fc94f 100644
--- a/js/table2CSV.js
+++ b/js/table2CSV.js
@@ -1,64 +1,47 @@
+/*global $:false */
 jQuery.fn.table2CSV = function(pOptions) {
-    var options = jQuery.extend({
-        separator: ',',
-        header: [],
-        delivery: 'popup' // popup, value
-    },
-    pOptions);
-
-    var csvData = [];
-    var headerArr = [];
-    var el = this;
-
-    //header
-    var numCols = options.header.length;
-    var tmpRow = []; // construct header avalible array
-
-    if (numCols > 0) {
-        for (var i = 0; i < numCols; i++) {
-            tmpRow[tmpRow.length] = formatData(options.header[i]);
-        }
-    } else {
-        $(el).filter(':visible').find('th').each(function() {
-            if ($(this).css('display') != 'none') tmpRow[tmpRow.length] = 
formatData($(this).html());
-        });
-    }
-
-    row2CSV(tmpRow);
-
-    // actual data
-    $(el).find('tr').each(function() {
-        var tmpRow = [];
-        $(this).filter(':visible').find('td').each(function() {
-            if ($(this).css('display') != 'none') tmpRow[tmpRow.length] = 
formatData($(this).html());
-        });
-        row2CSV(tmpRow);
-    });
-    if (options.delivery == 'popup') {
-        var mydata1 = csvData.join('\n');
-        return popup(mydata1);
-    } else {
-        var mydata2 = csvData.join('\n');
-        return mydata2;
-    }
-
-    function row2CSV(tmpRow) {
-        var tmp = tmpRow.join(''); // to remove any blank rows
+       var
+               options = jQuery.extend({
+                                                               separator: ',',
+                                                               header: [],
+                                                               delivery: 
'popup' // popup, value
+                                                               },
+                                                               pOptions),
+               csvData = [],
+               //headerArr = [],
+               el = this,
+               numCols = options.header.length, //header
+               tmpRow = [], // construct header avalible array
+               i,//for loop for
+               mydata1,
+               mydata2;
+       
+       // functions*****************************
+       
+       function row2CSV(tmpRow) {
+               var
+                       tmp = tmpRow.join(''), // to remove any blank rows
+                       mystr;
+        
         // alert(tmp);
         if (tmpRow.length > 0 && tmp !== '') {
-            var mystr = tmpRow.join(options.separator);
+            mystr = tmpRow.join(options.separator);
             csvData[csvData.length] = mystr;
         }
     }
+    
     function formatData(input) {
         // replace " with “
-        var regexp1 = new RegExp(/["]/g);
-        var output1 = input.replace(regexp1, "“");
-        //HTML
-        var regexp2 = new RegExp(/\&lt;[^\&lt;]+\&gt;/g);
-        var output2 = output1.replace(regexp2, "");
-        if (output2 === "") return '';
-        return '"' + output2 + '"';
+               var
+                       regexp1 = new RegExp(/["]/g),
+                       output1 = input.replace(regexp1, '“'),
+                       regexp2 = new RegExp('\\&lt;[^\\&lt;]+\\&gt;','g'),
+                       output2 = output1.replace(regexp2, '');
+               
+               if (output2 === ''){
+                       return '';
+                       }
+               return '"' + output2 + '"';
     }
     function popup(data) {
         var generator = window.open('', 'csv', 'height=400,width=600');
@@ -71,20 +54,58 @@
         generator.document.close();
         return true;
     }
+       
+       //constructor****************************
+
+    if (numCols > 0) {
+        for (i = 0; i < numCols; i++) {
+            tmpRow[tmpRow.length] = formatData(options.header[i]);
+        }
+    } else {
+        $(el).filter(':visible').find('th').each(function() {
+                       if ($(this).css('display') !== 'none'){
+                               tmpRow[tmpRow.length] = 
formatData($(this).html());
+                       }
+               });
+    }
+
+    row2CSV(tmpRow);
+
+       // actual data
+       $(el).find('tr').each(function() {
+               var tmpRow = [];
+               $(this).filter(':visible').find('td').each(function() {
+                       if ($(this).css('display') !== 'none'){
+                               tmpRow[tmpRow.length] = 
formatData($(this).html());
+                       }
+               });
+               row2CSV(tmpRow);
+       });
+       if (options.delivery === 'popup') {
+               mydata1 = csvData.join('\n');
+               return popup(mydata1);
+       } else {
+               mydata2 = csvData.join('\n');
+               return mydata2;
+       }
+
 };
 
 $( function () {
-    // This code must not be executed before the document is loaded. 
-    
- //$("div").css("border","9px solid purple");
- 
+       // This code must not be executed before the document is loaded. 
+       //$("div").css("border","9px solid purple");
+
   $('table').each(function() {
-    var $table = $(this);
-    var $l = $table.find(".csv");
-    $l.click(function() {
-       var csv = $table.table2CSV({delivery:'value'});
-       window.location.href = 'data:text/csv;charset=UTF-8,'+
-                               encodeURIComponent(csv);
+       var
+               $table = $(this),
+               $l = $table.find('.csv');
+       
+       $l.click(function() {
+               var csv = $table.table2CSV({delivery:'value'});
+               //remove last line table
+               csv = csv.substring(0, csv.lastIndexOf('\n'));
+               window.location.href = 'data:text/csv;charset=UTF-8,'+
+                                       encodeURIComponent(csv);
        });
     
 //$('#example1').table2CSV({
diff --git a/lib/sparql/Endpoint.php b/lib/sparql/Endpoint.php
index 2005c69..92cb3ed 100644
--- a/lib/sparql/Endpoint.php
+++ b/lib/sparql/Endpoint.php
@@ -144,7 +144,11 @@
        public function query($q, $result_format = '') {        
                $t1 = Endpoint::mtime();
                $response = $this->queryRead($q);
-               xml_parse($this->_parserSparqlResult->getParser(),$response, 
true);             
+               xml_parse($this->_parserSparqlResult->getParser(),$response, 
true);
+               // to find bug during the parsing
+               //$parser = $this->_parserSparqlResult->getParser();
+               //xml_parse($parser,$response, true);
+               //echo "ERROR*************".xml_error_string 
(xml_get_error_code($parser));
                $result = $this->_parserSparqlResult->getResult();
                $result['query_time'] =   Endpoint::mtime() - $t1 ;
                return $result;
diff --git a/lib/sparql/ParserSparqlResult.php 
b/lib/sparql/ParserSparqlResult.php
index 9ed1b69..515dad8 100644
--- a/lib/sparql/ParserSparqlResult.php
+++ b/lib/sparql/ParserSparqlResult.php
@@ -80,7 +80,7 @@
    function contentHandler($parser_object,$data)
    {
                if($this->_cellCurrent != null){
-                  //   echo "DATA". $data." - ".$this->_cellCurrent."\n";
+                       //echo "DATA". $data." - ".$this->_cellCurrent."\n";
                        $this->_value .= $data;
                }
    }

-- 
To view, visit https://gerrit.wikimedia.org/r/83227
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I205974a6f6c60ff764ec48755e97467fe9701965
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LinkedWiki
Gerrit-Branch: master
Gerrit-Owner: Karima Rafes <karima.ra...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to