Streaming live at 10am (PST)

Webflow parser rejects custom code in footer


#1

Hi!

Since the new Dashboard was pushed into action, I having a big trouble of adding or changing my custom codes.
Apparently there's som issues stating "Line 19 column 11: Named entity expected. Got none.". I had this before too, but my codes worked and still works perfectly fine...but I can't edit it.

What to do?

t


#2

probably will do nothing - but you have tried removing lines 18 / 19 ?

From the image - it seems lines 18 and 19 are "blank".

Perhaps delete them and re-add a blank line.... may be a hidden character in there ?


#3

Hi @StevenP can you paste the line of code from your body here to the post, and then I can give you a slightly modified version of entering that to custom code, by using the document.write method. Cheers, Dave


#5

Don't know if this code is showing up correctly...how are you suppose to post it? Blockquotes?


#6

Select all the code then select the code toggle for preformatted code text... smile


#7
<script>
$(document).ready(function() {
  var mapState = true;

  $('.togglemapbutton').click(function(e) {
    e.preventDefault();

    if(mapState) {
      $(this).html('Hide map');
      mapState = false;
    } else {
      $(this).html('Show map');
      mapState = true;
    }
  });
});
</script>


<script src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDGh_pfKG3qM_zNbOWqolFkGsuV9DoCXIM&sensor&sensor=false&extension=.js'></script> 

<script> 
    google.maps.event.addDomListener(window, 'load', init);
    var map;
    function init() {
        var mapOptions = {
            center: new google.maps.LatLng(61.736728,17.1178),
            zoom: 13,
            zoomControl: false,
            disableDoubleClickZoom: true,
            mapTypeControl: false,
            scaleControl: false,
            scrollwheel: true,
            panControl: false,
            streetViewControl: false,
            draggable : true,
            overviewMapControl: false,
            overviewMapControlOptions: {
                opened: false,
            },
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            styles: [ { "stylers": [ { "saturation": -100 } ] },{ "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#0099dd" } ] },{ "elementType": "labels", "stylers": [ { "visibility": "off" } ] },{ "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [ { "color": "#aadd55" } ] },{ "featureType": "road.highway", "elementType": "labels", "stylers": [ { "visibility": "on" } ] },{ "featureType": "road.arterial", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] },{ "featureType": "road.local", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] },{ } ],
        }
        var mapElement = document.getElementById('Map');
        var map = new google.maps.Map(mapElement, mapOptions);
        var locations = [
['Steven Persson', 'I\'m a graphic designer working with responsive web, branding and prints. I\'m currently available for freelance projects or a full time job.', '070 27 50 644', 'stevenpersson@gmail.com', 'stevenpersson.com', 61.74359039999999, 17.1249836, 'https://mapbuildr.com/assets/img/markers/hollow-pin-black.png']
        ];
        for (i = 0; i < locations.length; i++) {
			if (locations[i][1] =='undefined'){ description ='';} else { description = locations[i][1];}
			if (locations[i][2] =='undefined'){ telephone ='';} else { telephone = locations[i][2];}
			if (locations[i][3] =='undefined'){ email ='';} else { email = locations[i][3];}
           if (locations[i][4] =='undefined'){ web ='';} else { web = locations[i][4];}
           if (locations[i][7] =='undefined'){ markericon ='';} else { markericon = locations[i][7];}
            marker = new google.maps.Marker({
                icon: markericon,
                position: new google.maps.LatLng(locations[i][5], locations[i][6]),
                map: map,
                title: locations[i][0],
                desc: description,
                tel: telephone,
                email: email,
                web: web
            });
     }

}
</script>

#8

Hi @StevenP, thanks for your quick response. The issue seems to be the script on line 20 that is being called, there is some code there our parser does not like. The workaround is listed below, backup and copy your existing code to somewhere so you can get it back, and then replace the code in the Footer with the following code, save changes and republish. See if that helps smile Let me know, Cheers, Dave

<script>
$(document).ready(function() {
  var mapState = true;

  $('.togglemapbutton').click(function(e) {
    e.preventDefault();

    if(mapState) {
      $(this).html('Hide map');
      mapState = false;
    } else {
      $(this).html('Show map');
      mapState = true;
    }
  });
});
</script>

<script language="JavaScript">
<!--
document.writeln("<script src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDGh_pfKG3qM_zNbOWqolFkGsuV9DoCXIM&sensor&sensor=false&extension=.js'></script> ");
//-->
</script>


<script> 
    google.maps.event.addDomListener(window, 'load', init);
    var map;
    function init() {
        var mapOptions = {
            center: new google.maps.LatLng(61.736728,17.1178),
            zoom: 13,
            zoomControl: false,
            disableDoubleClickZoom: true,
            mapTypeControl: false,
            scaleControl: false,
            scrollwheel: true,
            panControl: false,
            streetViewControl: false,
            draggable : true,
            overviewMapControl: false,
            overviewMapControlOptions: {
                opened: false,
            },
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            styles: [ { "stylers": [ { "saturation": -100 } ] },{ "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#0099dd" } ] },{ "elementType": "labels", "stylers": [ { "visibility": "off" } ] },{ "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [ { "color": "#aadd55" } ] },{ "featureType": "road.highway", "elementType": "labels", "stylers": [ { "visibility": "on" } ] },{ "featureType": "road.arterial", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] },{ "featureType": "road.local", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] },{ } ],
        }
        var mapElement = document.getElementById('Map');
        var map = new google.maps.Map(mapElement, mapOptions);
        var locations = [
['Steven Persson', 'I\'m a graphic designer working with responsive web, branding and prints. I\'m currently available for freelance projects or a full time job.', '070 27 50 644', 'stevenpersson@gmail.com', 'stevenpersson.com', 61.74359039999999, 17.1249836, 'https://mapbuildr.com/assets/img/markers/hollow-pin-black.png']
        ];
        for (i = 0; i < locations.length; i++) {
			if (locations[i][1] =='undefined'){ description ='';} else { description = locations[i][1];}
			if (locations[i][2] =='undefined'){ telephone ='';} else { telephone = locations[i][2];}
			if (locations[i][3] =='undefined'){ email ='';} else { email = locations[i][3];}
           if (locations[i][4] =='undefined'){ web ='';} else { web = locations[i][4];}
           if (locations[i][7] =='undefined'){ markericon ='';} else { markericon = locations[i][7];}
            marker = new google.maps.Marker({
                icon: markericon,
                position: new google.maps.LatLng(locations[i][5], locations[i][6]),
                map: map,
                title: locations[i][0],
                desc: description,
                tel: telephone,
                email: email,
                web: web
            });
     }

}
</script>

#9

Thanks for your quick response in return..:)

I seem to get that error everytime I put in a script-code. That means that I got to have my code re-written each time I'm putting anything in there in order to edit the code later on?


#10

What did you do specifically @cyberdave?

Just added the:

<!--
document.writeln(
//-->

?

(So I know what to add when I need to put some custom code and doing it on my own...)


#11

Hi @StevenP, whenever you get a script error in the Footer Custom code section, if the code is valid, but is rejected because our Parser cannot handle it, then you can use the document.writeln method to write out just that part of the script at run time.

This is the part I changed:

<script language="JavaScript">
<!--
document.writeln("<script src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDGh_pfKG3qM_zNbOWqolFkGsuV9DoCXIM&sensor&sensor=false&extension=.js'></script> ");
//-->
</script>

To load this original script line:

<script src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDGh_pfKG3qM_zNbOWqolFkGsuV9DoCXIM&sensor&sensor=false&extension=.js'></script>

This does essentially the same thing as if you were able to paste in the code without error, it just creates that offending script in the code at page load, instead of at design time in the Custom Code panel.

I hope that makes sense, if not, let me know smile Cheers, Dave


#12

Thanks a lot for a crystal clear reply on the matter! smile


#13