Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Version 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudruffin committed Dec 14, 2016
2 parents d23b3b9 + 7306573 commit b11466e
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 84 deletions.
8 changes: 6 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var javascript = require('./routes/javascript');

var app = express();

global.DROP_IT_VERSION=2.2;
global.DROP_IT_VERSION=parseFloat(require("./package.json").version);

// view engine setup
app.set('views', path.join(__dirname, 'views'));
Expand All @@ -47,7 +47,7 @@ app.use(express.static(path.join(__dirname, path.join('node_modules', 'tether',
app.use(express.static(path.join(__dirname, path.join('node_modules', 'boosted', 'dist'))));
app.use(express.static(path.join(__dirname, path.join('node_modules', 'jquery', 'dist','cdn'))));
app.use(express.static(path.join(__dirname, path.join('node_modules', 'jquery-file-download', 'src','Scripts'))));
app.use(express.static(path.join(__dirname, path.join('node_modules', 'zeroclipboard', 'dist'))));
app.use(express.static(path.join(__dirname, path.join('node_modules', 'clipboard', 'dist'))));

var receiveUriPath = '/receive';
app.use('/', send);
Expand Down Expand Up @@ -75,6 +75,8 @@ if (app.get('env') === 'development') {
console.error(err);
res.status(err.status || 500);
res.render('error', {
dumbContent : "",
isLocal : typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion: global.DROP_IT_VERSION,
message: err.message,
sub_message: err.sub_message,
Expand All @@ -90,7 +92,9 @@ if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
dumbContent : "",
isLocal : typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion : global.DROP_IT_VERSION,
message: err.message,
sub_message: err.sub_message,
stack: err.stack
Expand Down
90 changes: 51 additions & 39 deletions client/jdropit-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,7 @@ SenderHandler.prototype = {


this.socket.on('server_receiver_ready', function (receiverId) {
$('#copyLinkContainer').hide();
$('#transfertMessage').html("Transfer in progress...");

//init container
var transferContainer = $('#transferContainer');
transferContainer.show();

var rowReceiverTemplate = $("#rowReceiverTemplate");
var newRow = rowReceiverTemplate.clone();
newRow.removeAttr("id");
newRow.show();
var linkRemove = newRow.find(".icon-delete");
linkRemove.on("click", function (e) {
e.preventDefault();
newRow.hide();
});
linkRemove.tooltip();

var pbContainer = newRow.children(".col-xs-7");
var transferProgressBar = pbContainer.find("progress");
var displayProgressBar = pbContainer.find(".text-xs-center");
displayProgressBar.attr("id", "progress-"+receiverId);
transferProgressBar.attr("aria-describedby", "progress-"+receiverId);
transferContainer.append(newRow);
that.receiverInfos[receiverId] = new ReceiverInfo(pbContainer, transferProgressBar, displayProgressBar, linkRemove);

that.startUpload(receiverId);

that.receiverIsReady(receiverId);
});


Expand All @@ -138,6 +111,18 @@ SenderHandler.prototype = {
});
},

setNavigationStep: function(step) {
$(".o-stepbar > ol > li").each(function (idx) {
if(step > idx) {
$(this).removeClass("current");
$(this).addClass("done");
}
else if(step == idx){
$(this).addClass("current");
}
});
},

fileIsReady: function (fileToTransfert) {
var sizeDisplay = fileToTransfert.size > (1024 * 1024) ? Math.round(fileToTransfert.size / 1024 / 1024) + " Mo" :
fileToTransfert.size > 1024 ? Math.round(fileToTransfert.size / 1024) + " Ko" : fileToTransfert.size + " o";
Expand All @@ -153,6 +138,38 @@ SenderHandler.prototype = {
$('#copyLinkContainer').show(500);
$('#warning-window').show(500);
$('#selectFileContainer').hide(500);
this.setNavigationStep(1);
},

receiverIsReady: function(receiverId) {
$('#copyLinkContainer').hide();
this.setNavigationStep(2);
$('#transfertMessage').html("Transfer in progress...");

//init container
var transferContainer = $('#transferContainer');
transferContainer.show();

var rowReceiverTemplate = $("#rowReceiverTemplate");
var newRow = rowReceiverTemplate.clone();
newRow.removeAttr("id");
newRow.show();
var linkRemove = newRow.find(".icon-delete");
linkRemove.on("click", function (e) {
e.preventDefault();
newRow.hide();
});
linkRemove.tooltip();

var pbContainer = newRow.children(".col-xs-8");
var transferProgressBar = pbContainer.find("progress");
var displayProgressBar = pbContainer.find(".text-xs-center");
displayProgressBar.attr("id", "progress-"+receiverId);
transferProgressBar.attr("aria-describedby", "progress-"+receiverId);
transferContainer.append(newRow);
this.receiverInfos[receiverId] = new ReceiverInfo(pbContainer, transferProgressBar, displayProgressBar, linkRemove);

this.startUpload(receiverId);
},

startUpload: function (receiverId) {
Expand Down Expand Up @@ -213,18 +230,13 @@ function sendFile(isLocal) {
var senderHandler = new SenderHandler(isLocal);

$("#clipboardcopyok").hide();
//____ Handling of copy to clipboard with zeroClipboard
var clip = new ZeroClipboard(document.getElementById("copy-button"));
clip.on("ready", function () {
clip.on("copy", function (event) {
var clipboard = event.clipboardData;
clipboard.setData("text/plain", 'http://' + senderHandler.receiverUrl);
});
clip.on("aftercopy", function () {
$("#clipboardcopyok").show(300);
});
});

var clipboard = new Clipboard('#copy-button');
clipboard.on('success', function(e) {
console.info('Copied to clipboard:', e.text);
$("#clipboardcopyok").show(300);
e.clearSelection();
});

var dropZone = $('#drop-zone');
//----- Handling drag and drop zone style
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Just-Drop-It",
"version": "1.0.0",
"version": "2.3.0",
"description": "Simply beam files between two browsers",
"keywords": [
"Transfer",
Expand Down Expand Up @@ -30,7 +30,7 @@
"uglify-js" : "~2.4.23",
"boosted" : "~4.0.0-alpha.4",
"tether" : "~1.1.1",
"zeroclipboard" : "~2.2.0",
"clipboard" : "~1.5.16",
"jquery" : "1.11.2",
"jquery-file-download" : "1.4.5"

Expand Down
4 changes: 3 additions & 1 deletion public/css/justdropit.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ header {
}

main {
padding: 1.5rem 0px 1.1rem;
padding: 2rem 0px 1.1rem;
}

main em {
Expand Down Expand Up @@ -211,6 +211,8 @@ input[type='file'] {
display: inline;
}

/*to add margin between rows*/
.top-buffer { margin-top:30px; }



Expand Down
1 change: 1 addition & 0 deletions routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ router.get('/', function(req, res) {
res.render('admin', {title : "Just drop it Admin",
isLocal : typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion : global.DROP_IT_VERSION,
dumbContent : "",
senders : senders});
});

Expand Down
3 changes: 2 additions & 1 deletion routes/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ router.get(router.servePagePath + ':id', function (req, res, next) {
debug('receive - rendering receive for uri %s', uri);
res.render('receive', {
isLocal: typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion: global.DROP_IT_VERSION,
dumbContent : "",
fileName: sender.fileName,
fileSize: sender.fileSize,
jdropitVersion: global.DROP_IT_VERSION,
senderId: sender.senderId
});
}, function () {
Expand Down
11 changes: 10 additions & 1 deletion routes/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ var fs = require("fs");

debug.log = console.log.bind(console);

var dumbQuotes = ["Let us ease your file transfers",
"Making the world a better place",
"Make file transfers, not war",
"When file transfer becomes pleasure",
"File transfer is not a fatality",
"Helping humanity thrive"];

/* GET home page. */
router.get('/', function(req, res) {
debug('serving send');
res.render('send', {
isLocal : typeof process.env.OPENSHIFT_NODEJS_IP === "undefined",
jdropitVersion : global.DROP_IT_VERSION});
jdropitVersion : global.DROP_IT_VERSION,
dumbContent : dumbQuotes[Math.floor(Math.random() * dumbQuotes.length)]
});
});

/* GET home page. */
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
require("./ioserver")(app, server);
// Start the app on the specific interface (and port).
server.listen(port, ipAddress, function () {
var mDate = new Date(Date.now());
debug('%s: Node server started on %s:%d ...', mDate, ipAddress == null ? "*" : ipAddress, port);
debug('%s: JustDropIt(%s) started on %s:%d ...',
new Date(Date.now()), global.DROP_IT_VERSION, ipAddress == null ? "*" : ipAddress, port);
});


Expand Down
6 changes: 3 additions & 3 deletions url-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ UriGenerator.prototype.generateUrl = function () {
error("url generation not ready: file are not all loaded");
return null;
} else {
return this.adv[Math.floor(Math.random() * this.adv.length) + 1] + '-' +
this.adj[Math.floor(Math.random() * this.adj.length) + 1] + '-' +
this.noun[Math.floor(Math.random() * this.noun.length) + 1];
return this.adv[Math.floor(Math.random() * this.adv.length)] + '-' +
this.adj[Math.floor(Math.random() * this.adj.length)] + '-' +
this.noun[Math.floor(Math.random() * this.noun.length)];
}
};

Expand Down
7 changes: 2 additions & 5 deletions views/header.jade
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ header(role="banner")
div.row
div.col-xs-12
h1 Just drop it
small «Let us ease your file transfer»

small= dumbContent

script.
function enableNotifications() {
if (jdNotif.isAlreadyGranted()) {
jdNotif.notify("Great!", "Notifications are enabled");
} else if(jdNotif.isNotificationAvailable()){
if(jdNotif.isNotificationAvailable() && !jdNotif.isAlreadyGranted()){
var container = $(".notification-header").first();
var dismiss = container.find(".dismiss-notification").first();
container.show();
Expand Down
11 changes: 6 additions & 5 deletions views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ html
body
include ./header
main
div.alert.alert-warning#warning-window(style="display: none;")
span.icon-Warningimportant(aria-hidden="true")
span.sr-only Warning:
span
|   Don't close this window!
div.container
div.alert.alert-warning#warning-window(style="display: none;")
span.icon-Warningimportant(aria-hidden="true")
span.sr-only Warning:
span
|   Don't close this window!

include ./user_messages
block content
include ./footer
Expand Down
2 changes: 1 addition & 1 deletion views/receive.jade
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ block content
div.row#completeContainer(style="display: none;")
div.col-xs-12
h2 Thank you!
p Your friend knows you received the file. You can close this page now.
p Your friend knows you've received the file. You can close this page now.
div.row#errorContainer(style="display: none;")
div.col-xs-12
h2 Error
Expand Down
48 changes: 30 additions & 18 deletions views/send.jade
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ block extra_scripts
script(src="/js/HackTimer.js")
script(src="/js/HackTimerWorker.js")
script(src="/js/socket.io-stream.js")
script(src="/ZeroClipboard.js")
script(src="/clipboard.js")
script(src="/js/jdropit-send.js")
else
script(src="/js/HackTimer.silent.min.js")
script(src="/js/HackTimerWorker.min.js")
script(src="/js/socket.io-stream.min.js")
script(src="/ZeroClipboard.min.js")
script(src="/clipboard.min.js")
script(src="/js/jdropit-send.min.js")
script.

Expand All @@ -41,37 +41,49 @@ block extra_scripts
sendFile(#{isLocal});
enableNotifications();
}

block content
div.row#selectFileContainer
div.row
div.col-xs-12
h2 Select your file
nav.o-stepbar
ol
li.stepbar-item.current
a.stepbar-link(title="Select your file")
span.step-number 1
span.step-title Select your file
li.stepbar-item
a.stepbar-link(title="Share it with your friends")
span.step-number 2
span.step-title Share it with your friends
li.stepbar-item
a.stepbar-link(title="Transfer")
span.step-number 3
span.step-title Transfer

div.row.top-buffer#selectFileContainer
div.col-xs-12
p.lead Either drop a file below:
div.upload-drop-zone#drop-zone Just drag and drop a file here
form.form-inline#myform(action="")
form.form-inline.float-xs-right#myform(action="")
label.lead(for="file") Or select it with the file explorer: 
input#file(type="file")
div.row#copyLinkContainer(style="display: none;")
div.row.top-buffer#copyLinkContainer(style="display: none;")
div.col-xs-12
h2 Ready to transfer!
p.lead Tell your friend to go to this url:
div.text-muted
p#generatedurl
button.btn.btn-orange#copy-button(title="Click to copy url to clipboard") Copy to clipoard
span.text-success.icon-checkbox-tick#clipboardcopyok(aria-hidden="true")
p.text-muted.text-xs-center.lead#generatedurl
span.text-success.pull-xs-right.icon-checkbox-tick#clipboardcopyok(aria-hidden="true")
button.btn.btn-orange.pull-xs-right#copy-button(title="Click to copy url to clipboard",data-clipboard-target="#generatedurl") Copy to clipboard
div#transferContainer(style="display: none;")
div.row
div.row.top-buffer
div.col-xs-12
em The transfer will start as soon as your friends open the link.

p.text-muted#generatedurlreminder
p.lead Each transfer will start as soon as your friends open the link.
p.text-muted.text-xs-center.lead#generatedurlreminder
p  
span#filename
div#rowReceiverTemplate.row(style="display: none;")
div.col-xs-1
div.col-xs-1.text-right
div.col-xs-1.offset-xs-1.text-right
span.icon-Adult.big-icon
div.col-xs-7
div.col-xs-8
div.text-xs-center#progressDisplay 0%
progress.progress(value="0" max="100" style="min-width: 2em;" aria-describedby="progressDisplay" aria-valuenow="0")
div.col-xs-1
Expand Down
Loading

0 comments on commit b11466e

Please sign in to comment.