mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-09-11 11:50:25 +08:00
REVISION CONTROL
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
$(function(){
|
||||
//alert("jquery works");
|
||||
|
||||
|
||||
$("#COMMIT").click(function(){
|
||||
socket.emit("COMMIT");
|
||||
});
|
||||
|
||||
$(".getRevHistory").click(function(){
|
||||
socket.emit("revHistoryRequest");
|
||||
});
|
||||
|
||||
$(".toggleSidebar").click(function(){
|
||||
$("#mainPanel").toggleClass("floatRight centering");
|
||||
$("#metaSidebar").toggleClass("hideBar");
|
||||
});
|
||||
|
||||
$("#markdownButton").click(function(){
|
||||
vo.thisView.createMarkDownBullet();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var nodesCollection = Backbone.Collection.extend({
|
||||
var NodesCollection = Backbone.Collection.extend({
|
||||
|
||||
model: NodeModel
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
renderRevControl = function(rootNode, timeStamp){
|
||||
var finalCollection = [];
|
||||
rootSnap = fetchLTE(rootNode, timeStamp );
|
||||
|
||||
var queue = [rootSnap];
|
||||
while(queue.length > 0){
|
||||
snap = queue.shift();
|
||||
finalCollection.push(snap);
|
||||
childrenSnaps = fetchChildren(snap);
|
||||
_.each(childrenSnaps, function(childSnap){queue.push(childSnap)});
|
||||
}
|
||||
console.log("FINALCOLLECTION");
|
||||
console.log(finalCollection);
|
||||
nodesCollection = new NodesCollection(finalCollection);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//we want the first snap that has a timestamp lessThan or Equal to this.
|
||||
//(if none exists, then this call is made in error!).
|
||||
function fetchLTE(nodeId, timeStamp){
|
||||
var snapList = snapHash[nodeId]; //sorted, [0] is smallest
|
||||
for(var i = snapList.length-1 ; i >= 0; i--){ //start with biggest/mostRecent.
|
||||
if(snapList[i].timestamp <= timeStamp){
|
||||
return snapList[i];
|
||||
}
|
||||
}
|
||||
alert("error!!");
|
||||
}
|
||||
|
||||
function fetchChildren(subRootSnap){
|
||||
childrenSnaps = [];
|
||||
var timeStamp = snap.timestamp;
|
||||
_.each(subRootSnap.children, function(childId){
|
||||
childrenSnaps.push( fetchLTE(childId, timeStamp) );
|
||||
});
|
||||
return childrenSnaps;
|
||||
}
|
||||
+57
-3
@@ -29,7 +29,7 @@
|
||||
socket.on('nodeData', function(data){
|
||||
//alert("data");
|
||||
console.log(data);
|
||||
nodesCollection = new nodesCollection(data);
|
||||
nodesCollection = new NodesCollection(data);
|
||||
var id = nodesCollection.findWhere({text: "0root"}).get("_id");
|
||||
if(otherID){
|
||||
id = otherID
|
||||
@@ -39,6 +39,42 @@
|
||||
that.viewRoot(id);
|
||||
});
|
||||
|
||||
|
||||
socket.on("commitReceived", function(){
|
||||
alert("commitReceived");
|
||||
});
|
||||
|
||||
socket.on("revHistory", function(data){
|
||||
alert("revHistory!!");
|
||||
console.log("revHistory!!");
|
||||
snapHash = data[0];
|
||||
timeHash = data[1];
|
||||
console.log("snapHash");
|
||||
console.log(snapHash);
|
||||
console.log("timeHash");
|
||||
console.log(timeHash);
|
||||
|
||||
var list = "";
|
||||
_.each(Object.keys(timeHash), function(timestamp){
|
||||
list += "<li><a class='timestamp'>"+timestamp+"</a></li>";
|
||||
})
|
||||
|
||||
$("#revTimestamps").html(list);
|
||||
})
|
||||
|
||||
$("#revTimestamps").on("click", "a.timestamp", function(event){
|
||||
// debugger;
|
||||
var a = event.target;
|
||||
var timestamp = parseInt($(a).html());
|
||||
renderRevControl("53ea3f506dc8d39342bf4f9f", timestamp);
|
||||
setTimeout(function(){
|
||||
// debugger;
|
||||
console.log("nodesCollection")
|
||||
console.log(nodesCollection);
|
||||
that.viewRoot("53ea3f506dc8d39342bf4f9f")
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
socket.on('edit', function(data){
|
||||
var id = data[0];
|
||||
var newText = data[1];
|
||||
@@ -130,9 +166,24 @@
|
||||
var thisModel = nodesCollection.findWhere({_id: ids[0]});
|
||||
var oldParModel = nodesCollection.findWhere({_id: ids[1]});
|
||||
var newParModel = nodesCollection.findWhere({_id: ids[2]});
|
||||
debugger;
|
||||
// debugger;
|
||||
moveNode(thisModel, indices[0], oldParModel, newParModel, indices[1]);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
socket.on("revControl", function(data){
|
||||
//(store all of this...).
|
||||
var timeHash = data[0];
|
||||
var snapHash = data[1];
|
||||
var timeStamps = timeHash.keys;
|
||||
|
||||
//To be continued...
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +191,9 @@
|
||||
|
||||
viewRoot: function(id){
|
||||
var rootNode = nodesCollection.findWhere({_id: id});
|
||||
if(!rootNode){
|
||||
rootNode = nodesCollection.findWhere({cur_id: id});
|
||||
}
|
||||
// alert("viewNode");
|
||||
console.log("ViewRoot + rootNode");
|
||||
console.log(rootNode);
|
||||
|
||||
@@ -55,6 +55,7 @@ var listView = Backbone.View.extend({
|
||||
var childrenIds = that.model.get("children");
|
||||
_.each(childrenIds, function(childId, index){
|
||||
var childModel = nodesCollection.findWhere({_id: childId});
|
||||
if(!childModel){childModel= nodesCollection.findWhere({cur_id: childId});}
|
||||
console.log("childModelId = " + childId);
|
||||
console.log(childModel);
|
||||
var tempView = new showView({
|
||||
|
||||
@@ -8,80 +8,44 @@ body {
|
||||
}
|
||||
|
||||
/************** Navbar *****************/
|
||||
.navbar-primary .navbar {
|
||||
border-bottom:none;
|
||||
}
|
||||
.navbar-primary .navbar .navbar-brand {
|
||||
color:#fff;
|
||||
}
|
||||
.navbar-nav.navbar-right:last-child {
|
||||
margin-right: 0;
|
||||
.myNav{
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 26px;
|
||||
background-color: black;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
/* Navbar-xs */
|
||||
.navbar-xs .navbar-primary .navbar {
|
||||
min-height:36px;
|
||||
.btn{
|
||||
height: 20px;
|
||||
width: 10px;
|
||||
}
|
||||
/* Sidebar Link */
|
||||
.navbar-xs a.navbar-left {
|
||||
margin: 7px;
|
||||
margin-left: 10px;
|
||||
|
||||
ul.navbar-right {
|
||||
list-style-type: none;
|
||||
}
|
||||
.navbar-xs a i {
|
||||
margin: 0;
|
||||
|
||||
.navbar-right > li {
|
||||
position: relative;
|
||||
float: left;
|
||||
/*border*/
|
||||
}
|
||||
/* Navbar-Brand */
|
||||
.navbar-xs .navbar-primary .navbar .navbar-brand {
|
||||
padding: 8px 8px;
|
||||
font-size: 16px;
|
||||
line-height: 18px;
|
||||
|
||||
.navbar-right > li > a{
|
||||
display: block;
|
||||
padding: 2px 20px;
|
||||
}
|
||||
.navbar-xs .navbar-brand {
|
||||
margin-top: 2px;
|
||||
}
|
||||
/* Search Form */
|
||||
.navbar-xs .navbar-form {
|
||||
height: 28px;
|
||||
margin-top: 4px;
|
||||
margin-bottom: 0;
|
||||
padding-right: 6px;
|
||||
}
|
||||
.navbar-xs .navbar-form .form-control {
|
||||
height: 28px;
|
||||
/*padding: 0 12px;*/
|
||||
font-size: 14px;
|
||||
line-height: 1.42857;
|
||||
border-radius: 3px;
|
||||
}
|
||||
/* Star Button */
|
||||
.navbar-xs .btn {
|
||||
min-width: 27px;
|
||||
width: 27px;
|
||||
height: 28px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.navbar-xs .btn i {
|
||||
margin-left: -7px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
/* Navbar Nav */
|
||||
.navbar-xs ul {
|
||||
margin: 2px
|
||||
}
|
||||
.navbar-xs .navbar-primary .navbar .navbar-nav > li > a {
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.navbar-xs a img {
|
||||
height: 16px;
|
||||
margin-top: 0px;
|
||||
|
||||
.navbar-right > li:hover > a {
|
||||
background: grey;
|
||||
}
|
||||
|
||||
/************* End Navbar **************/
|
||||
|
||||
/*************** Sidebar ***************/
|
||||
|
||||
.sidebar .list-group-item {
|
||||
/*.sidebar .list-group-item {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding-top: 6px;
|
||||
@@ -102,18 +66,61 @@ body {
|
||||
|
||||
.sidebar .list-group-item-text {
|
||||
margin-left: 4px;
|
||||
}*/
|
||||
|
||||
#metaSidebar{
|
||||
position: fixed;
|
||||
height: 100%;
|
||||
top: 60px;
|
||||
left: 15px;
|
||||
width: 200px;
|
||||
background-color: beige;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
#metaSidebar.hideBar{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nodeAttributes{
|
||||
background-color: rgb(147, 213, 202);
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.nodeAttributes > ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.revHistory{
|
||||
background-color: rgb(48, 127, 189);
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.revHistory > a{
|
||||
color: white
|
||||
}
|
||||
|
||||
#revTimestamps > li > a{
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************* End Sidebar *************/
|
||||
|
||||
/**************** Panel ****************/
|
||||
/*.main-container {
|
||||
margin-top: 60px;
|
||||
margin-bottom: 30px;
|
||||
}*/
|
||||
.floatRight{
|
||||
float: right;
|
||||
margin-top: 40px;
|
||||
width: 760px;
|
||||
}
|
||||
|
||||
.centering{
|
||||
width: 800px;
|
||||
width: 760px;
|
||||
margin: auto;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
|
||||
Reference in New Issue
Block a user