diff --git a/script/Appilcation.js b/script/Appilcation.js
index fb71077..0a83b21 100644
--- a/script/Appilcation.js
+++ b/script/Appilcation.js
@@ -1474,20 +1474,12 @@ Application.prototype.LoadUserSettings = function(json)
Application.prototype.EncodeToHTML = function (str)
{
- return str.replace(/&/g, '&')
- .replace(//g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''');
+ return gEncodeToHTML(str);
}
Application.prototype.DecodeFromHTML = function (str)
{
- return str.replace(/'/g, "'")
- .replace(/"/g, '"')
- .replace(/>/g, '>')
- .replace(/</g, '<')
- .replace(/&/g, '&');
+ return gDecodeFromHTML(str);
}
Application.prototype.SetVertexStyle = function (index, style)
diff --git a/script/BaseEdge.js b/script/BaseEdge.js
index 6f0569f..ea6d745 100755
--- a/script/BaseEdge.js
+++ b/script/BaseEdge.js
@@ -54,8 +54,8 @@ BaseEdge.prototype.SaveToXML = function ()
"weight=\"" + this.weight + "\" " +
"useWeight=\"" + this.useWeight + "\" " +
"id=\"" + this.id + "\" " +
- "text=\"" + this.text + "\" " +
- "upText=\"" + this.upText + "\" " +
+ "text=\"" + gEncodeToHTML(this.text) + "\" " +
+ "upText=\"" + gEncodeToHTML(this.upText) + "\" " +
"arrayStyleStart=\"" + this.arrayStyleStart + "\" " +
"arrayStyleFinish=\"" + this.arrayStyleFinish + "\" " +
this.model.SaveToXML() +
@@ -85,7 +85,7 @@ BaseEdge.prototype.LoadFromXML = function (xml, graph)
this.hasPair = xml.attr('hasPair') == "true";
this.useWeight = xml.attr('useWeight') == "true";
this.id = xml.attr('id');
- this.text = xml.attr("text") == null ? "" : xml.attr("text");
+ this.text = xml.attr("text") == null ? "" : gDecodeFromHTML(xml.attr("text"));
this.arrayStyleStart = xml.attr("arrayStyleStart") == null ? "" : xml.attr("arrayStyleStart");
this.arrayStyleFinish = xml.attr("arrayStyleFinish") == null ? "" : xml.attr("arrayStyleFinish");
this.upText = xml.attr('upText');
@@ -93,6 +93,10 @@ BaseEdge.prototype.LoadFromXML = function (xml, graph)
{
this.upText = "";
}
+ else
+ {
+ this.upText = gDecodeFromHTML(this.upText);
+ }
this.model.LoadFromXML(xml);
}
diff --git a/script/BaseVertex.js b/script/BaseVertex.js
index e6ef0c2..c1ed4c8 100755
--- a/script/BaseVertex.js
+++ b/script/BaseVertex.js
@@ -34,8 +34,8 @@ BaseVertex.prototype.SaveToXML = function ()
"positionX=\"" + this.position.x + "\" " +
"positionY=\"" + this.position.y + "\" " +
"id=\"" + this.id + "\" " +
- "mainText=\"" + this.mainText + "\" " +
- "upText=\"" + this.upText + "\" " +
+ "mainText=\"" + gEncodeToHTML(this.mainText) + "\" " +
+ "upText=\"" + gEncodeToHTML(this.upText) + "\" " +
">";
}
@@ -52,8 +52,13 @@ BaseVertex.prototype.LoadFromXML = function (xml)
if (typeof this.mainText === 'undefined')
this.mainText = this.id;
+ else
+ this.mainText = gDecodeFromHTML(this.mainText);
+
if (typeof this.upText === 'undefined')
this.upText = "";
+ else
+ this.upText = gDecodeFromHTML(this.upText);
}
BaseVertex.prototype.SetId = function (id)
diff --git a/script/merge.php b/script/merge.php
index 5fbec94..489ed82 100755
--- a/script/merge.php
+++ b/script/merge.php
@@ -3,6 +3,7 @@ $outputFilename = 'example.js';
unlink($outputFilename);
+file_put_contents($outputFilename, file_get_contents("utils.js"), FILE_APPEND);
file_put_contents($outputFilename, file_get_contents("texts.js"), FILE_APPEND);
file_put_contents($outputFilename, file_get_contents("point.js"), FILE_APPEND);
file_put_contents($outputFilename, file_get_contents("EdgeModel.js"), FILE_APPEND);
diff --git a/script/utils.js b/script/utils.js
new file mode 100644
index 0000000..f5bff40
--- /dev/null
+++ b/script/utils.js
@@ -0,0 +1,18 @@
+
+function gEncodeToHTML(str)
+{
+ return str.replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
+function gDecodeFromHTML(str)
+{
+ return str.replace(/'/g, "'")
+ .replace(/"/g, '"')
+ .replace(/>/g, '>')
+ .replace(/</g, '<')
+ .replace(/&/g, '&');
+}
diff --git a/tpl/home.php b/tpl/home.php
index a3973b4..cf34569 100755
--- a/tpl/home.php
+++ b/tpl/home.php
@@ -10,7 +10,7 @@
-
+