From 587c9f7d3f4ac9efbd8851dad1c2f62b9e7e6e61 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 9 Apr 2015 01:07:37 -0400 Subject: stub in video field --- themes/okadmin/public/js/parser.js | 282 +++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 themes/okadmin/public/js/parser.js (limited to 'themes/okadmin/public/js/parser.js') diff --git a/themes/okadmin/public/js/parser.js b/themes/okadmin/public/js/parser.js new file mode 100644 index 0000000..411f425 --- /dev/null +++ b/themes/okadmin/public/js/parser.js @@ -0,0 +1,282 @@ +var Parser = { + integrations: [{ + type: 'image', + regex: /\.(jpeg|jpg|gif|png|svg)(\?.*)?$/i, + 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: "", + width: width, + height: height, + }) + } + img.src = url + if (img.complete) { + img.onload() + } + }, + tag: function (media) { + return ''; + } + }, { + type: 'video', + regex: /\.(mp4|webm)(\?.*)?$/i, + fetch: function(url, done) { + var video = document.createElement("video") + video.addEventListener("loadedmetadata", function(){ + var width = video.videoWidth, height = video.videoHeight + video = null + done({ + url: url, + type: "video", + token: "", + thumbnail: "", + title: "", + width: width, + height: height, + }) + }) + video.src = url + video.load() + }, + tag: function (media) { + return '