-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkouts.js
33 lines (29 loc) · 1.09 KB
/
linkouts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Yelp = {
test: function(url){ return /yelp.com.biz/.test(url) },
convert: function(url, pn){ pn.data.appUrl = "yelp://"+ url.split(".com")[1] }
}
var Gmaps = {
test: function(url){ return /maps.google/.test(url) },
convert: function(url, pn){ pn.data.appUrl = url; }
}
var Rdio = {
test: function(url){ return /rdio.com/.test(url) },
convert: function(url, pn){
$.getJSON("http://www.rdio.com/api/oembed/?url=" + escape(url), function(data){
url_string = $(data.html).attr('src')
url_string = url_string.replace(/^http/, "rdio")
url_string = url_string.replace(/\/?\?.*/,"") // Get rid of the search string
url_string = url_string.replace(/\/\w\//, "/x/") // for whatever weird reason this must be an "x"
pn.data.appUrl = url_string
})
}
}
var Instagram = {
test: function(url){ return /instagr.am/.test(url) },
convert: function(url, pn){
$.getJSON("http://api.instagram.com/oembed?url=" + escape(url), function(data) {
pn.data.appUrl = "instagram://media?id=" + data.media_id
})
}
}
var linkouts = [Yelp, Gmaps, Instagram, Rdio]