2018-04-29 12:47:24 +00:00
/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */
2017-01-14 09:16:47 +00:00
2019-09-01 19:23:16 +00:00
const lsKeys = {
token : 'token' ,
chunkSize : 'chunkSize' ,
2019-09-08 01:56:29 +00:00
parallelUploads : 'parallelUploads' ,
2019-09-15 07:20:55 +00:00
uploadsHistoryOrder : 'uploadsHistoryOrder' ,
2019-09-17 04:13:41 +00:00
previewImages : 'previewImages' ,
2019-09-08 01:56:29 +00:00
fileLength : 'fileLength' ,
uploadAge : 'uploadAge'
2019-09-01 19:23:16 +00:00
}
2018-10-09 19:52:41 +00:00
const page = {
2018-04-29 12:47:24 +00:00
// user token
2019-09-01 19:23:16 +00:00
token : localStorage [ lsKeys . token ] ,
2018-04-29 12:47:24 +00:00
// configs from api/check
private : null ,
enableUserAccounts : null ,
2019-08-20 02:16:34 +00:00
maxSize : null ,
2018-05-09 08:41:30 +00:00
chunkSize : null ,
2019-09-08 01:56:29 +00:00
temporaryUploadAges : null ,
fileIdentifierLength : null ,
2018-04-29 12:47:24 +00:00
// store album id that will be used with upload requests
album : null ,
2019-10-11 05:36:59 +00:00
parallelUploads : 2 ,
2019-09-17 04:13:41 +00:00
previewImages : null ,
2019-09-08 01:56:29 +00:00
fileLength : null ,
uploadAge : null ,
2019-09-01 19:23:16 +00:00
maxSizeBytes : null ,
urlMaxSize : null ,
urlMaxSizeBytes : null ,
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
tabs : [ ] ,
2019-09-08 01:56:29 +00:00
activeTab : null ,
2018-05-06 14:14:57 +00:00
albumSelect : null ,
2018-05-11 14:34:13 +00:00
previewTemplate : null ,
2018-05-06 14:14:57 +00:00
2018-04-29 12:47:24 +00:00
dropzone : null ,
clipboardJS : null ,
2018-10-18 13:26:40 +00:00
lazyLoad : null ,
2018-01-23 20:06:30 +00:00
2019-11-29 10:42:29 +00:00
// additional vars for url uploads
urlsQueue : [ ] ,
activeUrlsQueue : 0 ,
2019-09-17 04:13:41 +00:00
// Include BMP for uploads preview only, cause the real images will be used
// Sharp isn't capable of making their thumbnails for dashboard and album public pages
imageExts : [ '.webp' , '.jpg' , '.jpeg' , '.bmp' , '.gif' , '.png' , '.tiff' , '.tif' , '.svg' ] ,
videoExts : [ '.webm' , '.mp4' , '.wmv' , '.avi' , '.mov' , '.mkv' ] ,
2019-09-19 01:27:19 +00:00
albumTitleMaxLength : 70 ,
2019-09-17 04:13:41 +00:00
albumDescMaxLength : 4000
2018-10-18 13:26:40 +00:00
}
2018-01-23 20:06:30 +00:00
2019-09-19 07:19:11 +00:00
// Handler for errors during initialization
2019-09-15 18:18:22 +00:00
page . onInitError = error => {
// Hide these elements
document . querySelector ( '#albumDiv' ) . classList . add ( 'is-hidden' )
document . querySelector ( '#tabs' ) . classList . add ( 'is-hidden' )
document . querySelectorAll ( '.tab-content' ) . forEach ( element => {
return element . classList . add ( 'is-hidden' )
} )
// Update upload button
const uploadButton = document . querySelector ( '#loginToUpload' )
uploadButton . innerText = 'An error occurred. Try to reload?'
uploadButton . classList . remove ( 'is-loading' )
uploadButton . classList . remove ( 'is-hidden' )
uploadButton . addEventListener ( 'click' , ( ) => {
location . reload ( )
} )
2019-09-19 07:19:11 +00:00
if ( error . response )
page . onAxiosError ( error )
else
page . onError ( error )
}
// Handler for regular JS errors
page . onError = error => {
console . error ( error )
const content = document . createElement ( 'div' )
content . innerHTML = ` <code> ${ error . toString ( ) } </code> `
return swal ( {
title : 'An error occurred!' ,
icon : 'error' ,
content
} )
}
// Handler for Axios errors
page . onAxiosError = error => {
console . error ( error )
2019-09-15 18:18:22 +00:00
2019-09-19 07:19:11 +00:00
// Better Cloudflare errors
2019-09-15 18:18:22 +00:00
const cloudflareErrors = {
520 : 'Unknown Error' ,
521 : 'Web Server Is Down' ,
522 : 'Connection Timed Out' ,
523 : 'Origin Is Unreachable' ,
524 : 'A Timeout Occurred' ,
525 : 'SSL Handshake Failed' ,
526 : 'Invalid SSL Certificate' ,
527 : 'Railgun Error' ,
530 : 'Origin DNS Error'
}
2019-09-19 07:19:11 +00:00
2019-09-15 18:18:22 +00:00
const statusText = cloudflareErrors [ error . response . status ] || error . response . statusText
const description = error . response . data && error . response . data . description
? error . response . data . description
2019-09-19 07:19:11 +00:00
: 'There was an error with the request, please check the console for more information.'
2019-09-15 18:18:22 +00:00
2019-09-19 07:19:11 +00:00
return swal ( ` ${ error . response . status } ${ statusText } ` , description , 'error' )
2019-09-15 18:18:22 +00:00
}
2019-09-19 13:39:23 +00:00
page . checkIfPublic = ( ) => {
2019-09-15 18:18:22 +00:00
let renderShown = false
return axios . get ( 'api/check' , {
onDownloadProgress : ( ) => {
// Only show render after this request has been initiated
if ( ! renderShown && typeof page . doRender === 'function' ) {
page . doRender ( )
renderShown = true
}
}
} ) . then ( response => {
page . private = response . data . private
page . enableUserAccounts = response . data . enableUserAccounts
page . maxSize = parseInt ( response . data . maxSize )
page . maxSizeBytes = page . maxSize * 1e6
page . chunkSize = parseInt ( response . data . chunkSize )
page . temporaryUploadAges = response . data . temporaryUploadAges
page . fileIdentifierLength = response . data . fileIdentifierLength
2019-09-19 13:39:23 +00:00
return page . preparePage ( )
2019-09-15 18:18:22 +00:00
} ) . catch ( page . onInitError )
2018-01-23 20:06:30 +00:00
}
2019-09-15 18:18:22 +00:00
page . preparePage = ( ) => {
2018-12-18 17:01:28 +00:00
if ( page . private )
2018-04-29 12:47:24 +00:00
if ( page . token ) {
2019-09-15 18:18:22 +00:00
return page . verifyToken ( page . token , true )
2018-01-24 15:31:23 +00:00
} else {
2019-08-20 02:16:34 +00:00
const button = document . querySelector ( '#loginToUpload' )
2018-03-28 20:05:01 +00:00
button . href = 'auth'
2018-05-06 14:14:57 +00:00
button . classList . remove ( 'is-loading' )
2018-12-18 17:01:28 +00:00
if ( page . enableUserAccounts )
2019-09-10 16:31:27 +00:00
button . innerText = 'Anonymous upload is disabled. Log in to upload.'
2018-12-18 17:01:28 +00:00
else
2019-09-10 16:31:27 +00:00
button . innerText = 'Running in private mode. Log in to upload.'
2018-01-24 15:31:23 +00:00
}
2018-12-18 17:01:28 +00:00
else
2019-09-15 18:18:22 +00:00
return page . prepareUpload ( )
2018-01-23 20:06:30 +00:00
}
2019-09-15 18:18:22 +00:00
page . verifyToken = ( token , reloadOnError ) => {
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
return axios . post ( 'api/tokens/verify' , { token } ) . then ( response => {
2018-12-18 17:01:28 +00:00
if ( response . data . success === false )
2018-10-09 19:52:41 +00:00
return swal ( {
title : 'An error occurred!' ,
text : response . data . description ,
icon : 'error'
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
} ) . then ( ( ) => {
2018-12-18 17:01:28 +00:00
if ( ! reloadOnError ) return
2018-10-09 19:52:41 +00:00
localStorage . removeItem ( 'token' )
location . reload ( )
} )
2018-07-14 03:42:18 +00:00
2019-09-19 07:19:11 +00:00
localStorage [ lsKeys . token ] = token
2018-10-09 19:52:41 +00:00
page . token = token
2019-09-15 18:18:22 +00:00
return page . prepareUpload ( )
} ) . catch ( page . onInitError )
2018-01-23 20:06:30 +00:00
}
2019-09-15 18:18:22 +00:00
page . prepareUpload = ( ) => {
2018-01-23 20:06:30 +00:00
// I think this fits best here because we need to check for a valid token before we can get the albums
2018-04-29 12:47:24 +00:00
if ( page . token ) {
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Display the album selection
document . querySelector ( '#albumDiv' ) . classList . remove ( 'is-hidden' )
2019-08-20 02:16:34 +00:00
page . albumSelect = document . querySelector ( '#albumSelect' )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . albumSelect . addEventListener ( 'change' , ( ) => {
2018-05-06 14:14:57 +00:00
page . album = parseInt ( page . albumSelect . value )
2019-09-08 01:56:29 +00:00
// Re-generate ShareX config file
if ( typeof page . prepareShareX === 'function' )
page . prepareShareX ( )
2018-01-23 20:06:30 +00:00
} )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Fetch albums
2019-09-15 18:18:22 +00:00
page . fetchAlbums ( )
2018-01-23 20:06:30 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Prepare & generate config tab
2019-09-02 10:24:04 +00:00
page . prepareUploadConfig ( )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Update elements wherever applicable
document . querySelector ( '#maxSize > span' ) . innerHTML = page . getPrettyBytes ( page . maxSizeBytes )
2019-09-10 16:31:27 +00:00
document . querySelector ( '#loginToUpload' ) . classList . add ( 'is-hidden' )
2018-01-23 20:06:30 +00:00
2018-12-18 17:01:28 +00:00
if ( ! page . token && page . enableUserAccounts )
2019-08-20 02:16:34 +00:00
document . querySelector ( '#loginLinkText' ) . innerHTML = 'Create an account and keep track of your uploads'
2018-01-23 20:06:30 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Prepare & generate files upload tab
2018-04-29 12:47:24 +00:00
page . prepareDropzone ( )
2018-05-11 14:34:13 +00:00
2019-09-08 01:56:29 +00:00
// Generate ShareX config file
if ( typeof page . prepareShareX === 'function' )
page . prepareShareX ( )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Prepare urls upload tab
2019-09-02 10:24:04 +00:00
const urlMaxSize = document . querySelector ( '#urlMaxSize' )
if ( urlMaxSize ) {
page . urlMaxSize = parseInt ( urlMaxSize . innerHTML )
page . urlMaxSizeBytes = page . urlMaxSize * 1e6
urlMaxSize . innerHTML = page . getPrettyBytes ( page . urlMaxSizeBytes )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
document . querySelector ( '#uploadUrls' ) . addEventListener ( 'click' , event => {
2019-11-29 10:42:29 +00:00
page . addUrlsToQueue ( )
2018-05-11 14:34:13 +00:00
} )
2018-12-18 17:41:42 +00:00
}
2019-09-02 10:24:04 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Get all tabs
const tabsContainer = document . querySelector ( '#tabs' )
const tabs = tabsContainer . querySelectorAll ( 'li' )
for ( let i = 0 ; i < tabs . length ; i ++ ) {
const id = tabs [ i ] . dataset . id
const tabContent = document . querySelector ( ` # ${ id } ` )
if ( ! tabContent ) continue
tabs [ i ] . addEventListener ( 'click' , ( ) => {
page . setActiveTab ( i )
2019-09-02 10:24:04 +00:00
} )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . tabs . push ( { tab : tabs [ i ] , content : tabContent } )
}
2018-01-23 20:06:30 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Set first valid tab as the default active tab
if ( page . tabs . length ) {
page . setActiveTab ( 0 )
tabsContainer . classList . remove ( 'is-hidden' )
}
}
2018-05-06 14:14:57 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . setActiveTab = index => {
for ( let i = 0 ; i < page . tabs . length ; i ++ )
if ( i === index ) {
page . tabs [ i ] . tab . classList . add ( 'is-active' )
page . tabs [ i ] . content . classList . remove ( 'is-hidden' )
page . activeTab = index
} else {
page . tabs [ i ] . tab . classList . remove ( 'is-active' )
page . tabs [ i ] . content . classList . add ( 'is-hidden' )
2018-10-09 19:52:41 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
}
2019-09-15 18:18:22 +00:00
page . fetchAlbums = ( ) => {
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
return axios . get ( 'api/albums' , { headers : { token : page . token } } ) . then ( response => {
2018-12-18 17:01:28 +00:00
if ( response . data . success === false )
2018-10-09 19:52:41 +00:00
return swal ( 'An error occurred!' , response . data . description , 'error' )
2018-05-06 14:14:57 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Create an option for each album
if ( Array . isArray ( response . data . albums ) && response . data . albums . length )
for ( let i = 0 ; i < response . data . albums . length ; i ++ ) {
const album = response . data . albums [ i ]
const option = document . createElement ( 'option' )
option . value = album . id
option . innerHTML = album . name
page . albumSelect . appendChild ( option )
}
2019-09-15 18:18:22 +00:00
} ) . catch ( page . onInitError )
2018-05-06 14:14:57 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . prepareDropzone = ( ) => {
// Parse template element
const previewNode = document . querySelector ( '#tpl' )
page . previewTemplate = previewNode . innerHTML
previewNode . parentNode . removeChild ( previewNode )
2018-05-11 14:34:13 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Generate files upload tab
2019-08-20 02:16:34 +00:00
const tabDiv = document . querySelector ( '#tab-files' )
2018-10-09 19:52:41 +00:00
const div = document . createElement ( 'div' )
2018-05-11 14:34:13 +00:00
div . className = 'control is-expanded'
2018-10-09 19:52:41 +00:00
div . innerHTML = `
2019-09-19 07:19:11 +00:00
< div id = "dropzone" class = "button is-danger is-outlined is-fullwidth is-unselectable" >
2018-10-09 19:52:41 +00:00
< span class = "icon" >
< i class = "icon-upload-cloud" > < / i >
< / s p a n >
2019-09-02 10:24:04 +00:00
< span > Click here or drag & drop files < / s p a n >
2018-10-09 19:52:41 +00:00
< / d i v >
`
2018-10-18 13:26:40 +00:00
tabDiv . querySelector ( '.dz-container' ) . appendChild ( div )
2018-09-04 15:49:37 +00:00
2018-10-18 13:26:40 +00:00
const previewsContainer = tabDiv . querySelector ( '#tab-files .field.uploads' )
2019-08-20 02:16:34 +00:00
2019-09-08 01:56:29 +00:00
page . dropzone = new Dropzone ( document . body , {
2018-01-24 15:31:23 +00:00
url : 'api/upload' ,
2018-01-23 20:06:30 +00:00
paramName : 'files[]' ,
2019-09-08 01:56:29 +00:00
clickable : tabDiv . querySelector ( '#dropzone' ) ,
2019-09-01 19:23:16 +00:00
maxFilesize : page . maxSizeBytes / 1024 / 1024 , // this option expects MiB
2019-09-02 10:24:04 +00:00
parallelUploads : page . parallelUploads ,
2018-01-23 20:06:30 +00:00
uploadMultiple : false ,
2018-10-09 19:52:41 +00:00
previewsContainer ,
2018-05-11 14:34:13 +00:00
previewTemplate : page . previewTemplate ,
2018-01-23 20:06:30 +00:00
createImageThumbnails : false ,
autoProcessQueue : true ,
2018-04-29 12:47:24 +00:00
headers : { token : page . token } ,
2018-05-09 08:41:30 +00:00
chunking : Boolean ( page . chunkSize ) ,
2019-11-26 14:58:10 +00:00
chunkSize : page . chunkSize * 1e6 , // this option expects Bytes
parallelChunkUploads : false , // for now, enabling this breaks descriptive upload progress
2019-11-25 08:18:14 +00:00
timeout : 0 ,
2019-11-26 14:58:10 +00:00
2019-11-25 08:18:14 +00:00
init ( ) {
this . on ( 'addedfile' , file => {
// Set active tab to file uploads, if necessary
if ( page . activeTab !== 0 )
page . setActiveTab ( 0 )
2019-11-26 14:58:10 +00:00
2019-11-25 08:18:14 +00:00
// Add file entry
tabDiv . querySelector ( '.uploads' ) . classList . remove ( 'is-hidden' )
2019-11-26 14:58:10 +00:00
2019-11-25 08:18:14 +00:00
file . previewElement . querySelector ( '.name' ) . innerHTML = file . name
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML = 'Waiting in queue\u2026'
2019-11-25 08:18:14 +00:00
} )
this . on ( 'sending' , ( file , xhr ) => {
// Add timeout listener (hacky method due to lack of built-in timeout handler)
if ( ! xhr . ontimeout )
xhr . ontimeout = ( ) => {
const instances = page . dropzone . getUploadingFiles ( )
. filter ( instance => instance . xhr === xhr )
page . dropzone . _handleUploadError ( instances , xhr , 'Connection timed out. Try to reduce upload chunk size.' )
}
2019-11-26 14:58:10 +00:00
// Add start timestamp of upload attempt
if ( xhr . _start === undefined )
xhr . _start = Date . now ( )
2019-11-25 08:18:14 +00:00
2019-11-26 14:58:10 +00:00
// If not chunked uploads, add extra headers
if ( ! file . upload . chunked ) {
if ( page . album !== null ) xhr . setRequestHeader ( 'albumid' , page . album )
if ( page . fileLength !== null ) xhr . setRequestHeader ( 'filelength' , page . fileLength )
if ( page . uploadAge !== null ) xhr . setRequestHeader ( 'age' , page . uploadAge )
}
2019-11-26 17:57:55 +00:00
if ( ! file . upload . chunked )
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML = 'Uploading\u2026'
2019-11-26 17:57:55 +00:00
else if ( file . upload . chunks . length === 1 )
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML = ` Uploading chunk 1/ ${ file . upload . totalChunkCount } \u 2026 `
2019-11-25 08:18:14 +00:00
} )
2019-11-26 14:58:10 +00:00
// Update descriptive progress
2019-11-25 08:18:14 +00:00
this . on ( 'uploadprogress' , ( file , progress ) => {
2019-11-26 14:58:10 +00:00
// Total bytes will eventually be bigger than file size when chunked
const total = Math . max ( file . size , file . upload . total )
2019-11-26 17:57:55 +00:00
const percentage = ( file . upload . bytesSent / total * 100 ) . toFixed ( 0 )
2019-11-26 14:58:10 +00:00
const upl = file . upload . chunked
? file . upload . chunks [ file . upload . chunks . length - 1 ]
: file . upload
const xhr = upl . xhr || file . xhr
2019-11-26 17:57:55 +00:00
let prefix = 'Uploading\u2026'
let skipProgress = false
if ( file . upload . chunked ) {
const done = upl . bytesSent === upl . total
const last = file . upload . chunks . length === file . upload . totalChunkCount
let chunkIndex = file . upload . chunks . length
if ( done && ! last ) {
chunkIndex ++
skipProgress = true
}
prefix = ` Uploading chunk ${ chunkIndex } / ${ file . upload . totalChunkCount } \u 2026 `
}
2019-11-26 14:58:10 +00:00
2019-11-26 17:57:55 +00:00
let prettyBytesPerSec
if ( ! skipProgress ) {
const elapsed = ( Date . now ( ) - xhr . _start ) / 1000
const bytesPerSec = elapsed ? ( upl . bytesSent / elapsed ) : 0
prettyBytesPerSec = page . getPrettyBytes ( bytesPerSec )
}
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML =
2019-11-26 17:57:55 +00:00
` ${ prefix } ${ percentage } % ${ prettyBytesPerSec ? ` at ~ ${ prettyBytesPerSec } /s ` : '' } `
2019-11-25 08:18:14 +00:00
} )
2019-11-29 10:42:29 +00:00
this . on ( 'success' , ( file , data ) => {
if ( ! data ) return
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . classList . add ( 'is-hidden' )
2019-11-25 08:18:14 +00:00
2019-11-29 10:42:29 +00:00
if ( data . success === false ) {
file . previewElement . querySelector ( '.error' ) . innerHTML = data . description
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.error' ) . classList . remove ( 'is-hidden' )
}
2019-11-25 08:18:14 +00:00
2019-11-29 10:42:29 +00:00
if ( Array . isArray ( data . files ) && data . files [ 0 ] )
page . updateTemplate ( file , data . files [ 0 ] )
2019-11-25 08:18:14 +00:00
} )
this . on ( 'error' , ( file , error ) => {
// Clean up file size errors
if ( ( typeof error === 'string' && /^File is too big/ . test ( error ) ) ||
( typeof error === 'object' && /File too large/ . test ( error . description ) ) )
error = ` File too large ( ${ page . getPrettyBytes ( file . size ) } ). `
page . updateTemplateIcon ( file . previewElement , 'icon-block' )
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . classList . add ( 'is-hidden' )
2019-11-25 08:18:14 +00:00
file . previewElement . querySelector ( '.error' ) . innerHTML = error . description || error
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.error' ) . classList . remove ( 'is-hidden' )
2019-11-25 08:18:14 +00:00
} )
} ,
2019-11-26 14:58:10 +00:00
2018-10-09 19:52:41 +00:00
chunksUploaded ( file , done ) {
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML =
` Rebuilding ${ file . upload . totalChunkCount } chunks \u 2026 `
2018-03-28 11:36:28 +00:00
2018-10-09 19:52:41 +00:00
return axios . post ( 'api/upload/finishchunks' , {
2019-08-20 02:16:34 +00:00
// This API supports an array of multiple files
2018-10-09 19:52:41 +00:00
files : [ {
uuid : file . upload . uuid ,
original : file . name ,
type : file . type ,
2019-09-08 01:56:29 +00:00
albumid : page . album ,
filelength : page . fileLength ,
age : page . uploadAge
2018-10-09 19:52:41 +00:00
} ]
2019-11-26 14:58:10 +00:00
} , {
headers : {
token : page . token
}
} ) . catch ( error => {
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
// Format error for display purpose
return error . response . data ? error . response : {
2019-09-08 01:56:29 +00:00
data : {
success : false ,
description : error . toString ( )
}
2018-10-09 19:52:41 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
} ) . then ( response => {
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.descriptive-progress' ) . classList . add ( 'is-hidden' )
2018-07-14 03:42:18 +00:00
2019-11-26 14:58:10 +00:00
if ( response . data . success === false ) {
2018-10-09 19:52:41 +00:00
file . previewElement . querySelector ( '.error' ) . innerHTML = response . data . description
2019-11-26 14:58:10 +00:00
file . previewElement . querySelector ( '.error' ) . classList . remove ( 'is-hidden' )
}
2018-07-14 03:42:18 +00:00
2018-12-18 17:01:28 +00:00
if ( response . data . files && response . data . files [ 0 ] )
2018-10-09 19:52:41 +00:00
page . updateTemplate ( file , response . data . files [ 0 ] )
2018-12-18 17:01:28 +00:00
2018-10-09 19:52:41 +00:00
return done ( )
} )
2018-01-23 20:06:30 +00:00
}
} )
}
2019-11-29 10:42:29 +00:00
page . addUrlsToQueue = ( ) => {
const urls = document . querySelector ( '#urls' ) . value
. split ( /\r?\n/ )
. filter ( url => {
return url . trim ( ) . length
} )
2018-05-11 14:34:13 +00:00
2019-11-29 10:42:29 +00:00
if ( ! urls . length )
return swal ( 'An error occurred!' , 'You have not entered any URLs.' , 'error' )
2018-05-11 14:34:13 +00:00
2019-11-29 10:42:29 +00:00
const tabDiv = document . querySelector ( '#tab-urls' )
tabDiv . querySelector ( '.uploads' ) . classList . remove ( 'is-hidden' )
2018-07-14 03:42:18 +00:00
2019-11-29 10:42:29 +00:00
for ( let i = 0 ; i < urls . length ; i ++ ) {
const previewTemplate = document . createElement ( 'template' )
previewTemplate . innerHTML = page . previewTemplate . trim ( )
const previewElement = previewTemplate . content . firstChild
previewElement . querySelector ( '.name' ) . innerHTML = urls [ i ]
previewElement . querySelector ( '.descriptive-progress' ) . innerHTML = 'Waiting in queue\u2026'
2019-09-08 01:56:29 +00:00
2019-08-20 02:16:34 +00:00
const previewsContainer = tabDiv . querySelector ( '.uploads' )
2019-11-29 10:42:29 +00:00
previewsContainer . appendChild ( previewElement )
2019-11-26 14:58:10 +00:00
2019-11-29 10:42:29 +00:00
page . urlsQueue . push ( {
url : urls [ i ] ,
previewElement
} )
}
2018-05-12 22:13:26 +00:00
2019-11-29 10:42:29 +00:00
page . processUrlsQueue ( )
document . querySelector ( '#urls' ) . value = ''
}
2018-05-12 22:13:26 +00:00
2019-11-29 10:42:29 +00:00
page . processUrlsQueue = ( ) => {
if ( ! page . urlsQueue . length ) return
2019-11-26 14:58:10 +00:00
2019-11-29 10:42:29 +00:00
function finishedUrlUpload ( file , data ) {
file . previewElement . querySelector ( '.descriptive-progress' ) . classList . add ( 'is-hidden' )
2019-11-26 14:58:10 +00:00
2019-11-29 10:42:29 +00:00
if ( data . success === false ) {
const match = data . description . match ( / over limit: (\d+)$/ )
if ( match && match [ 1 ] )
data . description = ` File exceeded limit of ${ page . getPrettyBytes ( match [ 1 ] ) } . `
2019-11-26 14:58:10 +00:00
2019-11-29 10:42:29 +00:00
file . previewElement . querySelector ( '.error' ) . innerHTML = data . description
file . previewElement . querySelector ( '.error' ) . classList . remove ( 'is-hidden' )
}
2018-05-11 14:34:13 +00:00
2019-11-29 10:42:29 +00:00
if ( Array . isArray ( data . files ) && data . files [ 0 ] )
page . updateTemplate ( file , data . files [ 0 ] )
2018-07-14 03:42:18 +00:00
2019-11-29 10:42:29 +00:00
page . activeUrlsQueue --
return shiftQueue ( )
}
2019-11-26 14:58:10 +00:00
2019-11-29 10:42:29 +00:00
function initUrlUpload ( file ) {
file . previewElement . querySelector ( '.descriptive-progress' ) . innerHTML =
'Waiting for server to fetch URL\u2026'
return axios . post ( 'api/upload' , {
urls : [ file . url ]
} , {
headers : {
token : page . token ,
albumid : page . album ,
age : page . uploadAge ,
filelength : page . fileLength
}
} ) . catch ( error => {
// Format error for display purpose
return error . response . data ? error . response : {
data : {
success : false ,
description : error . toString ( )
2019-04-18 09:06:14 +00:00
}
2018-07-14 03:42:18 +00:00
}
2019-11-29 10:42:29 +00:00
} ) . then ( response => {
return finishedUrlUpload ( file , response . data )
} )
}
2018-07-14 03:42:18 +00:00
2019-11-29 10:42:29 +00:00
function shiftQueue ( ) {
while ( page . urlsQueue . length && ( page . activeUrlsQueue < page . parallelUploads ) ) {
page . activeUrlsQueue ++
initUrlUpload ( page . urlsQueue . shift ( ) )
2018-05-11 14:34:13 +00:00
}
2018-07-14 03:42:18 +00:00
}
2019-11-29 10:42:29 +00:00
return shiftQueue ( )
2018-05-11 14:34:13 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . updateTemplateIcon = ( templateElement , iconClass ) => {
2019-04-18 09:06:14 +00:00
const iconElement = templateElement . querySelector ( '.icon' )
if ( ! iconElement ) return
2019-11-26 14:58:10 +00:00
2019-04-18 09:06:14 +00:00
iconElement . classList . add ( iconClass )
2019-09-10 16:31:27 +00:00
iconElement . classList . remove ( 'is-hidden' )
2019-04-18 09:06:14 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . updateTemplate = ( file , response ) => {
2018-12-18 17:01:28 +00:00
if ( ! response . url ) return
2018-04-29 12:47:24 +00:00
2019-11-26 14:58:10 +00:00
const link = file . previewElement . querySelector ( '.link' )
const a = link . querySelector ( 'a' )
2018-10-09 19:52:41 +00:00
const clipboard = file . previewElement . querySelector ( '.clipboard-mobile > .clipboard-js' )
2019-08-20 02:16:34 +00:00
a . href = a . innerHTML = clipboard . dataset . clipboardText = response . url
2019-11-26 14:58:10 +00:00
link . classList . remove ( 'is-hidden' )
2019-09-10 16:31:27 +00:00
clipboard . parentElement . classList . remove ( 'is-hidden' )
2018-03-28 20:05:01 +00:00
2018-10-09 19:52:41 +00:00
const exec = /.[\w]+(\?|$)/ . exec ( response . url )
2019-09-17 04:13:41 +00:00
const extname = exec && exec [ 0 ]
? exec [ 0 ] . toLowerCase ( )
: null
if ( page . imageExts . includes ( extname ) )
if ( page . previewImages ) {
const img = file . previewElement . querySelector ( 'img' )
img . setAttribute ( 'alt' , response . name || '' )
img . dataset . src = response . url
img . classList . remove ( 'is-hidden' )
img . onerror = event => {
// Hide image elements that fail to load
// Consequently include WEBP in browsers that do not have WEBP support (e.i. IE)
event . currentTarget . classList . add ( 'is-hidden' )
page . updateTemplateIcon ( file . previewElement , 'icon-picture' )
}
page . lazyLoad . update ( file . previewElement . querySelectorAll ( 'img' ) )
} else {
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . updateTemplateIcon ( file . previewElement , 'icon-picture' )
2018-12-18 17:41:42 +00:00
}
2019-09-17 04:13:41 +00:00
else if ( page . videoExts . includes ( extname ) )
page . updateTemplateIcon ( file . previewElement , 'icon-video' )
else
2019-04-18 09:06:14 +00:00
page . updateTemplateIcon ( file . previewElement , 'icon-doc-inv' )
2019-09-08 01:56:29 +00:00
if ( response . expirydate ) {
const expiryDate = file . previewElement . querySelector ( '.expiry-date' )
2019-09-17 04:13:41 +00:00
expiryDate . innerHTML = ` EXP: ${ page . getPrettyDate ( new Date ( response . expirydate * 1000 ) ) } `
2019-09-10 16:31:27 +00:00
expiryDate . classList . remove ( 'is-hidden' )
2019-09-08 01:56:29 +00:00
}
2018-03-28 11:36:28 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . createAlbum = ( ) => {
2018-10-09 19:52:41 +00:00
const div = document . createElement ( 'div' )
div . innerHTML = `
< div class = "field" >
< div class = "controls" >
2019-09-17 04:13:41 +00:00
< input id = "swalName" class = "input" type = "text" placeholder = "Name" maxlength = "${page.albumTitleMaxLength}" >
2018-12-13 09:09:46 +00:00
< / d i v >
2019-09-17 04:13:41 +00:00
< p class = "help" > Max length is $ { page . albumTitleMaxLength } characters . < / p >
2018-12-13 09:09:46 +00:00
< / d i v >
< div class = "field" >
< div class = "control" >
2019-09-17 04:13:41 +00:00
< textarea id = "swalDescription" class = "textarea" placeholder = "Description" rows = "2" maxlength = "${page.albumDescMaxLength}" > < / t e x t a r e a >
2018-10-09 19:52:41 +00:00
< / d i v >
2019-09-17 04:13:41 +00:00
< p class = "help" > Max length is $ { page . albumDescMaxLength } characters . < / p >
2018-10-09 19:52:41 +00:00
< / d i v >
< div class = "field" >
< div class = "control" >
< label class = "checkbox" >
< input id = "swalDownload" type = "checkbox" checked >
Enable download
< / l a b e l >
< / d i v >
< / d i v >
< div class = "field" >
< div class = "control" >
< label class = "checkbox" >
< input id = "swalPublic" type = "checkbox" checked >
Enable public link
< / l a b e l >
< / d i v >
< / d i v >
`
2018-09-04 15:49:37 +00:00
2018-07-14 03:42:18 +00:00
swal ( {
2018-05-06 14:14:57 +00:00
title : 'Create new album' ,
icon : 'info' ,
content : div ,
buttons : {
cancel : true ,
confirm : {
closeModal : false
}
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
} ) . then ( value => {
2018-12-18 17:01:28 +00:00
if ( ! value ) return
2018-10-09 19:52:41 +00:00
2019-09-08 01:56:29 +00:00
const name = document . querySelector ( '#swalName' ) . value . trim ( )
2018-10-09 19:52:41 +00:00
axios . post ( 'api/albums' , {
name ,
2019-09-08 01:56:29 +00:00
description : document . querySelector ( '#swalDescription' ) . value . trim ( ) ,
2019-08-20 02:16:34 +00:00
download : document . querySelector ( '#swalDownload' ) . checked ,
public : document . querySelector ( '#swalPublic' ) . checked
2018-10-09 19:52:41 +00:00
} , {
headers : {
token : page . token
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
} ) . then ( response => {
2018-12-18 17:01:28 +00:00
if ( response . data . success === false )
2018-10-09 19:52:41 +00:00
return swal ( 'An error occurred!' , response . data . description , 'error' )
const option = document . createElement ( 'option' )
2019-08-20 02:16:34 +00:00
page . albumSelect . appendChild ( option )
2018-10-09 19:52:41 +00:00
option . value = response . data . id
option . innerHTML = name
2019-08-20 02:16:34 +00:00
option . selected = true
2018-10-09 19:52:41 +00:00
2019-09-02 10:24:04 +00:00
swal ( 'Woohoo!' , 'Album was created successfully.' , 'success' )
2019-09-19 07:19:11 +00:00
} ) . catch ( page . onError )
2018-10-09 19:52:41 +00:00
} )
2018-05-06 14:14:57 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . prepareUploadConfig = ( ) => {
2019-09-02 10:24:04 +00:00
const fallback = {
2019-09-08 01:56:29 +00:00
chunkSize : page . chunkSize ,
2019-10-11 05:36:59 +00:00
parallelUploads : page . parallelUploads
2019-09-02 10:24:04 +00:00
}
2019-10-11 05:36:59 +00:00
const temporaryUploadAges = Array . isArray ( page . temporaryUploadAges ) && page . temporaryUploadAges . length
const fileIdentifierLength = page . fileIdentifierLength &&
typeof page . fileIdentifierLength . min === 'number' &&
typeof page . fileIdentifierLength . max === 'number'
const config = {
siBytes : {
label : 'File size display' ,
select : [
{ value : 'default' , text : '1000 B = 1 kB = 1 Kilobyte' } ,
{ value : '0' , text : '1024 B = 1 KiB = 1 Kibibyte' }
] ,
help : 'This will be used in our homepage, dashboard, and album public pages.' ,
valueHandler ( ) { } // Do nothing
} ,
fileLength : {
display : fileIdentifierLength ,
label : 'File identifier length' ,
number : fileIdentifierLength ? {
2019-09-08 01:56:29 +00:00
min : page . fileIdentifierLength . min ,
2019-10-11 05:36:59 +00:00
max : page . fileIdentifierLength . max ,
round : true
} : undefined ,
help : true , // true means auto-generated, for number-based configs only
disabled : fileIdentifierLength && page . fileIdentifierLength . force
} ,
uploadAge : {
display : temporaryUploadAges ,
label : 'Upload age' ,
select : [ ] ,
help : 'This allows your files to automatically be deleted after a certain period of time.'
} ,
chunkSize : {
display : ! isNaN ( page . chunkSize ) ,
label : 'Upload chunk size (MB)' ,
number : {
min : 1 ,
max : 95 ,
suffix : ' MB' ,
round : true
} ,
help : true
} ,
parallelUploads : {
label : 'Parallel uploads' ,
number : {
min : 1 ,
max : 10 ,
round : true
} ,
help : true
} ,
uploadsHistoryOrder : {
label : 'Uploads history order' ,
select : [
{ value : 'default' , text : 'Older files on top' } ,
{ value : '0' , text : 'Newer files on top' }
] ,
help : ` Newer files on top will use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction#Accessibility_Concerns" target="_blank" rel="noopener">a CSS technique</a>.<br>
Trying to select their texts manually from top to bottom will end up selecting the texts from bottom to top instead . ` ,
valueHandler ( value ) {
if ( value === '0' ) {
const uploadFields = document . querySelectorAll ( '.tab-content > .uploads' )
for ( let i = 0 ; i < uploadFields . length ; i ++ )
uploadFields [ i ] . classList . add ( 'is-reversed' )
}
}
} ,
previewImages : {
label : 'Load images for preview' ,
select : [
{ value : 'default' , text : 'Yes' } ,
{ value : '0' , text : 'No' }
] ,
help : 'By default, uploaded images will be loaded as their previews.' ,
valueHandler ( value ) {
page . previewImages = value !== '0'
2019-09-08 01:56:29 +00:00
}
}
}
2019-10-11 05:36:59 +00:00
if ( temporaryUploadAges ) {
2019-09-08 01:56:29 +00:00
const stored = parseFloat ( localStorage [ lsKeys . uploadAge ] )
for ( let i = 0 ; i < page . temporaryUploadAges . length ; i ++ ) {
const age = page . temporaryUploadAges [ i ]
2019-10-11 05:36:59 +00:00
config . uploadAge . select . push ( {
value : i === 0 ? 'default' : String ( age ) ,
text : page . getPrettyUploadAge ( age )
} )
if ( age === stored )
config . uploadAge . value = stored
2019-09-08 01:56:29 +00:00
}
2019-10-11 05:36:59 +00:00
}
if ( fileIdentifierLength ) {
fallback . fileLength = page . fileIdentifierLength . default || undefined
const stored = parseInt ( localStorage [ lsKeys . fileLength ] )
if ( ! page . fileIdentifierLength . force &&
! isNaN ( stored ) &&
stored >= page . fileIdentifierLength . min &&
stored <= page . fileIdentifierLength . max )
config . fileLength . value = stored
2019-09-08 01:56:29 +00:00
}
2019-09-02 10:24:04 +00:00
const tabContent = document . querySelector ( '#tab-config' )
2019-10-11 05:36:59 +00:00
const form = document . createElement ( 'form' )
form . addEventListener ( 'submit' , event => event . preventDefault ( ) )
const configKeys = Object . keys ( config )
for ( let i = 0 ; i < configKeys . length ; i ++ ) {
const key = configKeys [ i ]
const conf = config [ key ]
// Skip only if display attribute is explicitly set to false
if ( conf . display === false )
continue
const field = document . createElement ( 'div' )
field . className = 'field'
let value
if ( ! conf . disabled ) {
if ( conf . value !== undefined ) {
value = conf . value
} else if ( conf . number !== undefined ) {
const parsed = parseInt ( localStorage [ lsKeys [ key ] ] )
if ( ! isNaN ( parsed ) )
value = parsed
} else {
value = localStorage [ lsKeys [ key ] ]
}
2019-09-02 10:24:04 +00:00
2019-10-11 05:36:59 +00:00
// If valueHandler function exists, defer to the function,
// otherwise pass value to global page object
if ( typeof conf . valueHandler === 'function' )
conf . valueHandler ( value )
else if ( value !== undefined )
page [ key ] = value
}
2019-09-02 10:24:04 +00:00
2019-10-11 05:36:59 +00:00
let control
if ( Array . isArray ( conf . select ) ) {
control = document . createElement ( 'div' )
control . className = 'select is-fullwidth'
const opts = [ ]
for ( let j = 0 ; j < conf . select . length ; j ++ ) {
const opt = conf . select [ j ]
const selected = value && ( opt . value === String ( value ) )
opts . push ( `
< option value = "${opt.value}" $ { selected ? ' selected' : '' } >
$ { opt . text } $ { opt . value === 'default' ? ' (default)' : '' }
< / o p t i o n >
` )
}
control . innerHTML = `
< select id = "${key}" >
$ { opts . join ( '\n' ) }
< / s e l e c t >
`
} else if ( conf . number !== undefined ) {
control = document . createElement ( 'input' )
control . id = control . name = key
control . className = 'input is-fullwidth'
control . type = 'number'
if ( conf . number . min !== undefined )
control . min = conf . number . min
if ( conf . number . max !== undefined )
control . max = conf . number . max
if ( typeof value === 'number' )
control . value = value
else if ( fallback [ key ] !== undefined )
control . value = fallback [ key ]
}
let help
if ( conf . disabled ) {
control . disabled = conf . disabled
help = 'This option is currently disabled.'
} else if ( typeof conf . help === 'string' ) {
help = conf . help
} else if ( conf . help === true && conf . number !== undefined ) {
const tmp = [ ]
if ( fallback [ key ] !== undefined )
tmp . push ( ` Default is ${ fallback [ key ] } ${ conf . number . suffix || '' } . ` )
if ( conf . number . min !== undefined )
tmp . push ( ` Min is ${ conf . number . min } ${ conf . number . suffix || '' } . ` )
if ( conf . number . max !== undefined )
tmp . push ( ` Max is ${ conf . number . max } ${ conf . number . suffix || '' } . ` )
help = tmp . join ( ' ' )
}
field . innerHTML = `
< label class = "label" > $ { conf . label } < / l a b e l >
< div class = "control" > < / d i v >
$ { help ? ` <p class="help"> ${ help } </p> ` : '' }
`
field . querySelector ( 'div.control' ) . appendChild ( control )
form . appendChild ( field )
2019-09-15 07:20:55 +00:00
}
2019-10-11 05:36:59 +00:00
const submit = document . createElement ( 'div' )
submit . className = 'field'
submit . innerHTML = `
< p class = "control" >
< button id = "saveConfig" type = "submit" class = "button is-danger is-outlined is-fullwidth" >
< span class = "icon" >
< i class = "icon-floppy" > < / i >
< / s p a n >
< span > Save & reload < / s p a n >
< / b u t t o n >
< / p >
< p class = "help" >
This configuration will only be used in this browser . < br >
After reloading the page , some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below .
< / p >
`
2019-09-17 04:13:41 +00:00
2019-10-11 05:36:59 +00:00
form . appendChild ( submit )
form . querySelector ( '#saveConfig' ) . addEventListener ( 'click' , ( ) => {
2019-09-08 01:56:29 +00:00
if ( ! form . checkValidity ( ) )
return
2019-10-11 05:36:59 +00:00
const keys = Object . keys ( config )
. filter ( key => config [ key ] . display !== false && config [ key ] . disabled !== true )
for ( let i = 0 ; i < keys . length ; i ++ ) {
const key = keys [ i ]
let value
if ( config [ key ] . select !== undefined ) {
if ( form . elements [ key ] . value !== 'default' )
value = form . elements [ key ] . value
} else if ( config [ key ] . number !== undefined ) {
const parsed = parseInt ( form . elements [ key ] . value )
if ( ! isNaN ( parsed ) )
value = Math . min ( Math . max ( parsed , config [ key ] . number . min ) , config [ key ] . number . max )
}
2019-09-02 10:24:04 +00:00
2019-10-11 05:36:59 +00:00
if ( value !== undefined && value !== fallback [ key ] )
localStorage [ lsKeys [ key ] ] = value
2019-09-02 10:24:04 +00:00
else
2019-10-11 05:36:59 +00:00
localStorage . removeItem ( lsKeys [ key ] )
2019-09-02 10:24:04 +00:00
}
swal ( {
title : 'Woohoo!' ,
2019-09-08 01:56:29 +00:00
text : 'Configuration saved into this browser.' ,
2019-09-02 10:24:04 +00:00
icon : 'success'
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
} ) . then ( ( ) => {
2019-09-02 10:24:04 +00:00
location . reload ( )
} )
} )
2019-10-11 05:36:59 +00:00
tabContent . appendChild ( form )
2019-09-02 10:24:04 +00:00
}
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . getPrettyUploadAge = hours => {
2019-09-08 01:56:29 +00:00
if ( hours === 0 ) {
return 'Permanent'
} else if ( hours < 1 ) {
const minutes = hours * 60
return ` ${ minutes } minute ${ minutes === 1 ? '' : 's' } `
2019-09-08 18:21:01 +00:00
} else if ( hours >= 24 ) {
2019-09-08 01:56:29 +00:00
const days = hours / 24
return ` ${ days } day ${ days === 1 ? '' : 's' } `
} else {
return ` ${ hours } hour ${ hours === 1 ? '' : 's' } `
}
}
2018-01-23 18:00:55 +00:00
// Handle image paste event
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
window . addEventListener ( 'paste' , event => {
2018-10-09 19:52:41 +00:00
const items = ( event . clipboardData || event . originalEvent . clipboardData ) . items
2019-09-01 19:23:16 +00:00
const index = Object . keys ( items )
for ( let i = 0 ; i < index . length ; i ++ ) {
const item = items [ index [ i ] ]
2018-01-23 20:06:30 +00:00
if ( item . kind === 'file' ) {
2018-10-09 19:52:41 +00:00
const blob = item . getAsFile ( )
2019-10-29 12:39:44 +00:00
/* eslint-disable-next-line compat/compat */
2019-09-10 16:31:27 +00:00
const file = new File ( [ blob ] , ` pasted-image. ${ blob . type . match ( /(?:[^/]*\/)([^;]*)/ ) [ 1 ] } ` , {
type : blob . type
} )
2018-04-29 12:47:24 +00:00
page . dropzone . addFile ( file )
2018-01-23 20:06:30 +00:00
}
}
} )
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
window . onload = ( ) => {
2019-09-15 18:18:22 +00:00
page . checkIfPublic ( )
2018-03-28 20:05:01 +00:00
2018-04-29 12:47:24 +00:00
page . clipboardJS = new ClipboardJS ( '.clipboard-js' )
2018-03-28 20:05:01 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
page . clipboardJS . on ( 'success' , ( ) => {
2019-10-29 12:39:44 +00:00
return swal ( '' , 'The link has been copied to clipboard.' , 'success' , {
buttons : false ,
timer : 1500
} )
2018-03-28 20:05:01 +00:00
} )
2019-09-19 07:19:11 +00:00
page . clipboardJS . on ( 'error' , page . onError )
2018-04-29 12:47:24 +00:00
2018-10-18 13:26:40 +00:00
page . lazyLoad = new LazyLoad ( {
elements _selector : '.field.uploads img'
} )
2018-07-17 03:21:04 +00:00
Updates (very important to read)
Client-side CSS & JS files will now be processed with Gulp.
Gulp tasks are configured in gulpfile.js file.
CSS files will be optimized with postcss-preset-env, which will
auto-add vendor prefixes and convert any parts necessary for browsers
compatibility.
Afterwards they will be minified with cssnano.
JS files will be optimized with bublé,
likewise for browsers compatibility.
Afterwards they will be minified with terser.
Unprocessed CSS & JS files will now be located at src directory, while
the processed results will be located at dist directory.
Due to bublé, the JS files should now be compatible up to IE 11
at the minimum.
Previously the safe would not work in IE 11 due to extensive usage of
template literals.
Due to that as well, JS files in src directory will now extensively use
arrow functions for my personal comfort (as they will be converted too).
The server will use the processed files at dist directory by default.
If you want to rebuild the files by your own, you can run "yarn build".
Gulp is a development dependency, so make sure you have installed all
development dependencies (e.i. NOT using "yarn install --production").
---
yarn lint -> gulp lint
yarn build -> gulp default
yarn watch -> gulp watch
yarn develop -> env NODE_ENV=development yarn watch
---
Fixed not being able to demote staff into normal users.
/api/token/verify will no longer respond with 401 HTTP error code,
unless an error occurred (which will be 500 HTTP error code).
Fixed /nojs route not displaying file's original name when a duplicate
is found on the server.
Removed is-breeze CSS class name, in favor of Bulma's is-info.
Removed custom styling from auth page, in favor of global styling.
Removed all usage of style HTML attribute in favor of CSS classes.
Renamed js/s/ to js/misc/.
Use loading spinners on dashboard's sidebar menus.
Disable all other sidebar menus when something is loading.
Changed title HTML attribute of disabled control buttons in
uploads & users list.
Hid checkboxes and WIP controls from users list.
Better error messages handling.
Especially homepage will now support CF's HTTP error codes.
Updated various icons.
Also, added fontello config file at public/libs/fontello/config.json.
This should let you edit them more easily with fontello.
Use Gatsby icon for my blog's link in homepage's footer.
A bunch of other improvements here & there.
2019-09-15 06:20:11 +00:00
document . querySelector ( '#createAlbum' ) . addEventListener ( 'click' , ( ) => {
2018-07-17 03:21:04 +00:00
page . createAlbum ( )
} )
2018-01-23 20:06:30 +00:00
}