From 91bae444089bd20819a896a75ec912463cdd0ea7 Mon Sep 17 00:00:00 2001 From: yomguy Date: Tue, 13 Dec 2011 15:32:47 +0100 Subject: [PATCH] add cleanup management script --- telemeta/htdocs/timeside/js/player.js | 72 +++++++++---------- telemeta/htdocs/timeside/js/timeside.js | 24 +++---- .../management/commands/telemeta-cleanup.py | 33 +++++++++ 3 files changed, 81 insertions(+), 48 deletions(-) create mode 100644 telemeta/management/commands/telemeta-cleanup.py diff --git a/telemeta/htdocs/timeside/js/player.js b/telemeta/htdocs/timeside/js/player.js index cdc7f065..4b6a1a0e 100644 --- a/telemeta/htdocs/timeside/js/player.js +++ b/telemeta/htdocs/timeside/js/player.js @@ -29,7 +29,7 @@ //playerDiv, sound, durationInMsec, visualizers, markerMap); Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ - + //sound duration is in milliseconds because the soundmanager has that unit, //player (according to timeside syntax) has durations in seconds // newMarkerCallback must be either a string or a function, the necessary checks is done in Timeside.load @@ -63,7 +63,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ } var onReadyWithImage = configObject.onReadyWithImage; - + if(typeof onReadyWithImage === 'function'){ var onReadyWithImageNamespace = 'imgRefreshed.temp_'+new Date().getTime(); //get an unique namespace this.bind(onReadyWithImageNamespace,function(data){ @@ -109,7 +109,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ var soundOptions = sound; if(sMan.canPlayURL(soundOptions.url)){ //this actually checks only if the url is well formed, not if the file is there //check if we specified a valid sound duration, otherwise the sound must be loaded - + sound = sMan.createSound(soundOptions); }else{ this.soundErrorMsg = 'bad sound parameter (soundManager.canPlayURL returned false)'; @@ -159,24 +159,24 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ this.playState = 0; //0: not playing, 1: loading, 2:buffering, 3 playing (sound heard) //container is the div #player - + this.getContainer = function(){ return container; }; - - + + var sd = this.toSec(soundDurationInMsec); this.getSoundDuration = function(){ return sd; }; - + this.soundPosition = sound.position ? this.toSec(sound.position) : 0; - - - + + + // - + //initializing markermap and markerui var map = new Timeside.classes.MarkerMap(); this.getMarkerMap = function(){ @@ -190,7 +190,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ this.newMarker = newMarker; } } - + //build the innerHTML as array, then join it. This is usually faster than string concatenation in some browsers. //Note that the player image (see below) is not created now, however, if it was, it should be given a src //as NOT specifying any src for image tags can be harmful, @@ -220,7 +220,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ ""]; container.html(html.join('')); - + var control = container.find('.ts-control'); //bind events to buttons: @@ -420,11 +420,11 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ //set sound position: var oldSoundPosition = this.soundPosition; this.soundPosition = newPositionInSeconds; - + //resume playing if it was playing: if(wasPlaying){ var player = this; - + //delay a little bit the play resume, this might avoid fast pointer repositioning //(it should not be the case, but it happens. why??) setTimeout(function(){ @@ -445,7 +445,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ //the value is in seconds //markerCrossedOffsetMargin : 0.5, play : function(){ - + if(this.soundErrorMsg){ alert(this.soundErrorMsg); return false; @@ -458,7 +458,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ //together with this.soundErrorMsg != "", so we should have catch the case above return false; } - + var fireOnMarkerPosition = function(seconds){}; //does nothing by default var map = player.getMarkerMap(); @@ -495,7 +495,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ data.currentSoundPosition = seconds; data.nextMarkerTimeInterval = marker ? [offs-margin, offs+margin] : undefined; player.fire('markerCrossed',data); - + if(idx'); } @@ -823,7 +823,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ this.isImgRefreshing = true; this.fire('imgRefreshing'); image.attr('src', imgSrc); - + }, getImageSize: function(){ var wave = this.getContainer().find('.ts-wave'); @@ -879,7 +879,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ idx++; } } - + if(idx< len){ offset = markers[idx].offset; } @@ -1006,9 +1006,9 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ //TODO: think about if clearing or not: we assign some bindings in the constructor, too: // map.clear(); // ruler.clear(); - + var rulerAdd = ruler.add; - + if(markers){ //add markers to the map. No listeners associated to it (for the moment) for(var i =0; i< markers.length; i++){ @@ -1020,7 +1020,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ rulerAdd.apply(ruler,[marker.offset, i, marker.isEditable]); }); } - + //the function above calls map.add: //add bindings when adding a marker: map.bind('add',function(data){ @@ -1043,7 +1043,7 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({ }); //and now add a binding to the map when we move a marker: - + map.bind('move', function(data){ var from = data.fromIndex; var to = data.toIndex; diff --git a/telemeta/htdocs/timeside/js/timeside.js b/telemeta/htdocs/timeside/js/timeside.js index 646d8c77..c764d46e 100644 --- a/telemeta/htdocs/timeside/js/timeside.js +++ b/telemeta/htdocs/timeside/js/timeside.js @@ -89,7 +89,7 @@ var Timeside = { * MIT Licensed. * (Inspired by base2 and Prototype) */ - + /* * In few words: the lightest and most-comprehensive way to implement inhertance and OOP in javascript. Usages can be found below. * Basically, @@ -118,7 +118,7 @@ var Timeside = { * this._super(); //!!!ERROR: methods defined in the init function don't have acces to _super * } * this.alert = function(){ //another public method, !!!WARNING: this will be put in the MyClass scope (NOT in the prototype) - * alert('ok'); + * alert('ok'); * } * }, * count:0, //public property @@ -131,7 +131,7 @@ var Timeside = { * this._super(); //call the super constructor * } * alert: function(){ //override a method - * this._super(); //call the super method, ie alerts 'no'. WARNING: However, as long as there is an alert written + * this._super(); //call the super method, ie alerts 'no'. WARNING: However, as long as there is an alert written * //in the init method of the superclass (see above), THAT method will be called * } * }); @@ -209,7 +209,7 @@ var Timeside = { // Populate our constructed prototype object Class.prototype = prototype; - + // Enforce the constructor to be what we expect Class.constructor = Class; @@ -233,7 +233,7 @@ Timeside.classes.TimesideClass = Timeside.Class.extend({ //(ie, every instance has its own copy) this.listenersMap={}; }, - + cssPrefix : 'ts-', //actually almost uneuseful, still here for backward compatibility with old code (TODO: remove?) $J : jQuery, //reference to jQuery for faster lookup inside methods $TU : Timeside.utils, //reference to Timeside variable for faster lookup inside methods @@ -265,7 +265,7 @@ Timeside.classes.TimesideClass = Timeside.Class.extend({ cb.apply(optionalThisArgInCallback,[data]); }; } - + if(listenersMap.hasOwnProperty(eventType)){ listenersMap[eventType].push(callback); }else{ @@ -342,7 +342,7 @@ Timeside.classes.TimesideClass = Timeside.Class.extend({ callbacks[i](dataArgument); } }, - + /* *formats (ie returns a string representation of) a time which is in the form seconds,milliseconds (eg 07.6750067) * formatArray is an array of strings which can be: @@ -363,7 +363,7 @@ Timeside.classes.TimesideClass = Timeside.Class.extend({ if(!(formatArray)){ formatArray = ['mm','ss']; } - + //marker offset is in float format second.decimalPart var pInt = parseInt; var round = Math.round; @@ -375,7 +375,7 @@ Timeside.classes.TimesideClass = Timeside.Class.extend({ time-=minutes*factor; var seconds = pInt(time); time-=seconds; - + //here below the function to format a number //ceilAsPowerOfTen is the ceil specifiedas integer indicating the relative power of ten //(0: return the number as it is, 1: format as "0#" and so on) @@ -475,7 +475,7 @@ Timeside.classes.TimesideArray = Timeside.classes.TimesideClass.extend({ //2) each(m, callback) iterates over the elements from m executing callback //3) each(m,n,callback) iterates over the elements from m (inclusive) to n-1 (inclusive) executing callback - //NOTE: writing each : function(startInclusive, endExclusive, callback) throws an error in chrome, as the last + //NOTE: writing each : function(startInclusive, endExclusive, callback) throws an error in chrome, as the last //argument (even if it is a function) is a number. Why????? //Anyway, we write the function arguments as empty each : function(){ @@ -512,7 +512,7 @@ Timeside.classes.TimesideArray = Timeside.classes.TimesideClass.extend({ for(var i = startInclusive; i