Merge branch 'master' into ui
This commit is contained in:
commit
be3df22757
@ -1,4 +1,5 @@
|
||||
const FileReceiver = require('./fileReceiver');
|
||||
const { notify } = require('./utils');
|
||||
const $ = require('jquery');
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -27,6 +28,7 @@ $(document).ready(function() {
|
||||
$('.send-new').show();
|
||||
$btn.text('Download complete!');
|
||||
$btn.attr('disabled', 'true');
|
||||
notify('Your download has finished.');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
const EventEmitter = require('events');
|
||||
const { ivToStr } = require('./utils');
|
||||
const { ivToStr, notify } = require('./utils');
|
||||
|
||||
class FileSender extends EventEmitter {
|
||||
constructor(file) {
|
||||
@ -23,7 +23,7 @@ class FileSender extends EventEmitter {
|
||||
}
|
||||
|
||||
if (xhr.status === 200) {
|
||||
console.log('The file was successfully deleted.');
|
||||
console.log('The file was successfully deleted.')
|
||||
} else {
|
||||
console.log('The file has expired, or has already been deleted.');
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const FileSender = require('./fileSender');
|
||||
const { notify } = require('./utils')
|
||||
const $ = require('jquery');
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -94,6 +95,9 @@ $(document).ready(function() {
|
||||
.querySelector('#progress-bar')
|
||||
.style.setProperty('--progress', percentComplete + '%');
|
||||
$('#progress-text').html(`${percentComplete}%`);
|
||||
if (percentComplete === 100) {
|
||||
notify('Your upload has finished.');
|
||||
}
|
||||
});
|
||||
fileSender.upload().then(info => {
|
||||
const url = info.url.trim() + `#${info.secretKey}`.trim();
|
||||
|
@ -20,7 +20,21 @@ function strToIv(str) {
|
||||
return iv;
|
||||
}
|
||||
|
||||
function notify(str) {
|
||||
if (!("Notification" in window)) {
|
||||
return;
|
||||
} else if (Notification.permission === 'granted') {
|
||||
new Notification(str)
|
||||
} else if (Notification.permission !== 'denied') {
|
||||
Notification.requestPermission(function(permission) {
|
||||
if (permission === 'granted')
|
||||
new Notification(str);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ivToStr,
|
||||
strToIv
|
||||
strToIv,
|
||||
notify
|
||||
};
|
||||
|
@ -22,6 +22,11 @@ const conf = convict({
|
||||
arg: 'port',
|
||||
env: 'PORT'
|
||||
},
|
||||
analytics_id: {
|
||||
format: String,
|
||||
default: 'UA-101393094-1',
|
||||
env: 'GOOGLE_ANALYTICS_ID'
|
||||
},
|
||||
env: {
|
||||
format: ['production', 'development', 'test'],
|
||||
default: 'development',
|
||||
|
@ -16,7 +16,10 @@ const log = mozlog('portal.server');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
|
||||
app.engine('handlebars', exphbs({
|
||||
defaultLayout: 'main',
|
||||
partialsDir: 'views/partials/'
|
||||
}));
|
||||
app.set('view engine', 'handlebars');
|
||||
|
||||
app.use(helmet());
|
||||
@ -25,7 +28,10 @@ app.use(bodyParser.json());
|
||||
app.use(express.static(path.join(__dirname, '../public')));
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.render('index');
|
||||
res.render('index', {
|
||||
shouldRenderAnalytics: notLocalHost,
|
||||
trackerId: conf.analytics_id
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/exists/:id', (req, res) => {
|
||||
@ -43,7 +49,9 @@ app.get('/download/:id', (req, res) => {
|
||||
.then(contentLength => {
|
||||
res.render('download', {
|
||||
filename: filename,
|
||||
filesize: bytes(contentLength)
|
||||
filesize: bytes(contentLength),
|
||||
shouldRenderAnalytics: notLocalHost,
|
||||
trackerId: conf.analytics_id
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
|
@ -6,6 +6,9 @@
|
||||
<script src="/bundle.js"></script>
|
||||
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css">
|
||||
<link rel="stylesheet" type="text/css" href="/main.css" />
|
||||
{{#if shouldRenderAnalytics}}
|
||||
{{> analytics trackerId=trackerId}}
|
||||
{{/if}}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
<script src="/bundle.js"></script>
|
||||
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css">
|
||||
<link rel="stylesheet" type="text/css" href="/main.css" />
|
||||
{{#if shouldRenderAnalytics}}
|
||||
{{> analytics trackerId=trackerId}}
|
||||
{{/if}}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
10
views/partials/analytics.handlebars
Normal file
10
views/partials/analytics.handlebars
Normal file
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{{trackerId}}}', 'auto');
|
||||
ga('set', 'anonymizeIp', true);
|
||||
ga('send', 'pageview');
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user