diff options
author | raylu <raylu@mixpanel.com> | 2011-08-06 22:20:31 -0700 |
---|---|---|
committer | raylu <raylu@mixpanel.com> | 2011-08-06 22:20:31 -0700 |
commit | f61e03f7f43536adce71c5783536aa67f63f029d (patch) | |
tree | 49672cf8ab557552911f5503c44513b2e60dc2ec | |
parent | dc49f0338a95f77a9b2a90804f2178cf8281b23e (diff) | |
download | audioaxis-f61e03f7f43536adce71c5783536aa67f63f029d.tar.xz |
fix JS errors, save user
-rw-r--r-- | main.go | 1 | ||||
-rw-r--r-- | static/script.js | 36 | ||||
-rw-r--r-- | templates/p.html | 3 |
3 files changed, 26 insertions, 14 deletions
@@ -221,6 +221,7 @@ func main() { fmt.Println(err) os.Exit(1) } + db.Reconnect = true http.HandleFunc("/", home) http.HandleFunc("/p/", playlist) diff --git a/static/script.js b/static/script.js index 26caefc..3be5775 100644 --- a/static/script.js +++ b/static/script.js @@ -3,14 +3,6 @@ var litColor = '#eee'; var dimmedColor = '#555'; var interval; $(document).ready(function () { - $('body').click(function (e) { - if (e.target.id !== 'results') { - $('#results').slideUp(100); - } - }); - for (var i = 0; i < ids.length; i++) { - drawBar(ids[i]); - } var poller = new Worker('/static/poller.js'); poller.onmessage = function (e) { for (var i = 0; i < e.data.updates.length; i++) { @@ -26,10 +18,25 @@ $(document).ready(function () { } } poller.postMessage({pid: pid}); + $('body').click(function (e) { + if (e.target.id !== 'results') { + $('#results').slideUp(100); + } + }); + var userElem = $('#user'); + if (localStorage['user'] && localStorage['user'].length > 0) + userElem.val(localStorage['user']); + userElem.change(function () { + localStorage['user'] = userElem.val(); + }); + for (var i = 0; i < ids.length; i++) { + drawBar(ids[i]); + } }); function drawBar(id) { var canvas = document.getElementById('c_' + id); + if (!canvas) return; canvas.height = canvas.height; //clear var context = canvas.getContext("2d"); @@ -112,14 +119,18 @@ function stop(yid) { function showPlay(yid) { var play = document.getElementById('play_' + yid); var pause = document.getElementById('pause_' + yid); - play.style.display = 'inline'; - pause.style.display = 'none'; + if (play) + play.style.display = 'inline'; + if (pause) + pause.style.display = 'none'; } function showPause(yid) { var pause = document.getElementById('pause_' + yid); var play = document.getElementById('play_' + yid); - pause.style.display = 'inline'; - play.style.display = 'none'; + if (pause) + pause.style.display = 'inline'; + if (play) + play.style.display = 'none'; } function search(query) { @@ -201,6 +212,7 @@ function remove(id) { function drawRemove(id) { var element = $('#' + id); element.slideUp(100, function () { + stop(id); element.remove(); }); } diff --git a/templates/p.html b/templates/p.html index f63c673..eb4dc80 100644 --- a/templates/p.html +++ b/templates/p.html @@ -33,16 +33,15 @@ var ids = []; </script> <script src="/static/jquery.min.js"></script> - <script src="/static/script.js"></script> <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> + --> <script src="/static/script.js"></script> <object data="http://www.youtube.com/v/{{$first}}?version=3&enablejsapi=1" id="player" width="1" height="1" type="application/x-shockwave-flash"> <param name="movie" value="http://www.youtube.com/v/{{$first}}?version=3&enablejsapi=1"> <param name="allowScriptAccess" value="always"> <embed src="http://www.youtube.com/v/{{$first}}?version=3&enablejsapi=1" allowScriptAccess="always"> </object> - --> </body> </html> |