diff options
Diffstat (limited to 'pyload/web/app/scripts')
-rw-r--r-- | pyload/web/app/scripts/helpers/truncate.js | 25 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/headerView.js | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/pyload/web/app/scripts/helpers/truncate.js b/pyload/web/app/scripts/helpers/truncate.js new file mode 100644 index 000000000..fb351b776 --- /dev/null +++ b/pyload/web/app/scripts/helpers/truncate.js @@ -0,0 +1,25 @@ +require(['underscore','handlebars'], function(_, Handlebars) { + 'use strict'; + + function truncate(fullStr, options) { + var strLen = 30; + if (_.isNumber(options)) + strLen = options; + + if (fullStr.length <= strLen) return fullStr; + + var separator = options.separator || '…'; + + var sepLen = separator.length, + charsToShow = strLen - sepLen, + frontChars = Math.ceil(charsToShow / 2), + backChars = Math.floor(charsToShow / 2); + + return fullStr.substr(0, frontChars) + + separator + + fullStr.substr(fullStr.length - backChars); + } + + Handlebars.registerHelper('truncate', truncate); + return truncate; +});
\ No newline at end of file diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js index 10e4dfaf9..991f0f32e 100644 --- a/pyload/web/app/scripts/views/headerView.js +++ b/pyload/web/app/scripts/views/headerView.js @@ -165,7 +165,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle if (data === null) return; if (data['@class'] === 'ServerStatus') { - // TODO: load interaction when none available this.status.set(data); // There tasks at the server, but not in queue: so fetch them @@ -213,7 +212,6 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle eta: prog.get('eta') }, {silent: true}); file.setDownloadStatus(prog.get('download').status); - file.trigger('change:progress'); } } |