-
Undo (Ctrl + Z)
- Redo (Ctrl + Y)
- Save (Ctrl + S)
- Save As
- Export
- Open
+ Undo (Ctrl + Z)
+ Redo (Ctrl + Y)
+ Save (Ctrl + S)
+ Save As
+ Export
+ Open
-
+
-
@@ -38,36 +38,86 @@
-
-
Dark mode, visualisation settings, draw @@init or not, collapse all edges between 2 states, language
+
+
+
+
+
| + General + | +|
|---|---|
| + + | ++ Dark Mode + | +
| + + | ++ Language + | +
| + Visualisation + | +|
| + + | ++ draw @@init or not, collapse all edges between 2 states + | +
+
+
+
+
-
Visualiser & editor for Uni2work workflows
+ Visualiser & editor for Uni2work workflows
-
Search for states, edges and their contents
+ Search for states, edges and their contents
-
+
+
-
+
-
Edge
-
+
Node
@@ -85,7 +135,7 @@
+
Hello
-
+
- New State
+ New State
-
+
- New Edge
+ New Edge
-
+
- New Edge from here
+ New Edge from here
-
+
- New Edge to here
+ New Edge to here
-
+
- Edit
+ Edit
-
+
- Duplicate
+ Duplicate
-
+
- Delete
+ Delete
-
+
- Edit
+ Edit
-
+
- Duplicate
+ Duplicate
-
+
diff --git a/editor.js b/editor.js
index 884af38..fcbbe68 100644
--- a/editor.js
+++ b/editor.js
@@ -1,5 +1,52 @@
-// Menu bar
+//Theme
+var darkMode = false;
+function toggleTheme() {
+ darkMode = !darkMode;
+ console.log('dark mode', darkMode);
+
+ var menus = [mainMenu, sidePanel, filePanel];
+ Array.from(document.getElementsByClassName('menuitem')).forEach(item =>
+ item !== fileMenu &&
+ Array.from(item.getElementsByClassName('submenu')).forEach(subMenu => menus.push(subMenu))
+ );
+ Array.from(fileMenu.children).forEach(child => menus.push(child));
+ Array.from(contextMenuBg.children).forEach(child => menus.push(child));
+ Array.from(contextMenuEd.children).forEach(child => menus.push(child));
+ Array.from(contextMenuSt.children).forEach(child => menus.push(child));
+ Array.from(document.getElementsByClassName('graph-tooltip')).forEach(tooltip => menus.push(tooltip));
+
+ var contentHints = [
+ document.getElementById('filename'),
+ document.getElementById('sidecontentedge'),
+ document.getElementById('sidecontentnode')
+ ];
+
+ if (darkMode) {
+ menus.forEach(target => {
+ target.classList.add('menu-darkmode');
+ target.classList.remove('menu-lightmode');
+ });
+ contentHints.forEach(hint => {
+ hint.classList.add('contenttype-darkmode');
+ hint.classList.remove('contenttype-lightmode');
+ });
+ wfGraph.backgroundColor('black');
+ } else {
+ menus.forEach(target => {
+ target.classList.add('menu-lightmode');
+ target.classList.remove('menu-darkmode');
+ });
+ contentHints.forEach(hint => {
+ hint.classList.add('contenttype-lightmode');
+ hint.classList.remove('contenttype-darkmode');
+ });
+ wfGraph.backgroundColor('white');
+ }
+}
+
+// Menu bar
+const mainMenu = document.getElementById('mainmenu');
var selectedMenuItem = null;
/**
@@ -181,6 +228,9 @@ fetch('http://localhost:8080/index.json')
for (var key in data)
workflow[key] = data[key];
wfGraph(document.getElementById('graph')).graphData({nodes: workflow.states, links: workflow.actions});
+ Array.from(document.getElementsByClassName('graph-tooltip')).forEach(tooltip =>
+ tooltip.classList.add('menu-lightmode')
+ );
runnn();
});
@@ -245,6 +295,7 @@ const sideButtons = document.getElementById('sidebuttons');
const sideInfoEdge = document.getElementById('sidecontentedge');
const sideInfoNode = document.getElementById('sidecontentnode');
//File panel
+const fileMenu = document.getElementById('filemenu');
const filePanel = document.getElementById('filepanel');
const fileHeading = document.getElementById('fileheading');
const fileContent = document.getElementById('filecontent');
@@ -674,10 +725,12 @@ function runnn() {
const edgeColourDefault = '#999999ff';
const edgeColourSelected = '#000000ff';
+const edgeColourSelectedDarkMode = '#ffffffff';
const edgeColourHighlightDefault = '#6ed4d4';
const edgeColourHighlightSelected = 'magenta';
const edgeColourSubtleDefault = '#99999955';
const edgeColourSubtleSelected = '#00000055';
+const edgeColourSubtleSelectedDarkMode = '#ffffff55';
const edgeColourMostSubtle = '#99999944';
/**
@@ -724,9 +777,11 @@ function getEdgeColour(edge) {
} else if (selectedViewer.value !== NO_VIEWER && !isHighlightedViewerEdge(edge)) {
return isSelected ? edgeColourSubtleDefault : edgeColourMostSubtle;
} else if (selectedActor.value !== NO_ACTOR) {
- return isSelected ? edgeColourSubtleSelected : edgeColourSubtleDefault;
+ return isSelected ? (darkMode ? edgeColourSubtleSelectedDarkMode : edgeColourSubtleSelected)
+ : edgeColourSubtleDefault;
} else {
- return isSelected ? edgeColourSelected : edgeColourDefault;
+ return isSelected ? (darkMode ? edgeColourSelectedDarkMode : edgeColourSelected)
+ : edgeColourDefault;
}
}
wfGraph
@@ -807,7 +862,7 @@ function getEdgeColour(edge) {
context.translate(textPos.x, textPos.y);
context.rotate(textAngle);
- context.fillStyle = 'rgba(255, 255, 255, 0.8)';
+ context.fillStyle = darkMode ? 'rgba(0, 0, 0, 0.8)' : 'rgba(255, 255, 255, 0.8)';
context.fillRect(- bckgDimensions[0] / 2, - bckgDimensions[1] / 2, ...bckgDimensions);
context.textAlign = 'center';
@@ -819,7 +874,7 @@ function getEdgeColour(edge) {
.linkLineDash(edge => edge.actionData.mode == 'automatic' && [2, 3]) //[dash, gap]
.linkWidth(edge => (((edge === selection || edge === rightSelection) ? 2 : 0) + (isHighlightedActorEdge(edge) || isHighlightedViewerEdge(edge)) ? 4 : 1))
.linkDirectionalParticles(2)
- .linkDirectionalParticleColor(() => '#00000055')
+ .linkDirectionalParticleColor(() => darkMode ? '#ffffff55' : '#00000055')
.linkDirectionalParticleWidth(edge => (isHighlightedActorEdge(edge)) ? 3 : 0)
.nodeCanvasObject((node, ctx) => {
ctx.fillStyle = getNodeColour(node);
@@ -827,7 +882,7 @@ function getEdgeColour(edge) {
ctx.arc(node.x, node.y, 2*node.val, 0, 2 * Math.PI, false);
ctx.fill();
if (node === selection || node === rightSelection) {
- ctx.strokeStyle = 'black';
+ ctx.strokeStyle = darkMode ? 'white' : 'black';
ctx.lineWidth = 1;
ctx.setLineDash([1, 2]);
ctx.lineCap = 'round';
- Delete
+ Delete