DONE.Release0.0. MISC small things. Fixed ClientRevBug

This commit is contained in:
Curtis SerVaas
2014-10-17 18:47:24 -04:00
parent 61284b39df
commit 366faa2ee6
16 changed files with 189 additions and 79 deletions
+1 -1
View File
@@ -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);
});
+17 -11
View File
@@ -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;
+10 -5
View File
@@ -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]
+1
View File
@@ -1,6 +1,7 @@
var mongoose = require('mongoose');
var userSchema = mongoose.Schema({
// _id: String,
google : {
id : String,
token : String,
+1 -1
View File
@@ -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");
+8 -17
View File
@@ -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];
+4 -1
View File
@@ -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();
}
File diff suppressed because one or more lines are too long
+3
View File
@@ -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)
+8 -9
View File
@@ -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) );
});
+30 -1
View File
@@ -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);
});
})
+31
View File
@@ -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;
}
+3 -1
View File
@@ -9,8 +9,10 @@ body {
/******* Body ********/
/**************** Panel ****************/
/*revListeners.js , index.ejs*/
.floatRight{
float: right;
float: left;
margin-top: 40px;
width: 760px;
}
+4
View File
@@ -4,4 +4,8 @@
.selectedSnap {
border: 2px solid red;
}
.recentSnap {
border: 1px dotted grey;
}
+6 -1
View File
@@ -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%;
+5 -30
View File
@@ -17,6 +17,7 @@
<link href="stylesheets/panel.css" rel="stylesheet" type="text/css">
<link href="stylesheets/revControl.css" rel="stylesheet" type="text/css">
<link href="stylesheets/sidebar.css" rel="stylesheet" type="text/css">
<link href="stylesheets/autoComplete.css" rel="stylesheet" type="text/css">
@@ -88,11 +89,11 @@
<div id='metaSidebar'>
<div class='nodeAttributes'>
Node Attributes
<b>Node Attributes</b>
<br><br>
<ul>
<li>author: you</li>
<li>timeStamp: now</li>
<li>etc</li>
<li id='authorLI'>author: you</li>
<li id='timestampLI'>timeStamp: now</li>
</ul>
</div>
<div class='revHistory'>
@@ -116,32 +117,6 @@
<script>
$(function(){
$('textarea').textareaAutoExpand();
$('#searchBar').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'
}
}
]);
});
var width;