org.jbpm.designer.public.js.simulation.timeline-min.js Maven / Gradle / Ivy
(function() {
var initializing = false,
fnTest = /xyz/.test(function() {
xyz;
}) ? /\b_super\b/: /.*/;
// The base Class implementation (does nothing)
this.Class = function() {};
// Create a new Class that inherits from this class
Class.extend = function(prop) {
var _super = this.prototype;
// Instantiate a base class (but only create the instance,
// don't run the init constructor)
initializing = true;
var prototype = new this();
initializing = false;
// Copy the properties over onto the new prototype
for (var name in prop) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function(name, fn) {
return function() {
var tmp = this._super;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
})(name, prop[name]) :
prop[name];
}
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if (!initializing && this.init)
this.init.apply(this, arguments);
}
// Populate our constructed prototype object
Class.prototype = prototype;
// Enforce the constructor to be what we expect
Class.prototype.constructor = Class;
// And make this class extendable
Class.extend = arguments.callee;
return Class;
};
})();
/* Access to the Global Object
access the global object without hard-coding the identifier window
================================================== */
var global = (function () {
return this || (1,eval)('this');
}());
/* VMM
================================================== */
if (typeof VMM == 'undefined') {
/* Main Scope Container
================================================== */
//var VMM = {};
var VMM = Class.extend({});
/* Debug
================================================== */
VMM.debug = true;
/* Master Config
================================================== */
VMM.master_config = ({
init: function() {
return this;
},
sizes: {
api: {
width: 0,
height: 0
}
},
vp: "Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",
api_keys_master: {
flickr: "",
google: "",
twitter: ""
},
timers: {
api: 7000
},
api: {
pushques: []
},
twitter: {
active: false,
array: [],
api_loaded: false,
que: []
},
flickr: {
active: false,
array: [],
api_loaded: false,
que: []
},
youtube: {
active: false,
array: [],
api_loaded: false,
que: []
},
vimeo: {
active: false,
array: [],
api_loaded: false,
que: []
},
googlemaps: {
active: false,
map_active: false,
places_active: false,
array: [],
api_loaded: false,
que: []
},
googledocs: {
active: false,
array: [],
api_loaded: false,
que: []
},
googleplus: {
active: false,
array: [],
api_loaded: false,
que: []
},
wikipedia: {
active: false,
array: [],
api_loaded: false,
que: [],
tries: 0
},
soundcloud: {
active: false,
array: [],
api_loaded: false,
que: []
}
}).init();
//VMM.createElement(tag, value, cName, attrs, styles);
VMM.createElement = function(tag, value, cName, attrs, styles) {
var ce = "";
if (tag != null && tag != "") {
// TAG
ce += "<" + tag;
if (cName != null && cName != "") {
ce += " class='" + cName + "'";
};
if (attrs != null && attrs != "") {
ce += " " + attrs;
};
if (styles != null && styles != "") {
ce += " style='" + styles + "'";
};
ce += ">";
if (value != null && value != "") {
ce += value;
}
// CLOSE TAG
ce = ce + "" + tag + ">";
}
return ce;
};
VMM.createMediaElement = function(media, caption, credit) {
var ce = "";
var _valid = false;
ce += "";
if (media != null && media != "") {
valid = true;
ce += "";
// CREDIT
if (credit != null && credit != "") {
ce += VMM.createElement("div", credit, "credit");
}
// CAPTION
if (caption != null && caption != "") {
ce += VMM.createElement("div", caption, "caption");
}
}
ce += "";
return ce;
};
// Hide URL Bar for iOS and Android by Scott Jehl
// https://gist.github.com/1183357
VMM.hideUrlBar = function () {
var win = window,
doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash || !win.addEventListener ){
//scroll to 1
window.scrollTo( 0, 1 );
var scrollTop = 1,
//reset to 0 on bodyready, if needed
bodycheck = setInterval(function(){
if( doc.body ){
clearInterval( bodycheck );
scrollTop = "scrollTop" in doc.body ? doc.body.scrollTop : 1;
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
}
}, 15 );
win.addEventListener( "load", function(){
setTimeout(function(){
//reset to hide addr bar at onload
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
}, 0);
}, false );
}
};
}
/* Trace (console.log)
================================================== */
function trace( msg ) {
if (VMM.debug) {
if (window.console) {
console.log(msg);
} else if ( typeof( jsTrace ) != 'undefined' ) {
jsTrace.send( msg );
} else {
//alert(msg);
}
}
}
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
}
/* Extending Date to include Week
================================================== */
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}
/* Extending Date to include Day of Year
================================================== */
Date.prototype.getDayOfYear = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((this - onejan) / 86400000);
}
/* A MORE SPECIFIC TYPEOF();
// http://rolandog.com/archives/2007/01/18/typeof-a-more-specific-typeof/
================================================== */
// type.of()
var is={
Null:function(a){return a===null;},
Undefined:function(a){return a===undefined;},
nt:function(a){return(a===null||a===undefined);},
Function:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/Function/)!==null:false;},
String:function(a){return(typeof(a)==="string")?true:(typeof(a)==="object")?a.constructor.toString().match(/string/i)!==null:false;},
Array:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:false;},
Boolean:function(a){return(typeof(a)==="boolean")?true:(typeof(a)==="object")?a.constructor.toString().match(/boolean/i)!==null:false;},
Date:function(a){return(typeof(a)==="date")?true:(typeof(a)==="object")?a.constructor.toString().match(/date/i)!==null:false;},
HTML:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/html/i)!==null:false;},
Number:function(a){return(typeof(a)==="number")?true:(typeof(a)==="object")?a.constructor.toString().match(/Number/)!==null:false;},
Object:function(a){return(typeof(a)==="object")?a.constructor.toString().match(/object/i)!==null:false;},
RegExp:function(a){return(typeof(a)==="function")?a.constructor.toString().match(/regexp/i)!==null:false;}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
/***********************************************
Begin VMM.Library.js
***********************************************/
/* * LIBRARY ABSTRACTION
================================================== */
if(typeof VMM != 'undefined') {
VMM.smoothScrollTo = function(elem, duration, ease) {
if( typeof( jQuery ) != 'undefined' ){
var _ease = "easein",
_duration = 1000;
if (duration != null) {
if (duration < 1) {
_duration = 1;
} else {
_duration = Math.round(duration);
}
}
if (ease != null && ease != "") {
_ease = ease;
}
if (jQuery(window).scrollTop() != VMM.Lib.offset(elem).top) {
VMM.Lib.animate('html,body', _duration, _ease, {scrollTop: VMM.Lib.offset(elem).top})
}
}
};
VMM.attachElement = function(element, content) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).html(content);
}
};
VMM.appendElement = function(element, content) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).append(content);
}
};
VMM.getHTML = function(element) {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
};
VMM.getElement = function(element, p) {
var e;
if( typeof( jQuery ) != 'undefined' ){
if (p) {
e = jQuery(element).parent().get(0);
} else {
e = jQuery(element).get(0);
}
return e;
}
};
VMM.bindEvent = function(element, the_handler, the_event_type, event_data) {
var e;
var _event_type = "click";
var _event_data = {};
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if (_event_data != null && _event_data != "") {
_event_data = event_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).bind(_event_type, _event_data, the_handler);
//return e;
}
};
VMM.unbindEvent = function(element, the_handler, the_event_type) {
var e;
var _event_type = "click";
var _event_data = {};
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).unbind(_event_type, the_handler);
//return e;
}
};
VMM.fireEvent = function(element, the_event_type, the_data) {
var e;
var _event_type = "click";
var _data = [];
if (the_event_type != null && the_event_type != "") {
_event_type = the_event_type;
}
if (the_data != null && the_data != "") {
_data = the_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).trigger(_event_type, _data);
//return e;
}
};
VMM.getJSON = function(url, data, callback) {
if( typeof( jQuery ) != 'undefined' ){
jQuery.ajaxSetup({
timeout: 3000
});
/* CHECK FOR IE
================================================== */
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
trace("IE JSON");
var ie_url = url;
if (ie_url.match('^http://')){
return jQuery.getJSON(ie_url, data, callback);
} else if (ie_url.match('^https://')) {
ie_url = ie_url.replace("https://","http://");
return jQuery.getJSON(ie_url, data, callback);
} else {
return jQuery.getJSON(url, data, callback);
}
} else {
return jQuery.getJSON(url, data, callback);
}
}
}
VMM.parseJSON = function(the_json) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery.parseJSON(the_json);
}
}
// ADD ELEMENT AND RETURN IT
VMM.appendAndGetElement = function(append_to_element, tag, cName, content) {
var e,
_tag = "",
_class = "",
_content = "",
_id = "";
if (tag != null && tag != "") {
_tag = tag;
}
if (cName != null && cName != "") {
_class = cName;
}
if (content != null && content != "") {
_content = content;
}
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(tag);
e.addClass(_class);
e.html(_content);
jQuery(append_to_element).append(e);
}
return e;
};
VMM.Lib = {
init: function() {
return this;
},
hide: function(element, duration) {
if (duration != null && duration != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).hide(duration);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).hide();
}
}
},
remove: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).remove();
}
},
detach: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).detach();
}
},
append: function(element, value) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).append(value);
}
},
prepend: function(element, value) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).prepend(value);
}
},
show: function(element, duration) {
if (duration != null && duration != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).show(duration);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).show();
}
}
},
load: function(element, callback_function, event_data) {
var _event_data = {elem:element}; // return element by default
if (_event_data != null && _event_data != "") {
_event_data = event_data;
}
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).load(_event_data, callback_function);
}
},
addClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).addClass(cName);
}
},
removeClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).removeClass(cName);
}
},
attr: function(element, aName, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).attr(aName, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).attr(aName);
}
}
},
prop: function(element, aName, value) {
if (typeof jQuery == 'undefined' || !/[1-9]\.[3-9].[1-9]/.test(jQuery.fn.jquery)) {
VMM.Lib.attribute(element, aName, value);
} else {
jQuery(element).prop(aName, value);
}
},
attribute: function(element, aName, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).attr(aName, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).attr(aName);
}
}
},
visible: function(element, show) {
if (show != null) {
if( typeof( jQuery ) != 'undefined' ){
if (show) {
jQuery(element).show(0);
} else {
jQuery(element).hide(0);
}
}
} else {
if( typeof( jQuery ) != 'undefined' ){
if ( jQuery(element).is(':visible')){
return true;
} else {
return false;
}
}
}
},
css: function(element, prop, value) {
if (value != null && value != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).css(prop, value);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).css(prop);
}
}
},
cssmultiple: function(element, propval) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).css(propval);
}
},
offset: function(element) {
var p;
if( typeof( jQuery ) != 'undefined' ){
p = jQuery(element).offset();
}
return p;
},
position: function(element) {
var p;
if( typeof( jQuery ) != 'undefined' ){
p = jQuery(element).position();
}
return p;
},
width: function(element, s) {
if (s != null && s != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).width(s);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).width();
}
}
},
height: function(element, s) {
if (s != null && s != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).height(s);
}
} else {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).height();
}
}
},
toggleClass: function(element, cName) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).toggleClass(cName);
}
},
each:function(element, return_function) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).each(return_function);
}
},
html: function(element, str) {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
if (str != null && str != "") {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).html(str);
}
} else {
var e;
if( typeof( jQuery ) != 'undefined' ){
e = jQuery(element).html();
return e;
}
}
},
find: function(element, selec) {
if( typeof( jQuery ) != 'undefined' ){
return jQuery(element).find(selec);
}
},
stop: function(element) {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).stop();
}
},
delay_animate: function(delay, element, duration, ease, att, callback_function) {
if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") {
var _tdd = Math.round((duration/1500)*10)/10,
__duration = _tdd + 's';
VMM.Lib.css(element, '-webkit-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-moz-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-o-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, '-ms-transition', 'all '+ __duration + ' ease');
VMM.Lib.css(element, 'transition', 'all '+ __duration + ' ease');
VMM.Lib.cssmultiple(element, _att);
} else {
if( typeof( jQuery ) != 'undefined' ){
jQuery(element).delay(delay).animate(att, {duration:duration, easing:ease} );
}
}
},
animate: function(element, duration, ease, att, que, callback_function) {
var _ease = "easein",
_que = false,
_duration = 1000,
_att = {};
if (duration != null) {
if (duration < 1) {
_duration = 1;
} else {
_duration = Math.round(duration);
}
}
if (ease != null && ease != "") {
_ease = ease;
}
if (que != null && que != "") {
_que = que;
}
if (att != null) {
_att = att
} else {
_att = {opacity: 0}
}
if (VMM.Browser.device == "mobile" || VMM.Browser.device == "tablet") {
var _tdd = Math.round((_duration/1500)*10)/10,
__duration = _tdd + 's';
_ease = " cubic-bezier(0.33, 0.66, 0.66, 1)";
//_ease = " ease-in-out";
for (x in _att) {
if (Object.prototype.hasOwnProperty.call(_att, x)) {
trace(x + " to " + _att[x]);
VMM.Lib.css(element, '-webkit-transition', x + ' ' + __duration + _ease);
VMM.Lib.css(element, '-moz-transition', x + ' ' + __duration + _ease);
VMM.Lib.css(element, '-o-transition', x + ' ' + __duration + _ease);
VMM.Lib.css(element, '-ms-transition', x + ' ' + __duration + _ease);
VMM.Lib.css(element, 'transition', x + ' ' + __duration + _ease);
}
}
VMM.Lib.cssmultiple(element, _att);
} else {
if( typeof( jQuery ) != 'undefined' ){
if (callback_function != null && callback_function != "") {
jQuery(element).animate(_att, {queue:_que, duration:_duration, easing:_ease, complete:callback_function} );
} else {
jQuery(element).animate(_att, {queue:_que, duration:_duration, easing:_ease} );
}
}
}
}
}
}
if( typeof( jQuery ) != 'undefined' ){
/* XDR AJAX EXTENTION FOR jQuery
https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
================================================== */
(function( jQuery ) {
if ( window.XDomainRequest ) {
jQuery.ajaxTransport(function( s ) {
if ( s.crossDomain && s.async ) {
if ( s.timeout ) {
s.xdrTimeout = s.timeout;
delete s.timeout;
}
var xdr;
return {
send: function( _, complete ) {
function callback( status, statusText, responses, responseHeaders ) {
xdr.onload = xdr.onerror = xdr.ontimeout = jQuery.noop;
xdr = undefined;
complete( status, statusText, responses, responseHeaders );
}
xdr = new XDomainRequest();
xdr.open( s.type, s.url );
xdr.onload = function() {
callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
};
xdr.onerror = function() {
callback( 404, "Not Found" );
};
if ( s.xdrTimeout ) {
xdr.ontimeout = function() {
callback( 0, "timeout" );
};
xdr.timeout = s.xdrTimeout;
}
xdr.send( ( s.hasContent && s.data ) || null );
},
abort: function() {
if ( xdr ) {
xdr.onerror = jQuery.noop();
xdr.abort();
}
}
};
}
});
}
})( jQuery );
/* jQuery Easing v1.3
http://gsgd.co.uk/sandbox/jquery/easing/
================================================== */
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing, {
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
//alert(jQuery.easing.default);
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
},
easeInExpo: function (x, t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
}
});
}
/***********************************************
Begin VMM.Browser.js
***********************************************/
/* * DEVICE AND BROWSER DETECTION
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.Browser == 'undefined') {
VMM.Browser = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
this.device = this.searchDevice(navigator.userAgent);
this.orientation = this.searchOrientation(window.orientation);
},
searchOrientation: function(orientation) {
var orient = "";
if ( orientation == 0 || orientation == 180) {
orient = "portrait";
} else if ( orientation == 90 || orientation == -90) {
orient = "landscape";
} else {
orient = "normal";
}
return orient;
},
searchDevice: function(d) {
var device = "";
if (d.match(/Android/i) || d.match(/iPhone|iPod/i)) {
device = "mobile";
} else if (d.match(/iPad/i)) {
device = "tablet";
} else if (d.match(/BlackBerry/i) || d.match(/IEMobile/i)) {
device = "other mobile";
} else {
device = "desktop";
}
return device;
},
searchString: function (data) {
for (var i=0;i 'mmmm d',' yyyy''",
full_long: "mmm d',' yyyy 'at' hh:MM TT",
full_long_small_date: "hh:MM TT'
mmm d',' yyyy''",
time_only : "hh:MM:ss:L TT"
},
month: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
month_abbr: ["Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."],
day: ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
day_abbr: ["Sun.", "Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat."],
hour: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
hour_suffix: ["am"],
//B.C.
bc_format: {
year: "yyyy",
month_short: "mmm",
month: "mmmm yyyy",
full_short: "mmm d",
full: "mmmm d',' yyyy",
time_no_seconds_short: "h:MM TT",
time_no_seconds_small_date: "dddd', 'h:MM TT'
'mmmm d',' yyyy''",
full_long: "dddd',' mmm d',' yyyy 'at' hh:MM TT",
full_long_small_date: "hh:MM TT'
'dddd',' mmm d',' yyyy''",
time_only : "hh:MM:ss:L TT"
},
setLanguage: function(lang) {
trace("SET DATE LANGUAGE");
VMM.Date.dateformats = lang.dateformats;
VMM.Date.month = lang.date.month;
VMM.Date.month_abbr = lang.date.month_abbr;
VMM.Date.day = lang.date.day;
VMM.Date.day_abbr = lang.date.day_abbr;
dateFormat.i18n.dayNames = lang.date.day_abbr.concat(lang.date.day);
dateFormat.i18n.monthNames = lang.date.month_abbr.concat(lang.date.month);
},
parse: function(d) {
"use strict";
var date,
date_array,
time_array,
time_parse;
if (type.of(d) == "date") {
date = d;
} else {
date = new Date(0, 0, 1, 0, 0, 0, 0);
if ( d.match(/,/gi) ) {
date_array = d.split(",");
for(var i = 0; i < date_array.length; i++) {
date_array[i] = parseInt(date_array[i], 10);
}
if ( date_array[0] ) { date.setFullYear( date_array[0]); }
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); }
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); }
if ( date_array[3] > 1 ) { date.setHours( date_array[3]); }
if ( date_array[4] > 1 ) { date.setMinutes( date_array[4]); }
if ( date_array[5] > 1 ) { date.setSeconds( date_array[5]); }
if ( date_array[6] > 1 ) { date.setMilliseconds( date_array[6]); }
} else if (d.match("/")) {
if (d.match(" ")) {
time_parse = d.split(" ");
if (d.match(":")) {
time_array = time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); }
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); }
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); }
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); }
}
date_array = time_parse[0].split("/");
} else {
date_array = d.split("/");
}
if ( date_array[2] ) { date.setFullYear( date_array[2]); }
if ( date_array[0] > 1 ) { date.setMonth( date_array[0] - 1); }
if ( date_array[1] > 1 ) { date.setDate( date_array[1]); }
} else if (d.length <= 5) {
date.setFullYear(parseInt(d, 10));
date.setMonth(0);
date.setDate(1);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
} else if (d.match("T")) {
if (navigator.userAgent.match(/MSIE\s(?!9.0)/)) {
// IE 8 < Won't accept dates with a "-" in them.
time_parse = d.split("T");
if (d.match(":")) {
time_array = _time_parse[1].split(":");
if ( time_array[0] >= 1 ) { date.setHours( time_array[0]); }
if ( time_array[1] >= 1 ) { date.setMinutes( time_array[1]); }
if ( time_array[2] >= 1 ) { date.setSeconds( time_array[2]); }
if ( time_array[3] >= 1 ) { date.setMilliseconds( time_array[3]); }
}
_d_array = time_parse[0].split("-");
if ( date_array[0] ) { date.setFullYear( date_array[0]); }
if ( date_array[1] > 1 ) { date.setMonth( date_array[1] - 1); }
if ( date_array[2] > 1 ) { date.setDate( date_array[2]); }
} else {
date = new Date(Date.parse(d));
}
} else {
date = new Date(
parseInt(d.slice(0,4), 10),
parseInt(d.slice(4,6), 10) - 1,
parseInt(d.slice(6,8), 10),
parseInt(d.slice(8,10), 10),
parseInt(d.slice(10,12), 10)
);
}
}
return date;
},
prettyDate: function(d, is_abbr, d2) {
var _date,
_date2,
format,
bc_check,
is_pair = false,
bc_original,
bc_number,
bc_string;
if (d2 != null) {
is_pair = true;
}
if (type.of(d) == "date") {
if (d.getMonth() === 0 && d.getDate() == 1 && d.getHours() === 0 && d.getMinutes() === 0 ) {
// YEAR ONLY
format = VMM.Date.dateformats.year;
} else if (d.getDate() <= 1 && d.getHours() === 0 && d.getMinutes() === 0) {
// YEAR MONTH
if (is_abbr) {
format = VMM.Date.dateformats.month_short;
} else {
format = VMM.Date.dateformats.month;
}
} else if (d.getHours() === 0 && d.getMinutes() === 0) {
// YEAR MONTH DAY
if (is_abbr) {
format = VMM.Date.dateformats.full_short;
} else {
format = VMM.Date.dateformats.full;
}
} else if (d.getMinutes() === 0) {
// YEAR MONTH DAY HOUR
if (is_abbr) {
format = VMM.Date.dateformats.time_no_seconds_short;
} else {
format = VMM.Date.dateformats.time_no_seconds_small_date;
}
} else {
// YEAR MONTH DAY HOUR MINUTE
if (is_abbr){
format = VMM.Date.dateformats.time_only;
} else {
format = VMM.Date.dateformats.time_only;
}
}
_date = dateFormat(d, format, false);
bc_check = _date.split(" ");
// BC TIME SUPPORT
for(var i = 0; i < bc_check.length; i++) {
if ( parseInt(bc_check[i], 10) < 0 ) {
trace("YEAR IS BC");
bc_original = bc_check[i];
bc_number = Math.abs( parseInt(bc_check[i], 10) );
bc_string = bc_number.toString() + " B.C.";
_date = _date.replace(bc_original, bc_string);
}
}
if (is_pair) {
_date2 = dateFormat(d2, format);
bc_check = _date2.split(" ");
// BC TIME SUPPORT
for(var j = 0; j < bc_check.length; j++) {
if ( parseInt(bc_check[j], 10) < 0 ) {
trace("YEAR IS BC");
bc_original = bc_check[j];
bc_number = Math.abs( parseInt(bc_check[j], 10) );
bc_string = bc_number.toString() + " B.C.";
_date2 = _date2.replace(bc_original, bc_string);
}
}
}
} else {
trace("NOT A VALID DATE?");
trace(d);
}
if (is_pair) {
return _date + " — " + _date2;
} else {
return _date;
}
}
}).init();
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan
* MIT license
*
* Includes enhancements by Scott Trenda
* and Kris Kowal
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
timezoneClip = /[^-+\dA-Z]/g,
pad = function (val, len) {
val = String(val);
len = len || 2;
while (val.length < len) val = "0" + val;
return val;
};
// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
var dF = dateFormat;
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
mask = date;
date = undefined;
}
// Passing date through Date applies Date.parse, if necessary
// Caused problems in IE
// date = date ? new Date(date) : new Date;
if (isNaN(date)) {
trace("invalid date " + date);
//return "";
}
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
// Allow setting the utc argument via the mask
if (mask.slice(0, 4) == "UTC:") {
mask = mask.slice(4);
utc = true;
}
var _ = utc ? "getUTC" : "get",
d = date[_ + "Date"](),
D = date[_ + "Day"](),
m = date[_ + "Month"](),
y = date[_ + "FullYear"](),
H = date[_ + "Hours"](),
M = date[_ + "Minutes"](),
s = date[_ + "Seconds"](),
L = date[_ + "Milliseconds"](),
o = utc ? 0 : date.getTimezoneOffset(),
flags = {
d: d,
dd: pad(d),
ddd: dF.i18n.dayNames[D],
dddd: dF.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dF.i18n.monthNames[m],
mmmm: dF.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(L > 99 ? Math.round(L / 10) : L),
t: H < 12 ? "a" : "p",
tt: H < 12 ? "am" : "pm",
T: H < 12 ? "A" : "P",
TT: H < 12 ? "AM" : "PM",
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
};
return mask.replace(token, function ($0) {
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
});
};
}();
// Some common format strings
dateFormat.masks = {
"default": "ddd mmm dd yyyy HH:MM:ss",
shortDate: "m/d/yy",
mediumDate: "mmm d, yyyy",
longDate: "mmmm d, yyyy",
fullDate: "dddd, mmmm d, yyyy",
shortTime: "h:MM TT",
mediumTime: "h:MM:ss TT",
longTime: "h:MM:ss TT Z",
isoDate: "yyyy-mm-dd",
isoTime: "HH:MM:ss",
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};
// For convenience...
Date.prototype.format = function (mask, utc) {
return dateFormat(this, mask, utc);
};
}
/***********************************************
Begin VMM.Util.js
***********************************************/
/* * Utilities and Useful Functions
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.Util == 'undefined') {
VMM.Util = ({
init: function() {
return this;
},
/* * CORRECT PROTOCOL (DOES NOT WORK)
================================================== */
correctProtocol: function(url) {
var loc = (window.parent.location.protocol).toString(),
prefix = "",
the_url = url.split("://", 2);
if (loc.match("http")) {
prefix = loc;
} else {
prefix = "https";
}
return prefix + "://" + the_url[1];
},
/* * MERGE CONFIG
================================================== */
mergeConfig: function(config_main, config_to_merge) {
var x;
for (x in config_to_merge) {
if (Object.prototype.hasOwnProperty.call(config_to_merge, x)) {
config_main[x] = config_to_merge[x];
}
}
return config_main;
},
/* * GET OBJECT ATTRIBUTE BY INDEX
================================================== */
getObjectAttributeByIndex: function(obj, index) {
if(typeof obj != 'undefined') {
var i = 0;
for (var attr in obj){
if (index === i){
return obj[attr];
}
i++;
}
return "";
} else {
return "";
}
},
/* * ORDINAL
================================================== */
ordinal: function(n) {
return ["th","st","nd","rd"][(!( ((n%10) >3) || (Math.floor(n%100/10)==1)) ) * (n%10)];
},
/* * RANDOM BETWEEN
================================================== */
//VMM.Util.randomBetween(1, 3)
randomBetween: function(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
},
/* * AVERAGE
* http://jsfromhell.com/array/average
* var x = VMM.Util.average([2, 3, 4]);
* VMM.Util.average([2, 3, 4]).mean
================================================== */
average: function(a) {
var r = {mean: 0, variance: 0, deviation: 0}, t = a.length;
for(var m, s = 0, l = t; l--; s += a[l]);
for(m = r.mean = s / t, l = t, s = 0; l--; s += Math.pow(a[l] - m, 2));
return r.deviation = Math.sqrt(r.variance = s / t), r;
},
/* * CUSTOM SORT
================================================== */
customSort: function(a, b) {
var a1= a, b1= b;
if(a1== b1) return 0;
return a1> b1? 1: -1;
},
/* * Remove Duplicates from Array
================================================== */
deDupeArray: function(arr) {
var i,
len=arr.length,
out=[],
obj={};
for (i=0;i h) {
_fit.height = h;
//_fit.width = Math.round((w / ratio_w) * ratio_h);
_fit.width = Math.round((h / ratio_h) * ratio_w);
if (_fit.width > w) {
trace("FIT: DIDN'T FIT!!! ")
}
}
return _fit;
},
r16_9: function(w,h) {
//VMM.Util.ratio.r16_9(w, h) // Returns corresponding number
if (w !== null && w !== "") {
return Math.round((h / 16) * 9);
} else if (h !== null && h !== "") {
return Math.round((w / 9) * 16);
}
},
r4_3: function(w,h) {
if (w !== null && w !== "") {
return Math.round((h / 4) * 3);
} else if (h !== null && h !== "") {
return Math.round((w / 3) * 4);
}
}
},
doubledigit: function(n) {
return (n < 10 ? '0' : '') + n;
},
/* * Returns a truncated segement of a long string of between min and max words. If possible, ends on a period (otherwise goes to max).
================================================== */
truncateWords: function(s, min, max) {
if (!min) min = 30;
if (!max) max = min;
var initial_whitespace_rExp = /^[^A-Za-z0-9\'\-]+/gi;
var left_trimmedStr = s.replace(initial_whitespace_rExp, "");
var words = left_trimmedStr.split(" ");
var result = [];
min = Math.min(words.length, min);
max = Math.min(words.length, max);
for (var i = 0; i$&")
.replace(pseudoUrlPattern, "$1$2")
.replace(emailAddressPattern, "$1");
},
linkify_with_twitter: function(text,targets,is_touch) {
// http://, https://, ftp://
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim;
var url_pattern = /(\()((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\))|(\[)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\])|(\{)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(\})|(<|&(?:lt|#60|#x3c);)((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]+)(>|&(?:gt|#62|#x3e);)|((?:^|[^=\s'"\]])\s*['"]?|[^=\s]\s+)(\b(?:ht|f)tps?:\/\/[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]+(?:(?!&(?:gt|#0*62|#x0*3e);|&(?:amp|apos|quot|#0*3[49]|#x0*2[27]);[.!&',:?;]?(?:[^a-z0-9\-._~!$&'()*+,;=:\/?#[\]@%]|$))&[a-z0-9\-._~!$'()*+,;=:\/?#[\]@%]*)*[a-z0-9\-_~$()*+=\/#[\]@%])/img;
var url_replace = '$1$4$7$10$13$2$5$8$11$14$3$6$9$12';
// www. sans http:// or https://
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp, "$3");
}
// Email addresses
var emailAddressPattern = /(([a-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim;
//var twitterHandlePattern = /(@([\w]+))/g;
var twitterHandlePattern = /\B@([\w-]+)/gm;
var twitterSearchPattern = /(#([\w]+))/g;
return text
//.replace(urlPattern, "$&")
.replace(url_pattern, url_replace)
.replace(pseudoUrlPattern, "$1$2")
.replace(emailAddressPattern, "$1")
.replace(twitterHandlePattern, "@$1")
.replace(twitterSearchPattern, "$1");
},
linkify_wikipedia: function(text) {
var urlPattern = /]*>(.*?)<\/i>/gim;
return text
.replace(urlPattern, "$&")
.replace(/]*>/gim, "")
.replace(/<\/i>/gim, "")
.replace(/]*>/gim, "")
.replace(/<\/b>/gim, "");
},
/* * Turns plain text links into real links
================================================== */
// VMM.Util.unlinkify();
unlinkify: function(text) {
if(!text) return text;
text = text.replace(/]*>/i,"");
text = text.replace(/<\/a>/i, "");
return text;
},
untagify: function(text) {
if (!text) {
return text;
}
text = text.replace(/<\s*\w.*?>/g,"");
return text;
},
/* * TK
================================================== */
nl2br: function(text) {
return text.replace(/(\r\n|[\r\n]|\\n|\\r)/g,"
");
},
/* * Generate a Unique ID
================================================== */
// VMM.Util.unique_ID(size);
unique_ID: function(size) {
var getRandomNumber = function(range) {
return Math.floor(Math.random() * range);
};
var getRandomChar = function() {
var chars = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
return chars.substr( getRandomNumber(62), 1 );
};
var randomID = function(size) {
var str = "";
for(var i = 0; i < size; i++) {
str += getRandomChar();
}
return str;
};
return randomID(size);
},
/* * Tells you if a number is even or not
================================================== */
// VMM.Util.isEven(n)
isEven: function(n){
return (n%2 === 0) ? true : false;
},
/* * Get URL Variables
================================================== */
// var somestring = VMM.Util.getUrlVars(str_url)["varname"];
getUrlVars: function(string) {
var str = string.toString();
if (str.match('&')) {
str = str.replace("&", "&");
} else if (str.match('&')) {
str = str.replace("&", "&");
} else if (str.match('&')) {
str = str.replace("&", "&");
}
var vars = [], hash;
var hashes = str.slice(str.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
/* * Cleans up strings to become real HTML
================================================== */
toHTML: function(text) {
text = this.nl2br(text);
text = this.linkify(text);
return text.replace(/\s\s/g," ");
},
/* * Returns text strings as CamelCase
================================================== */
toCamelCase: function(s,forceLowerCase) {
if(forceLowerCase !== false) forceLowerCase = true;
var sps = ((forceLowerCase) ? s.toLowerCase() : s).split(" ");
for(var i=0; i 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
},
/* * Transform text to Title Case
================================================== */
toTitleCase: function(t){
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7) {
return t.replace("_", "%20");
} else {
var __TitleCase = {
__smallWords: ['a', 'an', 'and', 'as', 'at', 'but','by', 'en', 'for', 'if', 'in', 'of', 'on', 'or','the', 'to', 'v[.]?', 'via', 'vs[.]?'],
init: function() {
this.__smallRE = this.__smallWords.join('|');
this.__lowerCaseWordsRE = new RegExp('\\b(' + this.__smallRE + ')\\b', 'gi');
this.__firstWordRE = new RegExp('^([^a-zA-Z0-9 \\r\\n\\t]*)(' + this.__smallRE + ')\\b', 'gi');
this.__lastWordRE = new RegExp('\\b(' + this.__smallRE + ')([^a-zA-Z0-9 \\r\\n\\t]*)$', 'gi');
},
toTitleCase: function(string) {
var line = '';
var split = string.split(/([:.;?!][ ]|(?:[ ]|^)["“])/);
for (var i = 0; i < split.length; ++i) {
var s = split[i];
s = s.replace(/\b([a-zA-Z][a-z.'’]*)\b/g,this.__titleCaseDottedWordReplacer);
// lowercase the list of small words
s = s.replace(this.__lowerCaseWordsRE, this.__lowerReplacer);
// if the first word in the title is a small word then capitalize it
s = s.replace(this.__firstWordRE, this.__firstToUpperCase);
// if the last word in the title is a small word, then capitalize it
s = s.replace(this.__lastWordRE, this.__firstToUpperCase);
line += s;
}
// special cases
line = line.replace(/ V(s?)\. /g, ' v$1. ');
line = line.replace(/(['’])S\b/g, '$1s');
line = line.replace(/\b(AT&T|Q&A)\b/ig, this.__upperReplacer);
return line;
},
__titleCaseDottedWordReplacer: function (w) {
return (w.match(/[a-zA-Z][.][a-zA-Z]/)) ? w : __TitleCase.__firstToUpperCase(w);
},
__lowerReplacer: function (w) { return w.toLowerCase() },
__upperReplacer: function (w) { return w.toUpperCase() },
__firstToUpperCase: function (w) {
var split = w.split(/(^[^a-zA-Z0-9]*[a-zA-Z0-9])(.*)$/);
if (split[1]) {
split[1] = split[1].toUpperCase();
}
return split.join('');
}
};
__TitleCase.init();
t = t.replace(/_/g," ");
t = __TitleCase.toTitleCase(t);
return t;
}
}
}).init();
}
/***********************************************
Begin VMM.LoadLib.js
***********************************************/
/* * LoadLib Based on LazyLoad by Ryan Grove
* https://github.com/rgrove/lazyload/
* Copyright (c) 2011 Ryan Grove
* All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the 'Software'), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
================================================== */
window.loadedJS = [];
if(typeof VMM != 'undefined' && typeof VMM.LoadLib == 'undefined') {
//VMM.LoadLib.js('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', onJQueryLoaded);
//VMM.LoadLib.css('http://someurl.css', onCSSLoaded);
VMM.LoadLib = (function (doc) {
var env,
head,
pending = {},
pollCount = 0,
queue = {css: [], js: []},
styleSheets = doc.styleSheets;
var loaded_Array = [];
function isLoaded(url) {
var has_been_loaded = false;
for(var i=0; i= 0) {
if (styleSheets[i].href === css.urls[0]) {
finish('css');
break;
}
}
pollCount += 1;
if (css) {
if (pollCount < 200) {
setTimeout(pollWebKit, 50);
} else {
finish('css');
}
}
}
}
return {
css: function (urls, callback, obj, context) {
if (isLoaded(urls)) {
return callback;
} else {
load('css', urls, callback, obj, context);
}
},
js: function (urls, callback, obj, context) {
if (isLoaded(urls)) {
return callback;
} else {
load('js', urls, callback, obj, context);
}
}
};
})(this.document);
}
/***********************************************
Begin VMM.ExternalAPI.js
***********************************************/
/* External API
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
VMM.ExternalAPI = {
pushQues: function() {
if (VMM.master_config.googlemaps.active) {
VMM.ExternalAPI.googlemaps.pushQue();
}
if (VMM.master_config.youtube.active) {
VMM.ExternalAPI.youtube.pushQue();
}
if (VMM.master_config.soundcloud.active) {
VMM.ExternalAPI.soundcloud.pushQue();
}
if (VMM.master_config.googledocs.active) {
VMM.ExternalAPI.googledocs.pushQue();
}
if (VMM.master_config.googleplus.active) {
VMM.ExternalAPI.googleplus.pushQue();
}
if (VMM.master_config.wikipedia.active) {
VMM.ExternalAPI.wikipedia.pushQue();
}
if (VMM.master_config.vimeo.active) {
VMM.ExternalAPI.vimeo.pushQue();
}
if (VMM.master_config.twitter.active) {
VMM.ExternalAPI.twitter.pushQue();
}
if (VMM.master_config.flickr.active) {
VMM.ExternalAPI.flickr.pushQue();
}
},
twitter: {
tweetArray: [],
get: function(mid, id) {
var tweet = {mid: mid, id: id};
VMM.master_config.twitter.que.push(tweet);
VMM.master_config.twitter.active = true;
//VMM.master_config.api.pushques.push(VMM.ExternalAPI.twitter.pushQue);
},
create: function(tweet, callback) {
var id = tweet.mid.toString(),
error_obj = { twitterid: tweet.mid },
the_url = "http://api.twitter.com/1/statuses/show.json?id=" + tweet.mid + "&include_entities=true&callback=?",
twitter_timeout = setTimeout(VMM.ExternalAPI.twitter.errorTimeOut, VMM.master_config.timers.api, tweet),
callback_timeout= setTimeout(callback, VMM.master_config.timers.api, tweet);
VMM.getJSON(the_url, function(d) {
var id = d.id_str,
twit = "",
td = VMM.Util.linkify_with_twitter(d.text, "_blank");
// TWEET CONTENT
twit += td;
twit += "
";
// TWEET MEDIA
if (typeof d.entities.media != 'undefined') {
if (d.entities.media[0].type == "photo") {
//twit += ""
}
}
// TWEET AUTHOR
twit += " ";
VMM.attachElement("#"+tweet.id.toString(), twit );
VMM.attachElement("#text_thumb_"+tweet.id.toString(), d.text );
})
.error(function(jqXHR, textStatus, errorThrown) {
trace("TWITTER error");
trace("TWITTER ERROR: " + textStatus + " " + jqXHR.responseText);
VMM.attachElement("#"+tweet.id, VMM.MediaElement.loadingmessage("ERROR LOADING TWEET " + tweet.mid) );
})
.success(function(d) {
clearTimeout(twitter_timeout);
clearTimeout(callback_timeout);
callback();
});
},
errorTimeOut: function(tweet) {
trace("TWITTER JSON ERROR TIMEOUT " + tweet.mid);
VMM.attachElement("#"+tweet.id.toString(), VMM.MediaElement.loadingmessage("Still waiting on Twitter: " + tweet.mid) );
// CHECK RATE STATUS
VMM.getJSON("http://api.twitter.com/1/account/rate_limit_status.json", function(d) {
trace("REMAINING TWITTER API CALLS " + d.remaining_hits);
trace("TWITTER RATE LIMIT WILL RESET AT " + d.reset_time);
var mes = "";
if (d.remaining_hits == 0) {
mes = "You've reached the maximum number of tweets you can load in an hour.
";
mes += "You can view tweets again starting at:
" + d.reset_time + "
";
} else {
mes = "Still waiting on Twitter. " + tweet.mid + "
";
//mes = "Tweet " + id + " was not found.
";
}
VMM.attachElement("#"+tweet.id.toString(), VMM.MediaElement.loadingmessage(mes) );
});
},
pushQue: function() {
if (VMM.master_config.twitter.que.length > 0) {
VMM.ExternalAPI.twitter.create(VMM.master_config.twitter.que[0], VMM.ExternalAPI.twitter.pushQue);
VMM.master_config.twitter.que.remove(0);
}
},
getHTML: function(id) {
//var the_url = document.location.protocol + "//api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?";
var the_url = "http://api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?";
VMM.getJSON(the_url, VMM.ExternalAPI.twitter.onJSONLoaded);
},
onJSONLoaded: function(d) {
trace("TWITTER JSON LOADED");
var id = d.id;
VMM.attachElement("#"+id, VMM.Util.linkify_with_twitter(d.html) );
},
parseTwitterDate: function(d) {
var date = new Date(Date.parse(d));
/*
var t = d.replace(/(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/, '$2 $1');
t = t.replace(/(\+\S+) (.*)/, '$2 $1');
var date = new Date(Date.parse(t)).toLocaleDateString();
var time = new Date(Date.parse(t)).toLocaleTimeString();
*/
return date;
},
prettyParseTwitterDate: function(d) {
var date = new Date(Date.parse(d));
return VMM.Date.prettyDate(date, true);
},
getTweets: function(tweets) {
var tweetArray = [];
var number_of_tweets = tweets.length;
for(var i = 0; i < tweets.length; i++) {
var twitter_id = "";
/* FIND THE TWITTER ID
================================================== */
if (tweets[i].tweet.match("status\/")) {
twitter_id = tweets[i].tweet.split("status\/")[1];
} else if (tweets[i].tweet.match("statuses\/")) {
twitter_id = tweets[i].tweet.split("statuses\/")[1];
} else {
twitter_id = "";
}
/* FETCH THE DATA
================================================== */
var the_url = "http://api.twitter.com/1/statuses/show.json?id=" + twitter_id + "&include_entities=true&callback=?";
VMM.getJSON(the_url, function(d) {
var tweet = {}
/* FORMAT RESPONSE
================================================== */
var twit = "";
var td = VMM.Util.linkify_with_twitter(d.text, "_blank");
twit += td;
twit += "
";
twit += "— " + d.user.name + " (@" + d.user.screen_name + ") " + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.created_at) + "
";
tweet.content = twit;
tweet.raw = d;
tweetArray.push(tweet);
/* CHECK IF THATS ALL OF THEM
================================================== */
if (tweetArray.length == number_of_tweets) {
var the_tweets = {tweetdata: tweetArray}
VMM.fireEvent(global, "TWEETSLOADED", the_tweets);
}
})
.success(function() { trace("second success"); })
.error(function() { trace("error"); })
.complete(function() { trace("complete"); });
}
},
getTweetSearch: function(tweets, number_of_tweets) {
var _number_of_tweets = 40;
if (number_of_tweets != null && number_of_tweets != "") {
_number_of_tweets = number_of_tweets;
}
var the_url = "http://search.twitter.com/search.json?q=" + tweets + "&rpp=" + _number_of_tweets + "&include_entities=true&result_type=mixed";
var tweetArray = [];
VMM.getJSON(the_url, function(d) {
/* FORMAT RESPONSE
================================================== */
for(var i = 0; i < d.results.length; i++) {
var tweet = {}
var twit = "";
var td = VMM.Util.linkify_with_twitter(d.results[i].text, "_blank");
twit += td;
twit += "
";
twit += "— " + d.results[i].from_user_name + " (@" + d.results[i].from_user + ") " + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.results[i].created_at) + "
";
tweet.content = twit;
tweet.raw = d.results[i];
tweetArray.push(tweet);
}
var the_tweets = {tweetdata: tweetArray}
VMM.fireEvent(global, "TWEETSLOADED", the_tweets);
});
},
prettyHTML: function(id, secondary) {
var id = id.toString();
var error_obj = {
twitterid: id
};
var the_url = "http://api.twitter.com/1/statuses/show.json?id=" + id + "&include_entities=true&callback=?";
var twitter_timeout = setTimeout(VMM.ExternalAPI.twitter.errorTimeOut, VMM.master_config.timers.api, id);
VMM.getJSON(the_url, VMM.ExternalAPI.twitter.formatJSON)
.error(function(jqXHR, textStatus, errorThrown) {
trace("TWITTER error");
trace("TWITTER ERROR: " + textStatus + " " + jqXHR.responseText);
VMM.attachElement("#twitter_"+id, "ERROR LOADING TWEET " + id + "
" );
})
.success(function(d) {
clearTimeout(twitter_timeout);
if (secondary) {
VMM.ExternalAPI.twitter.secondaryMedia(d);
}
});
},
formatJSON: function(d) {
var id = d.id_str;
var twit = "";
var td = VMM.Util.linkify_with_twitter(d.text, "_blank");
//td = td.replace(/(@([\w]+))/g,"$1");
//td = td.replace(/(#([\w]+))/g,"$1");
twit += td;
twit += "
";
//twit += " " + "" + " ";
twit += " ";
if (typeof d.entities.media != 'undefined') {
if (d.entities.media[0].type == "photo") {
twit += ""
}
}
VMM.attachElement("#twitter_"+id.toString(), twit );
VMM.attachElement("#text_thumb_"+id.toString(), d.text );
}
},
googlemaps: {
get: function(url, id) {
var timer, api_key, map_vars;
map_vars = VMM.Util.getUrlVars(url);
if (VMM.master_config.Timeline.api_keys.google != "") {
api_key = VMM.master_config.Timeline.api_keys.google;
} else {
api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.google, VMM.master_config.vp, 256);
}
var map_url = "http://maps.googleapis.com/maps/api/js?key=" + api_key + "&libraries=places&sensor=false&callback=VMM.ExternalAPI.googlemaps.onMapAPIReady";
var map = { url: url, vars: map_vars, id: id };
if (VMM.master_config.googlemaps.active) {
VMM.master_config.googlemaps.que.push(map);
} else {
VMM.master_config.googlemaps.que.push(map);
if (VMM.master_config.googlemaps.api_loaded) {
} else {
VMM.LoadLib.js(map_url, function() {
trace("Google Maps API Library Loaded");
});
}
}
},
create: function(m) {
var map_attribution = "";
var layer;
var map;
function mapProvider(name) {
if (name in VMM.ExternalAPI.googlemaps.map_providers) {
map_attribution = VMM.ExternalAPI.googlemaps.map_attribution[VMM.ExternalAPI.googlemaps.map_providers[name].attribution];
return VMM.ExternalAPI.googlemaps.map_providers[name];
} else {
if (VMM.ExternalAPI.googlemaps.defaultType(name)) {
trace("GOOGLE MAP DEFAULT TYPE");
return google.maps.MapTypeId[name.toUpperCase()];
} else {
trace("Not a maptype: " + name );
}
}
}
google.maps.VeriteMapType = function(name) {
if (VMM.ExternalAPI.googlemaps.defaultType(name)) {
return google.maps.MapTypeId[name.toUpperCase()];
} else {
var provider = mapProvider(name);
return google.maps.ImageMapType.call(this, {
"getTileUrl": function(coord, zoom) {
var index = (zoom + coord.x + coord.y) % VMM.ExternalAPI.googlemaps.map_subdomains.length;
return [
provider.url
.replace("{S}", VMM.ExternalAPI.googlemaps.map_subdomains[index])
.replace("{Z}", zoom)
.replace("{X}", coord.x)
.replace("{Y}", coord.y)
.replace("{z}", zoom)
.replace("{x}", coord.x)
.replace("{y}", coord.y)
];
},
"tileSize": new google.maps.Size(256, 256),
"name": name,
"minZoom": provider.minZoom,
"maxZoom": provider.maxZoom
});
}
};
google.maps.VeriteMapType.prototype = new google.maps.ImageMapType("_");
/* Make the Map
================================================== */
if (type.of(VMM.master_config.Timeline.maptype) == "string") {
if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) {
layer = google.maps.MapTypeId[VMM.master_config.Timeline.maptype.toUpperCase()];
} else {
layer = VMM.master_config.Timeline.maptype;
}
} else {
layer = "toner";
}
var location = new google.maps.LatLng(41.875696,-87.624207);
var latlong;
var zoom = 11;
var has_location = false;
var has_zoom = false;
var map_bounds;
if (type.of(VMM.Util.getUrlVars(m.url)["ll"]) == "string") {
has_location = true;
latlong = VMM.Util.getUrlVars(m.url)["ll"].split(",");
location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1]));
} else if (type.of(VMM.Util.getUrlVars(m.url)["sll"]) == "string") {
latlong = VMM.Util.getUrlVars(m.url)["sll"].split(",");
location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1]));
}
if (type.of(VMM.Util.getUrlVars(m.url)["z"]) == "string") {
has_zoom = true;
zoom = parseFloat(VMM.Util.getUrlVars(m.url)["z"]);
}
var map_options = {
zoom: zoom,
disableDefaultUI: true,
mapTypeControl: false,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.TOP_RIGHT
},
center: location,
mapTypeId: layer,
mapTypeControlOptions: {
mapTypeIds: [layer]
}
}
var unique_map_id = m.id.toString() + "_gmap";
VMM.attachElement("#" + m.id, "");
var map = new google.maps.Map(document.getElementById(unique_map_id), map_options);
if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) {
} else {
map.mapTypes.set(layer, new google.maps.VeriteMapType(layer));
// ATTRIBUTION
var map_attribution_html = "" + map_attribution + "";
VMM.appendElement("#"+unique_map_id, map_attribution_html);
}
loadKML();
// KML
function loadKML() {
var kml_url = m.url + "&output=kml";
kml_url = kml_url.replace("&output=embed", "");
var kml_layer = new google.maps.KmlLayer(kml_url, {preserveViewport:true});
var infowindow = new google.maps.InfoWindow();
kml_layer.setMap(map);
google.maps.event.addListenerOnce(kml_layer, "defaultviewport_changed", function() {
map.fitBounds(kml_layer.getDefaultViewport() );
if (has_location) {
map.panTo(location);
}
if (has_zoom) {
map.setZoom(zoom);
}
});
google.maps.event.addListener(kml_layer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showInfoWindow(text);
function showInfoWindow(c) {
infowindow.setContent(c);
infowindow.open(map);
}
});
}
},
pushQue: function() {
for(var i = 0; i < VMM.master_config.googlemaps.que.length; i++) {
VMM.ExternalAPI.googlemaps.create(VMM.master_config.googlemaps.que[i]);
}
VMM.master_config.googlemaps.que = [];
},
onMapAPIReady: function() {
VMM.master_config.googlemaps.map_active = true;
VMM.master_config.googlemaps.places_active = true;
VMM.ExternalAPI.googlemaps.onAPIReady();
},
onPlacesAPIReady: function() {
VMM.master_config.googlemaps.places_active = true;
VMM.ExternalAPI.googlemaps.onAPIReady();
},
onAPIReady: function() {
if (!VMM.master_config.googlemaps.active) {
if (VMM.master_config.googlemaps.map_active && VMM.master_config.googlemaps.places_active) {
VMM.master_config.googlemaps.active = true;
VMM.ExternalAPI.googlemaps.pushQue();
}
}
},
defaultType: function(name) {
if (name.toLowerCase() == "satellite" || name.toLowerCase() == "hybrid" || name.toLowerCase() == "terrain" || name.toLowerCase() == "roadmap") {
return true;
} else {
return false;
}
},
map_subdomains: ["", "a.", "b.", "c.", "d."],
map_attribution: {
"stamen": "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.",
"apple": "Map data © 2012 Apple, Imagery © 2012 Apple"
},
map_providers: {
"toner": {
"url": "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png",
"minZoom": 0,
"maxZoom": 20,
"attribution": "stamen"
},
"toner-lines": {
"url": "http://{S}tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png",
"minZoom": 0,
"maxZoom": 20,
"attribution": "stamen"
},
"toner-labels": {
"url": "http://{S}tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png",
"minZoom": 0,
"maxZoom": 20,
"attribution": "stamen"
},
"sterrain": {
"url": "http://{S}tile.stamen.com/terrain/{Z}/{X}/{Y}.jpg",
"minZoom": 4,
"maxZoom": 20,
"attribution": "stamen"
},
"apple": {
"url": "http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9",
"minZoom": 4,
"maxZoom": 14,
"attribution": "apple"
},
"watercolor": {
"url": "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg",
"minZoom": 3,
"maxZoom": 16,
"attribution": "stamen"
}
}
},
googleplus: {
get: function(user, activity) {
var api_key;
var gplus = {user: user, activity: activity};
VMM.master_config.googleplus.que.push(gplus);
VMM.master_config.googleplus.active = true;
},
create: function(gplus, callback) {
var mediaElem = "",
api_key = "",
g_activity = "",
g_content = "",
g_attachments = "",
gperson_api_url,
gactivity_api_url;
googleplus_timeout = setTimeout(VMM.ExternalAPI.googleplus.errorTimeOut, VMM.master_config.timers.api, gplus),
callback_timeout = setTimeout(callback, VMM.master_config.timers.api, gplus);
if (VMM.master_config.Timeline.api_keys.google != "") {
api_key = VMM.master_config.Timeline.api_keys.google;
} else {
api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.google, VMM.master_config.vp, 256);
}
gperson_api_url = "https://www.googleapis.com/plus/v1/people/" + gplus.user + "/activities/public?alt=json&maxResults=100&fields=items(id,url)&key=" + api_key;
//mediaElem = "";
mediaElem = "GOOGLE PLUS API CALL";
VMM.getJSON(gperson_api_url, function(p_data) {
for(var i = 0; i < p_data.items.length; i++) {
trace("loop");
if (p_data.items[i].url.split("posts/")[1] == gplus.activity) {
trace("FOUND IT!!");
g_activity = p_data.items[i].id;
gactivity_api_url = "https://www.googleapis.com/plus/v1/activities/" + g_activity + "?alt=json&key=" + api_key;
VMM.getJSON(gactivity_api_url, function(a_data) {
trace(a_data);
//a_data.url
//a_data.image.url
//a_data.actor.displayName
//a_data.provider.title
//a_data.object.content
//g_content += "" + a_data.title + "
";
if (typeof a_data.annotation != 'undefined') {
g_content += "'" + a_data.annotation + "";
g_content += a_data.object.content;
} else {
g_content += a_data.object.content;
}
if (typeof a_data.object.attachments != 'undefined') {
//g_attachments += "";
for(var k = 0; k < a_data.object.attachments.length; k++) {
if (a_data.object.attachments[k].objectType == "photo") {
g_attachments = "" + "" + g_attachments;
} else if (a_data.object.attachments[k].objectType == "video") {
g_attachments = "" + g_attachments;
g_attachments += "";
g_attachments += ""
g_attachments += "" + a_data.object.attachments[k].displayName + "
";
//g_attachments += "" + a_data.object.attachments[k].content + "
";
g_attachments += "";
g_attachments += "";
} else if (a_data.object.attachments[k].objectType == "article") {
g_attachments += "";
g_attachments += ""
g_attachments += "" + a_data.object.attachments[k].displayName + "
";
g_attachments += "" + a_data.object.attachments[k].content + "
";
g_attachments += "";
g_attachments += "";
}
trace(a_data.object.attachments[k]);
}
g_attachments = " ";
}
//mediaElem = "";
mediaElem = "" + g_content + g_attachments + "";
mediaElem += " ";
VMM.attachElement("#googleplus_" + gplus.activity, mediaElem);
});
break;
}
}
})
.error(function(jqXHR, textStatus, errorThrown) {
var error_obj = VMM.parseJSON(jqXHR.responseText);
trace(error_obj.error.message);
VMM.attachElement("#googleplus_" + gplus.activity, VMM.MediaElement.loadingmessage("ERROR LOADING GOOGLE+
" + error_obj.error.message + "
"));
})
.success(function(d) {
clearTimeout(googleplus_timeout);
clearTimeout(callback_timeout);
callback();
});
},
pushQue: function() {
if (VMM.master_config.googleplus.que.length > 0) {
VMM.ExternalAPI.googleplus.create(VMM.master_config.googleplus.que[0], VMM.ExternalAPI.googleplus.pushQue);
VMM.master_config.googleplus.que.remove(0);
}
/*
for(var i = 0; i < VMM.master_config.googleplus.que.length; i++) {
VMM.ExternalAPI.googleplus.create(VMM.master_config.googleplus.que[i]);
}
VMM.master_config.googleplus.que = [];
*/
},
errorTimeOut: function(gplus) {
trace("GOOGLE+ JSON ERROR TIMEOUT " + gplus.activity);
VMM.attachElement("#googleplus_" + gplus.activity, VMM.MediaElement.loadingmessage("Still waiting on GOOGLE+
" + gplus.activity + "
"));
}
},
googledocs: {
get: function(url, id) {
var doc = {url: url, id: id};
VMM.master_config.googledocs.que.push(doc);
VMM.master_config.googledocs.active = true;
},
create: function(doc) {
var mediaElem = "";
if (doc.url.match(/docs.google.com/i)) {
mediaElem = "";
} else {
mediaElem = "";
}
VMM.attachElement("#"+doc.id, mediaElem);
},
pushQue: function() {
for(var i = 0; i < VMM.master_config.googledocs.que.length; i++) {
VMM.ExternalAPI.googledocs.create(VMM.master_config.googledocs.que[i]);
}
VMM.master_config.googledocs.que = [];
}
},
flickr: {
get: function(mid, id, link) {
var flick = {mid: mid, id: id, link:link};
VMM.master_config.flickr.que.push(flick);
VMM.master_config.flickr.active = true;
},
create: function(flick, callback) {
var api_key,
callback_timeout= setTimeout(callback, VMM.master_config.timers.api, flick);
if (VMM.master_config.Timeline.api_keys.flickr != "") {
api_key = VMM.master_config.Timeline.api_keys.flickr;
} else {
api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.flickr, VMM.master_config.vp, 256)
}
var the_url = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=" + api_key + "&photo_id=" + flick.mid + "&format=json&jsoncallback=?";
VMM.getJSON(the_url, function(d) {
var flickr_id = d.sizes.size[0].url.split("photos\/")[1].split("/")[1];
var flickr_large_id = "#" + flick.id,
flickr_thumb_id = "#" + flick.id + "_thumb";
//flickr_thumb_id = "flickr_" + uid + "_thumb";
var flickr_img_size,
flickr_img_thumb,
flickr_size_found = false,
flickr_best_size = "Large";
flickr_best_size = VMM.ExternalAPI.flickr.sizes(VMM.master_config.sizes.api.height);
for(var i = 0; i < d.sizes.size.length; i++) {
if (d.sizes.size[i].label == flickr_best_size) {
flickr_size_found = true;
flickr_img_size = d.sizes.size[i].source;
}
}
if (!flickr_size_found) {
flickr_img_size = d.sizes.size[d.sizes.size.length - 1].source;
}
flickr_img_thumb = d.sizes.size[0].source;
VMM.Lib.attr(flickr_large_id, "src", flickr_img_size);
//VMM.attachElement(flickr_large_id, "");
VMM.attachElement(flickr_thumb_id, "");
})
.error(function(jqXHR, textStatus, errorThrown) {
trace("FLICKR error");
trace("FLICKR ERROR: " + textStatus + " " + jqXHR.responseText);
})
.success(function(d) {
clearTimeout(callback_timeout);
callback();
});
},
pushQue: function() {
if (VMM.master_config.flickr.que.length > 0) {
VMM.ExternalAPI.flickr.create(VMM.master_config.flickr.que[0], VMM.ExternalAPI.flickr.pushQue);
VMM.master_config.flickr.que.remove(0);
}
},
sizes: function(s) {
var _size = "";
if (s <= 75) {
_size = "Thumbnail";
} else if (s <= 180) {
_size = "Small";
} else if (s <= 240) {
_size = "Small 320";
} else if (s <= 375) {
_size = "Medium";
} else if (s <= 480) {
_size = "Medium 640";
} else if (s <= 600) {
_size = "Medium 800";
} else {
_size = "Large";
}
return _size;
}
},
instagram: {
get: function(mid, thumb) {
if (thumb) {
return "http://instagr.am/p/" + mid + "/media/?size=t";
} else {
return "http://instagr.am/p/" + mid + "/media/?size=" + VMM.ExternalAPI.instagram.sizes(VMM.master_config.sizes.api.height);
}
},
sizes: function(s) {
var _size = "";
if (s <= 150) {
_size = "t";
} else if (s <= 306) {
_size = "m";
} else {
_size = "l";
}
return _size;
}
},
soundcloud: {
get: function(mid, id) {
var sound = {mid: mid, id: id};
VMM.master_config.soundcloud.que.push(sound);
VMM.master_config.soundcloud.active = true;
},
create: function(sound, callback) {
var the_url = "http://soundcloud.com/oembed?url=" + sound.mid + "&format=js&callback=?";
VMM.getJSON(the_url, function(d) {
VMM.attachElement("#"+sound.id, d.html);
callback();
});
},
pushQue: function() {
if (VMM.master_config.soundcloud.que.length > 0) {
VMM.ExternalAPI.soundcloud.create(VMM.master_config.soundcloud.que[0], VMM.ExternalAPI.soundcloud.pushQue);
VMM.master_config.soundcloud.que.remove(0);
}
}
},
wikipedia: {
get: function(url, id, lang) {
var api_obj = {url: url, id: id, lang: lang};
VMM.master_config.wikipedia.que.push(api_obj);
VMM.master_config.wikipedia.active = true;
},
create: function(api_obj, callback) {
var the_url = "http://" + api_obj.lang + ".wikipedia.org/w/api.php?action=query&prop=extracts&redirects=&titles=" + api_obj.url + "&exintro=1&format=json&callback=?";
callback_timeout= setTimeout(callback, VMM.master_config.timers.api, api_obj);
if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 7 && window.XDomainRequest) {
var temp_text = "" + api_obj.url + "
";
temp_text += "" + VMM.master_config.language.messages.wikipedia + "";
temp_text += "Wikipedia entry unable to load using Internet Explorer 8 or below.
";
VMM.attachElement("#"+api_obj.id, temp_text );
}
VMM.getJSON(the_url, function(d) {
if (d.query) {
var wiki_extract,
wiki_title,
_wiki = "",
wiki_text = "",
wiki_number_of_paragraphs = 1,
wiki_text_array = [];
wiki_extract = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).extract;
wiki_title = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).title;
if (wiki_extract.match("")) {
wiki_text_array = wiki_extract.split("
");
} else {
wiki_text_array.push(wiki_extract);
}
for(var i = 0; i < wiki_text_array.length; i++) {
if (i+1 <= wiki_number_of_paragraphs && i+1 < wiki_text_array.length) {
wiki_text += "
" + wiki_text_array[i+1];
}
}
_wiki = "
" + wiki_title + "
";
_wiki += "" + VMM.master_config.language.messages.wikipedia + "";
_wiki += VMM.Util.linkify_wikipedia(wiki_text);
if (wiki_extract.match("REDIRECT")) {
} else {
VMM.attachElement("#"+api_obj.id, _wiki );
}
}
//callback();
})
.error(function(jqXHR, textStatus, errorThrown) {
trace("WIKIPEDIA error");
trace("WIKIPEDIA ERROR: " + textStatus + " " + jqXHR.responseText);
trace(errorThrown);
VMM.attachElement("#"+api_obj.id, VMM.MediaElement.loadingmessage("Wikipedia is not responding
"));
// TRY AGAIN?
clearTimeout(callback_timeout);
if (VMM.master_config.wikipedia.tries < 4) {
trace("WIKIPEDIA ATTEMPT " + VMM.master_config.wikipedia.tries);
trace(api_obj);
VMM.master_config.wikipedia.tries++;
VMM.ExternalAPI.wikipedia.create(api_obj, callback);
} else {
callback();
}
})
.success(function(d) {
VMM.master_config.wikipedia.tries = 0;
clearTimeout(callback_timeout);
callback();
});
},
pushQue: function() {
if (VMM.master_config.wikipedia.que.length > 0) {
trace("WIKIPEDIA PUSH QUE " + VMM.master_config.wikipedia.que.length);
VMM.ExternalAPI.wikipedia.create(VMM.master_config.wikipedia.que[0], VMM.ExternalAPI.wikipedia.pushQue);
VMM.master_config.wikipedia.que.remove(0);
}
}
},
youtube: {
get: function(mid, id, start) {
var the_url = "http://gdata.youtube.com/feeds/api/videos/" + mid + "?v=2&alt=jsonc&callback=?",
vid = {mid: mid, id: id, start: start};
VMM.master_config.youtube.que.push(vid);
if (!VMM.master_config.youtube.active) {
if (!VMM.master_config.youtube.api_loaded) {
VMM.LoadLib.js('http://www.youtube.com/player_api', function() {
trace("YouTube API Library Loaded");
});
}
}
// THUMBNAIL
VMM.getJSON(the_url, function(d) {
VMM.ExternalAPI.youtube.createThumb(d, vid)
});
},
create: function(vid) {
if (typeof(vid.start) != 'undefined') {
var vidstart = vid.start.toString(),
vid_start_minutes = 0,
vid_start_seconds = 0;
if (vidstart.match('m')) {
vidstart = vidstart.split("=")[1];
vid_start_minutes = parseInt(vidstart.split("m")[0], 10);
vid_start_seconds = parseInt(vidstart.split("m")[1].split("s")[0], 10);
vid.start = (vid_start_minutes * 60) + vid_start_seconds;
} else {
vid.start = 0;
}
} else {
vid.start = 0;
}
var p = {
active: false,
player: {},
name: vid.id,
playing: false
};
p.player[vid.id] = new YT.Player(vid.id, {
height: '390',
width: '640',
playerVars: {
enablejsapi: 1,
color: 'white',
showinfo: 0,
theme: 'light',
start: vid.start,
rel: 0
},
videoId: vid.mid,
events: {
'onReady': VMM.ExternalAPI.youtube.onPlayerReady,
'onStateChange': VMM.ExternalAPI.youtube.onStateChange
}
});
VMM.master_config.youtube.array.push(p);
},
createThumb: function(d, vid) {
trace("CREATE THUMB");
trace(d);
trace(vid);
//if (typeof d.data != 'undefined') {
var thumb_id = "#" + vid.id + "_thumb";
VMM.attachElement(thumb_id, "");
//}
},
pushQue: function() {
for(var i = 0; i < VMM.master_config.youtube.que.length; i++) {
VMM.ExternalAPI.youtube.create(VMM.master_config.youtube.que[i]);
}
VMM.master_config.youtube.que = [];
},
onAPIReady: function() {
VMM.master_config.youtube.active = true;
VMM.ExternalAPI.youtube.pushQue();
},
stopPlayers: function() {
for(var i = 0; i < VMM.master_config.youtube.array.length; i++) {
if (VMM.master_config.youtube.array[i].playing) {
var the_name = VMM.master_config.youtube.array[i].name;
VMM.master_config.youtube.array[i].player[the_name].stopVideo();
}
}
},
onStateChange: function(e) {
for(var i = 0; i < VMM.master_config.youtube.array.length; i++) {
var the_name = VMM.master_config.youtube.array[i].name;
if (VMM.master_config.youtube.array[i].player[the_name] == e.target) {
if (e.data == YT.PlayerState.PLAYING) {
VMM.master_config.youtube.array[i].playing = true;
}
}
}
},
onPlayerReady: function(e) {
}
},
vimeo: {
get: function(mid, id) {
var vid = {mid: mid, id: id};
VMM.master_config.vimeo.que.push(vid);
VMM.master_config.vimeo.active = true;
},
create: function(vid, callback) {
trace("VIMEO CREATE");
// THUMBNAIL
var the_url = "http://vimeo.com/api/v2/video/" + vid.mid + ".json";
VMM.getJSON(the_url, function(d) {
VMM.ExternalAPI.vimeo.createThumb(d, vid);
callback();
});
},
createThumb: function(d, vid) {
trace("VIMEO CREATE THUMB");
var thumb_id = "#" + vid.id + "_thumb";
VMM.attachElement(thumb_id, "");
},
pushQue: function() {
if (VMM.master_config.vimeo.que.length > 0) {
VMM.ExternalAPI.vimeo.create(VMM.master_config.vimeo.que[0], VMM.ExternalAPI.vimeo.pushQue);
VMM.master_config.vimeo.que.remove(0);
}
/*
for(var i = 0; i < VMM.master_config.vimeo.que.length; i++) {
VMM.ExternalAPI.vimeo.create(VMM.master_config.vimeo.que[i]);
}
VMM.master_config.vimeo.que = [];
*/
}
}
}
}
/* YOUTUBE API READY
Can't find a way to customize this callback and keep it in the VMM namespace
Youtube wants it to be this function.
================================================== */
function onYouTubePlayerAPIReady() {
trace("GLOBAL YOUTUBE API CALLED")
VMM.ExternalAPI.youtube.onAPIReady();
}
/***********************************************
Begin VMM.MediaElement.js
***********************************************/
/* MediaElement
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
VMM.MediaElement = ({
init: function() {
return this;
},
loadingmessage: function(m) {
return "" + "";
},
thumbnail: function(data, w, h, uid) {
var _w = 16,
_h = 24,
_uid = "";
if (w != null && w != "") {_w = w};
if (h != null && h != "") {_h = h};
if (uid != null && uid != "") {_uid = uid};
if (data.thumbnail != null && data.thumbnail != "") {
return "";
}
},
create: function(data, uid) {
var _valid = false,
//loading_messege = "" + VMM.master_config.language.messages.loading + "
";
loading_messege = VMM.MediaElement.loadingmessage(VMM.master_config.language.messages.loading + "...");
if (data.media != null && data.media != "") {
var mediaElem = "", captionElem = "", creditElem = "", _id = "", isTextMedia = false, m;
m = VMM.MediaType(data.media); //returns an object with .type and .id
_valid = true;
// CREDIT
if (data.credit != null && data.credit != "") {
creditElem = "" + VMM.Util.linkify_with_twitter(data.credit, "_blank") + "";
}
// CAPTION
if (data.caption != null && data.caption != "") {
captionElem = " ";
}
// IMAGE
if (m.type == "image") {
mediaElem = "";
// FLICKR
} else if (m.type == "flickr") {
//mediaElem = "" + loading_messege + "";
mediaElem = "";
VMM.ExternalAPI.flickr.get(m.id, uid, m.link);
// INSTAGRAM
} else if (m.type == "instagram") {
mediaElem = "";
//VMM.ExternalAPI.instagram.get(m.id, uid);
// GOOGLE DOCS
} else if (m.type == "googledoc") {
mediaElem = "" + loading_messege + "";
VMM.ExternalAPI.googledocs.get(m.id, uid);
// YOUTUBE
} else if (m.type == "youtube") {
mediaElem = "" + loading_messege + "";
VMM.ExternalAPI.youtube.get(m.id, uid, m.start);
// VIMEO
} else if (m.type == "vimeo") {
mediaElem = "";
VMM.ExternalAPI.vimeo.get(m.id, uid);
// DAILYMOTION
} else if (m.type == "dailymotion") {
mediaElem = "";
// TWITTER
} else if (m.type == "twitter"){
mediaElem = "" + loading_messege + "";
isTextMedia = true;
VMM.ExternalAPI.twitter.get(m.id, uid);
// TWITTER
} else if (m.type == "twitter-ready") {
isTextMedia = true;
mediaElem = m.id;
// SOUNDCLOUD
} else if (m.type == "soundcloud") {
mediaElem = "" + loading_messege + "";
VMM.ExternalAPI.soundcloud.get(m.id, uid);
// GOOGLE MAPS
} else if (m.type == "google-map") {
mediaElem = "" + loading_messege + "";
VMM.ExternalAPI.googlemaps.get(m.id, uid);
// GOOGLE PLUS
} else if (m.type == "googleplus") {
_id = "googleplus_" + m.id;
mediaElem = "" + loading_messege + "";
isTextMedia = true;
VMM.ExternalAPI.googleplus.get(m.user, m.id, uid);
// WIKIPEDIA
} else if (m.type == "wikipedia") {
mediaElem = "" + loading_messege + "";
isTextMedia = true;
VMM.ExternalAPI.wikipedia.get(m.id, uid, m.lang);
// STORIFY
} else if (m.type == "storify") {
isTextMedia = true;
mediaElem = "" + m.id + "";
// QUOTE
} else if (m.type == "quote") {
isTextMedia = true;
mediaElem = "" + m.id + "";
// UNKNOWN
} else if (m.type == "unknown") {
trace("NO KNOWN MEDIA TYPE FOUND TRYING TO JUST PLACE THE HTML");
isTextMedia = true;
mediaElem = "" + VMM.Util.properQuotes(m.id) + "";
// WEBSITE
} else if (m.type == "website") {
//mediaElem = "";
//mediaElem = "" + "";
mediaElem = "";
// NO MATCH
} else {
trace("NO KNOWN MEDIA TYPE FOUND");
trace(m.type);
}
// WRAP THE MEDIA ELEMENT
mediaElem = "" + mediaElem + creditElem + captionElem + "";
// RETURN
if (isTextMedia) {
return "" + mediaElem + "";
} else {
return "" + mediaElem + "";
}
};
}
}).init();
}
/***********************************************
Begin VMM.MediaType.js
***********************************************/
/* MediaType
Determines the type of media the url string is.
returns an object with .type and .id
the id is a key piece of information needed to make
the request of the api.
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
VMM.MediaType = function(d) {
var success = false,
media = {
type: "unknown",
id: "",
start: 0,
link: "",
lang: "",
uniqueid: VMM.Util.unique_ID(6)
};
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"];
media.start = VMM.Util.getUrlVars(d)["t"];
} else if (d.match('\/embed\/')) {
media.id = d.split("embed\/")[1].split(/[?&]/)[0];
media.start = d.split("embed\/")[1].split(/[?&]/)[1];
} else {
media.id = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
media.start = d.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[1];
}
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') && d.match('status') ) {
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("plus.google")) {
media.type = "googleplus";
media.id = d.split("/posts/")[1];
//https://plus.google.com/u/0/112374836634096795698/posts/bRJSvCb5mUU
//https://plus.google.com/107096716333816995401/posts/J5iMpEDHWNL
if (d.split("/posts/")[0].match("u/0/")) {
media.user = d.split("u/0/")[1].split("/posts")[0];
} else {
media.user = d.split("google.com/")[1].split("/posts/")[0];
}
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("instagr.am/p/")) {
media.type = "instagram";
media.link = d;
media.id = d.split("\/p\/")[1].split("/")[0];
success = true;
} else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap") || d.match("yfrog.com") || d.match("twitpic.com")) {
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 = wiki_id.replace(" ", "%20");
media.lang = d.split("//")[1].split(".wikipedia")[0];
success = true;
} else if (d.indexOf('http://') == 0) {
media.type = "website";
media.id = d;
success = true;
} else if (d.match('storify')) {
media.type = "storify";
media.id = d;
success = true;
} else if (d.match('blockquote')) {
media.type = "quote";
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;
}
}
/***********************************************
Begin VMM.Media.js
***********************************************/
/* Media
================================================== */
if(typeof VMM != 'undefined' && typeof VMM.Media == 'undefined') {
// something = new VMM.Media(parent, w, h, {thedata});
VMM.Media = function(parent, w, h, thedata) {
/* PRIVATE VARS
================================================== */
var data = {}; // HOLDS DATA
var _valid = false;
var config = {
width: 720,
height: 400,
content_width: 720,
content_height: 400,
ease: "easeInOutExpo",
duration: 1000,
spacing: 15
};
/* ELEMENTS
================================================== */
var $media = "";
var $container = "";
var $mediacontainer = "";
var $mediaelement = "";
var layout = parent; // expecting media div
if (w != null && w != "") {config.width = w};
if (h != null && h != "") {config.height = h};
/*
if (typeof thedata != "undefined") {
data = thedata;
this.init(data);
}
*/
/* PUBLIC FUNCTIONS
================================================== */
this.init = function(d) {
if(typeof d != 'undefined') {
this.setData(d);
} else {
trace("WAITING ON DATA");
}
};
var build = function(media, caption, credit) {
$media = VMM.appendAndGetElement(layout, "", "media");
$container = VMM.appendAndGetElement($media, "", "container");
$mediacontainer = VMM.appendAndGetElement($container, "", "media-container");
if (data.media != null && data.media != "") {
_valid = true;
var m = {};
m = VMM.MediaType(data.media); //returns an object with .type and .id
if (m.type == "image") {
VMM.appendElement($mediacontainer, "");
} else if (m.type == "youtube") {
VMM.appendElement($mediacontainer, "