Almost original website. Just removed tracking links

This commit is contained in:
Fijxu 2023-12-30 23:37:27 -03:00
commit 37870e1217
23 changed files with 439 additions and 0 deletions

File diff suppressed because one or more lines are too long

42
changelog.txt Normal file
View File

@ -0,0 +1,42 @@
keygenmusic.tk changes log
==========================
Contact me:
- Twitter: https://twitter.com/keygenmusicTK
- Email: keygenmusic.tk{at}outlook.com
------------------------------------------------------
β11 (2020.12.08)
- fix issue appeared in Chromium based browsers (was not able to play)
β10 (2016.02.05)
- remove zero-clipboard (solution via document.execCommand)
- add track title to playlist
- search also by track title
2015.10.02 - update to September 2015 pack (keygenmusic.net)
β9 (2015.10.01)
- fix bug with broken link to song
- share song on twitter button
- some styles fixes
2015.09.07 - update to July 2015 pack (keygenmusic.net)
2015.06.05 - β8 - now playing in playlist
2015.06.04 - upd to April 2015 pack (keygenmusic.net)
2015.05.25 - β7
2015.05.18 - β6 - spectrum
2015.05.12 - β5 - favorites, link to song
2015.05.08 - β4 - optimizations
2015.05.04 - β2 - Shuffle on/off, song search
2015.04.30 - β1 - February 2015 music pack from keygenmusic.net

1
css/libs/cog.css Normal file
View File

@ -0,0 +1 @@
.overlay-loader{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000}.overlay-loader .loader-background{position:absolute;top:0;right:0;bottom:0;left:0;background-color:#2b2b2b;-webkit-transition:background-color .2s 0s linear,right .2s .3s ease-out;-moz-transition:background-color .2s 0s linear,right .2s .3s ease-out;-o-transition:background-color .2s 0s linear,right .2s .3s ease-out;transition:background-color .2s 0s linear,right .2s .3s ease-out}.overlay-loader .loader-icon{position:absolute;top:50%;left:50%;margin:-48px 0 0 -48px;font-size:96px;color:#fff}.overlay-loader .loader-icon.spinning-cog{-webkit-animation:spinning-cog 1.3s infinite ease;-moz-animation:spinning-cog 1.3s infinite ease;-ms-animation:spinning-cog 1.3s infinite ease;-o-animation:spinning-cog 1.3s infinite ease;animation:spinning-cog 1.3s infinite ease}@-webkit-keyframes spinning-cog{0%{-webkit-transform:rotate(0deg)}20%{-webkit-transform:rotate(-45deg)}100%{-webkit-transform:rotate(360deg)}}@-moz-keyframes spinning-cog{0%{-moz-transform:rotate(0deg)}20%{-moz-transform:rotate(-45deg)}100%{-moz-transform:rotate(360deg)}}@-o-keyframes spinning-cog{0%{-o-transform:rotate(0deg)}20%{-o-transform:rotate(-45deg)}100%{-o-transform:rotate(360deg)}}@keyframes spinning-cog{0%{transform:rotate(0deg)}20%{transform:rotate(-45deg)}100%{transform:rotate(360deg)}}

1
css/libs/tabs.css Normal file
View File

@ -0,0 +1 @@
ul.tabs_nav{list-style:none;padding:0;width:550px}.tabs_nav li{display:inline;border:1px solid #515658;background-color:#3c3e3f;padding:7px;margin-right:-9px;margin-bottom:-1px;cursor:pointer}.tabs_nav li.active{border-bottom:1px solid #e6e6e6;background-color:#515658}.tabs_nav a{text-decoration:none;font-weight:700;color:#a9b7c6}.tabs_nav li.active a{text-decoration:none;color:#e6e6e6}.tabs_content{color:#a9b7c6;width:550px;margin:0 auto}.tabs_content>div{padding:5px 5px 0 10px}.tabs_content a{color:#9876aa}

1
css/main.css Normal file

File diff suppressed because one or more lines are too long

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

29
img/cog08.svg Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="cog8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="96px" height="96px" viewBox="0 0 96 96" enable-background="new 0 0 96 96" xml:space="preserve">
<g>
<g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M81.379,60.37c1.278-3.584,2.02-7.422,2.11-11.432
c0.46-0.144,0.943-0.29,1.385-0.434c4.905-1.599,9.091-3.101,10.968-4.423l-1.536-8.765c-2.02-0.54-5.96-0.584-10.489-0.458
c-0.872,0.025-1.806,0.07-2.747,0.115c-1.318-3.415-3.119-6.581-5.341-9.398c0.511-0.804,1.013-1.602,1.47-2.355
c2.374-3.918,4.069-7.239,4.619-9.286l-6.656-5.492c-1.889,0.904-4.714,3.084-8.103,6.138c-0.647,0.583-1.329,1.221-2.016,1.866
c-3.102-1.726-6.483-2.992-10.061-3.716c-0.117-0.94-0.236-1.872-0.363-2.74c-0.661-4.551-1.358-7.868-2.233-9.793l-8.769,0
c-0.875,1.925-1.571,5.242-2.234,9.793c-0.125,0.868-0.245,1.8-0.363,2.74c-3.576,0.724-6.958,1.99-10.06,3.716
c-0.687-0.645-1.368-1.282-2.017-1.866c-3.388-3.054-6.212-5.234-8.103-6.138l-6.615,5.45c0.548,2.046,2.206,5.41,4.579,9.328
c0.457,0.753,0.96,1.552,1.47,2.355c-2.223,2.817-4.024,5.983-5.339,9.398c-0.943-0.045-1.877-0.09-2.75-0.115
c-4.528-0.126-8.526,0.111-10.545,0.651l-1.459,8.285c1.875,1.322,6.043,3.11,10.949,4.709c0.441,0.144,0.924,0.29,1.384,0.434
c0.089,4.01,0.832,7.848,2.108,11.432c-0.052,0.041-0.1,0.079-0.152,0.121c-2.957,2.396-6.302,5.127-9.873,8.035l4.398,7.456
c4.266-1.683,8.15-3.191,11.671-4.593c0.056-0.021,0.105-0.043,0.161-0.065c2.636,3.18,5.812,5.869,9.37,7.969
c-0.011,0.063-0.023,0.121-0.036,0.186c-0.749,3.767-1.456,7.522-2.351,12.082l8.192,2.929c2.203-4.074,3.99-7.327,5.801-10.701
c0.033-0.059,0.06-0.115,0.093-0.175c1.985,0.351,4.02,0.568,6.104,0.568c2.084,0,4.118-0.218,6.104-0.568
c0.032,0.06,0.059,0.116,0.093,0.175c1.81,3.374,3.597,6.626,5.799,10.7l8.192-2.929c-0.893-4.56-1.601-8.314-2.35-12.081
c-0.013-0.064-0.024-0.122-0.037-0.186c3.56-2.1,6.734-4.789,9.371-7.969c0.056,0.022,0.105,0.044,0.162,0.065
c3.522,1.401,7.394,2.922,11.659,4.604l4.41-7.478c-2.027-1.651-5.371-4.377-9.873-8.025C81.48,60.449,81.433,60.411,81.379,60.37
z M48,72.047c-13.255,0-24-10.766-24-24.047s10.745-24.047,24-24.047S72,34.719,72,48S61.255,72.047,48,72.047z"/>
</g>
</g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M48,36c6.627,0,12,5.373,12,12s-5.373,12-12,12s-12-5.373-12-12
S41.373,36,48,36z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/darcula-spectrum.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

212
index.html Normal file
View File

@ -0,0 +1,212 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="description" content="Online chiptune music player. Charged with music from keygens. Streams directly in your browser">
<meta name="keywords" content="keygen music, keygenmusic, chiptune, chiptunes, chip, tune, MOD, XM, s3m, IT, stream, MOS 6581, MOS 8580, intro, music" />
<title>keygenmusic.tk - tracker music player</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="css/libs/cog.css">
<link rel="stylesheet" href="css/libs/tabs.css" />
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div id="headline">
<h1><span>keygenmusic</span><span class="magenta">.tk</span><span class="version">&beta;11-version</span>
<span class="follow"><a href="https://twitter.com/keygenmusicTK" target="_blank"><img src="img/soc/brandico-twitter-bird_20_0_a9b7c6_none.png" alt="twitter" /></a></span>
</h1>
</div>
<div id="playlist_bar">
<input id="search" type="text" placeholder="type to search then press ENTER" />
<label>
<select id="pl_select">
<option selected value>Keygen Music Lib</option>
<option value="my-fav">&#10084; Favorites</option>
</select>
</label>
</div>
<div id="playlist">
<div class="scroller">
<table data-selected cellspacing="0">
</table>
<div class="scroller__bar"></div>
</div>
</div>
<div id="player">
<div class="container">
<div class="center">
<canvas id="spectrum" class="spectrum" width="100%" height="200" style="transform: rotate(180deg);"></canvas>
</div>
<div id="song_info_con">
<table id="song_info" class="center" cellspacing="0" cellpadding="0">
<tr>
<td class="track_number"></td>
<td class="song">
<span class="rg"></span>
<span class="soft"></span>
</td>
<td title="Favorite" class="heart"><span>&#10084;</span></td>
<td class="direct_link" title="Copy link to this song to clipboard"><span>&#128279;</span></td>
<td class="share_twitter" title="Share this song on the Twitter"><a "https://keygenmusic.tk/href" target="_blank"><img src="img/soc/brandico-twitter-bird_20_0_a9b7c6_none.png" alt="Twitter" /></a></td>
</tr>
</table>
</div>
<div id="metadata_info" class="center">
<span class="track_number">track metadata: </span>
<span class="rg"></span>
<span class="dash"> &nbsp; </span>
<span class="soft"></span>
<span class="time"></span>
<span id="message" title>message</span>
</div>
<div id="controls" class="center">
<div id="container_button_prev">
<div id="hole_prev">
<div id="button_prev">
<div id="triangle_prev"></div>
<div id="lighter_triangle_prev"></div>
<div id="darker_triangle_prev"></div>
<div id="triangle_prev_2"></div>
<div id="lighter_triangle_prev_2"></div>
<div id="darker_triangle_prev_2"></div>
</div>
</div>
</div>
<div id="container_button">
<div id="hole">
<div id="button">
<div id="triangle"></div>
<div id="lighter_triangle"></div>
<div id="darker_triangle"></div>
</div>
</div>
</div>
<div id="container_button_next">
<div id="hole_next">
<div id="button_next">
<div id="triangle_next"></div>
<div id="lighter_triangle_next"></div>
<div id="darker_triangle_next"></div>
<div id="triangle_next_2"></div>
<div id="lighter_triangle_next_2"></div>
<div id="darker_triangle_next_2"></div>
</div>
</div>
</div>
</div>
<div id="more_controls" class="center">
<strong>SHUFFLE</strong>
<div class="switch">
<input type="checkbox" id="shuffle" class="switch-check" checked>
<label for="shuffle" class="switch-label">
Check
<span></span>
</label>
</div>
</div>
</div>
</div>
<div id="dev_bar">
<div id="btn">
i
</div>
<div id="text">
<div id="tabs" class="container">
<ul class="tabs_nav center">
<li><a href="index.html#about">About</a></li>
<li><a href="index.html#news">News</a></li>
<li><a href="index.html#credits">Credits</a></li>
</ul>
<div class="tabs_content center">
<div id="about">
<h1>Online Tracker Music Player</h1>
&beta;-version<br/>
Supports <span class="rg">.mod | .xm | .s3m | .it</span> formats.<br/>
Thanks to <a href="http://keygenmusic.net" target="_blank">keygenmusic.net</a> for the music
packs.<br/>
There is no illegal content. Just music from keygens<br/>
<br/>
<strong>Contact me:</strong><br/>
<span class="soft">
<a href="https://twitter.com/keygenmusicTK" target="_blank"><img src="img/soc/brandico-twitter-bird_20_0_a9b7c6_none.png" alt="twitter" /></a>
</span><br/>
<span class="soft"><i>keygenmusic.tk</i>{at}<i>outlook.com</i></span>
</div>
<div id="news">
<a href="changelog.txt" target="_blank">Changes Log</a><br>
<strong>2020.12.08</strong> - &beta;11 - fix Chromium issue ...<br>
<strong>2016.02.05</strong> - &beta;10 - mod title, search by mod titles ...<br>
<strong>2015.10.02</strong> - update to September 2015 pack (keygenmusic.net)<br>
<strong>2015.10.01</strong> - &beta;9<br>
<strong>2015.09.07</strong> - update to July 2015 pack (keygenmusic.net)<br>
<strong>2015.06.05</strong> - &beta;8 - now playing in playlist<br>
<strong>2015.06.04</strong> - upd to April 2015 pack (keygenmusic.net)<br>
<strong>2015.05.25</strong> - &beta;7<br>
<strong>2015.05.18</strong> - &beta;6 - spectrum<br>
<strong>2015.05.12</strong> - &beta;5 - favorites, link to song<br>
<strong>2015.05.08</strong> - &beta;4 - optimizations<br>
<strong>2015.05.04</strong> - &beta;2 - Shuffle on/off, song search<br>
<strong>2015.04.30</strong> - &beta;1 -
February 2015 music pack from keygenmusic.net
</div>
<div id="credits">
dev. by <a href="https://github.com/onikienko" target="_blank">Mikhailo Onikiienko</a><br/>
music from <a href="http://keygenmusic.net" target="_blank">keygenmusic.net</a><br/>
#libs, tools etc# <br/>
<a href="https://github.com/deskjet/chiptune2.js" target="_blank">chiptune2.js</a>,
<a href="http://lib.openmpt.org/" target="_blank">libopenmpt</a>,
<a href="https://github.com/kripken/emscripten" target="_blank">emscripten</a>,
<a href="https://github.com/onikienko/jsTabs" target="_blank">jsTabs</a>,
<a href="https://github.com/Diokuz/baron" target="_blank">baron</a>,
<a href="http://cssdeck.com/labs/amazing-play-button-in-css3" target="_blank">Sergio
Camalich</a>,
<a href="http://www.wothke.ch/webaudio68/" target="_blank">wothke.ch/webaudio68</a>,
thanks to Darcula color scheme,
<a href="http://cssdeck.com/labs/hp17u02i" target="_blank">Shuffle on/off switcher</a><br/>
<br/>
<strong>Contact me:</strong><br/>
<span class="soft">
<a href="https://twitter.com/keygenmusicTK" target="_blank"><img src="img/soc/brandico-twitter-bird_20_0_a9b7c6_none.png" alt="twitter" /></a>
</span><br/>
<span class="soft"><i>keygenmusic.tk</i>{at}<i>outlook.com</i></span>
</div>
</div>
</div>
</div>
</div>
<div id="info_bar">
<span class="rg">Total played: </span><span id="total_played"></span>
<span class="rg">Tracks played: </span><span id="tracks_played"></span>
</div>
<div id="loader" class="overlay-loader">
<div class="loader-background color-flip"></div>
<div id="browser">Your browser do not support AudioContext. Use modern browsers like
<a href="https://google.com/chrome">Chrome</a>,
<a href="http://firefox.com/">FireFox</a>,
<a href="http://opera.com/">Opera</a> ...
</div>
<img class="loader-icon spinning-cog" src="img/cog08.svg" data-cog="cog08">
</div>
<script type="text/javascript">
if (!(window.AudioContext || window.webkitAudioContext)) {
var loader = document.getElementById('loader');
loader.querySelector('img').style.display = 'none';
loader.querySelector('#browser').style.display = 'block';
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="js/libs/baron.min.js" type="text/javascript"></script>
<script src="js/libs/tabs.js" type="text/javascript"></script>
<script src="js/analyzer.js" type="text/javascript"></script>
<script src="js/libs/libopenmpt.js" type="text/javascript"></script>
<script src="js/libs/chiptune2-08.12.2020-fix.js" type="text/javascript"></script>
<script src="js/utils.js" type="text/javascript"></script>
<script src="js/model-localStorage.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
<script src="cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js"></script></body>
</html>

2
js/analyzer.js Normal file
View File

@ -0,0 +1,2 @@
var Graphix=function(audio){this.audio=audio;this.backgroundImg=0;};Graphix.prototype={updateImage:function(src){this.backgroundImg=0;var imgObj=new Image();imgObj.onload=function(){this.backgroundImg=imgObj;}.bind(this);imgObj.src=src;},reqAnimationFrame:function(){window.requestAnimationFrame(this.redrawSpectrum.bind(this));},redrawSpectrum:function(){this.reqAnimationFrame();if(!this.audio.analyzerNode){return false;}
var freqByteData=new Uint8Array(this.audio.analyzerNode.frequencyBinCount);this.audio.analyzerNode.getByteFrequencyData(freqByteData);var WIDTH=document.querySelector('.container').clientWidth;var HEIGHT=200;var canvasSpectrum=document.getElementById('spectrum');var ctxSpectrum=canvasSpectrum.getContext('2d');canvasSpectrum.width=WIDTH;var SPACER_WIDTH=8;var BAR_WIDTH=5;var OFFSET=100;var numBars=Math.round(WIDTH/SPACER_WIDTH);ctxSpectrum.clearRect(0,0,WIDTH,HEIGHT);var o;for(var i=0;i<numBars;++i){var magnitude=freqByteData[i+OFFSET]*HEIGHT/255;if(this.backgroundImg){o=Math.round(HEIGHT-magnitude);ctxSpectrum.drawImage(this.backgroundImg,0,0,BAR_WIDTH,255,i*SPACER_WIDTH,o,BAR_WIDTH,Math.round(magnitude));}}}};function updateGUI(){gfx.reqAnimationFrame();if(!gfx.backgroundImg)gfx.updateImage("img/darcula-spectrum.png");}

1
js/libs/baron.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
const OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT=0
const OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH=1
var ChiptuneAudioContext=window['AudioContext']||window['webkitAudioContext'];var ChiptuneJsConfig=function(repeatCount,stereoSeparation,interpolationFilter,context)
{this.repeatCount=repeatCount;this.stereoSeparation=stereoSeparation;this.interpolationFilter=interpolationFilter;this.context=context;}
ChiptuneJsConfig.prototype.constructor=ChiptuneJsConfig;var ChiptuneJsPlayer=function(config){this.config=config;this.context=config.context||new ChiptuneAudioContext();this.currentPlayingNode=null;this.gainNode=null;this.analyzerNode=null;this.handlers=[];this.touchLocked=true;}
ChiptuneJsPlayer.prototype.constructor=ChiptuneJsPlayer;ChiptuneJsPlayer.prototype.fireEvent=function(eventName,response){var handlers=this.handlers;if(handlers.length){handlers.forEach(function(handler){if(handler.eventName===eventName){handler.handler(response);}})}}
ChiptuneJsPlayer.prototype.addHandler=function(eventName,handler){this.handlers.push({eventName:eventName,handler:handler});}
ChiptuneJsPlayer.prototype.onEnded=function(handler){this.addHandler('onEnded',handler);}
ChiptuneJsPlayer.prototype.onError=function(handler){this.addHandler('onError',handler);}
ChiptuneJsPlayer.prototype.duration=function(){return Module._openmpt_module_get_duration_seconds(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentRow=function(){return Module._openmpt_module_get_current_row(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentPattern=function(){return Module._openmpt_module_get_current_pattern(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentOrder=function(){return Module._openmpt_module_get_current_order(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.metadata=function(){var data={};var keys=Pointer_stringify(Module._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';');var keyNameBuffer=0;for(var i=0;i<keys.length;i++){keyNameBuffer=Module._malloc(keys[i].length+1);writeAsciiToMemory(keys[i],keyNameBuffer);data[keys[i]]=Pointer_stringify(Module._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr,keyNameBuffer));Module._free(keyNameBuffer);}
return data;}
ChiptuneJsPlayer.prototype.module_ctl_set=function(ctl,value){return Module.ccall('openmpt_module_ctl_set','number',['number','string','string'],[this.currentPlayingNode.modulePtr,ctl,value])===1;}
ChiptuneJsPlayer.prototype.unlock=function(){var context=this.context;var buffer=context.createBuffer(1,1,22050);var unlockSource=context.createBufferSource();unlockSource.buffer=buffer;unlockSource.connect(context.destination);unlockSource.start(0);this.touchLocked=false;}
ChiptuneJsPlayer.prototype.load=function(input,callback){if(this.touchLocked){this.unlock();}
var player=this;if(input instanceof File){var reader=new FileReader();reader.onload=function(){return callback(reader.result);}.bind(this);reader.readAsArrayBuffer(input);}else{var xhr=new XMLHttpRequest();xhr.open('GET',input,true);xhr.responseType='arraybuffer';xhr.onload=function(e){if(xhr.status===200){return callback(xhr.response);}else{player.fireEvent('onError',{type:'onxhr'});}}.bind(this);xhr.onerror=function(){player.fireEvent('onError',{type:'onxhr'});};xhr.onabort=function(){player.fireEvent('onError',{type:'onxhr'});};xhr.send();}}
ChiptuneJsPlayer.prototype.play=function(buffer){this.stop();var processNode=this.createLibopenmptNode(buffer,this.config);if(processNode==null){return;}
Module._openmpt_module_set_repeat_count(processNode.modulePtr,this.config.repeatCount);Module._openmpt_module_set_render_param(processNode.modulePtr,OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT,this.config.stereoSeparation);Module._openmpt_module_set_render_param(processNode.modulePtr,OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH,this.config.interpolationFilter);this.currentPlayingNode=processNode;processNode.connect(this.gainNode);this.gainNode.connect(this.analyzerNode);this.analyzerNode.connect(this.context.destination);}
ChiptuneJsPlayer.prototype.stop=function(){if(this.currentPlayingNode!=null){this.currentPlayingNode.disconnect();this.currentPlayingNode.cleanup();this.currentPlayingNode=null;this.gainNode=null;this.analyzerNode=null;}}
ChiptuneJsPlayer.prototype.togglePause=function(){if(this.currentPlayingNode!=null){this.currentPlayingNode.togglePause();}}
ChiptuneJsPlayer.prototype.createLibopenmptNode=function(buffer,config){var maxFramesPerChunk=4096;var processNode=this.context.createScriptProcessor(2048,0,2);this.analyzerNode=this.context.createAnalyser();this.gainNode=this.context.createGain();processNode.config=config;processNode.player=this;var byteArray=new Int8Array(buffer);var ptrToFile=Module._malloc(byteArray.byteLength);Module.HEAPU8.set(byteArray,ptrToFile);processNode.modulePtr=Module._openmpt_module_create_from_memory(ptrToFile,byteArray.byteLength,0,0,0);processNode.paused=false;processNode.leftBufferPtr=Module._malloc(4*maxFramesPerChunk);processNode.rightBufferPtr=Module._malloc(4*maxFramesPerChunk);processNode.cleanup=function(){if(this.modulePtr!=0){Module._openmpt_module_destroy(this.modulePtr);this.modulePtr=0;}
if(this.leftBufferPtr!=0){Module._free(this.leftBufferPtr);this.leftBufferPtr=0;}
if(this.rightBufferPtr!=0){Module._free(this.rightBufferPtr);this.rightBufferPtr=0;}}
processNode.stop=function(){this.disconnect();this.cleanup();}
processNode.pause=function(){this.paused=true;}
processNode.unpause=function(){this.paused=false;}
processNode.togglePause=function(){this.paused=!this.paused;}
processNode.onaudioprocess=function(e){var outputL=e.outputBuffer.getChannelData(0);var outputR=e.outputBuffer.getChannelData(1);var framesToRender=outputL.length;if(this.ModulePtr==0){for(var i=0;i<framesToRender;++i){outputL[i]=0;outputR[i]=0;}
this.disconnect();this.cleanup();return;}
if(this.paused){for(var i=0;i<framesToRender;++i){outputL[i]=0;outputR[i]=0;}
return;}
var framesRendered=0;var ended=false;var error=false;while(framesToRender>0){var framesPerChunk=Math.min(framesToRender,maxFramesPerChunk);var actualFramesPerChunk=Module._openmpt_module_read_float_stereo(this.modulePtr,this.context.sampleRate,framesPerChunk,this.leftBufferPtr,this.rightBufferPtr);if(actualFramesPerChunk==0){ended=true;error=!this.modulePtr;}
var rawAudioLeft=Module.HEAPF32.subarray(this.leftBufferPtr/4,this.leftBufferPtr/4+actualFramesPerChunk);var rawAudioRight=Module.HEAPF32.subarray(this.rightBufferPtr/4,this.rightBufferPtr/4+actualFramesPerChunk);for(var i=0;i<actualFramesPerChunk;++i){outputL[framesRendered+i]=rawAudioLeft[i];outputR[framesRendered+i]=rawAudioRight[i];}
for(var i=actualFramesPerChunk;i<framesPerChunk;++i){outputL[framesRendered+i]=0;outputR[framesRendered+i]=0;}
framesToRender-=framesPerChunk;framesRendered+=framesPerChunk;}
if(ended){this.disconnect();this.cleanup();error?processNode.player.fireEvent('onError',{type:'openmpt'}):processNode.player.fireEvent('onEnded');}}
return processNode;}

View File

@ -0,0 +1,40 @@
const OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT=2
const OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH=3
var ChiptuneAudioContext=window['AudioContext']||window['webkitAudioContext'];var ChiptuneJsConfig=function(repeatCount,stereoSeparation,interpolationFilter,context)
{this.repeatCount=repeatCount;this.stereoSeparation=stereoSeparation;this.interpolationFilter=interpolationFilter;this.context=context;}
ChiptuneJsConfig.prototype.constructor=ChiptuneJsConfig;var ChiptuneJsPlayer=function(config){this.config=config;this.context=config.context||new ChiptuneAudioContext();this.currentPlayingNode=null;this.gainNode=null;this.analyzerNode=null;this.handlers=[];this.touchLocked=true;}
ChiptuneJsPlayer.prototype.constructor=ChiptuneJsPlayer;ChiptuneJsPlayer.prototype.fireEvent=function(eventName,response){var handlers=this.handlers;if(handlers.length){handlers.forEach(function(handler){if(handler.eventName===eventName){handler.handler(response);}})}}
ChiptuneJsPlayer.prototype.addHandler=function(eventName,handler){this.handlers.push({eventName:eventName,handler:handler});}
ChiptuneJsPlayer.prototype.onEnded=function(handler){this.addHandler('onEnded',handler);}
ChiptuneJsPlayer.prototype.onError=function(handler){this.addHandler('onError',handler);}
ChiptuneJsPlayer.prototype.duration=function(){return Module._openmpt_module_get_duration_seconds(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentRow=function(){return Module._openmpt_module_get_current_row(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentPattern=function(){return Module._openmpt_module_get_current_pattern(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.getCurrentOrder=function(){return Module._openmpt_module_get_current_order(this.currentPlayingNode.modulePtr);}
ChiptuneJsPlayer.prototype.metadata=function(){var data={};var keys=Pointer_stringify(Module._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';');var keyNameBuffer=0;for(var i=0;i<keys.length;i++){keyNameBuffer=Module._malloc(keys[i].length+1);writeAsciiToMemory(keys[i],keyNameBuffer);data[keys[i]]=Pointer_stringify(Module._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr,keyNameBuffer));Module._free(keyNameBuffer);}
return data;}
ChiptuneJsPlayer.prototype.module_ctl_set=function(ctl,value){return Module.ccall('openmpt_module_ctl_set','number',['number','string','string'],[this.currentPlayingNode.modulePtr,ctl,value])===1;}
ChiptuneJsPlayer.prototype.unlock=function(){var context=this.context;var buffer=context.createBuffer(1,1,22050);var unlockSource=context.createBufferSource();unlockSource.buffer=buffer;unlockSource.connect(context.destination);unlockSource.start(0);this.touchLocked=false;}
ChiptuneJsPlayer.prototype.load=function(input,callback){if(this.touchLocked){this.unlock();}
var player=this;if(input instanceof File){var reader=new FileReader();reader.onload=function(){return callback(reader.result);}.bind(this);reader.readAsArrayBuffer(input);}else{var xhr=new XMLHttpRequest();xhr.open('GET',input,true);xhr.responseType='arraybuffer';xhr.onload=function(e){if(xhr.status===200){return callback(xhr.response);}else{player.fireEvent('onError',{type:'onxhr'});}}.bind(this);xhr.onerror=function(){player.fireEvent('onError',{type:'onxhr'});};xhr.onabort=function(){player.fireEvent('onError',{type:'onxhr'});};xhr.send();}}
ChiptuneJsPlayer.prototype.play=function(buffer){this.stop();var processNode=this.createLibopenmptNode(buffer,this.config);if(processNode==null){return;}
Module._openmpt_module_set_repeat_count(processNode.modulePtr,this.config.repeatCount);Module._openmpt_module_set_render_param(processNode.modulePtr,OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT,this.config.stereoSeparation);Module._openmpt_module_set_render_param(processNode.modulePtr,OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH,this.config.interpolationFilter);this.currentPlayingNode=processNode;processNode.connect(this.gainNode);this.gainNode.connect(this.analyzerNode);this.analyzerNode.connect(this.context.destination);}
ChiptuneJsPlayer.prototype.stop=function(){if(this.currentPlayingNode!=null){this.currentPlayingNode.disconnect();this.currentPlayingNode.cleanup();this.currentPlayingNode=null;this.gainNode=null;this.analyzerNode=null;}}
ChiptuneJsPlayer.prototype.togglePause=function(){if(this.currentPlayingNode!=null){this.currentPlayingNode.togglePause();}}
ChiptuneJsPlayer.prototype.createLibopenmptNode=function(buffer,config){var maxFramesPerChunk=4096;var processNode=this.context.createScriptProcessor(2048,0,2);this.analyzerNode=this.context.createAnalyser();this.gainNode=this.context.createGain();processNode.config=config;processNode.player=this;var byteArray=new Int8Array(buffer);var ptrToFile=Module._malloc(byteArray.byteLength);Module.HEAPU8.set(byteArray,ptrToFile);processNode.modulePtr=Module._openmpt_module_create_from_memory(ptrToFile,byteArray.byteLength,0,0,0);processNode.paused=false;processNode.leftBufferPtr=Module._malloc(4*maxFramesPerChunk);processNode.rightBufferPtr=Module._malloc(4*maxFramesPerChunk);processNode.cleanup=function(){if(this.modulePtr!=0){Module._openmpt_module_destroy(this.modulePtr);this.modulePtr=0;}
if(this.leftBufferPtr!=0){Module._free(this.leftBufferPtr);this.leftBufferPtr=0;}
if(this.rightBufferPtr!=0){Module._free(this.rightBufferPtr);this.rightBufferPtr=0;}}
processNode.stop=function(){this.disconnect();this.cleanup();}
processNode.pause=function(){this.paused=true;}
processNode.unpause=function(){this.paused=false;}
processNode.togglePause=function(){this.paused=!this.paused;}
processNode.onaudioprocess=function(e){var outputL=e.outputBuffer.getChannelData(0);var outputR=e.outputBuffer.getChannelData(1);var framesToRender=outputL.length;if(this.ModulePtr==0){for(var i=0;i<framesToRender;++i){outputL[i]=0;outputR[i]=0;}
this.disconnect();this.cleanup();return;}
if(this.paused){for(var i=0;i<framesToRender;++i){outputL[i]=0;outputR[i]=0;}
return;}
var framesRendered=0;var ended=false;var error=false;while(framesToRender>0){var framesPerChunk=Math.min(framesToRender,maxFramesPerChunk);var actualFramesPerChunk=Module._openmpt_module_read_float_stereo(this.modulePtr,this.context.sampleRate,framesPerChunk,this.leftBufferPtr,this.rightBufferPtr);if(actualFramesPerChunk==0){ended=true;error=!this.modulePtr;}
var rawAudioLeft=Module.HEAPF32.subarray(this.leftBufferPtr/4,this.leftBufferPtr/4+actualFramesPerChunk);var rawAudioRight=Module.HEAPF32.subarray(this.rightBufferPtr/4,this.rightBufferPtr/4+actualFramesPerChunk);for(var i=0;i<actualFramesPerChunk;++i){outputL[framesRendered+i]=rawAudioLeft[i];outputR[framesRendered+i]=rawAudioRight[i];}
for(var i=actualFramesPerChunk;i<framesPerChunk;++i){outputL[framesRendered+i]=0;outputR[framesRendered+i]=0;}
framesToRender-=framesPerChunk;framesRendered+=framesPerChunk;}
if(ended){this.disconnect();this.cleanup();error?processNode.player.fireEvent('onError',{type:'openmpt'}):processNode.player.fireEvent('onEnded');}}
return processNode;}

14
js/libs/libopenmpt.js Normal file

File diff suppressed because one or more lines are too long

14
js/libs/libopenmpt.js.bak Normal file

File diff suppressed because one or more lines are too long

BIN
js/libs/libopenmpt.js.mem Normal file

Binary file not shown.

8
js/libs/tabs.js Normal file
View File

@ -0,0 +1,8 @@
function Tabs(tabs_id,handlers){this.html=document.querySelector(tabs_id);this.nav_links=this.html.querySelectorAll('.tabs_nav li a');this.ontoggle_handlers_list={};var self=this;this.nav_links_array=(function(){var arr=[];[].forEach.call(self.nav_links,function(el){arr.push(el.hash);});return arr;}());if(handlers){this.onToggle(handlers);}
this.go_();}
Tabs.prototype={fireOnToggle_:function(tab_name){if(this.ontoggle_handlers_list.hasOwnProperty(tab_name)&&this.ontoggle_handlers_list[tab_name].length>0){this.ontoggle_handlers_list[tab_name].forEach(function(handler){handler(tab_name);});}},toggle:function(tab_name){if(tab_name&&this.nav_links_array.indexOf(tab_name)!==-1){[].forEach.call(this.html.querySelectorAll('.tabs_content>div'),function(el){el.style.display=('#'+el.id===tab_name)?'block':'none';});[].forEach.call(this.nav_links,function(el){if(el.hash===tab_name){el.parentNode.classList.add('active');}else{el.parentNode.classList.remove('active');}});this.fireOnToggle_(tab_name);}},onToggle:function(handlers){var tab,self=this;function addHandler(tab_name,handler){if(!self.ontoggle_handlers_list[tab_name]){self.ontoggle_handlers_list[tab_name]=[];}
self.ontoggle_handlers_list[tab_name].push(handler);}
if(typeof handlers==='function'){this.nav_links_array.forEach(function(el){addHandler(el,handlers);});}else if(typeof handlers==='object'){for(tab in handlers){if(this.nav_links_array.indexOf(tab)!==-1){addHandler(tab,handlers[tab]);}}}},onNavClick_:function(){var self=this;self.html.querySelector('.tabs_nav').addEventListener('click',function(e){var hash=e.target.hash,li;if(!hash){if(e.target.tagName==='LI'){li=e.target.querySelector('a');hash=li.hash;}}
if(hash&&self.nav_links_array.indexOf(hash)!==-1&&!e.target.parentElement.classList.contains('active')){self.toggle(hash);}
e.preventDefault();e.stopPropagation();},false);},go_:function(){if(this.nav_links_array.length>0){var hash=window.location.hash;if(!hash||this.nav_links_array.indexOf(hash)===-1){hash=this.nav_links[0].hash;}
this.toggle(hash);this.onNavClick_();}}};

25
js/main.js Normal file
View File

@ -0,0 +1,25 @@
var urls={lib:'./kgm/lib.txt',lib_version:'./kgm/ver.txt',music_dir:'/kgm/',origin:window.location.origin},tabs=new Tabs('#tabs'),t_o,table=document.querySelector('#playlist table'),$scroller=$('.scroller'),player_container=document.getElementById('player'),play_btn=document.querySelector('#button'),prev_btn=document.querySelector('#button_prev'),next_btn=document.querySelector('#button_next'),song_info_container=document.getElementById('song_info'),song_info={track_number:song_info_container.querySelector('.track_number'),rg:song_info_container.querySelector('.rg'),dash:song_info_container.querySelector('.dash'),soft:song_info_container.querySelector('.soft'),heart:song_info_container.querySelector('.heart span'),direct_link:song_info_container.querySelector('.direct_link'),share_fb:song_info_container.querySelector('.share_fb a'),share_twitter:song_info_container.querySelector('.share_twitter a')},metadata_container=document.getElementById('metadata_info'),metadata={artist:metadata_container.querySelector('.rg'),title:metadata_container.querySelector('.soft'),message:metadata_container.querySelector('#message'),time:metadata_container.querySelector('.time')},info_bar_container=document.getElementById('info_bar'),info_bar={total_played:info_bar_container.querySelector('#total_played'),tracks_played:info_bar_container.querySelector('#tracks_played')},shuffle=document.getElementById('shuffle'),search_input=document.getElementById('search'),player=new ChiptuneJsPlayer(new ChiptuneJsConfig(1)),playList={song_lib:[],selected:[],current_playlist:[],current_playlist_name:'',track_num_in_cur_pl:0,favorites_playlist:[],xhrVersion:function(callback){var xhr=new XMLHttpRequest();xhr.open('GET',urls.lib_version,true);xhr.onload=function(e){callback(xhr.status===200&&xhr.responseText?xhr.responseText:null);};xhr.onerror=function(e){callback(null);};xhr.send();},xhrLib:function(callback){var xhr=new XMLHttpRequest();xhr.open('GET',urls.lib,true);xhr.onload=function(e){callback(xhr.status===200&&xhr.responseText?xhr.responseText:null);};xhr.onerror=function(e){callback(null);};xhr.send();},setLibPlayList:function(spl){playList.song_lib=spl;},shufflePlaylist:function(pl){for(var j,x,i=pl.length;i;j=Math.floor(Math.random()*i),x=pl[--i],pl[i]=pl[j],pl[j]=x);return pl;},setCurrentPlayList:function(shuffle){if(shuffle==='on'){playList.current_playlist=playList.shufflePlaylist(playList.selected.slice());}else{playList.current_playlist=playList.selected.slice();}},getCurrentSongPath:function(){return playList.current_playlist[playList.track_num_in_cur_pl].path;},nextSong:function(){if(playList.track_num_in_cur_pl>=playList.current_playlist.length-1){playList.track_num_in_cur_pl=0;}else{playList.track_num_in_cur_pl++;}
return playList.current_playlist[playList.track_num_in_cur_pl].path;},prevSong:function(){if(playList.track_num_in_cur_pl<=0){playList.track_num_in_cur_pl=playList.current_playlist.length-1;}else{playList.track_num_in_cur_pl--;}
return playList.current_playlist[playList.track_num_in_cur_pl].path;},getSongInfoByPath:function(path){var i,len=playList.song_lib.length;for(i=0;i<len;i++){if(playList.song_lib[i].path===path){return playList.song_lib[i];}}},isSongInCurrentPlaylist:function(path){var i,len=playList.current_playlist.length;for(i=0;i<len;i++){if(playList.current_playlist[i].path===path){return true;}}
return false;},moveToSongInCurrentPlayList:function(path){var i,len=playList.current_playlist.length;for(i=0;i<len;i++){if(playList.current_playlist[i].path===path){playList.track_num_in_cur_pl=i;break;}}},setSelected:function(val){var track_number=0,song_to_list;val=val.toLowerCase();function pushThis(song){song_to_list=$.extend({},song);song_to_list.n=++track_number;playList.selected.push(song_to_list);}
playList.selected=[];if(val===''){playList.selected=playList.song_lib.slice();}else{playList.song_lib.forEach(function(song){if(val==='my-fav'){if(playList.favorites_playlist.indexOf(song.path)!==-1){pushThis(song);}}else{if(song.path.toLowerCase().indexOf(val)!==-1||song.mdt.toLowerCase().indexOf(val)!==-1){pushThis(song);}}})}
return playList.selected;},getCurrentPlayListName:function(){return playList.current_playlist_name;},setCurrentPlayListName:function(name){playList.current_playlist_name=name;},setFavorites:function(favorites){playList.favorites_playlist=favorites;},toggleSongInFavorites:function(path){var is_fav=false,filtered=(function(){return playList.favorites_playlist.filter(function(fav_song){if(fav_song.toLowerCase()===path.toLowerCase()){is_fav=true;return false;}else{return true;}})})();if(!is_fav){filtered.push(path);}
playList.favorites_playlist=filtered;return playList.favorites_playlist;},isFavoriteSong:function(song_path){var is=false;playList.favorites_playlist.forEach(function(fav_song){if(fav_song.toLowerCase()===song_path.toLowerCase()){is=true;return true;}});return is;}},UI={track_html:null,removeSpinner:function(){document.querySelector('#loader').remove();},applyScrollBars:function(){$scroller.baron({scroller:'.scroller',bar:'.scroller__bar'});},renderPlaylist:function(playlist,list_name){var playlist_html='';playlist.forEach(function(song_info){playlist_html+='<tr data-path="'+song_info.path+'"><td class="track_number">'+song_info.n+'</td>'+
'<td class="track"><span class="rg"> '+song_info.rg+'</span>'+'<span class="dash"> </span>'+
'<span class="soft"> '+song_info.sn+'</span>'+
'<br><span class="mdt time">'+song_info.mdt+'</span>'+
'</td>'+
'<td title="Favorite" class="heart '+(playList.isFavoriteSong(song_info.path)?'favorite':'')+'"><span>&#10084;</span></td></tr>';});table.innerHTML=playlist_html;table.setAttribute('data-selected',list_name)},renderSongName:function(info){var heart_classes=song_info.heart.parentNode.classList,song_url=urls.origin+'/#track='+encodeURI(info.path.match(new RegExp(urls.music_dir+'(.+)'))[1]),s_soc=encodeURIComponent(urls.origin+'/#track='+encodeURI(info.path.match(new RegExp(urls.music_dir+'(.+)'))[1]));song_info_container.querySelector('tr').setAttribute('data-path',info.path);song_info.track_number.textContent=info.n+'. ';song_info.rg.textContent=info.rg;song_info.soft.textContent=info.sn;playList.isFavoriteSong(info.path)?heart_classes.add('favorite'):heart_classes.remove('favorite');song_info.direct_link.setAttribute('data-clipboard-text',song_url);song_info.share_twitter.setAttribute('href','http://twitter.com/intent/tweet?status='+s_soc);},renderMetadata:function(md){metadata.artist.textContent=md.artist?md.artist.replace(/\n+/gm,''):'';metadata.title.textContent=md.title?md.title.replace(/\n+/gm,''):'';metadata.message.setAttribute('title',md.message?md.message.replace(/"+/gm,'\''):'no message');metadata.time.textContent=md.duration?utils.durationToHuman(md.duration):'';},scrollToSongInPlaylist:function(path){var song_tr=table.querySelector('tr[data-path="'+path+'"]'),row_pos;if(song_tr){row_pos=$(song_tr).position();$scroller.scrollTop($scroller.scrollTop()+row_pos.top);}},highlightSongInPlaylist:function(path){var song_tr=table.querySelector('tr[data-path="'+path+'"]'),prev_song=table.querySelector('tr.now_playing');prev_song&&prev_song.classList.remove('now_playing');song_tr&&song_tr.classList.add('now_playing');},playPlayBtn:function(){play_btn.classList.add('playing');player_container.classList.add('playing');},togglePlayBtn:function(){play_btn.classList.toggle('playing');player_container.classList.toggle('playing');},getPlayBtnStatus:function(){return play_btn.classList.contains('playing')?'playing':'';},getShuffleBtnStatus:function(){return shuffle.checked?'on':'off';},getRenderedPlaylistName:function(){return table.getAttribute('data-selected');},renderTracksPlayed:function(num){info_bar.tracks_played.textContent=''+num;},renderTotalPlayed:function(time){info_bar.total_played.textContent=utils.msToHuman(time);},getPathForFavorite:function(fav_td_node){return fav_td_node.parentNode.getAttribute('data-path');},toggleFavorite:function(fav_td_node){var tr_node=fav_td_node.parentNode,path=tr_node.getAttribute('data-path');function toggleFavoriteInPlaylist(path){var song_tr=table.querySelector('tr[data-path="'+path+'"]');if(song_tr){if(UI.getRenderedPlaylistName()==='my-fav'){song_tr.remove();}else{song_tr.querySelector('.heart').classList.toggle('favorite');}}}
function toggleFavoriteInSongInfo(path){if(song_info_container.querySelector('tr').getAttribute('data-path')===path){song_info.heart.parentNode.classList.toggle('favorite');}}
if(tr_node.parentNode.parentNode.getAttribute('id')==='song_info'){fav_td_node.classList.toggle('favorite');toggleFavoriteInPlaylist(path);}else{if(UI.getRenderedPlaylistName()==='my-fav'){fav_td_node.parentNode.remove();}else{fav_td_node.classList.toggle('favorite');}
toggleFavoriteInSongInfo(path);}},},jsPlayer={playing:undefined,init:function(){if(player===undefined){player=new ChiptuneJsPlayer(new ChiptuneJsConfig(1));}
else{player.stop();}},loadFile:function(path,callback){jsPlayer.init();player.load('.'+path,function(buffer){var meta;player.play(buffer);jsPlayer.playing=path;meta=player.metadata();meta.duration=player.duration();callback(meta);});},togglePause:function(){player.togglePause();}},user={getFavorites:function(callback){model.read('favorites',function(favorites){callback(favorites);});},setFavorites:function(favorites){model.write('favorites',favorites);},getLibVersion:function(callback){model.read('lib_version',function(ver){callback(ver);});},setLibVersion:function(ver){model.write('lib_version',ver);},getLibList:function(callback){model.read('lib_list',function(lib_list){callback(lib_list);});},setLibList:function(lib_list){model.write('lib_list',lib_list);},getTotalPlayed:function(callback){model.read('total_played',function(played){callback(played);})},addToTotalPlayed:function(time,callback){user.getTotalPlayed(function(total_played){var new_total_played=parseInt(total_played,10)+time;model.write('total_played',new_total_played);callback&&callback(new_total_played);});},getTracksPlayed:function(callback){model.read('tracks_played',function(played){callback(played);});},addToTracksPlayed:function(callback){user.getTracksPlayed(function(num){var new_count=parseInt(num,10)+1;model.write('tracks_played',new_count);callback&&callback(new_count)})}},watcher={tick_start:undefined,client:undefined,updateSongInfo:function(song_path){UI.renderSongName(playList.getSongInfoByPath(song_path));},handleTotalPlayed:function(){var now=Date.now(),played;if(watcher.tick_start!==undefined){played=now-watcher.tick_start;user.addToTotalPlayed(played,function(time){UI.renderTotalPlayed(time);watcher.tick_start=UI.getPlayBtnStatus()!=='playing'?undefined:now;});}else{user.getTotalPlayed(function(time){UI.renderTotalPlayed(time);watcher.tick_start=UI.getPlayBtnStatus()!=='playing'?undefined:now;});}},toggleFavorite:function(fav_td_node){UI.toggleFavorite(fav_td_node);user.setFavorites(playList.toggleSongInFavorites(UI.getPathForFavorite(fav_td_node)));},loadSong:function(song){if(t_o){clearTimeout(t_o);}
t_o=window.setTimeout(function(){jsPlayer.loadFile(song,function(metadata){clearTimeout(t_o);watcher.handleTotalPlayed();UI.renderMetadata(metadata);});},200);},play:function(song){UI.playPlayBtn();UI.highlightSongInPlaylist(song);UI.scrollToSongInPlaylist(song);watcher.updateSongInfo(song);watcher.loadSong(song);},search:function(val){UI.renderPlaylist(playList.setSelected(val),val);},setHandlers:function(){song_info.direct_link.addEventListener('click',function(){utils.copyTextToClipboard(song_info.direct_link.getAttribute('data-clipboard-text'));var div=document.createElement('div'),rec=song_info.direct_link.getBoundingClientRect();div.className='copied_to_cb';div.style.top=(40+parseInt(rec.top,10))+'px';div.style.left=(parseInt(rec.left,10)-90)+'px';div.innerHTML='Link copied to clipboard';document.body.appendChild(div);setTimeout(function(){div.style.opacity=0;},50);setTimeout(function(){div.remove();},3000);});table.addEventListener('click',function(event){var target=event.target,path,rendered_pl_name=UI.getRenderedPlaylistName();function favorite(){if(target.classList.contains('heart')){event.stopPropagation();watcher.toggleFavorite(target);return true;}
return false;}
while(target!=this){if(favorite()){return false;}
if(target.tagName==='TR'){path=target.getAttribute('data-path');UI.highlightSongInPlaylist(path);watcher.updateSongInfo(path);watcher.handleTotalPlayed();jsPlayer.loadFile(path,function(metadata){if(playList.getCurrentPlayListName()!==rendered_pl_name){playList.setCurrentPlayListName(rendered_pl_name);playList.setCurrentPlayList(UI.getShuffleBtnStatus());}
playList.moveToSongInCurrentPlayList(path);UI.playPlayBtn();UI.renderMetadata(metadata);});}
target=target.parentNode;}});song_info.heart.addEventListener('click',function(e){watcher.toggleFavorite(e.target.parentNode);});document.querySelector('#playlist_bar select').addEventListener('change',function(e){watcher.search(this.options[this.selectedIndex].value);search_input.value='';});shuffle.addEventListener('change',function(){playList.setCurrentPlayList(UI.getShuffleBtnStatus());playList.moveToSongInCurrentPlayList(jsPlayer.playing);});search_input.addEventListener('keyup',function(e){if(e.keyCode===13||e.target.value===''){watcher.search(e.target.value);}});play_btn.addEventListener('click',function(){UI.togglePlayBtn();if(player.currentPlayingNode){watcher.handleTotalPlayed();jsPlayer.togglePause();}else{watcher.play(playList.getCurrentSongPath());}});prev_btn.addEventListener('click',function(){watcher.play(playList.prevSong());});next_btn.addEventListener('click',function(){watcher.play(playList.nextSong());});player.onEnded(function(){user.addToTracksPlayed(function(num){UI.renderTracksPlayed(num);});watcher.play(playList.nextSong());});player.onError(function(e){watcher.play(playList.nextSong());});},go:function(){function start(){var song_on_start;function getSongToPlay(){var hash=window.location.hash,path;if(hash&&hash.indexOf('#track=')===0){path=urls.music_dir+decodeURI(hash.match(/#track=([\s\S]*)$/)[1]);}
if(path&&playList.isSongInCurrentPlaylist(path)){playList.moveToSongInCurrentPlayList(path);watcher.play(path);window.location.hash='';return path;}else{window.location.hash='';return playList.getCurrentSongPath();}}
user.getFavorites(function(favorites){playList.setFavorites(favorites);UI.renderPlaylist(playList.song_lib,'');UI.applyScrollBars();playList.setSelected('');});playList.setCurrentPlayList(UI.getShuffleBtnStatus());song_on_start=getSongToPlay();UI.renderSongName(playList.getSongInfoByPath(song_on_start));jsPlayer.playing=song_on_start;UI.removeSpinner();watcher.handleTotalPlayed();user.getTracksPlayed(function(num){UI.renderTracksPlayed(num);});}
playList.xhrVersion(function(ver){user.getLibVersion(function(stored_ver){if(stored_ver==ver){user.getLibList(function(lib_list){playList.setLibPlayList(lib_list);start();})}else{playList.xhrLib(function(lib_list){if(lib_list){user.setLibVersion(ver);user.setLibList(lib_list);playList.setLibPlayList(JSON.parse(lib_list));start();}})}});});this.setHandlers();}};var gfx=new Graphix(player);updateGUI();watcher.go();

3
js/model-localStorage.js Normal file
View File

@ -0,0 +1,3 @@
var model={defaults:{total_played:0,tracks_played:0,favorites:[],lib_version:'',lib_list:''},init:function(key,value,callback){if(!localStorage.hasOwnProperty(key)){model.write(key,value);callback();}},write:function(key,value,callback){var write=typeof value==='object'?JSON.stringify(value):''+value;localStorage[key]=write;callback&&callback(write);},read:function(key,callback){var res;if(localStorage.hasOwnProperty(key)){try{res=JSON.parse(localStorage[key]);}
catch(e){res=localStorage[key];}
callback(res);}else if(model.defaults.hasOwnProperty(key)){model.init(key,model.defaults[key],function(){res=model.defaults[key];callback(res);});}}};

3
js/utils.js Normal file
View File

@ -0,0 +1,3 @@
var utils={convertMs:function(ms){var d,h,m,s;s=Math.floor(parseInt(ms,10)/1000);m=Math.floor(s/60);s=s%60;h=Math.floor(m/60);m=m%60;d=Math.floor(h/24);h=h%24;return{d:d,h:h,m:m,s:s};},msToHuman:function(ms){var date=utils.convertMs(ms),human;human=date.d?date.d+'d':'';human+=date.h?' '+date.h+'h':' 0'+'h';human+=date.m?' '+date.m+'min':' 0'+'min';return human;},durationToHuman:function(sec){var duration=utils.convertMs(sec*1000);return((duration.m?' '+duration.m+'min':' 0'+'min')+
(duration.s?' '+duration.s+'sec':' 0'+'sec'));},copyTextToClipboard:function(text){var textArea=document.createElement('textarea');textArea.style.position='fixed';textArea.style.top=0;textArea.style.left=0;textArea.style.width='2em';textArea.style.height='2em';textArea.style.padding=0;textArea.style.border='none';textArea.style.outline='none';textArea.style.boxShadow='none';textArea.style.background='transparent';textArea.value=text;document.body.appendChild(textArea);textArea.select();try{document.execCommand('copy');}catch(err){}
document.body.removeChild(textArea);}};

1
kgm/lib.txt Normal file

File diff suppressed because one or more lines are too long

1
kgm/ver.txt Normal file
View File

@ -0,0 +1 @@
1454680636006