Skip to content

Commit

Permalink
It works again! (fingers crossed).
Browse files Browse the repository at this point in the history
  • Loading branch information
bakercp committed May 18, 2014
1 parent 7cc5af1 commit 6a003ab
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 163 deletions.
14 changes: 9 additions & 5 deletions ofSketchApp/bin/data/DocumentRoot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,14 @@ <h4 class="modal-title">Not implemented yet ...</h4>
</div>


<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/ofxHTTP.js"></script>
<script src="./js/ofSketch.js"></script>
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/ofxHTTP.js"></script>
<script src="./js/ofxUtils.js"></script>
<script src="./js/ofSketch.js"></script>
<script src="./js/jquery.jsonrpcclient.js"></script>
<script src="./js/jquery.json.js"></script>
<script src="./js/prism.js"></script>

<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="js/vendor/jquery.ui.widget.js"></script>
Expand All @@ -259,7 +263,7 @@ <h4 class="modal-title">Not implemented yet ...</h4>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="js/canvas-to-blob.min.js"></script>

<script src="./js/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>

<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="js/jquery.iframe-transport.js"></script>
Expand Down
169 changes: 92 additions & 77 deletions ofSketchApp/bin/data/DocumentRoot/js/ofSketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,76 @@
// =============================================================================


function makeCommandDataMessage(command, data)
var JSONRPCClient; ///< The core JSONRPC WebSocket client.
var editor;

function addError(error)
{
txt = typeof txt !== 'undefined' ? data : null;

return JSON.stringify(
{
command: command,
data: txt
}
);
console.log(error);
}

function onOpen(ws)
function onWebSocketOpen(ws)
{
ofLogNotice("Connection Opened " + ws);
console.log("on open");
console.log(ws);
}

function onMessage(evt)
function onWebSocketMessage(evt)
{

// console.log(evt.data);
// messages are sent sent
var message = JSON.parse(evt.data);

if(message.method == "setEditorSource") {
editor.setValue(message.data.source);

// console.log(message.error.code);

} else {
console.log("Unknown method: " + message.method);
}

console.log("on message:");
constle.log(evt.data);
}

function onClose()
function onWebSocketClose()
{
console.log("Connection closed.");
console.log("on close");
}

function onError()
function onWebSocketError()
{
console.log("Connection Error.");
console.log("on error");
}

function play() {
var $this = $(this);

function play()
{
var message = makeCommandDataMessage("toolbar-play", editor.getValue());
ws.send(message);
// Collect the information to send to the server.
var params = {
source: editor.getValue()
};

JSONRPCClient.call('play',
params,
function(result) {
console.log(result);
},
function(error) {
addError(error);
});
}

function stop()
{
var message = makeCommandDataMessage("toobar-stop", editor.getValue());
ws.send(message);
function stop() {
var $this = $(this);
JSONRPCClient.call('stop',
null,
function(result) {
console.log(result);
},
function(error) {
addError(error);
});
}

function save()
{
var message = makeCommandDataMessage("toobar-save", editor.getValue());
ws.send(message);
function load() {
var $this = $(this);
JSONRPCClient.call('load',
null,
function(result) {
editor.setValue(result.source);
},
function(error) {
addError(error);
});
}

$(document).ready( function()
Expand All @@ -99,46 +107,52 @@ $(document).ready( function()
// ws.setOnClose(onClose);
// ws.setOnError(onError);

// Initialize our JSONRPCClient
JSONRPCClient = new $.JsonRpcClient(
{
ajaxUrl: getDefaultPostURL(),
socketUrl: getDefaultWebSocketURL(), // get a websocket for the localhost
onmessage: onWebSocketMessage,
onopen: onWebSocketOpen,
onclose: onWebSocketClose,
onerror: onWebSocketError
}
);

// button controls
$("#toolbar-play").click(function() {
play();
});

// button controls
$("#toobar-stop").click(function() {
stop();
});
$('#toolbar-play').on('click', play);
$('#toolbar-stop').on('click', stop);

var editor = ace.edit("editor");
editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.getSession().setMode("ace/mode/c_cpp");

editor.commands.addCommand({
name: 'save',
bindKey: {win: 'Ctrl-s', mac: 'Command-s'},
exec: function(editor) {
console.log("Just saved!");
},
readOnly: true // false if this command should not apply in readOnly mode
});

editor.commands.addCommand({
name: 'run',
bindKey: {win: 'Ctrl-R', mac: 'Command-R'},
exec: function(editor) {
console.log("Just Ran!");
},
readOnly: true // false if this command should not apply in readOnly mode
});

editor.commands.addCommand({
name: 'present',
bindKey: {win: 'Shift-Ctrl-r', mac: 'Shift-Command-r'},
exec: function(editor) {
console.log("Just presented!");
},
readOnly: true // false if this command should not apply in readOnly mode
});
// editor.commands.addCommand({
// name: 'save',
// bindKey: {win: 'Ctrl-s', mac: 'Command-s'},
// exec: function(editor) {
// console.log("Just saved!");
// },
// readOnly: true // false if this command should not apply in readOnly mode
// });

// editor.commands.addCommand({
// name: 'run',
// bindKey: {win: 'Ctrl-R', mac: 'Command-R'},
// exec: function(editor) {
// console.log("Just Ran!");
// },
// readOnly: true // false if this command should not apply in readOnly mode
// });

// editor.commands.addCommand({
// name: 'present',
// bindKey: {win: 'Shift-Ctrl-r', mac: 'Shift-Command-r'},
// exec: function(editor) {
// console.log("Just presented!");
// },
// readOnly: true // false if this command should not apply in readOnly mode
// });
// // connect to the websocket

// ws.connect();
Expand Down Expand Up @@ -185,5 +199,6 @@ $(document).ready( function()
// $('#toolbar-export-project').tooltip()


load();

});
28 changes: 15 additions & 13 deletions ofSketchApp/src/AddonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace of {
namespace Sketch {


const std::string AddonManager::DEFAULT_ADDON_PATH = "addons/";


AddonManager::AddonManager(const std::string& path):
_path(path)
{
Expand All @@ -46,11 +49,11 @@ AddonManager::AddonManager(const std::string& path):

std::vector<std::string>::iterator iter = files.begin();

while(iter != files.end())
{
cout << *iter << endl;
++iter;
}
// while(iter != files.end())
// {
// cout << *iter << endl;
// ++iter;
// }

}

Expand All @@ -65,46 +68,45 @@ void AddonManager::setup()
}


void AddonManager::updateAddon(const Poco::URI&)
void AddonManager::updateAddon(const Poco::URI& uri)
{
}


void AddonManager::onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
ofSendMessage("Added: " + evt.item.path());
// ofSendMessage("Added: " + evt.item.path());
}


void AddonManager::onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
ofSendMessage("Removed: " + evt.item.path());
// ofSendMessage("Removed: " + evt.item.path());
}


void AddonManager::onDirectoryWatcherItemModified(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
ofSendMessage("Modified: " + evt.item.path());
// ofSendMessage("Modified: " + evt.item.path());
}


void AddonManager::onDirectoryWatcherItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
ofLogNotice("ofApp::onDirectoryWatcherItemMovedFrom") << "Moved From: " << evt.item.path();
// ofLogNotice("ofApp::onDirectoryWatcherItemMovedFrom") << "Moved From: " << evt.item.path();
}


void AddonManager::onDirectoryWatcherItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
ofLogNotice("ofApp::onDirectoryWatcherItemMovedTo") << "Moved To: " << evt.item.path();
// ofLogNotice("ofApp::onDirectoryWatcherItemMovedTo") << "Moved To: " << evt.item.path();
}


void AddonManager::onDirectoryWatcherError(const Poco::Exception& exc)
{
ofLogError("ofApp::onDirectoryWatcherError") << "Error: " << exc.displayText();
// ofLogError("ofApp::onDirectoryWatcherError") << "Error: " << exc.displayText();
}



} } // namespace of::Sketch
4 changes: 3 additions & 1 deletion ofSketchApp/src/AddonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddonManager

void setup();

void updateAddon(const Poco::URI&);
void updateAddon(const Poco::URI& uri);

void onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt);
Expand All @@ -65,6 +65,8 @@ class AddonManager
return SharedPtr(new AddonManager(addonsPath));
}

static const std::string DEFAULT_ADDON_PATH;

private:
std::string _path;
std::set<Addon::SharedPtr> _addons;
Expand Down
Loading

0 comments on commit 6a003ab

Please sign in to comment.