From 94c2b213102c2bfc3bb2c40c3e421db03054bfdf Mon Sep 17 00:00:00 2001 From: Zach Wise Date: Mon, 2 Apr 2012 00:17:45 -0500 Subject: [PATCH] Still fixing the IE json issue --- examples/embed.html | 4 ++-- source/js/VMM.js | 7 ++++++- source/js/timeline.js | 29 ++++++++++++++++++----------- timeline.js | 36 ++++++++++++++++++++++++------------ 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/examples/embed.html b/examples/embed.html index 43dddec..bc505a5 100644 --- a/examples/embed.html +++ b/examples/embed.html @@ -21,8 +21,8 @@ width: 900, height: 700, source: 'https://docs.google.com/a/digitalartwork.net/spreadsheet/ccc?hl=en_US&key=0Agl_Dv6iEbDadGRwZjJSRTR4RHJpanE2U3lkb0lyYUE&rm=full#gid=0', - css: 'http://veritetimeline.appspot.com/latest/timeline.css', - js: 'http://veritetimeline.appspot.com/latest/timeline-min.js' + css: '../timeline.css', + js: '../timeline.js' } diff --git a/source/js/VMM.js b/source/js/VMM.js index 32f062a..b6a57b4 100644 --- a/source/js/VMM.js +++ b/source/js/VMM.js @@ -347,7 +347,12 @@ if (typeof VMM == 'undefined') { $.getJSON(url, the_function); } } - + // VMM.parseJSON(the_json); + VMM.parseJSON = function(the_json) { + if( typeof( jQuery ) != 'undefined' ){ + return $.parseJSON(the_json); + } + } // ADD ELEMENT AND RETURN IT // VMM.appendAndGetElement(append_to_element, tag, cName, content, [attrib]); VMM.appendAndGetElement = function(append_to_element, tag, cName, content) { diff --git a/source/js/timeline.js b/source/js/timeline.js index 3fbd18f..66b9daa 100755 --- a/source/js/timeline.js +++ b/source/js/timeline.js @@ -119,12 +119,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { /* CHECK FOR IE7 ================================================== */ var ie7 = false; - - if ( $.browser.msie ) { - if ( parseInt($.browser.version, 10) == 7) { + if (VMM.Browser.browser == "MSIE") { + if ( parseInt(VMM.Browser.version, 10) == 7) { ie7 = true; } } + /* VER @@ -1973,17 +1973,24 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { getData: function(raw_data) { var _key = VMM.Util.getUrlVars(raw_data)["key"]; var _url = "https://spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json"; - - if ( $.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { + + if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 8 && window.XDomainRequest) { // Use Microsoft XDR - var xdr = new XDomainRequest(); - xdr.open("get", _url); - xdr.onload = function() { - var json = $.parseJSON( xdr.responseText ); - VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData( json ); + // going to move this to VMM.getJSON + trace("it's ie"); + var ie_xdr = new XDomainRequest(); + var _url = "//spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json"; + + ie_xdr.open("get", _url); + ie_xdr.onload = function() { + var ie_j = {}; + var ie_json = VMM.parseJSON(ie_xdr.responseText); + VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData(ie_json); + } - xdr.send(); + ie_xdr.send(); } else { + trace("not ie"); VMM.getJSON(_url, VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData); } diff --git a/timeline.js b/timeline.js index e6fbdb0..ac8ee3d 100644 --- a/timeline.js +++ b/timeline.js @@ -347,7 +347,12 @@ if (typeof VMM == 'undefined') { $.getJSON(url, the_function); } } - + // VMM.parseJSON(the_json); + VMM.parseJSON = function(the_json) { + if( typeof( jQuery ) != 'undefined' ){ + return $.parseJSON(the_json); + } + } // ADD ELEMENT AND RETURN IT // VMM.appendAndGetElement(append_to_element, tag, cName, content, [attrib]); VMM.appendAndGetElement = function(append_to_element, tag, cName, content) { @@ -3598,12 +3603,12 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { /* CHECK FOR IE7 ================================================== */ var ie7 = false; - - if ( $.browser.msie ) { - if ( parseInt($.browser.version, 10) == 7) { + if (VMM.Browser.browser == "MSIE") { + if ( parseInt(VMM.Browser.version, 10) == 7) { ie7 = true; } } + /* VER @@ -5452,17 +5457,24 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { getData: function(raw_data) { var _key = VMM.Util.getUrlVars(raw_data)["key"]; var _url = "https://spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json"; - - if ( $.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) { + + if ( VMM.Browser.browser == "Explorer" && parseInt(VMM.Browser.version, 10) >= 8 && window.XDomainRequest) { // Use Microsoft XDR - var xdr = new XDomainRequest(); - xdr.open("get", _url); - xdr.onload = function() { - var json = $.parseJSON( xdr.responseText ); - VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData( json ); + // going to move this to VMM.getJSON + trace("it's ie"); + var ie_xdr = new XDomainRequest(); + var _url = "//spreadsheets.google.com/feeds/list/" + _key + "/od6/public/values?alt=json"; + + ie_xdr.open("get", _url); + ie_xdr.onload = function() { + var ie_j = {}; + var ie_json = VMM.parseJSON(ie_xdr.responseText); + VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData(ie_json); + } - xdr.send(); + ie_xdr.send(); } else { + trace("not ie"); VMM.getJSON(_url, VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData); }