Commit a280eea6 authored by PkSM3's avatar PkSM3

save as ok

parent 278dd127
......@@ -70,17 +70,28 @@
<div id="left" style="margin:0em 2em;">
<ul class="nav navbar-nav">
<li>
<li>
<a>
<button type="button" id="changetype" class="btn btn-primary btn-sm">Change Type</button>
</a>
</li>
<li>
</li>
<!--
<li class="dropdown btn-group">
<button href="#" class="dropdown-toggle btn btn-primary btn-sm" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true">
Scholars <b class="caret"></b>
</button>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Keywords</a></li>
</ul>
</li> -->
<li>
<a>
<button type="button" id="changelevel" class="btn btn-info btn-sm" disabled>Change Level</button>
</a>
</li>
</li>
<!--
<li>
......@@ -208,19 +219,21 @@
<li>
<a href="#" id="geomapicon" onclick="$('#geomapmodal').modal('show'); callGeomap();">
<img width="34px" src="img/world.png"></img>
<img title="World Map Distribution" width="34px" src="img/world.png"></img>
</a>
</li>
<li>
<a href="#" id="statsicon" onclick="$('#statsmodal').modal('show');" >
<img width="34px" src="img/stats.png"></img>
<img title="Network Stats" width="34px" src="img/stats.png"></img>
</a>
</li>
<li>
<a href="#" id="saveAs"><img width="30px" src="img/save.png"></img></a>
<a href="#" id="saveAs">
<img width="30px" title="Save As..." src="img/save.png"></img>
</a>
</li>
<li>
......@@ -257,7 +270,45 @@
</div>
<div id="savemodal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body form-horizontal">
What do you want to save?:
<div class="form-group">
<label class="col-lg-2 control-label"> </label>
<div class="col-lg-10">
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="fullgraph" value="option1" checked="true">
Complete Graph
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="visgraph" value="option2">
Visible Graph
</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button id="closesavemodal" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="saveGraph();">Save File</button>
</div>
</div>
</div>
</div>
<div id="modalloader" class="modal fade">
......@@ -286,6 +337,7 @@
<script src="libs/bootstrap/js/bootstrap.min.js"></script>
<script src="bootswatch/js/bootswatch.js"></script>
<script src="libs/bootstrap/js/bootstrap-modal.js" type="text/javascript"></script>
<script src="libs/bootstrap/js/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="geomap2/js/raphael/raphael-min.js" charset="utf-8" ></script>
......
/**
* @preserve
* Project: Bootstrap Hover Dropdown
* Author: Cameron Spear
* Version: v2.0.10
* Contributors: Mattia Larentis
* Dependencies: Bootstrap's Dropdown plugin, jQuery
* Description: A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
* License: MIT
* Homepage: http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
*/
!function($,n,e){var o=$();$.fn.dropdownHover=function(e){return"ontouchstart"in document?this:(o=o.add(this.parent()),this.each(function(){function t(e){o.find(":focus").blur(),h.instantlyCloseOthers===!0&&o.removeClass("open"),n.clearTimeout(c),i.addClass("open"),r.trigger(a)}var r=$(this),i=r.parent(),d={delay:500,instantlyCloseOthers:!0},s={delay:$(this).data("delay"),instantlyCloseOthers:$(this).data("close-others")},a="show.bs.dropdown",u="hide.bs.dropdown",h=$.extend(!0,{},d,e,s),c;i.hover(function(n){return i.hasClass("open")||r.is(n.target)?void t(n):!0},function(){c=n.setTimeout(function(){i.removeClass("open"),r.trigger(u)},h.delay)}),r.hover(function(n){return i.hasClass("open")||i.is(n.target)?void t(n):!0}),i.find(".dropdown-submenu").each(function(){var e=$(this),o;e.hover(function(){n.clearTimeout(o),e.children(".dropdown-menu").show(),e.siblings().children(".dropdown-menu").hide()},function(){var t=e.children(".dropdown-menu");o=n.setTimeout(function(){t.hide()},h.delay)})})}))},$(document).ready(function(){$('[data-hover="dropdown"]').dropdownHover()})}(jQuery,this);
\ No newline at end of file
......@@ -406,8 +406,8 @@ function theListeners(){
updateMap();
updateDownNodeEvent(false);
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(2,2,2);
$("#saveAs").click(function() {
saveGEXF();
$("#saveAs").click(function() {
$('#savemodal').modal('show');
});
/******************* /SEARCH ***********************/
......
......@@ -534,7 +534,6 @@ function updateLeftPanel_fix() {
$("#information").html(informationDIV);
$("#tips").html("");
// $("#topPapers").show();
}
function printStates() {
......@@ -1450,9 +1449,6 @@ function unHide(id){
}
}
function pushFilterValue(filtername,arg){
lastFilter[filtername] = arg;
}
......@@ -1776,44 +1772,63 @@ function selectOpossites (list){//Expanding selection
partialGraph.draw();
}
function saveGEXF(){
json = '<?xml version="1.0" encoding="UTF-8"?>\n';
json += '<gexf xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gephi.org/gexf/viz" version="1.1">\n';
json += '<graph type="static">';
//json += '<attributes class="node" type="static">\n';
//json += ' <attribute id="0" title="category" type="string"> </attribute>\n';
//json += ' <attribute id="1" title="occurrences" type="float"> </attribute>\n';
//json += ' <attribute id="2" title="content" type="string"> </attribute>\n';
//json += ' <attribute id="3" title="keywords" type="string"> </attribute>\n';
//json += ' <attribute id="4" title="weight" type="float"> </attribute>\n';
//json += '</attributes>\n';
json += '<attributes class="edge" type="float">\n';
json += ' <attribute id="6" title="type" type="string"> </attribute>\n';
json += '</attributes>\n';
json += "<nodes>\n";
nodes = partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden'];
});
edges = partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'];
});
function getByID(elem) {
return document.getElementById(elem);
}
function saveGraph() {
if(getByID("fullgraph").checked) {
saveGEXF ( getnodes() , getedges() );
}
if(getByID("visgraph").checked) {
saveGEXF ( getVisibleNodes() , getVisibleEdges() )
}
$("#closesavemodal").click();
}
function saveGEXF(nodes,edges){
gexf = '<?xml version="1.0" encoding="UTF-8"?>\n';
gexf += '<gexf xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gephi.org/gexf/viz" version="1.1">\n';
gexf += '<graph defaultedgetype="undirected" type="static">\n';
gexf += '<attributes class="node" type="static">\n';
gexf += ' <attribute id="0" title="category" type="string"> </attribute>\n';
gexf += ' <attribute id="1" title="country" type="float"> </attribute>\n';
//gexf += ' <attribute id="2" title="content" type="string"> </attribute>\n';
//gexf += ' <attribute id="3" title="keywords" type="string"> </attribute>\n';
//gexf += ' <attribute id="4" title="weight" type="float"> </attribute>\n';
gexf += '</attributes>\n';
gexf += '<attributes class="edge" type="float">\n';
gexf += ' <attribute id="6" title="type" type="string"> </attribute>\n';
gexf += '</attributes>\n';
gexf += "<nodes>\n";
for(var n in nodes){
json += '<node id="'+nodes[n].id+'" label="'+nodes[n].label+'">\n';
json += '<viz:position x="'+nodes[n].x+'" y="'+nodes[n].y+'" z="0" />\n';
json += '</node>\n';
gexf += '<node id="'+nodes[n].id+'" label="'+nodes[n].label+'">\n';
gexf += ' <viz:position x="'+nodes[n].x+'" y="'+nodes[n].y+'" z="0" />\n';
col = hex2rga(nodes[n].color);
gexf += ' <viz:color r="'+col[0]+'" g="'+col[1]+'" b="'+col[2]+'" a="1"/>\n';
gexf += ' <attvalues>\n';
gexf += ' <attvalue for="0" value="'+nodes[n].type+'"/>\n';
gexf += ' <attvalue for="1" value="'+Nodes[nodes[n].id].CC+'"/>\n';
gexf += ' </attvalues>\n';
gexf += '</node>\n';
}
json += "</nodes\n>";
json += "<edges>\n";
gexf += "\n</nodes>\n";
gexf += "<edges>\n";
cont = 1;
for(var e in edges){
json += '<edge id="'+cont+'" source="'+edges[e].source.id+'" target="'+edges[e].target.id+'" weight="'+edges[e].weight+'">\n';
json += '<attvalues> <attvalue for="6" value="'+edges[e].label+'"/></attvalues>';
json += '</edge>\n';
gexf += '<edge id="'+cont+'" source="'+edges[e].source.id+'" target="'+edges[e].target.id+'" weight="'+edges[e].weight+'">\n';
gexf += '<attvalues> <attvalue for="6" value="'+edges[e].label+'"/></attvalues>';
gexf += '</edge>\n';
cont++;
}
json += "</edges></graph></gexf>";
uriContent = "data:application/octet-stream," + encodeURIComponent(json);
gexf += "\n</edges>\n</graph>\n</gexf>";
uriContent = "data:application/octet-stream," + encodeURIComponent(gexf);
newWindow=window.open(uriContent, 'neuesDokument');
}
......
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