# HG changeset patch # User veltr # Date 1352467983 -3600 # Node ID 9ee8c00ae5b70e04824ee60e11c97f3f985227d0 # Parent ff62016e051d55e49038d3ae5f5e08f8abc99211 Improvement of the Sparkline widget diff -r ff62016e051d -r 9ee8c00ae5b7 src/js/defaults.js --- a/src/js/defaults.js Tue Nov 06 10:59:57 2012 +0100 +++ b/src/js/defaults.js Fri Nov 09 14:33:03 2012 +0100 @@ -56,6 +56,9 @@ noCss: true, requires: [ "swfObject" ] }, + AdaptivePlayer: { + noCss: true + }, AutoPlayer: { noCss: true }, diff -r ff62016e051d -r 9ee8c00ae5b7 src/js/model.js --- a/src/js/model.js Tue Nov 06 10:59:57 2012 +0100 +++ b/src/js/model.js Fri Nov 09 14:33:03 2012 +0100 @@ -1,33 +1,30 @@ /* TODO: Separate Project-specific data from Source */ /* model.js is where data is stored in a standard form, whatever the serializer */ + IriSP.Model = (function (ns) { + + function pad(n, x, b) { + b = b || 10; + var s = (x).toString(b); + while (s.length < n) { + s = "0" + s; + } + return s; + } + + function rand16(n) { + return pad(n, Math.floor(Math.random()*Math.pow(16,n)), 16); + } + + var uidbase = rand16(8) + "-" + rand16(4) + "-", uidincrement = Math.floor(Math.random()*0x10000); var Model = { _SOURCE_STATUS_EMPTY : 0, _SOURCE_STATUS_WAITING : 1, _SOURCE_STATUS_READY : 2, - _ID_AUTO_INCREMENT : 0, - _ID_BASE : (function(_d) { - function pad(n){return n<10 ? '0'+n : n} - function fillrand(n) { - var _res = '' - for (var i=0; i= _begin && _annotation.end < _end; - }).length; + var _begin = (_i*_duration/this.slice_count), + _end = ((_i+1)*_duration/this.slice_count), + _annotations = _list.reduce(function(_m, _annotation) { + if (_annotation.begin < _end && _annotation.begin >= _begin) { + var _d = _annotation.getDuration().milliseconds; + if (!_d) { + return _m + 1; + } else { + return _m + (Math.min(_annotation.end, _end) - Math.max(_annotation.begin, _begin)) / _d; + } + } else { + return _m + } + },0); _max = Math.max(_max, _annotations); _slices.push(_annotations); }