1/** 2* Simple Stats 3* version 1.1 4* --- 5* A simple stats collection module for MP3-jPlayer 6* http://mp3-jplayer.com/simple-stats 7*/ 8 9MJPsimplestats = { 10 11 showPlayCounts: 0, 12 showDownloadCounts: 0, 13 14 //~~ 15 init: function () { 16 //collect plays 17 var extCall = function ( data ) { 18 MJPstats_request( data, 'change_post_MJPsimplestats'); 19 }; 20 MP3_JPLAYER.extCalls.change_post.push( extCall ); 21 22 //collect downloads 23 var extCallD = function ( data ) { 24 MJPstats_request( data, 'download_MJPsimplestats'); 25 }; 26 MP3_JPLAYER.extCalls.download.push( extCallD ); 27 }, 28 29 30 //~~ 31 displayCounts: function () { 32 var j; 33 var playlist; 34 var i; 35 var L; 36 var html; 37 38 for ( j in MP3jPLAYERS ) { 39 playlist = MP3jPLAYERS[ j ].list; 40 L = playlist.length; 41 for ( i = 0; i < L; i += 1 ) { 42 html = MJPsimplestats.makeCountHtml( j, i ); 43 if ( MJPsimplestats.isPlaylister( j ) ) { 44 jQuery('#mjp_ext_li_' + j + '_' + i ).append( '<div class="emjp_stats_counts">' + html + '</div>' ); 45 } else if ( MJPsimplestats.isSingle( j ) ) { 46 jQuery('#mp3jWrap_' + j ).append( '<span class="emjp_stats_counts">' + html + '</span>' ); 47 break; 48 } 49 } 50 } 51 }, 52 53 54 //~~ 55 makeCountHtml: function ( j, i ) { 56 var track = MP3jPLAYERS[ j ].list[ i ]; 57 var plays = typeof track.play_total !== 'undefined' ? track.play_total : '0'; 58 var downloads = typeof track.download_total !== 'undefined' ? track.download_total : '0'; 59 60 var html = ''; 61 if ( MJPsimplestats.showPlayCounts ) { 62 html += '<span class="emjp_stats_number">' + plays + '</span> Play' + ( plays == 1 ? '' : 's' ); 63 } 64 if ( MJPsimplestats.showDownloadCounts ) { 65 html += html == '' ? '' : ', '; 66 html += '<span class="emjp_stats_number">' + downloads + '</span> Download' + ( downloads == 1 ? '' : 's' ); 67 } 68 return html; 69 }, 70 71 72 //~~ 73 isPlaylister: function ( j ) { 74 var p = MP3jPLAYERS[ j ] 75 return ( 'MI' === p.type ) ? true : false; 76 }, 77 78 79 //~~ 80 isSingle: function ( j ) { 81 var p = MP3jPLAYERS[ j ] 82 return ( 'single' === p.type ) ? true : false; 83 } 84 85}; 86 87 88function MJPstats_request( info, action, callback ) { 89 var data = { 90 'action': action, 91 'info': info, 92 'tID': MP3_JPLAYER.tID 93 }; 94 jQuery.ajax({ 95 type: "POST", 96 data: data, 97 url: statsMJPajax.WPajaxurl, 98 success: function( response ) { 99 if ( typeof callback !== 'undefined' ) { 100 callback( response ); 101 } 102 } 103 }); 104}; 105 106 107jQuery( document ).ready( function () { 108 if ( typeof MP3_JPLAYER !== 'undefined' ) { 109 MJPsimplestats.init(); 110 } 111});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.