~rodrigo-moya/libubuntuone/location-property

« back to all changes in this revision

Viewing changes to data/u1-preview.js

  • Committer: Tarmac
  • Author(s): stuart.langridge at canonical
  • Date: 2010-03-05 16:11:31 UTC
  • mfrom: (52.1.1 obvious-wma-aac-527684)
  • Revision ID: rodrigo@megeve-20100305161131-6a6yt90g2g9bm6wz
Display an in-page warning for albums that don't have mp3 format downloads

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
        if (ply) {
12
12
                ply.parentNode.removeChild(ply);
13
13
        }
 
14
 
 
15
        // look to see if this is WMA or AAC only and if so inject a warning
 
16
        var hasNonMP3 = false;
 
17
        var hasMP3 = false;
 
18
        var medias = document.querySelectorAll("img.mediaIcon");
 
19
        for (var i=0; i<medias.length; i++) {
 
20
            if (medias[i].src.indexOf("fmt_mp3") != -1) {
 
21
                hasMP3 = true;
 
22
            } else if (medias[i].src.indexOf("fmt_320") != -1) { // sigh
 
23
                hasMP3 = true; 
 
24
            } else if (medias[i].src.indexOf("fmt_") != -1) {
 
25
                hasNonMP3 = true;
 
26
            }
 
27
        }
 
28
        if (hasMP3 && hasNonMP3) {
 
29
            // has both; do nothing; mp3 will be downloaded automatically
 
30
        } else if (hasMP3 && !hasNonMP3) {
 
31
            // only has MP3, no problem
 
32
        } else if (!hasMP3 && !hasNonMP3) {
 
33
            // doesn't have a format at all. Probably means that the HTML
 
34
            // has changed. Do nothing.
 
35
        } else if (!hasMP3 && hasNonMP3) {
 
36
            // does not have MP3, does have others. Problem. Add a warning.
 
37
            var warn = document.createElement("div");
 
38
            warn.appendChild(document.createTextNode(
 
39
              "Warning: this album does not appear to be in MP3 format."));
 
40
            warn.style.borderWidth = "3px";
 
41
            warn.style.borderColor = "red";
 
42
            warn.style.borderStyle = "solid";
 
43
            warn.style.padding = "25px";
 
44
            warn.style.textAlign = "center";
 
45
            warn.style.backgroundColor = "#ff9b9b";
 
46
            
 
47
            var mainContent = document.querySelector("td.mainContent");
 
48
            if (mainContent && mainContent.firstChild) {
 
49
                mainContent.insertBefore(warn, mainContent.firstChild);
 
50
            }
 
51
        }
14
52
})()