Last active
March 8, 2017 06:46
-
-
Save marekhrabe/8310229 to your computer and use it in GitHub Desktop.
Using Photoshop generator plugin together with HTML panel. Pseudo-untested-code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.init = function (generator, config) { | |
var io = require('socket.io').listen(1234); // put your unique port here | |
io.sockets.on('connection', function (socket) { | |
socket.emit('message', 'i am ready'); | |
socket.on('doStuff', function (data) { | |
generator.getDocumentInfo().then(function (document) { | |
socket.emit('message', 'working with document…'); | |
}, function (err) { | |
console.log(err); | |
}).done(); | |
}); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button>Do stuff</button> | |
<div></div> | |
<script src="http://127.0.0.1:1234/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect('http://127.0.0.1:1234'); | |
var div = document.querySelector('div'); | |
socket.on('message', function (data) { | |
div.innerHTML = data; | |
}); | |
var button = document.querySelector('button'); | |
button.addEventListener('click', function () { | |
socket.emit('doStuff'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment