Global.js fails to run on Chrome/Safari

Report issues with Enuuk Auction Platform or Mods here - remember to raise a ticket with phpauction.net as well
Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Global.js fails to run on Chrome/Safari

Post by RWAP » Tue May 29, 2012 10:06 am

Some of my users have complained that they could not see any errors when trying to register on my site in Google Chrome, or Safari browsers.

After checking, the issue arises if Google Maps is disabled - both Chrome and Safari report an error in global.js that GBrowserIsCompatible is undefined and then do not process the remainder of global.js (including the form trapping and reporting errors!)

Luckily the solution is fairly simple:

The line in global.js (showMap function):

Code: Select all

    if (GBrowserIsCompatible()) {
Needs to read:

Code: Select all

    if (typeof(GBrowserIsCompatible)!="undefined" && GBrowserIsCompatible()) {

bamse
Posts: 220
Joined: Mon Feb 06, 2012 12:05 pm
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by bamse » Thu Jun 07, 2012 5:15 pm

That's for which version? I don't seem to have that line in 2.11.

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by RWAP » Thu Jun 07, 2012 8:48 pm

bamse wrote:That's for which version? I don't seem to have that line in 2.11.
Ah - this seems to only affect up to v2.10 - v2.11 uses a new google maps API - although it does remind you to check that global.js works OK in Safari !!

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by RWAP » Fri Jan 25, 2013 10:43 am

This is again broken in the latest global.js, where they use the newest Google Maps API.

The problem is only apparent when you do not enable google maps.

If google maps is disabled, then the javascript breaks with variable google not defined

The function ShowMap() in global.js needs to read:

Code: Select all

function showMap(address)
{   
    var geocoder;
    var map;
    if (typeof google !== 'undefined') {
        geocoder = new google.maps.Geocoder();
        //general options for the map
        var myOptions = {
            zoom: 13,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map = new google.maps.Map(document.getElementById("map"), myOptions);
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
            }else{
                closeAllTabsOpenFirst();
                //alert("Geocode was not successful for the following reason: " + status);
            }
        });  
    }
}

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by RWAP » Tue Sep 03, 2013 2:25 pm

There are similar problems with global.js on the registration page in Google Chrome if you have not set up the facebook login application.

The issue is the section of the code in global.js:

Code: Select all

    // Login via facebook
    if(/userForm/.test(template)){
        var fbAppId = $("#fbAppId").val();
        window.fbAsyncInit = function() {
                FB.init({
                    appId      : fbAppId,
                    status     : true, 
                    cookie     : true,
                    xfbml      : true,
                    oauth      : true
                });
                
                FB.Event.subscribe('auth.login', function(response) {
                    window.location.reload();
                });
            };
            
            (function(d){
                var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                d.getElementsByTagName('head')[0].appendChild(js);
            }(document));
    }
This needs to be changed to:

Code: Select all

    // Login via facebook
    if(/userForm/.test(template)){
        var fbAppId = $("#fbAppId").val();
        if (typeof fbAppId !== 'undefined') {
            window.fbAsyncInit = function() {
                    FB.init({
                        appId      : fbAppId,
                        status     : true, 
                        cookie     : true,
                        xfbml      : true,
                        oauth      : true
                    });
                    
                    FB.Event.subscribe('auth.login', function(response) {
                        window.location.reload();
                    });
                };
                
                (function(d){
                    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                    js = d.createElement('script'); js.id = id; js.async = true;
                    js.src = "//connect.facebook.net/en_US/all.js";
                    d.getElementsByTagName('head')[0].appendChild(js);
                }(document));
        }
    } 

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by RWAP » Tue Sep 03, 2013 2:44 pm

Hmm having fixed the facebook one, I cannot replicate the issue with the google maps - so maybe it was a knock on effect!

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Global.js fails to run on Chrome/Safari

Post by RWAP » Fri Sep 06, 2013 11:55 am

Aha - I have found the issue which originally caused the problem for me with google maps.

It only happens on the user registration / edit profile page and looks to be dependent on the version of tinyMCE and/or jQuery being used.

A better fix for the issue with Google Maps is not to alter the showMap() function in global.js, but instead to change the lines:

Code: Select all

    // google map init
    if(typeof(address)!="undefined" && typeof(address)=='string'){
        showMap(address);
    }
to read:

Code: Select all

    // google map init
    if(typeof(address)=='string' && typeof(google)!="undefined" ){
        showMap(address);
    }
and then further down, change:

Code: Select all

    //TABS in offerDetailsX
    //Default Action
    if(typeof(address)=="undefined"){
        // there is no Google map, so we can hide the tabs directly, otherwise showMap() will do it
        closeAllTabsOpenFirst();
    }
to read:

Code: Select all

    //TABS in offerDetailsX
    //Default Action
    if(typeof(address)!="string" || typeof(google)=="undefined"){
        // there is no Google map, so we can hide the tabs directly, otherwise showMap() will do it
        closeAllTabsOpenFirst();
    }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest