diff --git a/lib/helperLib.js b/lib/helperLib.js index 699c113..b001922 100644 --- a/lib/helperLib.js +++ b/lib/helperLib.js @@ -103,7 +103,7 @@ function attachLogInListeners(socket){ console.log("EDITING received!"); console.log(data); socket.broadcast.emit("editing", data); - socket.CUR_ID = data[0]; + socket.CUR_ID = data[0]; //(used for disconnecting on browserClose); }); diff --git a/lib/revAlgorithm.js b/lib/revAlgorithm.js index caaf6e4..54ae176 100644 --- a/lib/revAlgorithm.js +++ b/lib/revAlgorithm.js @@ -1,15 +1,20 @@ var _ = require('underscore'); -var MySnap = require('../models/Snap.js').MySnap +var MySnap = require('../models/Snap.js').MySnap; +var User = require('../models/User.js'); module.exports.getAndSendRevHistory = getAndSendRevHistory; function getAndSendRevHistory(subRootId, sock){ globalList = []; snapHash = {}; - timeHash = {}; + timeHash = {}; depth = 0; socket = sock; + User.find({}, '_id google.name' , function(err, users){ + socket.emit("UserList", users); + }); + // subRootId = "53f10817cb52c1e31cf45d94"; // FetchSelfAndChildrenBack(rootId, asyncLoopGetChildren); asyncLoopGetChildren([subRootId]); @@ -22,7 +27,7 @@ function updateGlobals(rootSnaps){ //snapHash[rootId] = rootSnaps; //should be equivalent. _.each(rootSnaps, function(snap){ - (timeHash[snap.timestamp] = timeHash[snap.timestamp] || []).push(snap); + (timeHash[snap.timestamp] = timeHash[snap.timestamp] || []).push(snap); }); globalList.push(rootId); @@ -30,7 +35,8 @@ function updateGlobals(rootSnaps){ //This should only be called once per ID. function FetchSelfAndChildrenBack(rootId, callback){ - MySnap.find({cur_id: rootId}).populate('authorId','_id google.name' ).sort({timestamp: 1}). + /*populate('authorId','_id google.name' ).*/ + MySnap.find({cur_id: rootId}).sort({timestamp: 1}). exec(function(err, rootSnaps){ if(err){console.log("ERROR HERE")} @@ -82,13 +88,13 @@ function asyncLoopGetChildren(d1Union){ if(typeof d1Union == 'undefined' || d1Union.length == 0){//bottomed out recursion = end of bfs - console.log("finished!!!!") - console.log("snapHash"); - console.log(snapHash); - console.log("timeHash"); - console.log(timeHash); - console.log("globalList"); - console.log(globalList); + // console.log("finished!!!!") + // console.log("snapHash"); + // console.log(snapHash); + // console.log("timeHash"); + // console.log(timeHash); + // console.log("globalList"); + // console.log(globalList); socket.emit("revHistory", [snapHash, timeHash]); return; diff --git a/models/Node.js b/models/Node.js index c87ad04..b358b3b 100644 --- a/models/Node.js +++ b/models/Node.js @@ -7,9 +7,9 @@ var NodeSchema = new mongoose.Schema({ parents: {type: Array}, markdown: {type: Boolean}, timestamp: {type: Number}, - author: {type: String, ref: 'User'}, //authorId is populated with limited AuthorObject + authorId: {type: String, ref: 'User'}, //authorId is populated with limited AuthorObject _id: String -}); +}); //mongoose.Schema.Types.ObjectId var MyNode = mongoose.model('nodes', NodeSchema); @@ -41,9 +41,13 @@ module.exports.addNode = addNode; // return rootID; // } +//http://mongoosejs.com/docs/populate.html function findAndSocketSend(socket, CURRENT_TIMESTAMP){ var nodes = {'keeping': 'calm'} - MyNode.find().populate('authorId','_id google.name' ).exec(function(err, nodes){ + // .populate('authorId').populate('google.name') + MyNode.find().exec(function(err, nodes){ + console.log("NODES"); + console.log(nodes); if(!err){ // require("underscore").each(nodes, function(node){console.log(node)}); socket.emit('nodeData', nodes, CURRENT_TIMESTAMP) @@ -61,9 +65,10 @@ function findAndSocketSend(socket, CURRENT_TIMESTAMP){ function setUpDB(){ MyNode.remove({}, function(err) { console.log('collection removed') }); MySnap.remove({}, function(err) { console.log('collection removed') }); - var curtisId = "53e4079cd7dbc73d16c87c53"; + var curtisId = "54412cf9d7018300009d42c7"; - addNode("0root", [], [], curtisId , "a42a" , function(err, rootNode){ + //"42" is there, so that it doesn't get deleted during snapCommits (for not having a parent). + addNode("0root", [], ["42"], curtisId , "a42a" , function(err, rootNode){ console.log("rootNode", rootNode); addNode("Welcolme!", [], [rootNode._id], curtisId , "b42b", function(err, firstBullet){ rootNode.children = [firstBullet._id] diff --git a/models/User.js b/models/User.js index 17c01e5..fa0fe63 100644 --- a/models/User.js +++ b/models/User.js @@ -1,6 +1,7 @@ var mongoose = require('mongoose'); var userSchema = mongoose.Schema({ + // _id: String, google : { id : String, token : String, diff --git a/public/js/backbone/models/node.js b/public/js/backbone/models/node.js index 497d037..11c12b8 100644 --- a/public/js/backbone/models/node.js +++ b/public/js/backbone/models/node.js @@ -5,7 +5,7 @@ var NodeModel = Backbone.Model.extend({ var ancestry = []; var parents = that.get("parents"); - while(parents.length != 0){ + while( !(parents[0] == "a42a" || parents[0]=="42" || parents.length==0) ) { ancestry.push(parents); parents = nodesCollection.findWhere({_id: parents[0]}).get("parents"); // parents = that.findModel(parents[0]).get("parents"); diff --git a/public/js/backbone/router.js b/public/js/backbone/router.js index 9d04da1..fcc607e 100644 --- a/public/js/backbone/router.js +++ b/public/js/backbone/router.js @@ -35,7 +35,7 @@ var AppRouter = Backbone.Router.extend({ socket.emit("logIn", data); //logs the user into the socket. - data.google.id = null; + data.google.id = null; //why? data.google.token = null; data.google.email = null; CurrentUser = data; @@ -140,7 +140,7 @@ socket.emitWrapper = function(eventName, data){ socket.on('nodeData', function(data, SERVER_TIMESTAMP){ //alert("data"); CURRENT_TIMESTAMP = SERVER_TIMESTAMP; - // console.log(data); + console.log(data[0]); nodesCollection = new NodesCollection(data); var id = nodesCollection.findWhere({text: "0root"}).get("_id"); // if(otherID){ @@ -170,23 +170,14 @@ socket.on("revHistory", function(data){ }) $("#revTimestamps").html(list); -}) - - -$("#revTimestamps").on("click", "a.timestamp", function(event){ - // debugger; - var a = event.target; - var timestamp = parseInt($(a).html()); - var subRootId = $(".getRevHistory").attr("data-id"); - - var snapCollection = renderRevControl(subRootId, timestamp); - - console.log("snapCollection") - console.log(snapCollection); - - that.viewRoot(subRootId, snapCollection); }); +UserHash = {}; +socket.on("UserList", function(data){ + _.each(data, function(user){ + UserHash[user._id] = user.google.name; + }); +}); socket.on('edit', function(data){ var id = data[0]; diff --git a/public/js/backbone/views/metaView.js b/public/js/backbone/views/metaView.js index 44f2c48..8f3c1ff 100644 --- a/public/js/backbone/views/metaView.js +++ b/public/js/backbone/views/metaView.js @@ -29,11 +29,14 @@ function assignProperties(object, options){ //object is a showView or listView } object.pushView = function(tempView, childId){ - debugger; + // debugger; var searchSet= object.searchSet; that.childViews.push(tempView); var tempLI = tempView.render().$el that.UL.append(tempLI); + if(that.snapView==1 && _.contains(thisTimeStampSnaps , childId) ){ + $(tempLI).addClass("recentSnap"); + } if(searchSet && !_.contains(searchSet, childId)){ $(tempLI).hide(); } diff --git a/public/js/libs/externalLibs/jqueryTextComplete.js b/public/js/libs/externalLibs/jqueryTextComplete.js index 3a3fbd4..57149e1 100644 --- a/public/js/libs/externalLibs/jqueryTextComplete.js +++ b/public/js/libs/externalLibs/jqueryTextComplete.js @@ -1,4 +1,60 @@ /*! jquery-textcomplete - v0.3.3 - 2014-09-25 */if("undefined"==typeof jQuery)throw new Error("jQuery.textcomplete requires jQuery");+function(a){"use strict";var b=function(a){console.warn&&console.warn(a)};a.fn.textcomplete=function(c,d){var e=Array.prototype.slice.call(arguments);return this.each(function(){var f=a(this),g=f.data("textComplete");if(g||(g=new a.fn.textcomplete.Completer(this,d||{}),f.data("textComplete",g)),"string"==typeof c){if(!g)return;e.shift(),g[c].apply(g,e)}else a.each(c,function(c){a.each(["header","footer","placement","maxCount"],function(a){c[a]&&(g.option[a]=c[a],b(a+"as a strategy param is deplicated. Use option."),delete c[a])})}),g.register(a.fn.textcomplete.Strategy.parse(c))})}}(jQuery),+function(a){"use strict";function b(c,d){if(this.$el=a(c),this.id="textcomplete"+e++,this.strategies=[],this.views=[],this.option=a.extend({},b.DEFAULTS,d),!this.$el.is("textarea")&&!c.isContentEditable)throw new Error("textcomplete must be called to a Textarea or a ContentEditable.");if(c===document.activeElement)this.initialize();else{var f=this;this.$el.one("focus."+this.id,function(){f.initialize()})}}var c=function(a){var b,c;return function(){var d=Array.prototype.slice.call(arguments);if(b)return c=d,void 0;b=!0;var e=this;d.unshift(function f(){if(c){var d=c;c=void 0,d.unshift(f),a.apply(e,d)}else b=!1}),a.apply(this,d)}},d=function(a){return"[object String]"===Object.prototype.toString.call(a)},e=0;b.DEFAULTS={appendTo:a("body"),zIndex:"100"},a.extend(b.prototype,{id:null,option:null,strategies:null,adapter:null,dropdown:null,$el:null,initialize:function(){var b=this.$el.get(0);this.dropdown=new a.fn.textcomplete.Dropdown(b,this,this.option);var c,d;this.option.adapter?c=this.option.adapter:(d=this.$el.is("textarea")?"number"==typeof b.selectionEnd?"Textarea":"IETextarea":"ContentEditable",c=a.fn.textcomplete[d]),this.adapter=new c(b,this,this.option)},destroy:function(){this.$el.off("."+this.id),this.adapter.destroy(),this.dropdown.destroy(),this.$el=this.adapter=this.dropdown=null},trigger:function(a,b){this.dropdown||this.initialize(),null!=a||(a=this.adapter.getTextFromHeadToCaret());var c=this._extractSearchQuery(a);if(c.length){var d=c[1];if(b&&this._term===d)return;this._term=d,this._search.apply(this,c)}else this._term=null,this.dropdown.deactivate()},fire:function(a){return this.$el.trigger(a),this},register:function(a){Array.prototype.push.apply(this.strategies,a)},select:function(a,b){this.adapter.select(a,b),this.fire("change").fire("textComplete:select",a,b),this.adapter.focus()},_clearAtNext:!0,_term:null,_extractSearchQuery:function(a){for(var b=0;b').css({display:"none",left:0,position:"absolute",zIndex:b.zIndex}).appendTo(c)),d}}),a.extend(b.prototype,{$el:null,$inputEl:null,completer:null,footer:null,header:null,id:null,maxCount:10,placement:"",shown:!1,data:[],className:"",destroy:function(){this.deactivate(),this.$el.off("."+this.id),this.$inputEl.off("."+this.id),this.clear(),this.$el=this.$inputEl=this.completer=null,delete d[this.id]},render:function(b){var c=this._buildContents(b),d=a.map(this.data,function(a){return a.value});this.data.length?(this._renderHeader(d),this._renderFooter(d),c&&(this._renderContents(c),this._activateIndexedItem()),this._setScroll()):this.shown&&this.deactivate()},setPosition:function(a){return this.$el.css(this._applyPlacement(a)),this},clear:function(){this.$el.html(""),this.data=[],this._index=0,this._$header=this._$footer=null},activate:function(){return this.shown||(this.clear(),this.$el.show(),this.className&&this.$el.addClass(this.className),this.completer.fire("textComplete:show"),this.shown=!0),this},deactivate:function(){return this.shown&&(this.$el.hide(),this.className&&this.$el.removeClass(this.className),this.completer.fire("textComplete:hide"),this.shown=!1),this},isUp:function(a){return 38===a.keyCode||a.ctrlKey&&80===a.keyCode},isDown:function(a){return 40===a.keyCode||a.ctrlKey&&78===a.keyCode},isEnter:function(a){var b=a.ctrlKey||a.altKey||a.metaKey||a.shiftKey;return!b&&(13===a.keyCode||9===a.keyCode)},isPageup:function(a){return 33===a.keyCode},isPagedown:function(a){return 34===a.keyCode},_data:null,_index:null,_$header:null,_$footer:null,_bindEvents:function(){this.$el.on("mousedown."+this.id,".textcomplete-item",a.proxy(this._onClick,this)),this.$el.on("mouseover."+this.id,".textcomplete-item",a.proxy(this._onMouseover,this)),this.$inputEl.on("keydown."+this.id,a.proxy(this._onKeydown,this))},_onClick:function(b){var c=a(b.target);b.preventDefault(),b.originalEvent.keepTextCompleteDropdown=this.id,c.hasClass("textcomplete-item")||(c=c.closest(".textcomplete-item"));var d=this.data[parseInt(c.data("index"),10)];this.completer.select(d.value,d.strategy);var e=this;setTimeout(function(){e.deactivate()},0)},_onMouseover:function(b){var c=a(b.target);b.preventDefault(),c.hasClass("textcomplete-item")||(c=c.closest(".textcomplete-item")),this._index=parseInt(c.data("index"),10),this._activateIndexedItem()},_onKeydown:function(a){this.shown&&(this.isUp(a)?(a.preventDefault(),this._up()):this.isDown(a)?(a.preventDefault(),this._down()):this.isEnter(a)?(a.preventDefault(),this._enter()):this.isPageup(a)?(a.preventDefault(),this._pageup()):this.isPagedown(a)&&(a.preventDefault(),this._pagedown()))},_up:function(){0===this._index?this._index=this.data.length-1:this._index-=1,this._activateIndexedItem(),this._setScroll()},_down:function(){this._index===this.data.length-1?this._index=0:this._index+=1,this._activateIndexedItem(),this._setScroll()},_enter:function(){var a=this.data[parseInt(this._getActiveElement().data("index"),10)];this.completer.select(a.value,a.strategy),this._setScroll()},_pageup:function(){var b=0,c=this._getActiveElement().position().top-this.$el.innerHeight();this.$el.children().each(function(d){return a(this).position().top+a(this).outerHeight()>c?(b=d,!1):void 0}),this._index=b,this._activateIndexedItem(),this._setScroll()},_pagedown:function(){var b=this.data.length-1,c=this._getActiveElement().position().top+this.$el.innerHeight();this.$el.children().each(function(d){return a(this).position().top>c?(b=d,!1):void 0}),this._index=b,this._activateIndexedItem(),this._setScroll()},_activateIndexedItem:function(){this.$el.find(".textcomplete-item.active").removeClass("active"),this._getActiveElement().addClass("active")},_getActiveElement:function(){return this.$el.children(".textcomplete-item:nth("+this._index+")")},_setScroll:function(){var a=this._getActiveElement(),b=a.position().top,c=a.outerHeight(),d=this.$el.innerHeight(),e=this.$el.scrollTop();0===this._index||this._index==this.data.length-1||0>b?this.$el.scrollTop(b+e):b+c>d&&this.$el.scrollTop(b+c+e-d)},_buildContents:function(a){var b,d,e,f="";for(d=0;d',f+=b.strategy.template(b.value),f+="");return f},_renderHeader:function(b){if(this.header){this._$header||(this._$header=a('
  • ').prependTo(this.$el));var c=a.isFunction(this.header)?this.header(b):this.header;this._$header.html(c)}},_renderFooter:function(b){if(this.footer){this._$footer||(this._$footer=a('').appendTo(this.$el));var c=a.isFunction(this.footer)?this.footer(b):this.footer;this._$footer.html(c)}},_renderContents:function(a){this._$footer?this._$footer.before(a):this.$el.append(a)},_applyPlacement:function(a){return-1!==this.placement.indexOf("top")?a={top:"auto",bottom:this.$el.parent().height()-a.top+a.lineHeight,left:a.left}:(a.bottom="auto",delete a.lineHeight),-1!==this.placement.indexOf("absleft")?a.left=0:-1!==this.placement.indexOf("absright")&&(a.right=0,a.left="auto"),a}}),a.fn.textcomplete.Dropdown=b}(jQuery),+function(a){"use strict";function b(b){a.extend(this,b),this.cache&&(this.search=c(this.search))}var c=function(a){var b={};return function(c,d){b[c]?d(b[c]):a.call(this,c,function(a){b[c]=(b[c]||[]).concat(a),d.apply(null,arguments)})}};b.parse=function(c){return a.map(c,function(a){return new b(a)})},a.extend(b.prototype,{match:null,replace:null,search:null,cache:!1,context:function(){return!0},index:2,template:function(a){return a},idProperty:null}),a.fn.textcomplete.Strategy=b}(jQuery),+function(a){"use strict";function b(){}var c=Date.now||function(){return(new Date).getTime()},d=function(a,b){var d,e,f,g,h,i=function(){var j=c()-g;b>j?d=setTimeout(i,b-j):(d=null,h=a.apply(f,e),f=e=null)};return function(){return f=this,e=arguments,g=c(),d||(d=setTimeout(i,b)),h}};a.extend(b.prototype,{id:null,completer:null,el:null,$el:null,option:null,initialize:function(b,c,e){this.el=b,this.$el=a(b),this.id=c.id+this.constructor.name,this.completer=c,this.option=e,this.option.debounce&&(this._onKeyup=d(this._onKeyup,this.option.debounce)),this._bindEvents()},destroy:function(){this.$el.off("."+this.id),this.$el=this.el=this.completer=null},select:function(){throw new Error("Not implemented")},getCaretPosition:function(){var a=this._getCaretRelativePosition(),b=this.$el.offset();return a.top+=b.top,a.left+=b.left,a},focus:function(){this.$el.focus()},_bindEvents:function(){this.$el.on("keyup."+this.id,a.proxy(this._onKeyup,this))},_onKeyup:function(a){this._skipSearch(a)||this.completer.trigger(this.getTextFromHeadToCaret(),!0)},_skipSearch:function(a){switch(a.keyCode){case 40:case 38:return!0}if(a.ctrlKey)switch(a.keyCode){case 78:case 80:return!0}}}),a.fn.textcomplete.Adapter=b}(jQuery),+function(a){"use strict";function b(a,b,c){this.initialize(a,b,c)}b.DIV_PROPERTIES={left:-9999,position:"absolute",top:0,whiteSpace:"pre-wrap"},b.COPY_PROPERTIES=["border-width","font-family","font-size","font-style","font-variant","font-weight","height","letter-spacing","word-spacing","line-height","text-decoration","text-align","width","padding-top","padding-right","padding-bottom","padding-left","margin-top","margin-right","margin-bottom","margin-left","border-style","box-sizing","tab-size"],a.extend(b.prototype,a.fn.textcomplete.Adapter.prototype,{select:function(b,c){var d=this.getTextFromHeadToCaret(),e=this.el.value.substring(this.el.selectionEnd),f=c.replace(b);a.isArray(f)&&(e=f[1]+e,f=f[0]),d=d.replace(c.match,f),this.$el.val(d+e),this.el.selectionStart=this.el.selectionEnd=d.length},_getCaretRelativePosition:function(){var b=a("
    ").css(this._copyCss()).text(this.getTextFromHeadToCaret()),c=a("").text(".").appendTo(b);this.$el.before(b);var d=c.position();return d.top+=c.height()-this.$el.scrollTop(),d.lineHeight=c.height(),b.remove(),d},_copyCss:function(){return a.extend({overflow:this.el.scrollHeight>this.el.offsetHeight?"scroll":"auto"},b.DIV_PROPERTIES,this._getStyles())},_getStyles:function(a){var c=a("
    ").css(["color"]).color;return"undefined"!=typeof c?function(){return this.$el.css(b.COPY_PROPERTIES)}:function(){var c=this.$el,d={};return a.each(b.COPY_PROPERTIES,function(a,b){d[b]=c.css(b)}),d}}(a),getTextFromHeadToCaret:function(){return this.el.value.substring(0,this.el.selectionEnd)}}),a.fn.textcomplete.Textarea=b}(jQuery),+function(a){"use strict";function b(b,d,e){this.initialize(b,d,e),a(""+c+"").css({position:"absolute",top:-9999,left:-9999}).insertBefore(b)}var c="吶";a.extend(b.prototype,a.fn.textcomplete.Textarea.prototype,{select:function(b,c){var d=this._getTextFromHeadToCaret(),e=this.el.value.substring(d.length),f=c.replace(b);a.isArray(f)&&(e=f[1]+e,f=f[0]),d=d.replace(c.match,f),this.$el.val(d+e),this.el.focus();var g=this.el.createTextRange();g.collapse(!0),g.moveEnd("character",d.length),g.moveStart("character",d.length),g.select()},_getTextFromHeadToCaret:function(){this.el.focus();var a=document.selection.createRange();a.moveStart("character",-this.el.value.length);var b=a.text.split(c);return 1===b.length?b[0]:b[1]}}),a.fn.textcomplete.IETextarea=b}(jQuery),+function(a){"use strict";function b(a,b,c){this.initialize(a,b,c)}a.extend(b.prototype,a.fn.textcomplete.Adapter.prototype,{select:function(b,c){var d=this.getTextFromHeadToCaret(),e=window.getSelection(),f=e.getRangeAt(0),g=f.cloneRange();g.selectNodeContents(f.startContainer);var h=g.toString(),i=h.substring(f.startOffset),j=c.replace(b);a.isArray(j)&&(i=j[1]+i,j=j[0]),d=d.replace(c.match,j),f.selectNodeContents(f.startContainer),f.deleteContents();var k=document.createTextNode(d+i);f.insertNode(k),f.setStart(k,d.length),f.collapse(!0),e.removeAllRanges(),e.addRange(f)},_getCaretRelativePosition:function(){var b=window.getSelection().getRangeAt(0).cloneRange(),c=document.createElement("span");b.insertNode(c),b.selectNodeContents(c),b.deleteContents();var d=a(c),e=d.offset();e.left-=this.$el.offset().left,e.top+=d.height()-this.$el.offset().top,e.lineHeight=d.height();var f=this.$el.attr("dir")||this.$el.css("direction");return"rtl"===f&&(e.left-=this.listView.$el.width()),e},getTextFromHeadToCaret:function(){var a=window.getSelection().getRangeAt(0),b=a.cloneRange();return b.selectNodeContents(a.startContainer),b.toString().substring(0,a.startOffset)}}),a.fn.textcomplete.ContentEditable=b}(jQuery); /* //@ sourceMappingURL=dist/jquery.textcomplete.min.map -*/ \ No newline at end of file +*/ + +/*! jquery-overlay - v0.0.4 - 2014-06-11 */!function(a){"use strict";var b=function(){var b;return b=a("
    ").css(["color"]).color,"undefined"!=typeof b?function(a,b){return a.css(b)}:function(b,c){var d;return d={},a.each(c,function(a,c){d[c]=b.css(c)}),d}}(),c={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=/[&<>"'\/]/g,e=function(a){return a.replace(d,function(a){return c[a]})},f=function(){function c(c){var e,i;i=c.css("position"),"static"===i&&(i="relative"),e=a(d.wrapper).css(a.extend({},f.wrapper,b(c,g),{position:i})),this.textareaTop=parseInt(c.css("border-top-width")),this.$el=a(d.overlay).css(a.extend({},f.overlay,b(c,h),{top:this.textareaTop,right:parseInt(c.css("border-right-width")),bottom:parseInt(c.css("border-bottom-width")),left:parseInt(c.css("border-left-width"))})),this.$textarea=c.css(f.textarea),this.$textarea.wrap(e).before(this.$el),this.$textarea.origVal=c.val,this.$textarea.val=a.proxy(this.val,this),this.$textarea.on({"input.overlay":a.proxy(this.onInput,this),"change.overlay":a.proxy(this.onInput,this),"scroll.overlay":a.proxy(this.resizeOverlay,this),"resize.overlay":a.proxy(this.resizeOverlay,this)}),this.strategies=[]}var d,f,g,h;return d={wrapper:'
    ',overlay:'
    '},f={wrapper:{margin:0,padding:0,overflow:"hidden"},overlay:{position:"absolute",color:"transparent","white-space":"pre-wrap","word-wrap":"break-word",overflow:"hidden"},textarea:{background:"transparent",position:"relative",outline:0}},g=["display"],h=["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left","font-family","font-weight","font-size","background-color"],a.extend(c.prototype,{val:function(a){return null==a?this.$textarea.origVal():this.setVal(a)},setVal:function(a){return this.$textarea.origVal(a),this.renderTextOnOverlay(),this.$textarea},onInput:function(){this.renderTextOnOverlay()},renderTextOnOverlay:function(){var b,c,d,f,g,h;for(b=a("
    ").text(this.$textarea.val()),c=0,d=this.strategies.length;d>c;c++)f=this.strategies[c],g=f.match,a.isArray(g)&&(g=a.map(g,function(a){return a.replace(/(\(|\)|\|)/g,"$1")}),g=new RegExp("("+g.join("|")+")","g")),h="background-color:"+f.css["background-color"],b.contents().each(function(){var b,c,d,f;if(this.nodeType==Node.TEXT_NODE){for(b=this.textContent,c="",f=g.lastIndex=0;;f=g.lastIndex){if(d=g.exec(b),!d){f&&(c+=e(b.substr(f)));break}d=d[0],c+=e(b.substr(f,g.lastIndex-f-d.length)),c+=''+e(d)+""}f&&a(this).replaceWith(c)}});return this.$el.html(b.contents()),this},resizeOverlay:function(){this.$el.css({top:this.textareaTop-this.$textarea.scrollTop()})},register:function(b){return b=a.isArray(b)?b:[b],this.strategies=this.strategies.concat(b),this.renderTextOnOverlay()},destroy:function(){var a;this.$textarea.off(".overlay"),a=this.$textarea.parent(),a.after(this.$textarea).remove(),this.$textarea.removeData("overlay"),this.$textarea=null}}),c}();a.fn.overlay=function(b){var c;return c="overlay","destroy"===b?this.each(function(){var b=a(this).data(c);b&&b.destroy()}):this.each(function(){var d,e;d=a(this),e=d.data(c),e||(e=new f(d),d.data(c,e)),e.register(b)})}}(window.jQuery); +//# sourceMappingURL=jquery.overlay.min.map + +// (function($) { + $.fn.attachAutoComplete = function(){ + $(this).textcomplete([ + { // html + mentions: ['yuku_t'], + match: /\B@(\w*)$/, + search: function (term, callback) { + callback($.map(this.mentions, function (mention) { + return mention.indexOf(term) === 0 ? mention : null; + })); + }, + index: 1, + replace: function (mention) { + return '@' + mention + ' '; + } + } + ], { appendTo: 'body' }).overlay([ + { + match: /\B@\w+/g, + css: { + 'background-color': '#d8dfea' + } + } + ]); //first text-complete + + $(this).textcomplete([ + { // html + mentions: ['fuckYeah', "booyea"], + match: /\B#(\w*)$/, + search: function (term, callback) { + callback($.map(this.mentions, function (mention) { + return mention.indexOf(term) === 0 ? mention : null; + })); + }, + index: 1, + replace: function (mention) { + return '#' + mention + ' '; + } + } + ], { appendTo: 'body' }).overlay([ + { + match: /\B#\w+/g, + css: { + 'background-color': '#d8dfea' + } + } + ]); + + }//outerFN +// }(jQuery)); + + diff --git a/public/js/libs/myLogic/keydownHandler.js b/public/js/libs/myLogic/keydownHandler.js index 3603e86..c452d0d 100644 --- a/public/js/libs/myLogic/keydownHandler.js +++ b/public/js/libs/myLogic/keydownHandler.js @@ -187,7 +187,10 @@ if((vo.hitTab && event.shiftKey) || (event.keyCode == 37 && event.shiftKey)){// } } if(event.keyCode == 40){ //down + //if(thisLI.collapsed || empty) vo.thisLI.next().children().children("textarea").focus(); + //else => (focus on next El) + } // if(event.keyCode) diff --git a/public/js/libs/myLogic/revControl.js b/public/js/libs/myLogic/revControl.js index 964b99a..da68825 100644 --- a/public/js/libs/myLogic/revControl.js +++ b/public/js/libs/myLogic/revControl.js @@ -1,19 +1,18 @@ renderRevControl = function(rootNode, timeStamp){ + rootSnap = fetchLTE(rootNode, timeStamp ); //var? + var finalCollection = []; - rootSnap = fetchLTE(rootNode, timeStamp ); var queue = [rootSnap]; while(queue.length > 0){ snap = queue.shift(); finalCollection.push(snap); - childrenSnaps = fetchChildren(snap); + childrenSnaps = fetchChildren(snap,timeStamp); _.each(childrenSnaps, function(childSnap){queue.push(childSnap)}); - } - console.log("FINALCOLLECTION"); - console.log(finalCollection); - var snapCollection = new NodesCollection(finalCollection); - return snapCollection; + } + + return new NodesCollection(finalCollection); //snapCollection } @@ -29,9 +28,9 @@ function fetchLTE(nodeId, timeStamp){ alert("error!!"); } -function fetchChildren(subRootSnap){ +function fetchChildren(subRootSnap,timeStamp){ childrenSnaps = []; - var timeStamp = snap.timestamp; + // var timeStamp = snap.timestamp; _.each(subRootSnap.children, function(childId){ childrenSnaps.push( fetchLTE(childId, timeStamp) ); }); diff --git a/public/js/listeners/revListeners.js b/public/js/listeners/revListeners.js index c5fdc03..2366027 100644 --- a/public/js/listeners/revListeners.js +++ b/public/js/listeners/revListeners.js @@ -9,12 +9,41 @@ $(function(){ $(e.target).attr("data-id", rootId); }); + var currentSelected; $("body").on("click", ".snapLI", function(e){ - $(e.target).addClass("selectedSnap"); + if(!currentSelected){currentSelected=$(e.target)}//initialization + currentSelected.removeClass("selectedSnap"); + currentSelected=$(e.target); + currentSelected.addClass("selectedSnap"); + + displaySnapInfo(currentSelected.parent().parent()); }); + var displaySnapInfo = function(snapLI){ + debugger; + var snapModel = snapCollection.findWhere({_id: snapLI.attr("data-id")}); + $('#authorLI').html("author:" + UserHash[snapModel.get("authorId")]); + $('#timestampLI').html("timestamp:" + snapModel.get("timestamp")); + } + $(".toggleSidebar").click(function(){ $("#mainPanel").toggleClass("floatRight centering"); $("#metaSidebar").toggleClass("hideBar"); }); + + $("#revTimestamps").on("click", "a.timestamp", function(event){ + // debugger; + var a = event.target; + var timestamp = parseInt($(a).html()); + var subRootId = $(".getRevHistory").attr("data-id"); + + snapCollection = renderRevControl(subRootId, timestamp); + + thisTimeStampSnaps =[]; + _.each(snapCollection.models, function(model){ + if(model.get("timestamp") == timestamp){thisTimeStampSnaps.push(model.get("cur_id"))} + }); + + myRouter.viewRoot(subRootId, snapCollection); + }); }) \ No newline at end of file diff --git a/public/stylesheets/autoComplete.css b/public/stylesheets/autoComplete.css new file mode 100644 index 0000000..5664980 --- /dev/null +++ b/public/stylesheets/autoComplete.css @@ -0,0 +1,31 @@ +.dropdown-menu { + border: 1px solid #ddd; + background-color: white; +} + +.dropdown-menu li { + border-top: 1px solid #ddd; + padding: 2px 5px; +} + +.dropdown-menu li:first-child { + border-top: none; +} + +.dropdown-menu li:hover, +.dropdown-menu .active { + background-color: rgb(110, 183, 219); +} + + +/* SHOULD not modify */ + +.dropdown-menu { + list-style: none; + padding: 0; + margin: 0; +} + +.dropdown-menu a:hover { + cursor: pointer; +} \ No newline at end of file diff --git a/public/stylesheets/panel.css b/public/stylesheets/panel.css index 30d14fc..24b9817 100644 --- a/public/stylesheets/panel.css +++ b/public/stylesheets/panel.css @@ -9,8 +9,10 @@ body { /******* Body ********/ /**************** Panel ****************/ + +/*revListeners.js , index.ejs*/ .floatRight{ - float: right; + float: left; margin-top: 40px; width: 760px; } diff --git a/public/stylesheets/revControl.css b/public/stylesheets/revControl.css index a478afa..32aab1a 100644 --- a/public/stylesheets/revControl.css +++ b/public/stylesheets/revControl.css @@ -4,4 +4,8 @@ .selectedSnap { border: 2px solid red; +} + +.recentSnap { + border: 1px dotted grey; } \ No newline at end of file diff --git a/public/stylesheets/sidebar.css b/public/stylesheets/sidebar.css index 1b8aac4..99fb20b 100644 --- a/public/stylesheets/sidebar.css +++ b/public/stylesheets/sidebar.css @@ -27,7 +27,7 @@ position: fixed; height: 100%; top: 60px; - left: 15px; + right: 15px; width: 200px; background-color: beige; z-index: 999999; @@ -37,6 +37,11 @@ display: none; } + + + + + .nodeAttributes{ background-color: rgb(147, 213, 202); width: 100%; diff --git a/views/index.ejs b/views/index.ejs index 0e72d36..bbdcdf4 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -17,6 +17,7 @@ + @@ -88,11 +89,11 @@
    - Node Attributes + Node Attributes +

      -
    • author: you
    • -
    • timeStamp: now
    • -
    • etc
    • +
    • author: you
    • +
    • timeStamp: now
    @@ -116,32 +117,6 @@