Commit 711ec228 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

beautify HTML ans javascript.

parent cc4b1072
...@@ -27,9 +27,13 @@ ...@@ -27,9 +27,13 @@
<a id="zoom_in">Zoom +</a> <a id="zoom_in">Zoom +</a>
<a id="zoom_out">Zoom -</a> <a id="zoom_out">Zoom -</a>
<a id="export">Export</a> <a id="export">Export</a>
<form id="export_form" style="display:none" method="post" action="/postJSONData"><textarea id="export_json" name="data"></textarea></form> <form id="export_form" style="display:none" method="post" action="/postJSONData">
<textarea id="export_json" name="data"></textarea>
</form>
<a id="import">Import</a> <a id="import">Import</a>
<form id="import_form" style="display:none"><input id="import_file" name="file" type="file"></input></form> <form id="import_form" style="display:none">
<input id="import_file" name="file" type="file"></input>
</form>
</div> </div>
</div> </div>
......
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
box_left, box_top); box_left, box_top);
// find an unused ID // find an unused ID
var n = 1; var n = 1;
while ($('#'+tool.target.id+'_'+n).length > 0) { while ($('#' + tool.target.id + '_' + n).length > 0) {
n += 1; n += 1;
} }
_class = tool.target.id.replace('-', '.'); // XXX - vs . _class = tool.target.id.replace('-', '.'); // XXX - vs .
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
} }
}); });
var loadData = function(data) { var loadData = function (data) {
var preference = data.preference !== undefined ? var preference = data.preference !== undefined ?
data.preference : {}; data.preference : {};
dream_instance.setPreferences(preference); dream_instance.setPreferences(preference);
...@@ -271,7 +271,10 @@ ...@@ -271,7 +271,10 @@
var coordinates = preference['coordinates']; var coordinates = preference['coordinates'];
$.each(data.nodes, function (key, value) { $.each(data.nodes, function (key, value) {
if (coordinates === undefined || coordinates[key] === undefined) { if (coordinates === undefined || coordinates[key] === undefined) {
value['coordinate'] = {'top':0.0, 'left':0.0}; value['coordinate'] = {
'top': 0.0,
'left': 0.0
};
} else { } else {
value['coordinate'] = coordinates[key]; value['coordinate'] = coordinates[key];
} }
...@@ -367,8 +370,8 @@ ...@@ -367,8 +370,8 @@
otherwise we have a mapping avg, min max */ otherwise we have a mapping avg, min max */
if (obj.results.blockage_ratio !== undefined) { if (obj.results.blockage_ratio !== undefined) {
blockage_data.push([counter, obj.results.blockage_ratio blockage_data.push([counter, obj.results.blockage_ratio
.avg || obj.results.blockage_ratio .avg || obj.results.blockage_ratio
]); ]);
} else { } else {
blockage_data.push([counter, 0.0]); blockage_data.push([counter, 0.0]);
} }
...@@ -377,8 +380,8 @@ ...@@ -377,8 +380,8 @@
]); ]);
if (obj.results.failure_ratio !== undefined) { if (obj.results.failure_ratio !== undefined) {
failure_data.push([counter, obj.results.failure_ratio failure_data.push([counter, obj.results.failure_ratio
.avg || obj.results.failure_ratio .avg || obj.results.failure_ratio
]); ]);
} else { } else {
failure_data.push([counter, 0.0]); failure_data.push([counter, 0.0]);
} }
...@@ -471,7 +474,7 @@ ...@@ -471,7 +474,7 @@
function (e) { function (e) {
$('#import_file').click(); $('#import_file').click();
}); });
$("#import_file").change(function() { $("#import_file").change(function () {
var form = $(this).parent('form')[0]; var form = $(this).parent('form')[0];
var form_data = new FormData(form); var form_data = new FormData(form);
$.ajax('/postJSONFile', { $.ajax('/postJSONFile', {
...@@ -480,10 +483,10 @@ ...@@ -480,10 +483,10 @@
processData: false, processData: false,
data: form_data, data: form_data,
dataType: 'json', dataType: 'json',
error: function() { error: function () {
console.log('error'); console.log('error');
}, },
success: function(data, textStatus, jqXHR) { success: function (data, textStatus, jqXHR) {
form.reset(); form.reset();
dream_instance.clearAll(); dream_instance.clearAll();
$("#json_output").val(JSON.stringify(data)); $("#json_output").val(JSON.stringify(data));
...@@ -507,7 +510,7 @@ ...@@ -507,7 +510,7 @@
loadData(JSON.parse($("#json_output").val())); loadData(JSON.parse($("#json_output").val()));
}); });
$("#graph_zone").hide(); $("#graph_zone").hide();
}); });
})(jQuery); })(jQuery);
...@@ -89,8 +89,7 @@ ...@@ -89,8 +89,7 @@
} else { } else {
priv.edge_container[connection.id] = [ priv.edge_container[connection.id] = [
connection.sourceId, connection.sourceId,
connection.targetId, connection.targetId, {}
{}
]; ];
} }
priv.onDataChange(); priv.onDataChange();
...@@ -137,7 +136,7 @@ ...@@ -137,7 +136,7 @@
} }
}; };
priv.convertToAbsolutePosition = function(x, y) { priv.convertToAbsolutePosition = function (x, y) {
var canvas_size_x = $('#main').width(); var canvas_size_x = $('#main').width();
var canvas_size_y = $('#main').height(); var canvas_size_y = $('#main').height();
var node_style = priv.preference_container['node_style']; var node_style = priv.preference_container['node_style'];
...@@ -154,7 +153,7 @@ ...@@ -154,7 +153,7 @@
return [left, top]; return [left, top];
}; };
that.convertToRelativePosition = function(x, y) { that.convertToRelativePosition = function (x, y) {
var canvas_size_x = $('#main').width(); var canvas_size_x = $('#main').width();
var canvas_size_y = $('#main').height(); var canvas_size_y = $('#main').height();
var size_x = $('.window').width(); var size_x = $('.window').width();
...@@ -199,7 +198,8 @@ ...@@ -199,7 +198,8 @@
}; };
priv.style_attr_list = ['width', 'height', 'font-size', 'padding-top', priv.style_attr_list = ['width', 'height', 'font-size', 'padding-top',
'line-height']; 'line-height'
];
that.positionGraph = function () { that.positionGraph = function () {
$.ajax( $.ajax(
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
"general": priv.general_container "general": priv.general_container
}; };
if ($.sheet.instance !== undefined) { if ($.sheet.instance !== undefined) {
data['spreadsheet'] = $.sheet.instance[0].exportSheet.json(); data['spreadsheet'] = $.sheet.instance[0].exportSheet.json();
} }
return data; return data;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment