Skip to content

Commit d616d4f

Browse files
committed
Refactoring save-as mfunctions
1 parent f78a5eb commit d616d4f

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

templates/showHierarchy_Template.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,26 +249,14 @@
249249
}
250250

251251
function saveAsDgml() {
252-
const nodeExport = {};
253-
nodes.forEach(node => {
254-
nodeExport[node.id] = {
255-
id: node.id,
256-
label: cleanLabel(node.label),
257-
position: network.getPosition(node.id),
258-
boundingBox: network.getBoundingBox(node.id)
259-
};
260-
});
261-
const direction = hierarchicalOptionsDirectionSelect.value ? hierarchicalOptionsDirectionSelect.value : 'UD';
262-
vscode.postMessage({
263-
command: 'saveAsDgml',
264-
text: JSON.stringify({
265-
nodes: nodeExport,
266-
direction: direction
267-
})
268-
});
252+
postSaveAsCommand('saveAsDgml');
269253
}
270254

271255
function saveAsDot() {
256+
postSaveAsCommand('saveAsDot');
257+
}
258+
259+
function postSaveAsCommand(command) {
272260
const nodeExport = {};
273261
nodes.forEach(node => {
274262
nodeExport[node.id] = {
@@ -280,7 +268,7 @@
280268
});
281269
const direction = hierarchicalOptionsDirectionSelect.value ? hierarchicalOptionsDirectionSelect.value : 'UD';
282270
vscode.postMessage({
283-
command: 'saveAsDot',
271+
command: command,
284272
text: JSON.stringify({
285273
nodes: nodeExport,
286274
direction: direction

0 commit comments

Comments
 (0)