Mercurial > hg > dml-open-cliopatria
comparison cpack/dml/web/js/callgraph.js @ 0:718306e29690 tip
commiting public release
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 21:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:718306e29690 |
---|---|
1 /* Part of DML (Digital Music Laboratory) | |
2 Copyright 2014-2015 Samer Abdallah, University College London | |
3 Distributed under GPL v3 | |
4 */ | |
5 | |
6 /* clears the graph display element */ | |
7 function clear_output() { $('#output').html(''); } | |
8 | |
9 /* Following are three different ways to load a pan/zoom enabled SVG | |
10 * element into the #output element. */ | |
11 | |
12 /* USING JQUERY: loads SVG content from a URL into an element identified | |
13 * by a jQuery selector. Pan/Zoom controls are then enabled for the SVG element. */ | |
14 function load_svg(sel,url) { | |
15 target=$(sel); | |
16 target.load(url, function () { | |
17 console.log("SVG loaded"); | |
18 svg=target.find('svg'); | |
19 svg.attr('width','100%').attr('height','100%'); | |
20 svgPanZoom(svg.get(0),{ | |
21 zoomEnabled: true, | |
22 controlIconsEnabled: true, | |
23 fit: true, | |
24 center: true | |
25 }); | |
26 }); | |
27 } | |
28 | |
29 /* USING OBJECT element. No good. */ | |
30 function load_object(sel,url) { | |
31 console.log(url); | |
32 var obj=$('<object id="obj" width="100%" height="100%" type="image/svg+xml" data="'+url+'"></object>'); | |
33 $('#output').html(obj); | |
34 // cannot get hold of SVG element here for some reason... | |
35 // var svg=obj.get(0).contentDocument.getElementsByTagName('svg')[0]; | |
36 } | |
37 | |
38 /* Using SVG element with xlink:href attribute to link to content | |
39 * This does not seem so good for some reason... */ | |
40 function load_svg_href(sel,url) { | |
41 var svg=$('<svg id="svg" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><image x="0" y="0" width="100%" height="100%" xlink:href="'+url+'"></image></svg>'); | |
42 sel.html(svg); | |
43 svgPanZoom('#svg',{ | |
44 zoomEnabled: true, | |
45 controlIconsEnabled: true, | |
46 fit: true, | |
47 center: true | |
48 }); | |
49 } | |
50 | |
51 /* Gets module name from #module and loads callgraph into #output */ | |
52 function update_svg(loc) { | |
53 var module=$('#module').val(); | |
54 load_svg('#output',loc+"?format=svg&module="+module); | |
55 } |