Skip to content

Instantly share code, notes, and snippets.

@stagas
Created April 23, 2011 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stagas/939047 to your computer and use it in GitHub Desktop.
Save stagas/939047 to your computer and use it in GitHub Desktop.
dquery
var dnode = require('dnode')
, express = require('express')
, app = express.createServer()
app.use(express.static(__dirname))
app.listen(8080)
console.log('http://localhost:8080/')
var server = dnode(function(remote, conn) {
this.click = function() {
var $ = remote.$
$(function() {
$('body').append('world.')
}.toString())
}
})
server.listen(app, function(remote, conn) {
var $ = remote.$
$(function() {
$('body').append('Hello, ')
}.toString())
})
<html>
<head>
<script src="/dnode.js" type="text/javascript"></script>
<script src="/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var exec = function(s) {
eval('(' + s + ')()')
}
DNode({
$: exec
}).connect(function($$) {
$('body').click(function() {
$$.click()
})
})
})
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment