Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

basic keyboard hooks for putting cwf in to auto mode

  • Loading branch information...
commit b7c8bbd7f155e245bf83adc77f95631ad6823165 1 parent e021bff
straup authored
Showing with 38 additions and 7 deletions.
  1. +30 −0 www/javascript/cwf.js
  2. +8 −7 www/javascript/cwf.min.js
View
30 www/javascript/cwf.js
@@ -137,6 +137,21 @@ function cwf_init_layout(){
function cwf_init_shortcuts(){
+ var auto = false;
+ var auto_timeout = null;
+
+ var automatic = function(delay){
+
+ if (! delay){
+ delay = 20000;
+ }
+
+ auto_timeout = setTimeout(function(){
+ cwf_show_next_photo("overflow");
+ automatic();
+ }, delay);
+ };
+
var left = function(){
cwf_show_previous_photo("overflow");
};
@@ -172,6 +187,21 @@ function cwf_init_shortcuts(){
down();
}
+ /* to do: notifications */
+ /* to do: automode on shake */
+
+ else if (e.keyCode == 65){
+ auto = (auto) ? 0 : 1;
+
+ if (auto){
+ automatic(1000);
+ }
+
+ else {
+ clearTimeout(auto_timeout);
+ }
+ }
+
else if (e.keyCode == 80){
cwf_toggle_pixel_mode(e.shiftKey);
}
View
15 www/javascript/cwf.min.js
@@ -1,11 +1,12 @@
var photos=[],thumbs=[],images=[],count_photos=0,count_updates=0,can_fave=0,idx=0;
function cwf_init(a){photos=a;count_photos=photos.length;cwf_init_layout();cwf_init_shortcuts();a=location.hash;var b=null;if(a)a=parseInt(a.substring(1,a.length));for(var c=0;c<count_photos;c++){thumbs.push(photos[c][6]);images.push(photos[c][7]);if(a&&!b&&photos[c][0]==a)b=c}if(b)idx=b;$.backstretch(thumbs[idx]);$({}).imageLoader({images:thumbs,async:true});$({}).imageLoader({images:[images.shift()],async:false,complete:function(){cwf_show_photo(idx)}});a=parseInt(new Date/1E3);cwf_schedule_check_photos(a)}
-function cwf_init_subscription(){var a=function(b){b=JSON.parse(b);b=b.photos;var c=b.length;if(c){for(var e=[],d=0;d<c;d++){var f=b[d];e.push([f.photo_id,f.title,f.owner,f.ownername,f.faved_by_nsid,f.faved_by,f.thumb_url,f.display_url])}cwf_init(e)}else{b=new Date;b=String(b);b="Last checked at "+b+", still nothing yet.";$("#last_check").html(b);cwf_init_subscription(6E4)}};setTimeout(function(){$.ajax({url:"/api",data:{method:"flickr.photos.friends.faves"},success:a})},6E4)}
+function cwf_init_subscription(){var a=function(b){b=JSON.parse(b);b=b.photos;var c=b.length;if(c){for(var d=[],e=0;e<c;e++){var f=b[e];d.push([f.photo_id,f.title,f.owner,f.ownername,f.faved_by_nsid,f.faved_by,f.thumb_url,f.display_url])}cwf_init(d)}else{b=new Date;b=String(b);b="Last checked at "+b+", still nothing yet.";$("#last_check").html(b);cwf_init_subscription(6E4)}};setTimeout(function(){$.ajax({url:"/api",data:{method:"flickr.photos.friends.faves"},success:a})},6E4)}
function cwf_init_layout(){$("#content").hide();$("#main").css("background-color","transparent");$("#footer").css("opacity",".75");$("#main").append('<div id="cwf_about"></div>')}
-function cwf_init_shortcuts(){var a=function(){cwf_show_previous_photo("overflow")},b=function(){cwf_show_next_photo("overflow")},c=function(){cwf_show_photo(0)},e=function(){cwf_show_photo(photos.length-1)};$(document).keydown(function(d){if(d.keyCode==37)a();else if(d.keyCode==38)c();else if(d.keyCode==39)b();else if(d.keyCode==40)e();else d.keyCode==80&&cwf_toggle_pixel_mode(d.shiftKey)});$(document).touchwipe({wipeLeft:b,wipeRight:a,wipeUp:c,wipeDown:e,min_move_x:20,min_move_y:20,preventDefaultEvents:true})}
-function cwf_schedule_check_photos(a){setTimeout(function(){$.ajax({url:"/api",data:{method:"flickr.photos.friends.faves",older_than:a},success:cwf_check_photos_callback,error:function(b){console.log(b);cwf_schedule_check_photos(a)}})},6E4)}function cwf_check_photos_callback(a){try{_cwf_check_photos_callback(a)}catch(b){console.log(b);console.log(a)}last_check=parseInt(new Date/1E3);cwf_schedule_check_photos(last_check)}
-function _cwf_check_photos_callback(a){a=JSON.parse(a);a=a.photos;var b=a.length;if(b){a.reverse();for(var c=[],e=0;e<b;e++){var d=a[e];c.push(d.display_url);c.push(d.thumb_url);photos.unshift([d.photo_id,d.title,d.owner,d.ownername,d.faved_by_nsid,d.faved_by,d.thumb_url,d.display_url])}$({}).imageLoader({images:c,async:true});idx+=b;count_updates+=b;a='<a href="#" onclick="cwf_show_photo(0);return false;">';a+=count_updates>1?"there are "+count_updates+" new faves":"there are new faves";a+="</a>";
+function cwf_init_shortcuts(){var a=false,b=null,c=function(g){g||(g=2E4);b=setTimeout(function(){cwf_show_next_photo("overflow");c()},g)},d=function(){cwf_show_previous_photo("overflow")},e=function(){cwf_show_next_photo("overflow")},f=function(){cwf_show_photo(0)},h=function(){cwf_show_photo(photos.length-1)};$(document).keydown(function(g){if(g.keyCode==37)d();else if(g.keyCode==38)f();else if(g.keyCode==39)e();else if(g.keyCode==40)h();else if(g.keyCode==65)(a=a?0:1)?c(1E3):clearTimeout(b);else g.keyCode==
+80&&cwf_toggle_pixel_mode(g.shiftKey)});$(document).touchwipe({wipeLeft:e,wipeRight:d,wipeUp:f,wipeDown:h,min_move_x:20,min_move_y:20,preventDefaultEvents:true})}function cwf_schedule_check_photos(a){setTimeout(function(){$.ajax({url:"/api",data:{method:"flickr.photos.friends.faves",older_than:a},success:cwf_check_photos_callback,error:function(b){console.log(b);cwf_schedule_check_photos(a)}})},6E4)}
+function cwf_check_photos_callback(a){try{_cwf_check_photos_callback(a)}catch(b){console.log(b);console.log(a)}last_check=parseInt(new Date/1E3);cwf_schedule_check_photos(last_check)}
+function _cwf_check_photos_callback(a){a=JSON.parse(a);a=a.photos;var b=a.length;if(b){a.reverse();for(var c=[],d=0;d<b;d++){var e=a[d];c.push(e.display_url);c.push(e.thumb_url);photos.unshift([e.photo_id,e.title,e.owner,e.ownername,e.faved_by_nsid,e.faved_by,e.thumb_url,e.display_url])}$({}).imageLoader({images:c,async:true});idx+=b;count_updates+=b;a='<a href="#" onclick="cwf_show_photo(0);return false;">';a+=count_updates>1?"there are "+count_updates+" new faves":"there are new faves";a+="</a>";
$("#cwf_updates").html(a);$("#cwf_photo_idx").html(idx+1);$("#cwf_count_photos").html(photos.length)}}function cwf_next_photo(a){if(a)return idx<photos.length-1?idx+1:0;return idx<photos.length-1?idx+1:-1}function cwf_previous_photo(a){if(a)return idx>0?idx-1:count_photos-1;return idx>0?idx-1:-1}function cwf_show_previous_photo(a){a=cwf_previous_photo(a);cwf_show_photo(a)}function cwf_show_next_photo(a){a=cwf_next_photo(a);cwf_show_photo(a)}
-function cwf_show_photo(a){count_updates=0;idx=a;for(var b=[],c=0;c<2;c++){if(!images.length)break;b.push(images.shift());b.push(images.unshift())}b.length&&$({}).imageLoader({images:b,async:true});var e=photos[a];b=e[0];c=e[1];var d=e[2],f=e[3],g=e[4],h=e[5],i=e[6],j=e[7];e=e[8];a=a+1;c=c+", by "+f;msg='<a href="http://www.flickr.com/photos/'+d+"/"+b+'/" target="_flickr" title="'+c+'">';msg+='<img src="'+j+'" /></a><br >';msg+='<div id="cwf_about_text">';msg+='<a href="http://www.flickr.com/photos/'+
-g+'/faves/" target="_flickr">'+h+"</a>";msg+=" <span>"+symbols_faved+"</span> ";msg+='<a href="http://www.flickr.com/photos/'+d+'/" target="_flickr">'+f+"</a><br />";msg+='no. <span id="cwf_photo_idx">'+a+'</span> of <span id="cwf_count_photos">'+photos.length+"</span> faves";if(a>1)msg+=' / <a href="#" onclick="cwf_show_next_photo();return false;" title="before, keyboard shortcut: \u21e6">before</a>';if(a<count_photos)msg+=' / <a href="#" onclick="cwf_show_previous_photo();return false;" title="after, keyboard short: \u21e8">after</a>';
-msg+=" / "+photo_favorites_generate_html(b,e);msg+='<div id="cwf_updates"></div>';msg+="</div>";$("#cwf_about").html("");$.backstretch(i);$("#cwf_about").html(msg)}function cwf_toggle_pixel_mode(a){var b=$("#cwf_about"),c=$("#footer");if(b.css("display")=="none"){b.show();c.show();screenfull&&screenfull.exit()}else{b.hide();c.hide();a&&screenfull&&screenfull.request()}};
+function cwf_show_photo(a){count_updates=0;idx=a;for(var b=[],c=0;c<2;c++){if(!images.length)break;b.push(images.shift());b.push(images.unshift())}b.length&&$({}).imageLoader({images:b,async:true});var d=photos[a];b=d[0];c=d[1];var e=d[2],f=d[3],h=d[4],g=d[5],i=d[6],j=d[7];d=d[8];a=a+1;c=c+", by "+f;msg='<a href="http://www.flickr.com/photos/'+e+"/"+b+'/" target="_flickr" title="'+c+'">';msg+='<img src="'+j+'" /></a><br >';msg+='<div id="cwf_about_text">';msg+='<a href="http://www.flickr.com/photos/'+
+h+'/faves/" target="_flickr">'+g+"</a>";msg+=" <span>"+symbols_faved+"</span> ";msg+='<a href="http://www.flickr.com/photos/'+e+'/" target="_flickr">'+f+"</a><br />";msg+='no. <span id="cwf_photo_idx">'+a+'</span> of <span id="cwf_count_photos">'+photos.length+"</span> faves";if(a>1)msg+=' / <a href="#" onclick="cwf_show_next_photo();return false;" title="before, keyboard shortcut: \u21e6">before</a>';if(a<count_photos)msg+=' / <a href="#" onclick="cwf_show_previous_photo();return false;" title="after, keyboard short: \u21e8">after</a>';
+msg+=" / "+photo_favorites_generate_html(b,d);msg+='<div id="cwf_updates"></div>';msg+="</div>";$("#cwf_about").html("");$.backstretch(i);$("#cwf_about").html(msg)}function cwf_toggle_pixel_mode(a){var b=$("#cwf_about"),c=$("#footer");if(b.css("display")=="none"){b.show();c.show();screenfull&&screenfull.exit()}else{b.hide();c.hide();a&&screenfull&&screenfull.request()}};
Please sign in to comment.
Something went wrong with that request. Please try again.