diff --git a/lib/MessageQueue.js b/lib/MessageQueue.js index ece23e2..353f885 100644 --- a/lib/MessageQueue.js +++ b/lib/MessageQueue.js @@ -77,7 +77,7 @@ function addNode(data, socket){ var now = Date.now(); var callback = function(err, instance, now){ - socket.emit("updateReceived", [modelJson._id ,instance, data[0]]); + socket.emit("updateReceived", [modelJson._id ,instance, data[0]]); //(update the ID) socket.broadcast.emit("newNode", [ [parId,newIndex] , instance ]); diff --git a/lib/helperLib.js b/lib/helperLib.js index 8578a9a..4dfde2e 100644 --- a/lib/helperLib.js +++ b/lib/helperLib.js @@ -87,11 +87,14 @@ function attachLogInListeners(socket){ //This works for all ids except negative ids. socket.on("editing", function(data){ //data=[id, Author.name] + console.log("EDITING received!"); + console.log(data); socket.broadcast.emit("editing", data); }); socket.on("blurred", function(data){ + console.log("BLURRED"); socket.broadcast.emit("blurred", data); var id = data[0]; diff --git a/public/js/app.js b/public/js/app.js index acaca89..6aa1524 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,6 +1,7 @@ $(function(){ //alert("jquery works"); INPUT_PROCESSED = true; + // editing = false; myRouter = new AppRouter; Backbone.history.start(); @@ -93,6 +94,12 @@ voInitializer = function(that, event){ console.log(nodesCollection); console.log(vo.thisModel); + // if(!editing){ + // // alert("editing!"); + // socket.emit("editing", [vo.thisId, CurrentUser.google.name]); + // editing=true; + // } + @@ -116,7 +123,7 @@ voInitializer = function(that, event){ } vo.grandParentModel = nodesCollection.findWhere({_id: vo.grandParentId}); vo.parentModel = nodesCollection.findWhere({_id: vo.parentId}); -} +} //(vo-initializer) diff --git a/public/js/backbone/router.js b/public/js/backbone/router.js index d89fd7f..0315d72 100644 --- a/public/js/backbone/router.js +++ b/public/js/backbone/router.js @@ -198,11 +198,11 @@ socket.on("editing", function(data){ var id = data[0]; var authorName = data[1]; console.log("EDITING RECEIVED + ID"); - console.log(id); - if(id < 0){return;} + console.log(id, authorName); + if(id < 0){return;} //(ID is updated later) //(newNode is called); var tempViews = nodesCollection.findWhere({_id: id}).get("views"); _.each(tempViews, function(tempView){ - tempView.lock(); + tempView.lock(authorName); }); }); diff --git a/public/js/backbone/views/showView.js b/public/js/backbone/views/showView.js index ca456c7..1c04b2c 100644 --- a/public/js/backbone/views/showView.js +++ b/public/js/backbone/views/showView.js @@ -170,10 +170,12 @@ var showView = Backbone.View.extend({ lock: function(name){ //for concurrent editing... this.$el.children().children("textarea").attr("readonly", "readonly"); this.$el.children().children("textarea").val(name + " is editing."); + this.$el.addClass("editing"); }, unlock: function(){ this.$el.children().children("textarea").removeAttr("readonly"); this.$el.children().children("textarea").val(this.model.get("text")); + this.$el.removeClass("editing"); }, removeNode: function(index){ var that = this; diff --git a/public/js/listeners/editorListeners.js b/public/js/listeners/editorListeners.js index ab8c6d3..dcf9654 100644 --- a/public/js/listeners/editorListeners.js +++ b/public/js/listeners/editorListeners.js @@ -14,6 +14,7 @@ $(function(){ wrapper.html(html).addClass('markdown'); //editor.remove() is redundant. + alert("blur!!"); }); @@ -42,11 +43,12 @@ $(function(){ $("body").on("keydown", "textarea", keydownHandler); $("body").on("focus", "textarea", function(event){ var that = this; - voInitializer(that, event); + // alert("editing"); console.log("EDITING"); var id = $(event.target).closest("li").attr("data-id"); - keydownHandler(event); - socket.emit("editing", [id, CurrentUser.google.name]); + voInitializer(that, event); + keydownHandler(event); + //(This event is not firing for some reason..(I wonder if I put it at the top)). }); $("body").on("blur", "textarea", function(event){ var thisLI = $(event.target).closest("li"); @@ -54,7 +56,8 @@ $(function(){ var text = thisLI.children().children("textarea").val(); $("textarea").textareaAutoExpand(); socket.emit("blurred", [id, text, CurrentUser]); - + // alert("blur!!"); + // editing=false; }); $("body").on("click", ".transclude", function(event){ alert("Transclusion syncing with the server has not been implemented. KnownBugs:\n0.Don't make infinite loops.\n1."); diff --git a/public/stylesheets/list.css b/public/stylesheets/list.css index 3ba381c..f472336 100644 --- a/public/stylesheets/list.css +++ b/public/stylesheets/list.css @@ -29,7 +29,8 @@ background-repeat: no-repeat; list-style: none; - /*background-image: url(smiley.png); - /*background-size: 15px 15px; - background-position: -1px 2px; +} + +.root li.editing { + outline: 1px dotted black; } \ No newline at end of file