forked from gayanvirajith/harmony
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathxml-example.html
More file actions
14 lines (14 loc) · 1.34 KB
/
xml-example.html
File metadata and controls
14 lines (14 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html><html><script src="bower_components/yjs/y.es6"></script><script src="bower_components/jquery/dist/jquery.min.js"></script><script src="bower_components/yjs/Examples/Xml/index.js"></script><body><h1>Shared DOM Example</h1><p>Use native DOM function or jQuery to manipulate the shared DOM (window.sharedDom). <a href="https://github.com/y-js/yjs/tree/f21e1c549a12275c36980fe6d117fa1589f1ff69/Examples/Xml" target="_blank"><Source Code></a></p><div class="command"><button type="button">Execute</button> <input type="text" value='$(sharedDom).append("<h3>Appended headline</h3>")' size="40"></div><div class="command"><button type="button">Execute</button> <input type="text" value='$(sharedDom).attr("align","right")' size="40"></div><div class="command"><button type="button">Execute</button> <input type="text" value='$(sharedDom).attr("style","color:blue;")' size="40"></div><script>
var commands = document.querySelectorAll(".command");
Array.prototype.forEach.call(document.querySelectorAll('.command'), function (command) {
var execute = function(){
eval(command.querySelector("input").value);
}
command.querySelector("button").onclick = execute
$(command.querySelector("input")).keyup(function (e) {
if (e.keyCode == 13) {
execute()
}
})
})
</script></body></html>