Daniel@0: /* Part of DML (Digital Music Laboratory)
Daniel@0: Copyright 2014-2015 Samer Abdallah, University College London
Daniel@0: Distributed under GPL v3
Daniel@0: */
Daniel@0:
Daniel@0: /* clears the graph display element */
Daniel@0: function clear_output() { $('#output').html(''); }
Daniel@0:
Daniel@0: /* Following are three different ways to load a pan/zoom enabled SVG
Daniel@0: * element into the #output element. */
Daniel@0:
Daniel@0: /* USING JQUERY: loads SVG content from a URL into an element identified
Daniel@0: * by a jQuery selector. Pan/Zoom controls are then enabled for the SVG element. */
Daniel@0: function load_svg(sel,url) {
Daniel@0: target=$(sel);
Daniel@0: target.load(url, function () {
Daniel@0: console.log("SVG loaded");
Daniel@0: svg=target.find('svg');
Daniel@0: svg.attr('width','100%').attr('height','100%');
Daniel@0: svgPanZoom(svg.get(0),{
Daniel@0: zoomEnabled: true,
Daniel@0: controlIconsEnabled: true,
Daniel@0: fit: true,
Daniel@0: center: true
Daniel@0: });
Daniel@0: });
Daniel@0: }
Daniel@0:
Daniel@0: /* USING OBJECT element. No good. */
Daniel@0: function load_object(sel,url) {
Daniel@0: console.log(url);
Daniel@0: var obj=$('');
Daniel@0: $('#output').html(obj);
Daniel@0: // cannot get hold of SVG element here for some reason...
Daniel@0: // var svg=obj.get(0).contentDocument.getElementsByTagName('svg')[0];
Daniel@0: }
Daniel@0:
Daniel@0: /* Using SVG element with xlink:href attribute to link to content
Daniel@0: * This does not seem so good for some reason... */
Daniel@0: function load_svg_href(sel,url) {
Daniel@0: var svg=$('');
Daniel@0: sel.html(svg);
Daniel@0: svgPanZoom('#svg',{
Daniel@0: zoomEnabled: true,
Daniel@0: controlIconsEnabled: true,
Daniel@0: fit: true,
Daniel@0: center: true
Daniel@0: });
Daniel@0: }
Daniel@0:
Daniel@0: /* Gets module name from #module and loads callgraph into #output */
Daniel@0: function update_svg(loc) {
Daniel@0: var module=$('#module').val();
Daniel@0: load_svg('#output',loc+"?format=svg&module="+module);
Daniel@0: }