diff options
Diffstat (limited to 'app/client/api')
| -rw-r--r-- | app/client/api/crud.upload.js | 4 | ||||
| -rw-r--r-- | app/client/api/index.js | 1 | ||||
| -rw-r--r-- | app/client/api/util.js | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/app/client/api/crud.upload.js b/app/client/api/crud.upload.js index 97b6769..2e0269a 100644 --- a/app/client/api/crud.upload.js +++ b/app/client/api/crud.upload.js @@ -20,11 +20,13 @@ export function crud_upload(type, fd, data, dispatch) { dispatch && dispatch({ type: as_type(type, 'upload_loading')}) + let complete = false + function uploadProgress (e) { if (e.lengthComputable) { dispatch && dispatch({ type: as_type(type, 'upload_progress'), - percent: Math.round(e.loaded * 100 / e.total), + percent: Math.round(e.loaded * 100 / e.total) || 0, [type]: id, }) } diff --git a/app/client/api/index.js b/app/client/api/index.js index 82cd364..a0cae50 100644 --- a/app/client/api/index.js +++ b/app/client/api/index.js @@ -1,4 +1,5 @@ import { crud_actions } from './crud.actions' +import * as util from './util' /* for our crud events, create corresponding actions diff --git a/app/client/api/util.js b/app/client/api/util.js new file mode 100644 index 0000000..99d63b4 --- /dev/null +++ b/app/client/api/util.js @@ -0,0 +1,11 @@ +export const is_iphone = !!((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) +export const is_ipad = !!(navigator.userAgent.match(/iPad/i)) +export const is_android = !!(navigator.userAgent.match(/Android/i)) +export const is_mobile = is_iphone || is_ipad || is_android +export const is_desktop = ! is_mobile; + +const htmlClassList = document.body.parentNode.classList +htmlClassList.add(is_desktop ? 'desktop' : 'mobile') +htmlClassList.remove('loading') + +// window.debug = false |
