Skip to content

Instantly share code, notes, and snippets.

@daniyalzade
Created October 8, 2013 14:30
Show Gist options
  • Save daniyalzade/6885636 to your computer and use it in GitHub Desktop.
Save daniyalzade/6885636 to your computer and use it in GitHub Desktop.
Fancy's way of detecting if app exists and launching app accordingly. It does referrer checking to see if the link is coming from email, and only does it then.
<script>
var thing_id = "441444475001111765";
$('.thing-related-photo img').each(function(){
if($(this).width()>$(this).height()){
$(this).css("height","60px");
}else{
$(this).css("width","60px");
}
});
jQuery(function($){
var ref = "";
if(/ref=/.test(location.search)){
ref = "?ref="+(location.search).match(/ref=([^&]*)?/)[1];
}
$('#header a.app').attr('href','intent://things/'+thing_id+ref+'#Intent;scheme=fancy;package=com.thefancy.app;end');
if(!document.referrer) $('<iframe>').css({width:0,height:0,opacity:0}).attr('src', 'fancy://things/'+thing_id).appendTo('body');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment