(function () { /* * Api 0.1 Prerelease - The Dealer.com API * Copyright (C) 2007 Dealer.com * * October 2007 * Randy Morey, Web Developer */ /* TODO: * Implement Api.urlParams * Implement cross-browser debugging * Rewrite the if-block in Api.get as a series of inner functions, one for each case * Comment the Api.get function */ var Api = { version: '0.1 Prerelease', settings: { /** * Toggles debug mode: Api messages are logged to the console. * @type Boolean */ debug: true, /** * Toggles deploy mode: Api calls are made live instead of local. * @type Boolean */ deploy: true } }; // Assign Api global scope window.Api = Api; /** * Logs a message to the console in supported browsers. * In unsupported browsers, does nothing. * @param {String} msg Message to be logged */ Api.debug = !Api.settings.debug ? function () {} : function (msg) { if (typeof console != 'undefined') { console.log('[api] ' + msg); } }; /** * Extends an object with one or more additional objects. * If only one argument is passed, Api.extend extends Api itself. * @param {Object} Object to extend * @param {Object} Object with which to extend former */ Api.extend = function() { var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false; var prop; if (al == 1) { target = this; a = 0; } for (; a < al; a++) { if ((prop = arguments[a]) !== null) { for (var i in prop) { if (target == prop[i]) { continue; } if (deep && (typeof prop[i] == 'object') && target[i]) { Api.extend( target[i], prop[i]); } else if (prop[i] !== undefined) { target[i] = prop[i]; } } } } return target; }; /** * Gets a script or style sheet cross-domain. * @param {String} type type of file to get (style or script) * @param {String} url url of file to get * @param {Object} params object consisting of key/value pairs to be converted into url parameteres * @param {Function} callback called upon successful completetion of file get */ Api.load = function (type, url, params, success) { type = type || 'script'; url = url || ''; params = params || {}; success = success || function () {}; var el = document.createElement(type == 'script' ? type : 'link'); var head = document.getElementsByTagName('head')[0]; var loaded = false; if (type == 'script') { el.src = url + Api.urlParams(params); el.type = 'text/javascript'; el.onload = el.onreadystatechange = function () { if (!loaded && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { loaded = true; Api.debug('Api.get() - done loading ' + type + ': ' + url); if (navigator.appVersion.indexOf('MSIE ' + (arguments[0] || '')) == -1) { head.removeChild(el); } success(); } }; } else if (type == 'stylesheet') { el.href = url + Api.urlParams(params); el.type = 'text/css'; el.rel = type; } head.appendChild(el); Api.debug('Api.get() - loading ' + type + ': ' + url); }; Api.get = function( id ) { return document.getElementById(id) } /** * Loads a style sheet. * @param {String} url path to style sheet */ Api.getStyle = function (url) { Api.load('stylesheet', url); }; /** * Loads a script cross-domain. * @param {String} src path to script file (may be cross-domain) * @param {Function} success called after successful script load */ Api.getScript = function (url, success) { Api.load('script', url, {}, success); }; /** * Converts an object consisting of key/value pairs to a URL parameter list. * {foo: 'bar', world: 'hello'} becomes '?foo=bar&world=hello' * @param {String} type type of file to get (style or script) * @return {String} string representation of object, in url paramaeter format */ Api.urlParams = function (obj) { return ''; }; })();(function () { /** * apicall.js 1.5 - The Dealer.com Cross-Domain Data Getter * Copyright (C)2007 Dealer.com * * October 2007 **/ var USED_INVENTORY = window.USED_INVENTORY = 1; var NEW_INVENTORY = window.NEW_INVENTORY = 2; var ApiCall = window.ApiCall = function(settings) { return this instanceof ApiCall ? this.initialize(settings) : new ApiCall(settings); }; ApiCall.prototype = { initialize: function (settings) { this.params = []; this.params.index = []; Api.extend(this,settings); this.url = Api.settings.deploy ? 'http://apis.dealer.com/services/' : 'http://localhost:7070/services/'; Api.debug("url: " + this.url ); }, version: '1.5', url: '', reseller: '', accountId: '', service: '', operation: '', version: 'v1', output: 'json', callback: '', param: function(key, value) { this.params.index.push(key); this.params[key] = value; }, execute: function() { Api.debug('ApiCall.execute() - API call for service: ' + this.service); Api.getScript(this.toUrl()); }, toUrl: function() { var request = [ this.url, this.service, '/', this.version, '/', this.operation, '?reseller=', this.reseller, '&accountId=', this.accountId ].join(''); var thisUrl = request; if (this.callback != '') { thisUrl += '&callback=' + this.callback; } if (this.output != 'json') { thisUrl += '&output=' + this.output; } for (var i = 0; i < this.params.index.length; i++) thisUrl += '&' + this.params.index[i] + '=' + this.params[ this.params.index[i] ]; return thisUrl; } }; ApiCall.prototype.addParam = ApiCall.prototype.param; })();var SiSTeR = {}; (function(){ CarFlixWindow = { version: '1.5', autoplay: true, initialized: false, domain: "$base", imagePath: "", windowWidth: 560, windowHeight: 375, window: null, height: null, reseller: "", accountId: "", sessionId: "", branding:" vcl", deploy: true, vehicleDetailsPage: '', currentVehicleData: null, target: null, floatable: true, canSubmit: false, drag : { ie: document.all, nn6: (document.getElementById && !document.all), isdrag: false, x: 0, y: 0, tx: 0, ty: 0, dobj: null, movemouse: function(e) { if (DDC.CarFlixWindow.drag.isdrag) { DDC.CarFlixWindow.drag.dobj.style.left = DDC.CarFlixWindow.drag.nn6 ? (DDC.CarFlixWindow.drag.tx + e.clientX - DDC.CarFlixWindow.drag.x)+"px" : DDC.CarFlixWindow.drag.tx + event.clientX - DDC.CarFlixWindow.drag.x; DDC.CarFlixWindow.drag.dobj.style.top = DDC.CarFlixWindow.drag.nn6 ? (DDC.CarFlixWindow.drag.ty + e.clientY - DDC.CarFlixWindow.drag.y)+"px" : DDC.CarFlixWindow.drag.ty + event.clientY - DDC.CarFlixWindow.drag.y; if( (parseFloat(DDC.CarFlixWindow.drag.dobj.style.left) < 0) || (parseFloat(DDC.CarFlixWindow.drag.dobj.style.top) < 60) ) { DDC.CarFlixWindow.drag.isdrag = false; if( parseFloat(DDC.CarFlixWindow.drag.dobj.style.left) < 0 ) { DDC.CarFlixWindow.drag.dobj.style.left = DDC.CarFlixWindow.drag.nn6 ? "0px":0; } else { DDC.CarFlixWindow.drag.dobj.style.top = DDC.CarFlixWindow.drag.nn6 ? "60px":60; } } return false; } }, selectmouse: function(e) { var fobj = DDC.CarFlixWindow.drag.nn6 ? e.target : event.srcElement; var topelement = DDC.CarFlixWindow.drag.nn6 ? "HTML" : "BODY"; while (fobj.tagName != topelement && fobj.className != "dragme") { fobj = DDC.CarFlixWindow.drag.nn6 ? fobj.parentNode : fobj.parentElement; } if (fobj.className=="dragme") { DDC.CarFlixWindow.drag.isdrag = true; DDC.CarFlixWindow.drag.dobj = fobj; DDC.CarFlixWindow.drag.tx = parseInt(DDC.CarFlixWindow.drag.dobj.style.left+0); DDC.CarFlixWindow.drag.ty = parseInt(DDC.CarFlixWindow.drag.dobj.style.top+0); DDC.CarFlixWindow.drag.x = DDC.CarFlixWindow.drag.nn6 ? e.clientX : event.clientX; DDC.CarFlixWindow.drag.y = DDC.CarFlixWindow.drag.nn6 ? e.clientY : event.clientY; document.onmousemove = DDC.CarFlixWindow.drag.movemouse; return false; } } }, init: function (settings) { if( settings.deploy != undefined ) { Api.settings.deploy = settings.deploy; } Api.extend(this,settings); if( this.vehicleDetailsPage == '' ) { this.vehicleDetailsPage = "http://"+ this.accountId + ".vip.videocarlot.tv/used-inventory/vehicle-details.htm?vehicleId="; } Api.getStyle( this.domain + '/toolkit/carflix/css/window.css' ); this.imagePath = this.domain+"/toolkit/carflix/img"; //set country flag for units of measurement if (this.locale) { this.countryCode = this.locale.split('_')[1]; } SiSTeR.Config = { autoplay: this.autoplay, displaylogo: false, pubid: "3DF" } var carflix = document.createElement('div'); carflix.setAttribute('id', 'carFlixWindow'); carflix.className = "dragme"; carflix.style.position = 'absolute'; carflix.style.display = 'none'; carflix.style.width = this.windowWidth+'px'; carflix.style.height = this.windowHeight+'px'; carflix.style.top = '200px'; carflix.style.left = '200px'; this.window = carflix; // begin generated content from /carflix/window-layout.vm carflix.innerHTML = '
' +
'
' +
'' +
'
'+data.options[i]+'