canvas.on('mouse:down',function(o){mousedown(o,canvas)});
canvas.on('object:moving',function(o){movement(o,canvas)});
+ document.getElementById("fmt").onclick = function(e) {
+ ezformatter(canvas);
+ }
+ document.getElementById("label").onkeypress = function(e) {
+ if(e.key="Enter") {
+ submit()
+ }
+ };
}
return neighbors;
}
+var ezformatter = function(canvas) {
+ var retstr = "";
+ var useedges = document.getElementById("radioedge").checked;
+ var useids = document.getElementById("idlblid").checked;
+ canvas.forEachObject(function(o) {
+ if(useedges && o.type == 'Edge') {
+ console.log("a");
+ if(!useids) {
+ retstr = retstr.concat("("+o.vertices[0].label+
+ ", "+o.vertices[1].label+") ");
+ }
+ else {
+ retstr = retstr.concat("("+o.vertices[0].id+
+ ", "+o.vertices[1].id+") ");
+ }
+ }
+ else if(o.type == 'Vertex') {
+
+
+ }
+ });
+ document.getElementById("results").value = retstr;
+ document.getElementById("results").style.display = "block";
+}
+
+var runformatter = function(canvas) {
+ retstr = "";
+ fstr = document.getElementById("formatstr").value;
+ var in_escape = false;
+ for(i=0;i<fstr.length;i++) {
+ if(in_escape) {
+ if(fstr[i]=='\\') {
+ retstr.push('\\')
+ }
+ else if(fstr[i]=='{') {
+ retstr.push('a');
+ }
+
+ in_escape = false;
+ }
+
+
+ }
+
+ console.log(retstr);
+}
+
var Vertex = fabric.util.createClass(fabric.Circle, {
type: 'Vertex',
initialize: function(options) {
<button onclick="setMode('d')">Remove</button>
</div>
<div id="editor" style="display: none">
- Label: <input id="label" type="text" value=""/>
+ Label:
+ <input id="label" type="text" value=""/>
+ <input id="submitlabel" type="button" value="OK"
+ onclick="submit()" style="display:inline-block"/><br/>
ID: <div style="display:inline-block" id="elementid"></div><br/>
Neighbors: <div id="neighbors"></div><br/>
- <input id="submitlabel" type="button" value="OK" onclick="submit()"/>
+
+ </div>
+ <div id="formatter">
+ Formatter<br/>
+ <input type="radio" name="eorv"
+ id="radiovert">
+ <label for="radiovert">Run on vertices</label>
+ <input type="radio" name="eorv"
+ id="radioedge">
+ <label for="radioedge">Run on edges</label><br/>
+ <input type="radio" name="idolbl"
+ id="idlblid">
+ <label for="idlblid">Use automatically generated IDs</label>
+ <input type="radio" name="idolbl"
+ id="idlbllbl">
+ <label for="idlbllbl">Use user-given labels</label><br/>
+ <textarea name="formatstr" id="formatstr"></textarea><br/>
+ <button id="fmt">Format</button><br/>
+ <textarea name="results" id="results" style="display:none"></textarea>
</div>
</body>
</html>
+
+