summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/Parser.js
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-10-16 04:40:53 -0400
committerJulie Lala <jules@okfoc.us>2014-10-16 04:40:53 -0400
commit1a15b32d8cc8fcf27861f94151ca63eb6d8736c2 (patch)
tree5d4804e0be7a09c2bf4352e8affeea899de47ab7 /public/assets/javascripts/ui/lib/Parser.js
parent37851cbd12dcb17be77265164876184019d34602 (diff)
fix clone button, add urls you paste to your wallpaper
Diffstat (limited to 'public/assets/javascripts/ui/lib/Parser.js')
-rw-r--r--public/assets/javascripts/ui/lib/Parser.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/public/assets/javascripts/ui/lib/Parser.js b/public/assets/javascripts/ui/lib/Parser.js
index 52c96e6..aa8c480 100644
--- a/public/assets/javascripts/ui/lib/Parser.js
+++ b/public/assets/javascripts/ui/lib/Parser.js
@@ -5,9 +5,12 @@ var Parser = {
fetch: function(url, done) {
var img = new Image ()
img.onload = function(){
+ if (!img) return
var width = img.naturalWidth, height = img.naturalHeight
img = null
done({
+ url: url,
+ type: "image",
token: "",
thumbnail: "",
title: "",
@@ -32,6 +35,8 @@ var Parser = {
var width = video.videoWidth, height = video.videoHeight
video = null
done({
+ url: url,
+ type: "video",
token: "",
thumbnail: "",
title: "",
@@ -63,6 +68,8 @@ var Parser = {
success: function(result){
var res = result.items[0]
done({
+ url: url,
+ type: "youtube",
token: id,
thumbnail: thumb,
title: res.snippet.title,
@@ -92,6 +99,8 @@ var Parser = {
return
}
done({
+ url: url,
+ type: "vimeo",
token: id,
thumbnail: res.thumbnail_large,
title: res.title,
@@ -119,6 +128,8 @@ var Parser = {
+ '0673fbe6fc794a7750f680747e863b10',
success: function(result) {
done({
+ url: url,
+ type: "soundcloud",
token: result.id,
thumbnail: "",
title: "",
@@ -138,6 +149,8 @@ var Parser = {
regex: /^http.+/i,
fetch: function(url, done) {
done({
+ url: url,
+ type: "link",
token: "",
thumbnail: "",
title: "",
@@ -156,8 +169,6 @@ var Parser = {
var matched = Parser.integrations.some(function(integration){
if (integration.regex.test(url)) {
integration.fetch(url, function(res){
- res.url = url
- res.type = integration.type
cb(res)
})
return true
@@ -176,6 +187,15 @@ var Parser = {
return ""
},
+ loadImage: function(url, cb, error){
+ if (Parser.lookup.image.regex.test(url)) {
+ Parser.lookup.image.fetch(url, function(media){
+ cb(media)
+ })
+ }
+ else error && error()
+ },
+
thumbnail: function (media) {
return '<img src="' + (media.thumbnail || media.url) + '" class="thumb">';
},