wplayer

Check-in [ad7942058e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Support ES5 for now, Tint browser on tablet
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:ad7942058ecff2e34160c1556616e6344b2fd91ac3638f0a0122f8e2b35299ad
User & Date: ajv-899-334-8894@vsta.org 2017-04-22 03:41:13
Context
2017-04-22
03:41
Dynamic reload of index contents. check-in: 14a0ab9378 user: ajv-899-334-8894@vsta.org tags: master, trunk
03:41
Support ES5 for now, Tint browser on tablet check-in: ad7942058e user: ajv-899-334-8894@vsta.org tags: master, trunk
2017-03-13
13:27
Note on search check-in: 8d3bd7470b user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to js/player.js.

     1      1   //
     2      2   // player.js
     3      3   //	One-page-app to play music from a web server
     4      4   //
            5  +// This source file is written for pre-ES5, because:
            6  +//  The Tint browser does mp3/ogg/flac, but not ES5/ES6
            7  +//  Chrome does mp3/ogg/flac and ES6, but crashes on my tablet
            8  +//  Firefox does mp3/ogg and ES6, but not flac (on Android, thanks)
            9  +//
     5     10   
     6     11   
     7     12   // The HTML5 player
     8     13   var player = document.getElementById("player");
     9     14   
    10     15   // File/dir browsing
    11     16   var browser = document.getElementById("browser");
................................................................................
    61     66       }
    62     67       indexed = pcontents.index;
    63     68       searchbar.style.display = indexed ? '' : 'none';
    64     69   
    65     70       // Directories (if any)
    66     71       if (pcontents.dirs.length > 0) {
    67     72   	res += '<b>Directories</b>:<br>';
    68         -	for (var didx = 0; didx < pcontents.dirs.length; didx++) {
           73  +        var didx;
           74  +	for (didx = 0; didx < pcontents.dirs.length; didx++) {
    69     75   	    d = pcontents.dirs[didx];
    70     76   	    res += '<button onclick="return go_dir(' + didx.toString() + ');">'
    71     77   	    res += ' <img src="/imgs/player_play.png" alt="enter" />\n'
    72     78   	    res += '</button>' + unescape(d) + '<br>\n'
    73     79   	}
    74     80       }
    75     81   
    76     82       // Files (if any)
    77     83       if (pcontents.files.length > 0) {
    78     84   	res += '<b>Files</b>:<br>';
    79         -	for (var fidx = 0; fidx < pcontents.files.length; fidx++) {
           85  +        var fidx;
           86  +	for (fidx = 0; fidx < pcontents.files.length; fidx++) {
    80     87   	    f = pcontents.files[fidx];
    81     88   	    res += '<button onclick="return go_file(' + fidx.toString() + ');">'
    82     89   	    res += ' <img src="/imgs/player_play.png" alt="play" />\n'
    83     90   	    res += '</button>' + unescape(f) + '<br>\n'
    84     91   	}
    85     92       }
    86     93   
................................................................................
   113    120   	res += elem;
   114    121       }
   115    122       return res;
   116    123   }
   117    124   
   118    125   // Update playlist queue pane
   119    126   function paintQueue() {
   120         -    var f, res = '';
   121         -    for (var fidx = 0; fidx < playlist.length; fidx++) {
          127  +    var fidx, f, res = '';
          128  +    for (fidx = 0; fidx < playlist.length; fidx++) {
   122    129   	f = do_trim(unescape(playlist[fidx]));
   123    130   	res += f + '\n';
   124    131       }
   125    132       pqueue.textContent = res;
   126    133   }
   127    134   
   128    135   // Get a dir/file listing from the URL
................................................................................
   236    243       paintQueue();
   237    244   }
   238    245   
   239    246   // Add all files in current folder to playlist
   240    247   // (i.e., "play album")
   241    248   function addAll() {
   242    249       if (pcontents.files.length > 0) {
   243         -	for (var fidx = 0; fidx < pcontents.files.length; fidx++) {
          250  +        var fidx;
          251  +	for (fidx = 0; fidx < pcontents.files.length; fidx++) {
   244    252   	    go_file(fidx);
   245    253   	}
   246    254       }
   247    255   }
   248    256   
   249    257   // Clear the decks!
   250    258   function dropAll() {
................................................................................
   279    287   function srch() {
   280    288       // Action pending
   281    289       if (pcontents == null) {
   282    290           return;
   283    291       }
   284    292   
   285    293       // Probably backspace to clear out search field
   286         -    let s = searchval.value;
          294  +    var s = searchval.value;
   287    295       if (s.length == 0) {
   288    296           curdir();
   289    297           return;
   290    298       }
   291    299   
   292    300       // Get a set of options based on the current path
   293    301       //  and search value
   294         -    const url = "/search" + path + "?q=" + escape(s);
          302  +    var url = "/search" + path + "?q=" + escape(s);
   295    303       pdepth += 1;
   296    304       getDir(url);
   297    305   }
   298    306   
   299    307   // Set up the player
   300    308   player.addEventListener("ended", playNext);
   301    309   
   302    310   // Initial browser window update
   303    311   curdir();