Forums › Geo Job Manager › Geo Job Manager plugin throwing error
- This topic has 13 replies, 2 voices, and was last updated 7 years, 7 months ago by
Eyal Fitoussi.
-
AuthorPosts
-
September 26, 2014 at 2:41 pm #30943
Sembisoft Limited
MemberHi,
I have installed GEO Job Manager to display google map. but it is showing Javascript Syntax error ” }); “.
Here is below link for your reference.
http://devtest.hcrltd.co.uk/job/healthcare-assistants-loughborough/Please let me know anything require from my side.
Thanks,
September 30, 2014 at 11:36 am #30956Eyal Fitoussi
MemberThank you for the purchase Sembisoft.
Looking at the error in the console it seems that there are
tags that being automatically generated most likely by the theme that you are using.
Would you please change the theme you are using to a default WordPress theme and tell me if the problem is gone?
Thank you
October 2, 2014 at 10:25 pm #30955Sembisoft Limited
MemberHi,
You are right, it is something to do with the theme. I switched to the twenty fourteen theme and it works fine.
On closer inspection, with our theme, it seems that there are some <p> tags being inserted into the google maps script by the theme. Do you know how we can stop this? I tried to use the Disable Automatic p Tags plugin (https://wordpress.org/plugins/disable-automatic-p-tags/) but this did not stop them being inserted into the google maps script.
Would really appreciate any help you can give on troubleshooting this.
Thanks
October 2, 2014 at 10:32 pm #30954Eyal Fitoussi
MemberTry the below:
1) Open the file geo-job-manager/includes/gjm-funcitons.php
2) replace the lines 988 – 1006 which should be :
123456789101112131415161718?><script>jQuery(document).ready(function() {var latLng = new google.maps.LatLng('<?php echo $lat; ?>', '<?php echo $lng; ?>');clMap = new google.maps.Map(document.getElementById('<?php echo $this->prefix; ?>-single-map'), {scrollwheel: '<?php echo $this->settings['single_page'][$this->prefix.'_scroll_wheel']; ?>',zoom: 12,mapTypeId: google.maps.MapTypeId['<?php echo $this->settings['single_page'][$this->prefix.'_map_type']; ?>'],center: latLng});marker = new google.maps.Marker({position: latLng,map: clMap,});});</script><?phpwith the below:
12345678910111213141516echo "<script>jQuery(document).ready(function() {var latLng = new google.maps.LatLng('{$lat}', '{$lng}');clMap = new google.maps.Map(document.getElementById('{$this->prefix}-single-map'), {scrollwheel: '{$this->settings['single_page'][$this->prefix.'_scroll_wheel']}',zoom: 12,mapTypeId: google.maps.MapTypeId['{$this->settings['single_page'][$this->prefix.'_map_type']}'],center: latLng});marker = new google.maps.Marker({position: latLng,map: clMap,});});</script>";3) save and test
October 2, 2014 at 10:40 pm #30953Sembisoft Limited
MemberHi Eyal,
Thanks for the quick reply, you are a star! That code didn’t quite work, p tags were still being inserted, but you got me pointed in the right direction. I removed all line breaks from the script so the code is now:
123echo "<script>jQuery(document).ready(function() {var latLng = new google.maps.LatLng('{$lat}', '{$lng}');clMap = new google.maps.Map(document.getElementById('{$this->prefix}-single-map'), {scrollwheel: '{$this->settings['single_page'][$this->prefix.'_scroll_wheel']}',zoom: 12,mapTypeId: google.maps.MapTypeId['{$this->settings['single_page'][$this->prefix.'_map_type']}'],center: latLng});marker = new google.maps.Marker({position: latLng,map: clMap,});});</script>";That now works.
Thanks very much for your help, much appreciated.
October 2, 2014 at 10:51 pm #30952Eyal Fitoussi
MemberMakes sense. I guess that in the lines break is where the theme “injects” the P tags.
I am glad I could help.
I will either add the fix above or a different fix for the next official release.
October 10, 2014 at 10:32 am #30951Sembisoft Limited
MemberHi Eyal,
I have another JS issue unfortunately.
I have removed the line breaks as per the previous issue from the function javascript_trigger in includes/gjm-functions.php so that the code is now:
123function javascript_trigger( $gjmMap ) {?><script> jQuery(document).ready(function($) {if ( '<?php echo $this->filters['gjm_autocomplete']; ?>' == 1 ) {$('#search_location').bind('keypress', function (e){ if(e.keyCode == 13) { $('#search_location').val( $(this).val() ); var target = $(this).closest('div.job_listings'); target.trigger('update_results', [1, false]); } });} if ('<?php echo $gjmMap; ?>' == true) { gjmMapObject = {}; removeMarkers = true; jobMarkers = []; userMarker = false; window.gjmMarkerCluster = false; gjmLocations = []; $('form.job_filters').after(gjmMap); jQuery('body').on('DOMNodeInserted', '.no_job_listings_found', function() { if (jQuery('.gjm-map-wrapper').is(':visible')) jQuery('.gjm-map-wrapper').slideToggle(); }); gjmMap = new google.maps.Map(document.getElementById('gjm-locations-map'), { scrollwheel: '<?php echo $this->filters[$this->prefix.'_scroll_wheel']; ?>', zoom: 13, mapTypeId: google.maps.MapTypeId['<?php echo $this->filters[$this->prefix.'_map_type']; ?>'], styles: false }); setTimeout(function() { ExpandControl = document.getElementById('gjm-expand-map-trigger'); gjmMap.controls[google.maps.ControlPosition.TOP_RIGHT].push(ExpandControl); ExpandControl.style.display = 'block'; }, 1000); if ( jQuery('.gjm-map-wrapper #gjm-expand-map-trigger').length ) { jQuery('.gjm-map-wrapper #gjm-expand-map-trigger').click(function() {var detachMap = jQuery(this).closest('.gjm-map-wrapper'); var center = gjmMap.getCenter(); jQuery(this).closest('.gjm-map-wrapper').toggleClass('gjm-expanded-map'); jQuery(this).toggleClass('dashicons-editor-expand').toggleClass('dashicons-editor-contract'); if ( jQuery('.gjm-map-detach').length ) {detachMap.detach().insertAfter('.gjm-map-detach form.job_filters'); jQuery(this).closest('.job_listings').removeClass('gjm-map-detach');} else {jQuery(this).closest('.job_listings').addClass('gjm-map-detach');detachMap.detach().appendTo('body');} google.maps.event.trigger(gjmMap, 'resize'); gjmMap.setCenter(center); }); } $('.load_more_jobs').on("click", function() { removeMarkers = false; }); } $('#search_location').change(function() { if ( $(".gjm-radius option:first").is(":selected") && $('#search_location').val() != '' ) { $(".gjm-radius option:last-child").attr('selected', 'selected'); } }); $('.gjm-radius, .gjm-units').change(function() { if ($('#search_location').val() == '') return; var target = $(this).closest('div.job_listings'); target.trigger('update_results', [1, false]); }); $('.gjm-orderby').change(function() { var target = $(this).closest('div.job_listings'); target.trigger('update_results', [1, false]); }); $('.gjm-locator-button').click(function() { $('#search_location').val(''); $('.gjm-locator-button').fadeToggle('fast', function() { $('.gjm-locator-loader').fadeToggle('fast'); }); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError, {timeout: 10000}); } else { alert('Sorry! Geolocation is not supported by this browser and we cannot locate you.'); } function showPosition(position) { var geocoder = new google.maps.Geocoder(); geocoder.geocode({'latLng': new google.maps.LatLng(position.coords.latitude, position.coords.longitude)}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { $('#search_location').val(results[0].formatted_address); var target = $('#search_location').closest('div.job_listings'); target.trigger('update_results', [1, false]); $('.gjm-locator-loader').fadeToggle('fast', function() { $('.gjm-locator-button').fadeToggle('fast'); }); } else { alert('Geocoder failed due to: ' + status); } }); } function showError(error) { switch (error.code) { case error.PERMISSION_DENIED: alert('User denied the request for Geolocation.'); break; case error.POSITION_UNAVAILABLE: alert('Location information is unavailable.'); break; case 3: alert('The request to get user location timed out.'); break; case error.UNKNOWN_ERROR: alert('An unknown error occurred'); break; } $('.gjm-locator-loader').fadeToggle('fast', function() { $('.gjm-locator-button').fadeToggle('fast'); }); } }); }); </script><?php}After removing the line breaks, I am no longer getting the ‘invalid token’ error, but I am now getting the following error:
12345678910111213SyntaxError: Unexpected token ILLEGAL#1 http://hcrltd.co.uk/job-listing:206:69ReferenceError: gjmMarkerCluster is not defined#9 http://hcrltd.co.uk/wp-content/plugins/geo-job-manager/assets/js/map.min.js?ver=1.5:4:6#8 http://hcrltd.co.uk/wp-content/plugins/geo-job-manager/assets/js/map.min.js?ver=1.5:4:6 gjmMapInit()#7 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:2:2616 HTMLDocument.eval (eval at ()#6 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:3:8066 HTMLDocument.n.event.dispatch()#5 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:3:4774 HTMLDocument.r.handle()#4 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:3:7167 Object.n.event.trigger()#3 http://hcrltd.co.uk/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1:2:6732 Object.e.event.trigger()#2 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:4:22446 x()#1 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?ver=1.11.0:4:26298 XMLHttpRequest.b()&host=hcrltd.co.ukYou can see the issue at the following url:
Any idea on how we can resolve this?
Thanks
October 10, 2014 at 10:41 am #30950Eyal Fitoussi
MemberHi,
This JavaScript can be a bit tricky to manager this way.Have you tried adding the below to the functions.php file of your theme?
12remove_filter( 'the_content', 'wpautop' );remove_filter( 'the_excerpt', 'wpautop' );October 10, 2014 at 10:47 am #30949Sembisoft Limited
MemberHi Eyal,
Thanks for that. I have added those lines to functions.php and the auto p tag insertion is gone, I’ll save that one for the future too.
I have reverted the function back to the original code as well now.
But unfortunately the JS error remains:
12345678910111213141516171819SyntaxError: Unexpected token ILLEGAL#1 http://hcrltd.co.uk/job-listing:294:69SyntaxError: Unexpected token }#4 http://hcrltd.co.uk/job-listing:1:63#3 Object.parse (native)#2 http://www.cqc.org.uk/sites/all/modules/custom/cqc_widget/widget.js?data-id=1-135657969&data-host=www.cqc.org.uk&c6a9a0:39:31#1 http://www.cqc.org.uk/sites/all/modules/custom/cqc_widget/widget.js?data-id=1-135657969&data-host=www.cqc.org.uk&c6a9a0:90:3ReferenceError: gjmMarkerCluster is not defined#9 http://hcrltd.co.uk/wp-content/plugins/geo-job-manager/assets/js/map.min.js?c6a9a0:4:6#8 http://hcrltd.co.uk/wp-content/plugins/geo-job-manager/assets/js/map.min.js?c6a9a0:4:6 gjmMapInit()#7 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:2:2616 HTMLDocument.eval (eval at ()#6 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:3:8066 HTMLDocument.n.event.dispatch()#5 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:3:4774 HTMLDocument.r.handle()#4 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:3:7167 Object.n.event.trigger()#3 http://hcrltd.co.uk/wp-includes/js/jquery/jquery-migrate.min.js?c6a9a0:2:6732 Object.e.event.trigger()#2 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:4:22446 x()#1 http://hcrltd.co.uk/wp-includes/js/jquery/jquery.js?c6a9a0:4:26298 XMLHttpRequest.b()&host=hcrltd.co.ukThanks
October 10, 2014 at 11:02 am #30948Eyal Fitoussi
Memberlooks like the code is messed up a bit:
1if ( $(".gjm-radius option:first").is(":selected") && $('#search_location').val() != '' ) {the characters #038;& should be &&
October 10, 2014 at 11:19 am #30947Sembisoft Limited
MemberHi Eyal,
Where were you seeing the #038? I checked the includes/gjm-functions.php file and it has && in that line of code. I even removed the && and added in again. Could you please point me to where you are seeing the #038; please?
Thanks
October 10, 2014 at 11:22 am #30946Sembisoft Limited
MemberHi Eyal,
Ok, I found it, saw it in the page when I went to ‘view source’. I removed the following line from my themes functions.php
add_filter('the_content', 'wptexturize', 15);
That seems to have sorted it out.
Thanks for your help with this. Much appreciated.
October 10, 2014 at 11:23 am #30945Eyal Fitoussi
MemberThis is what I see in the console.
October 10, 2014 at 11:23 am #30944Eyal Fitoussi
MemberAwesome!
You are welcome.
-
AuthorPosts
You must be logged in to reply to this topic.