Permalink
Browse files

detab

  • Loading branch information...
1 parent 8ffc31d commit 08ee3a2b19adf8f9edc30e90d7e6973283bbe4f9 Alex Michael committed Dec 4, 2011
Showing with 133 additions and 133 deletions.
  1. +17 −17 app/app.js
  2. +116 −116 libs/js/knobknob.jquery.js
View
34 app/app.js
@@ -366,37 +366,37 @@ var App = function()
var boost = knobs[i].boost(),
searchTerm = knobs[i].searchTerm();
if (boost > 0) {
- moods.push([searchTerm, boost]);
+ moods.push([searchTerm, boost]);
}
}
enm.searchSongsByMoods(moods, $.proxy(function(err, songs) {
- if (err !== null) {
- throw 'error';
- }
- if (songs === null) {
- return;
- }
-
- $("#playlist #name div").html(this.derivePlaylistName());
+ if (err !== null) {
+ throw 'error';
+ }
+ if (songs === null) {
+ return;
+ }
+
+ $("#playlist #name div").html(this.derivePlaylistName());
$("#anim").children().fadeOut();
-
- this.buffer = [];
- var seen = {};
+
+ this.buffer = [];
+ var seen = {};
for (var i = 0; i < songs.length; i++) {
- var song = new Song(songs[i]);
+ var song = new Song(songs[i]);
var dedup = (song.title().replace(/\s/g, "")
+ song.artist().replace(" ", ""))
.toLowerCase();
if (!seen[dedup]) {
- this.buffer.push(song);
+ this.buffer.push(song);
seen[dedup] = true;
}
}
-
- shuffle(this.buffer);
+
+ shuffle(this.buffer);
window.setTimeout($.proxy(hiSongs, this), 1000);
-
+
}, this));
},
View
232 libs/js/knobknob.jquery.js
@@ -1,121 +1,121 @@
/**
- * @name jQuery KnobKnob plugin
- * @author Martin Angelov
- * @version 1.0
- * @url http://tutorialzine.com/2011/11/pretty-switches-css3-jquery/
- * @license MIT License
+ * @name jQuery KnobKnob plugin
+ * @author Martin Angelov
+ * @version 1.0
+ * @url http://tutorialzine.com/2011/11/pretty-switches-css3-jquery/
+ * @license MIT License
*/
(function($){
-
- $.fn.knobKnob = function(props){
-
- var options = $.extend({
- snap: 0,
- value: 0,
- turn: function(){},
- trigger: function(){}
- }, props || {});
-
- var tpl = '<div class="knob">\
- <div class="top"></div>\
- <div class="base"></div>\
- </div>';
-
- return this.each(function(i, e){
- var el = $(e);
- el.append(tpl);
-
- var knob = $('.knob',el),
- knobTop = knob.find('.top'),
- startDeg = -1,
- currentDeg = 0,
- rotation = 0,
- lastDeg = 0,
- doc = $(document);
-
- if(options.value > 0 && options.value <= 359){
- rotation = currentDeg = options.value;
- knobTop.css('transform','rotate('+(currentDeg)+'deg)');
- options.turn(currentDeg/359);
- }
-
- knob.on('mousedown touchstart', function(e){
- e.preventDefault();
-
- var offset = knob.offset();
- var center = {
- y : offset.top + knob.height()/2,
- x: offset.left + knob.width()/2
- };
-
- var a, b, deg, tmp,
- rad2deg = 180/Math.PI;
-
- knob.on('mousemove.rem touchmove.rem',function(e){
-
- e = (e.originalEvent.touches) ? e.originalEvent.touches[0] : e;
-
- a = center.y - e.pageY;
- b = center.x - e.pageX;
- deg = Math.atan2(a,b)*rad2deg;
-
- // we have to make sure that negative
- // angles are turned into positive:
- if(deg<0){
- deg = 360 + deg;
- }
-
- // Save the starting position of the drag
- if(startDeg == -1){
- startDeg = deg;
- }
-
- // Calculating the current rotation
- tmp = Math.floor((deg-startDeg) + rotation);
-
- // Making sure the current rotation
- // stays between 0 and 359
- if(tmp < 0){
- tmp = 360 + tmp;
- }
- else if(tmp > 359){
- tmp = tmp % 360;
- }
-
- // Snapping in the off position:
- if(options.snap && tmp < options.snap){
- tmp = 0;
- }
-
- // This would suggest we are at an end position;
- // we need to block further rotation.
- if(Math.abs(tmp - lastDeg) > 180){
- return false;
- }
-
- currentDeg = tmp;
- lastDeg = tmp;
-
- knobTop.css('transform','rotate('+(currentDeg)+'deg)');
- options.turn(currentDeg/359);
- });
-
- doc.on('mouseup.rem touchend.rem',function(){
- knob.off('.rem');
- doc.off('.rem');
-
- // Saving the current rotation
- rotation = currentDeg;
-
- // Marking the starting degree as invalid
- startDeg = -1;
-
- options.trigger()
- });
-
- });
- });
- };
-
+
+ $.fn.knobKnob = function(props){
+
+ var options = $.extend({
+ snap: 0,
+ value: 0,
+ turn: function(){},
+ trigger: function(){}
+ }, props || {});
+
+ var tpl = '<div class="knob">\
+ <div class="top"></div>\
+ <div class="base"></div>\
+ </div>';
+
+ return this.each(function(i, e){
+ var el = $(e);
+ el.append(tpl);
+
+ var knob = $('.knob',el),
+ knobTop = knob.find('.top'),
+ startDeg = -1,
+ currentDeg = 0,
+ rotation = 0,
+ lastDeg = 0,
+ doc = $(document);
+
+ if(options.value > 0 && options.value <= 359){
+ rotation = currentDeg = options.value;
+ knobTop.css('transform','rotate('+(currentDeg)+'deg)');
+ options.turn(currentDeg/359);
+ }
+
+ knob.on('mousedown touchstart', function(e){
+ e.preventDefault();
+
+ var offset = knob.offset();
+ var center = {
+ y : offset.top + knob.height()/2,
+ x: offset.left + knob.width()/2
+ };
+
+ var a, b, deg, tmp,
+ rad2deg = 180/Math.PI;
+
+ knob.on('mousemove.rem touchmove.rem',function(e){
+
+ e = (e.originalEvent.touches) ? e.originalEvent.touches[0] : e;
+
+ a = center.y - e.pageY;
+ b = center.x - e.pageX;
+ deg = Math.atan2(a,b)*rad2deg;
+
+ // we have to make sure that negative
+ // angles are turned into positive:
+ if(deg<0){
+ deg = 360 + deg;
+ }
+
+ // Save the starting position of the drag
+ if(startDeg == -1){
+ startDeg = deg;
+ }
+
+ // Calculating the current rotation
+ tmp = Math.floor((deg-startDeg) + rotation);
+
+ // Making sure the current rotation
+ // stays between 0 and 359
+ if(tmp < 0){
+ tmp = 360 + tmp;
+ }
+ else if(tmp > 359){
+ tmp = tmp % 360;
+ }
+
+ // Snapping in the off position:
+ if(options.snap && tmp < options.snap){
+ tmp = 0;
+ }
+
+ // This would suggest we are at an end position;
+ // we need to block further rotation.
+ if(Math.abs(tmp - lastDeg) > 180){
+ return false;
+ }
+
+ currentDeg = tmp;
+ lastDeg = tmp;
+
+ knobTop.css('transform','rotate('+(currentDeg)+'deg)');
+ options.turn(currentDeg/359);
+ });
+
+ doc.on('mouseup.rem touchend.rem',function(){
+ knob.off('.rem');
+ doc.off('.rem');
+
+ // Saving the current rotation
+ rotation = currentDeg;
+
+ // Marking the starting degree as invalid
+ startDeg = -1;
+
+ options.trigger()
+ });
+
+ });
+ });
+ };
+
})(jQuery);

0 comments on commit 08ee3a2

Please sign in to comment.