mirror of
https://github.com/UnickSoft/graphonline.git
synced 2025-08-16 16:16:19 +00:00
Fix bug with text for nodes. Add escaping symbols.
This commit is contained in:
parent
f068ee2a32
commit
475f4ea88b
@ -1474,20 +1474,12 @@ Application.prototype.LoadUserSettings = function(json)
|
||||
|
||||
Application.prototype.EncodeToHTML = function (str)
|
||||
{
|
||||
return str.replace(/&/g, '&')
|
||||
.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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) + "\" " +
|
||||
"></node>";
|
||||
|
||||
}
|
||||
@ -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)
|
||||
|
@ -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);
|
||||
|
18
script/utils.js
Normal file
18
script/utils.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
function gEncodeToHTML(str)
|
||||
{
|
||||
return str.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function gDecodeFromHTML(str)
|
||||
{
|
||||
return str.replace(/'/g, "'")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<')
|
||||
.replace(/&/g, '&');
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
|
||||
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
|
||||
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
|
||||
<script src="<?= Root("script/example.js?v=29")?>" ></script>
|
||||
<script src="<?= Root("script/example.js?v=30")?>" ></script>
|
||||
</head>
|
||||
<!--
|
||||
<div class="pull-right">
|
||||
|
Loading…
x
Reference in New Issue
Block a user