diff options
Diffstat (limited to 'themes/okadmin/public/js/parser.js')
| -rw-r--r-- | themes/okadmin/public/js/parser.js | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/themes/okadmin/public/js/parser.js b/themes/okadmin/public/js/parser.js index 411f425..81bba2d 100644 --- a/themes/okadmin/public/js/parser.js +++ b/themes/okadmin/public/js/parser.js @@ -31,15 +31,17 @@ var Parser = { regex: /\.(mp4|webm)(\?.*)?$/i, fetch: function(url, done) { var video = document.createElement("video") + var url_parts = url.replace(/\?.*$/, "").split("/") + var filename = url_parts[ url_parts.length-1 ] video.addEventListener("loadedmetadata", function(){ var width = video.videoWidth, height = video.videoHeight video = null done({ url: url, type: "video", - token: "", - thumbnail: "", - title: "", + token: url, + thumbnail: "http://okfocus.s3.amazonaws.com/misc/okcms/video.png", + title: filename, width: width, height: height, }) @@ -51,6 +53,31 @@ var Parser = { return '<video src="' + media.url + '">'; } }, { + type: 'audio', + regex: /\.(wav|mp3)(\?.*)?$/i, + fetch: function(url, done) { + var audio = document.createElement("audio") + var url_parts = url.replace(/\?.*$/, "").split("/") + var filename = url_parts[ url_parts.length-1 ] + audio.addEventListener("loadedmetadata", function(){ + var duration = audio.duration + audio = null + done({ + url: url, + type: "audio", + token: url, + thumbnail: "http://okfocus.s3.amazonaws.com/misc/okcms/audio.png", + title: filename, + duration: duration, + }) + }) + audio.src = url + audio.load() + }, + tag: function (media) { + return '<audio src="' + media.url + '">'; + } + }, { type: 'youtube', regex: /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i, fetch: function(url, done) { @@ -73,6 +100,8 @@ var Parser = { token: id, thumbnail: thumb, title: res.snippet.title, + autoplay: false, + loop: false, width: 640, height: 360, }) @@ -106,6 +135,8 @@ var Parser = { title: res.title, width: res.width, height: res.height, + autoplay: false, + loop: false, }) } }) @@ -114,8 +145,7 @@ var Parser = { // return '<img class="video" type="vimeo" vid="'+media.token+'" src="'+media.thumbnail+'"><span class="playvid">▶</span>'; return '<div class="video" style="width: ' + media.width + 'px; height: ' + media.height + 'px; overflow: hidden; position: relative;"><iframe frameborder="0" scrolling="no" seamless="seamless" webkitallowfullscreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowfullscreen="allowfullscreen" id="okplayer" src="http://player.vimeo.com/video/' + media.token + '?api=1&title=0&byline=0&portrait=0&playbar=0&player_id=okplayer&loop=0&autoplay=0" width="' + media.width + '" height="' + media.height + '" style="position: absolute; top: 0px; left: 0px; width: ' + media.width + 'px; height: ' + media.height + 'px;"></iframe></div>' } - }, - { + }, { type: 'soundcloud', regex: /soundcloud.com\/[-a-zA-Z0-9]+\/[-a-zA-Z0-9]+\/?$/i, fetch: function (url, done) { @@ -126,13 +156,14 @@ var Parser = { + '&client_id=' + '0673fbe6fc794a7750f680747e863b10', success: function(result) { - // console.log(result) + console.log(result) done({ url: url, type: "soundcloud", token: result.id, thumbnail: result.artwork_url || result.user.avatar_url, title: result.user.username + " - " + result.title, + duration: result.duration, width: 166, height: 166, }) @@ -145,7 +176,6 @@ var Parser = { '&color=ff6600&auto_play=false&show_artwork=true"></iframe>' } }, - /* { type: 'link', regex: /^http.+/i, @@ -163,8 +193,7 @@ var Parser = { tag: function (media) { return '<a href="' + media.url + '" target="_blank">' + media.url + '</a>' } - } - */ + }, ], tumblr: function(url, cb){ @@ -232,6 +261,8 @@ var Parser = { title: stripHTML(post['video-caption']), width: 640, height: 360, + autoplay: false, + loop: false, } media_list.push(media) } |
