Skip to content

Commit

Permalink
stufffffszzzzz FUCK YOU
Browse files Browse the repository at this point in the history
AWESOME COMMIT MESSAGE FUCK YOU FOR MAKING ME WRITE ONE!@#!@#
  • Loading branch information
setpixel committed Aug 5, 2015
1 parent dc8bbb9 commit 2617e06
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 7 deletions.
3 changes: 2 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ h2 {

.card div:empty {
display: block;
height: 1em;
height: auto;
min-width: 2px;

}


Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<script src="js/stats.js"></script>
<script src="js/awsuploader.js"></script>
<script src="js/circlebob.js"></script>
<script src="js/html2canvas.min.js" async></script>
<script src="js/main.js"></script>
<div id="inspector" class="hidden">
<h1>Edit some shit.</h1>
Expand Down
2 changes: 2 additions & 0 deletions js/circlebob.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@

var hoverTowards = function(x, y) {
destLoc = [x,y];
opacity = 1;
}

var flyTowards = function(x, y) {
destLoc = [x,y];
acceleration = 0.4;
elasticity = 1;
dampening = 0.7;
opacity = 1;
}

var ping = function(x,y) {
Expand Down
9 changes: 9 additions & 0 deletions js/html2canvas.min.js

Large diffs are not rendered by default.

38 changes: 35 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/*
HIGHLEVEL
//Save to google drive / import from google drive
Inspector - hook up
FILTERING - add tags, ability to show nodes that have tags
UI
Printing
Save to google drive / import from google drive
Presentation view
COLLABORATORS
TODAYS BUGS:
make a mode to always scale to fit
ability to deselect
make it so scroll pos changes based on focus
//fiz scaling bug
//make it so circle bob moves around appropriately
//figure out the scroll offset for dragging!!!
Expand Down Expand Up @@ -253,7 +256,7 @@
case "beat":
htmlList.push('<div class="card beat" id="' + obj.id + '">');
if (obj.imageURL) {
htmlList.push('<img src="' + obj.imageURL + '">');
htmlList.push('<img src="' + obj.imageURL + '?123123" crossorigin="anonymous">');
}
htmlList.push('<div class="title" contenteditable="true" spellcheck="false">' + obj.title + '</div>');
if (obj.synopsis) {
Expand Down Expand Up @@ -282,7 +285,7 @@
}
htmlList.push('<div class="clear"></div>');
if (obj.imageURL) {
htmlList.push('<img src="' + obj.imageURL + '">');
htmlList.push('<img src="' + obj.imageURL + '?123123" crossorigin="anonymous">');
}
htmlList.push('<div class="title" contenteditable="true" spellcheck="false">' + obj.title + '</div>');
if (obj.synopsis) {
Expand Down Expand Up @@ -698,6 +701,7 @@
$( function() {

$(document).on("mousemove", function(event) {
//circleBob.hoverTowards(event.clientX, event.clientY);
if (dragItem) {
var scrollOffsetX = $("#canvas-container").scrollLeft();
dragItem.toggleClass( "dragged", true )
Expand Down Expand Up @@ -874,6 +878,33 @@
$("#" + node.id + " .time-of-day").text(node.timeOfDay);
}


var screenshot = function(callbackfunction) {
var newDiv = $('<div style="opacity: 0.0; position: fixed;"></div>');
var newDiv2 = $('<div style="left: 40px; position: relative; transform: translate3d(0px, 0px, 0px) scale(0.8);"></div>');
newDiv.append(newDiv2.append($("#canvas-container").html()));
$('body').prepend(newDiv);

var canvasURL;

html2canvas(newDiv, {
onrendered: function(canvas) {
canvasURL = canvas.toDataURL("image/jpeg", 0.5);
newDiv.remove();
callbackfunction(canvasURL);
},
width: 800,
height: 600,
async: false,
removeContainer: true,
background: "#0e76bc",
allowTaint: false,
useCORS: true
});
}



window.outlinerApp = {
init: init,
load: load,
Expand All @@ -889,6 +920,7 @@
reflow: reflowScreen,
refreshNode: refreshNode,
scaleToFit: scaleToFit,
screenshot: screenshot,
getCurrentSelection: function() { return selectedItem; },
twoplus: function() { return 2+2; }
};
Expand Down
99 changes: 96 additions & 3 deletions js/realtimeModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ TODO

if (id) {
// Load the document id from the URL
realtimeUtils.load(id.replace('/', ''), onFileLoaded, onFileInitialize);
documentID = id.replace('/', '');
realtimeUtils.load(id.replace('/', ''), onFileLoaded, onFileInitialize);
} else {
// Create a new document, add it to the URL
window.gapi.client.load('drive', 'v2', function() {
Expand All @@ -75,6 +75,30 @@ TODO
};

function onFileInitialize(model) {
if (documentID) {
gapi.client.load('drive', 'v2', function(){
var request = gapi.client.drive.files.get({
'fileId': documentID,
'alt': 'media'
}).execute(function(e){
if (!e.id) {
createBasicNewDoc(model);
} else {
var request = gapi.client.request({
'path': '/upload/drive/v2/files/' + documentID + '/realtime',
'method': 'PUT',
'params': {'uploadType': 'media'},
'body': JSON.stringify(e.result)});
request.execute();
}
});
});
} else {
createBasicNewDoc(model);
}
};

var createBasicNewDoc = function(model) {
var documentMetadata = model.createMap();
model.getRoot().set('documentMetadata', documentMetadata);
documentMetadata.set('title', 'New Outline');
Expand Down Expand Up @@ -134,7 +158,7 @@ TODO
node.tags.push('excitement');
var index = outlineNodes.push(node);
node.order = index;
};
}

function displayObjectChangedEvent(evt) {
//console.log(evt);
Expand Down Expand Up @@ -197,7 +221,11 @@ TODO
outlinerApp.reflow();
}

// save dump to google drive file!
queueDump();




// console.log('Event type: ' + events[i].type);
// console.log('Local event: ' + events[i].isLocal);
Expand All @@ -206,6 +234,67 @@ TODO
}
}


var dumpTimeout;


var queueDump = function() {
clearTimeout(dumpTimeout);
dumpTimeout = setTimeout(dumpToDrive, 1000);
}

function encodeURL(str){
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
}


var dumpToDrive = function() {

outlinerApp.screenshot(function(canvasURL){

var jsonDoc = docModel.toJson();
var thumbnailData = encodeURL(canvasURL.replace(/^data:image\/(png|jpg|jpeg);base64,/, ""));
var thumbnail = {image: thumbnailData, mimeType: "image/jpeg"}

var fileMetadata = {mimeType: "application/vnd.google.drive.ext-type.otl", thumbnail: thumbnail};

const boundary = '-------314159265358979323846';
const delimiter = "\r\n--" + boundary + "\r\n";
const close_delim = "\r\n--" + boundary + "--";

var contentType = 'application/octet-stream';

var base64Data = btoa(jsonDoc);

var multipartRequestBody =
delimiter +
'Content-Type: application/json\r\n\r\n' +
JSON.stringify(fileMetadata) +
delimiter +
'Content-Type: ' + contentType + '\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'\r\n' +
base64Data +
close_delim;

var request = gapi.client.request({
'path': '/upload/drive/v2/files/' + documentID,
'method': 'PUT',
'params': {
'uploadType': 'multipart', 'alt': 'json'},
'headers': {
'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
},
'body': multipartRequestBody});
request.execute(function(e){});



})


}

var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
Expand All @@ -223,6 +312,9 @@ TODO


function onFileLoaded(doc) {
console.log("ON FILE LOADED")

//console.log(gapi.client.drive.realtime)
docModel = doc.getModel();
docRoot = docModel.getRoot();

Expand Down Expand Up @@ -300,7 +392,8 @@ TODO
remove: remove,
docModel: function(){ return docModel;},
docRoot: function(){ return docRoot;},
getID: function(){ return documentID; }
getID: function(){ return documentID; },
realtimeUtils: realtimeUtils
};

}).call(this);

0 comments on commit 2617e06

Please sign in to comment.