|
|
|
/* MediaType
|
|
|
|
================================================== */
|
|
|
|
if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
|
|
|
|
|
|
|
|
//VMM.mediaType.youtube(d); //should return a true or false
|
|
|
|
// VMM.MediaType(url); //returns an object with .type and .id
|
|
|
|
|
|
|
|
VMM.MediaType = function(d) {
|
|
|
|
var success = false;
|
|
|
|
var media = {};
|
|
|
|
|
|
|
|
if (d.match("div class='twitter'")) {
|
|
|
|
media.type = "twitter-ready";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(www.)?youtube|youtu\.be')) {
|
|
|
|
if (d.match('v=')) {
|
|
|
|
media.id = VMM.Util.getUrlVars(d)["v"];
|
|
|
|
} else {
|
|
|
|
media.id = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
|
|
|
|
}
|
|
|
|
media.type = "youtube";
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(player.)?vimeo\.com')) {
|
|
|
|
media.type = "vimeo";
|
|
|
|
media.id = d.split(/video\/|\/\/vimeo\.com\//)[1].split(/[?&]/)[0];;
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(www.)?dailymotion\.com')) {
|
|
|
|
media.id = d.split(/video\/|\/\/dailymotion\.com\//)[1];
|
|
|
|
media.type = "dailymotion";
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(player.)?soundcloud\.com')) {
|
|
|
|
media.type = "soundcloud";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(www.)?twitter\.com')) {
|
|
|
|
if (d.match("status\/")) {
|
|
|
|
media.id = d.split("status\/")[1];
|
|
|
|
} else if (d.match("statuses\/")) {
|
|
|
|
media.id = d.split("statuses\/")[1];
|
|
|
|
} else {
|
|
|
|
media.id = "";
|
|
|
|
}
|
|
|
|
media.type = "twitter";
|
|
|
|
success = true;
|
|
|
|
} else if (d.match("maps.google") && !d.match("staticmap")) {
|
|
|
|
media.type = "google-map";
|
|
|
|
media.id = d.split(/src=['|"][^'|"]*?['|"]/gi);
|
|
|
|
success = true;
|
|
|
|
} else if (d.match("flickr.com/photos")) {
|
|
|
|
media.type = "flickr";
|
|
|
|
media.id = d.split("photos\/")[1].split("/")[1];
|
|
|
|
media.link = d;
|
|
|
|
success = true;
|
|
|
|
} else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap")) {
|
|
|
|
media.type = "image";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
} else if (VMM.FileExtention.googleDocType(d)) {
|
|
|
|
media.type = "googledoc";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
} else if (d.match('(www.)?wikipedia\.org')) {
|
|
|
|
media.type = "wikipedia";
|
|
|
|
//media.id = d.split("wiki\/")[1];
|
|
|
|
var wiki_id = d.split("wiki\/")[1].split("#")[0].replace("_", " ");
|
|
|
|
media.id = VMM.Util.toTitleCase(wiki_id).replace(" ", "%20");
|
|
|
|
success = true;
|
|
|
|
} else if (d.indexOf('http://') == 0) {
|
|
|
|
media.type = "website";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
} else {
|
|
|
|
trace("unknown media");
|
|
|
|
media.type = "unknown";
|
|
|
|
media.id = d;
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
return media;
|
|
|
|
} else {
|
|
|
|
trace("No valid media id detected");
|
|
|
|
trace(d);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|