-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Two pages json.html and objects.html #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>flowchart.js · Playground</title> | ||
<style type="text/css"> | ||
.end-element { background-color : #FFCCFF; } | ||
</style> | ||
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script> | ||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | ||
<!--<script src="http://flowchart.js.org/flowchart-latest.js"></script>--> | ||
<script src="../release/flowchart.js"></script> | ||
<script> | ||
|
||
window.onload = function () { | ||
var btn = document.getElementById("run"), | ||
cd = document.getElementById("code"), | ||
chart; | ||
|
||
(btn.onclick = function () { | ||
var code = cd.value; | ||
|
||
if (chart) { | ||
chart.clean(); | ||
} | ||
|
||
|
||
|
||
var data = JSON.parse(code); | ||
|
||
var symbols=data.symbols; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing/formatting |
||
var directions=data.directions; | ||
|
||
|
||
var symbolsArray ={}; | ||
for(var key in symbols) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going with this C style curly braces? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bad idea in JavaScript. Every newLine triggers a “Should a ; be auto inserted. In compiled languages like C and Java the position of the { is a question of taste (and a source of religious wars second only to tabs vs spaces). In JavaScript it matters. Keep them at line end. |
||
var symbol=symbols[key]; | ||
symbolsArray[symbol.key]=symbol; | ||
} | ||
|
||
|
||
var directionsArray = {}; | ||
|
||
for(var key in directions) | ||
{ | ||
var direction=directions[key]; | ||
directionsArray[direction.key+"_"+direction.nextKey+"_"+direction.next]=direction; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make a note of these extra spaces and formatting between expressions. |
||
|
||
chart = flowchart.parseObject(symbolsArray, directionsArray); | ||
|
||
|
||
chart.drawSVG('canvas', { | ||
// 'x': 30, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove dead code |
||
// 'y': 50, | ||
'line-width': 3, | ||
'line-length': 50, | ||
'text-margin': 10, | ||
'font-size': 14, | ||
'font': 'normal', | ||
'font-family': 'Helvetica', | ||
'font-weight': 'normal', | ||
'font-color': 'black', | ||
'line-color': 'black', | ||
'element-color': 'black', | ||
'fill': 'white', | ||
'yes-text': 'yes', | ||
'no-text': 'no', | ||
'arrow-end': 'block', | ||
'scale': 1, | ||
'symbols': { | ||
'start': { | ||
'font-color': 'red', | ||
'element-color': 'green', | ||
'fill': 'yellow' | ||
}, | ||
'end':{ | ||
'class': 'end-element' | ||
} | ||
}, | ||
'flowstate' : { | ||
'past' : { 'fill' : '#CCCCCC', 'font-size' : 12}, | ||
'current' : {'fill' : 'yellow', 'font-color' : 'red', 'font-weight' : 'bold'}, | ||
'future' : { 'fill' : '#FFFF99'}, | ||
'request' : { 'fill' : 'blue'}, | ||
'invalid': {'fill' : '#444444'}, | ||
'approved' : { 'fill' : '#58C4A3', 'font-size' : 12, 'yes-text' : 'APPROVED', 'no-text' : 'n/a' }, | ||
'rejected' : { 'fill' : '#C45879', 'font-size' : 12, 'yes-text' : 'n/a', 'no-text' : 'REJECTED' } | ||
} | ||
}); | ||
|
||
$('[id^=sub1]').click(function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly is this supposed to do? |
||
alert('info here'); | ||
}); | ||
})(); | ||
|
||
}; | ||
</script> | ||
</head> | ||
<body> | ||
<div><textarea id="code" style="width: 100%;" rows="11"> | ||
{ | ||
"symbols":[ | ||
{ | ||
"key":"st", | ||
"symbolType":"start", | ||
"text":"Start", | ||
"link":"http://www.google.com", | ||
"target":"blank", | ||
"flowstate":"past" | ||
}, | ||
{ | ||
"key":"e", | ||
"symbolType":"end", | ||
"text":"End", | ||
"link":"http://www.google.com", | ||
"target":null, | ||
"flowstate":null | ||
}, | ||
{ | ||
"key":"op1", | ||
"symbolType":"operation", | ||
"text":"My Operation", | ||
"link":null, | ||
"target":null, | ||
"flowstate":"past" | ||
}, | ||
{ | ||
"key":"op2", | ||
"symbolType":"operation", | ||
"text":"Stuff", | ||
"link":null, | ||
"target":null, | ||
"flowstate":"current" | ||
}, | ||
{ | ||
"key":"sub1", | ||
"symbolType":"subroutine", | ||
"text":"My Subroutine", | ||
"link":null, | ||
"target":null, | ||
"flowstate":"invalid" | ||
}, | ||
{ | ||
"key":"cond", | ||
"symbolType":"condition", | ||
"text":"Yes or No?", | ||
"link":"http://www.google.com", | ||
"target":null, | ||
"flowstate":"approved" | ||
}, | ||
{ | ||
"key":"c2", | ||
"symbolType":"condition", | ||
"text":"Good idea", | ||
"link":null, | ||
"target":null, | ||
"flowstate":"rejected" | ||
}, | ||
{ | ||
"key":"io", | ||
"symbolType":"inputoutput", | ||
"text":"catch something...", | ||
"link":null, | ||
"target":null, | ||
"flowstate":"request" | ||
} | ||
], | ||
"directions":[ | ||
{ | ||
"key":"st", | ||
"symbolType":"start", | ||
"nextKey":"op1", | ||
"nextSymbolType":"operation", | ||
"next":"next", | ||
"direction":null | ||
}, | ||
{ | ||
"key":"op1", | ||
"symbolType":"operation", | ||
"nextKey":"cond", | ||
"nextSymbolType":"condition", | ||
"next":"next", | ||
"direction":"right" | ||
}, | ||
{ | ||
"key":"cond", | ||
"symbolType":"condition", | ||
"nextKey":"c2", | ||
"nextSymbolType":"condition", | ||
"next":"yes", | ||
"direction":"right" | ||
}, | ||
{ | ||
"key":"cond", | ||
"symbolType":"condition", | ||
"nextKey":"sub1", | ||
"nextSymbolType":"subroutine", | ||
"next":"no", | ||
"direction":null | ||
}, | ||
{ | ||
"key":"sub1", | ||
"symbolType":"subroutine", | ||
"nextKey":"op1", | ||
"nextSymbolType":"operation", | ||
"next":"next", | ||
"direction":"left" | ||
}, | ||
{ | ||
"key":"c2", | ||
"symbolType":"condition", | ||
"nextKey":"io", | ||
"nextSymbolType":"inputoutput", | ||
"next":"yes", | ||
"direction":null | ||
}, | ||
{ | ||
"key":"io", | ||
"symbolType":"inputoutput", | ||
"nextKey":"e", | ||
"nextSymbolType":"end", | ||
"next":"next", | ||
"direction":null | ||
}, | ||
{ | ||
"key":"c2", | ||
"symbolType":"condition", | ||
"nextKey":"op2", | ||
"nextSymbolType":"operation", | ||
"next":"no", | ||
"direction":null | ||
}, | ||
{ | ||
"key":"op2", | ||
"symbolType":"operation", | ||
"nextKey":"e", | ||
"nextSymbolType":"end", | ||
"next":"next", | ||
"direction":null | ||
} | ||
] | ||
} | ||
</textarea></div> | ||
<div><button id="run" type="button">Run</button></div> | ||
<div id="canvas"></div> | ||
</body> | ||
</html> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're already putting these on their own lines just declare the "var" for each. Makes your intentions a little clearer.