dom/tests/mochitest/ajax/scriptaculous/src/sound.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // script.aculo.us sound.js v1.7.1_beta2, Tue May 15 15:15:45 EDT 2007
michael@0 2
michael@0 3 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
michael@0 4 //
michael@0 5 // Based on code created by Jules Gravinese (http://www.webveteran.com/)
michael@0 6 //
michael@0 7 // script.aculo.us is freely distributable under the terms of an MIT-style license.
michael@0 8 // For details, see the script.aculo.us web site: http://script.aculo.us/
michael@0 9
michael@0 10 Sound = {
michael@0 11 tracks: {},
michael@0 12 _enabled: true,
michael@0 13 template:
michael@0 14 new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
michael@0 15 enable: function(){
michael@0 16 Sound._enabled = true;
michael@0 17 },
michael@0 18 disable: function(){
michael@0 19 Sound._enabled = false;
michael@0 20 },
michael@0 21 play: function(url){
michael@0 22 if(!Sound._enabled) return;
michael@0 23 var options = Object.extend({
michael@0 24 track: 'global', url: url, replace: false
michael@0 25 }, arguments[1] || {});
michael@0 26
michael@0 27 if(options.replace && this.tracks[options.track]) {
michael@0 28 $R(0, this.tracks[options.track].id).each(function(id){
michael@0 29 var sound = $('sound_'+options.track+'_'+id);
michael@0 30 sound.Stop && sound.Stop();
michael@0 31 sound.remove();
michael@0 32 })
michael@0 33 this.tracks[options.track] = null;
michael@0 34 }
michael@0 35
michael@0 36 if(!this.tracks[options.track])
michael@0 37 this.tracks[options.track] = { id: 0 }
michael@0 38 else
michael@0 39 this.tracks[options.track].id++;
michael@0 40
michael@0 41 options.id = this.tracks[options.track].id;
michael@0 42 if (Prototype.Browser.IE) {
michael@0 43 var sound = document.createElement('bgsound');
michael@0 44 sound.setAttribute('id','sound_'+options.track+'_'+options.id);
michael@0 45 sound.setAttribute('src',options.url);
michael@0 46 sound.setAttribute('loop','1');
michael@0 47 sound.setAttribute('autostart','true');
michael@0 48 $$('body')[0].appendChild(sound);
michael@0 49 }
michael@0 50 else
michael@0 51 new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
michael@0 52 }
michael@0 53 };
michael@0 54
michael@0 55 if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
michael@0 56 if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
michael@0 57 Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
michael@0 58 else
michael@0 59 Sound.play = function(){}
michael@0 60 }

mercurial