Add remove node support.

This commit is contained in:
Paulo Veiga
2011-09-11 00:07:43 -03:00
parent c1e0d52ff5
commit 5a08728686
11 changed files with 69 additions and 149 deletions

View File

@@ -8,40 +8,41 @@
app.addListener('modelLoad', function(model) {
var root = app.getModel().getRoot();
if (!root.get("mindmap7")) {
console.log("Creating empty map ...");
// var topics = app.getModel().create("List");
root.put("mindmap7", "start_");
var myList = root.get("myList");
if (!myList) {
myList = app.getModel().create("List");
root.put("myList", myList);
}
root.addListener('valueChanged', function(e) {
console.log("New item added ...:");
console.log(app.getModel().getRoot().get("mindmap7"));
myList.addListener('valuesAdded', function(event) {
console.log("value added:" + myList.size());
});
myList.addListener('valuesRemoved', function(event) {
console.log("value removed:" + myList.size());
});
});
removedAction = function() {
var root = app.getModel().getRoot();
var myList = root.get("myList");
myList.remove(myList.size() - 1);
};
addAction = function() {
var root = app.getModel().getRoot();
var myList = root.get("myList");
myList.add("Some elem " + myList.size());
console.log("Click on adding...");
};
};
function addTopic() {
console.log("Adding new item ver:2 ...");
var root = app.getModel().getRoot();
var topics = root.get("mindmap7");
// var topic = app.getModel().create("Map");
// topic.put("id", "topic_x");
// topic.put("text", "topic X text");
// topics.add(topic);
// root.put("mindmap7", topics);
root.put("mindmap7", app.getModel().getRoot().get("mindmap7") + "_algo");
}
</script>
Este es este no ?
<input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a2" onclick="addTopic(this)"/>
Funca?
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Add" id="a2" onclick="addAction(this)"/>
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Remove" id="a2"
onclick="removedAction(this)"/>
</body>
</html>

View File

@@ -11,18 +11,12 @@
<title>WiseMapping - Editor </title>
<link rel="stylesheet" type="text/css" href="../css/editor.css"/>
<link rel="stylesheet" type="text/css" href='/mindplot/src/main/javascript/libraries/moodialog/css/MooDialog.css'/>
<!--<script type='text/javascript' src='../js/wiseLibrary.js'></script>-->
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
<script type='text/javascript' src='../js/mootools-more-1.3.2.1-yui.js'></script>
<!--<script type='text/javascript' src='../js/common.js'></script>-->
<!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>-->
<script type='text/javascript' src='/core-js/target/classes/core.js'></script>
<!--<script type='text/javascript' src='js/core-min.js'></script>-->
<script type="text/javascript">

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML>
!DOCTYPE HTML>
<html>
<head>
@@ -22,8 +22,6 @@
}
};
$("someId").addEvent("click", function(event) {
$("someId").fireEvent("wiseNodeAdded",null)
});

View File

@@ -1,80 +0,0 @@
<html>
<body>
<script type="text/javascript" src="http://docs.google.com/brix/static/api/js/jsapi.nocache.js"></script>
<script type="text/javascript">
var app;
collabOnLoad = function() {
app = new goog.collab.CollaborativeApp();
app.start();
app.addListener('modelLoad', function(model) {
var root = app.getModel().getRoot();
if (root.isEmpty()) {
root.put("a1", ' ');
root.put("a2", " ");
root.put("a3", " ");
root.put("b1", " ");
root.put("b2", " ");
root.put("b3", " ");
root.put("c1", " ");
root.put("c2", " ");
root.put("c3", " ");
root.put("turn", "X");
}
var list1 = app.getModel().create("List");
root.put("list",list1);
document.getElementById("a1").value = root.get("a1");
document.getElementById("a2").value = root.get("a2");
document.getElementById("a3").value = root.get("a3");
document.getElementById("b1").value = root.get("b1");
document.getElementById("b2").value = root.get("b2");
document.getElementById("b3").value = root.get("b3");
document.getElementById("c1").value = root.get("c1");
document.getElementById("c2").value = root.get("c2");
document.getElementById("c3").value = root.get("c3");
relabelTurn(root.get("turn"));
root.addListener('valueChanged', function(e) {
document.getElementById(e.getProperty()).value = e.getNewValue();
relabelTurn(root.get("turn"));
});
});
};
function move(square) {
app.getModel().getRoot().put(square.id, app.getModel().getRoot().get("turn"));
var turn = app.getModel().getRoot().get("turn") == "X" ? "O" : "X";
app.getModel().getRoot().put("turn", turn);
relabelTurn(app.getModel().getRoot().get("turn"));
app.getModel().getRoot().get("list").add(turn);
}
function relabelTurn(turn) {
document.getElementById("turn").innerHTML = "Next move is: " + turn;
}
</script>
<p>
TIC TAC TOE!
<p>
<span id=turn></span>
<table>
<tr>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a1" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b1" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c1" onclick="move(this)"></td>
</tr>
<tr>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a2" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b2" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c2" onclick="move(this)"></td>
</tr>
<tr>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="a3" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="b3" onclick="move(this)"></td>
<td><input style="font-size:20px;width:50px;height:50px;" type="button" value=" " id="c3" onclick="move(this)"></td>
</tr>
</table>
</body>
</html>

View File

@@ -237,7 +237,7 @@ if (localEnv) {
}
});
} else {
Asset.javascript("../js/mindplot.svg.js", {
Asset.javascript("../js/mindplot-min.js", {
onLoad:function() {
$(document).fireEvent('loadcomplete', 'mind')
}