From 3df5507589e09b9ec75fb1f8e0c750c6590fc003 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Thu, 2 Feb 2017 23:27:34 +0800 Subject: Upgrade viz.js to fix manual workaround and get smaller file size --- public/js/extra.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'public/js') diff --git a/public/js/extra.js b/public/js/extra.js index b651d9e6..b0a4bdcb 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -345,30 +345,21 @@ export function finishView(view) { }); //graphviz var graphvizs = view.find("div.graphviz.raw").removeClass("raw"); - function parseGraphviz(key, value) { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var graphviz = Viz($value.text()); - if (!graphviz) throw Error('viz.js output empty graph'); - $value.html(graphviz); - - $ele.addClass('graphviz'); - $value.children().unwrap().unwrap(); - } graphvizs.each(function (key, value) { try { - parseGraphviz(key, value); + var $value = $(value); + var $ele = $(value).parent().parent(); + + var graphviz = Viz($value.text()); + if (!graphviz) throw Error('viz.js output empty graph'); + $value.html(graphviz); + + $ele.addClass('graphviz'); + $value.children().unwrap().unwrap(); } catch (err) { - // workaround for graphviz not recover from error - try { - parseGraphviz(key, value); - } catch (err) { - var $value = $(value); - $value.unwrap(); - $value.parent().append('