• Hi

    I got an “unterminated string literal” error message at the following part:

    56 jQuery(document).ready(function() {
    57 jQuery("a.ics-nav-button").click(function() {
    58 jQuery.get("

    in the cal-functions.php file’s line 21
    jQuery.get("' . ICSCALENDAR_URLPATH . 'ajax-load.php?showMonth="+jQuery(this).attr("month")+"'.$urlString.'", function(data) {

    and none of the next/previous month buttons works
    any idea, what’s wrong?

Viewing 15 replies - 1 through 15 (of 18 total)
  • I’m getting the same problem,

    I put an extra “in at the end of $urlString.'”, so now it reads

    jQuery.get("' . ICSCALENDAR_URLPATH . 'ajax-load.php?showMonth="+jQuery(this).attr("month")+"'.$urlString.'"", function(data) {

    Now I see that, in the function, the Quotes are being replaced with HTML entities.
    &#8221

    So you figured out how to fix the problem ?

    Thread Starter sebestenyb

    (@sebestenyb)

    no, for some reason if that JQuery string is too long, the special characters will be replaced by html entities. if you shorten the line, aka remove the $urlString from the code, it will show correctly the quote – but then the plugin won’t work ??

    Fixing this error is not hard, but it took me almost a good hour of poking around and angrily banging on my keyboard ??

    jQuery.get("' . ICSCALENDAR_URLPATH . 'ajax-load.php?showMonth="+jQuery(this).attr("month")+base64_decode("'.base64_encode($urlString).'"), function(data) {

    And that should work fine ?? What we did here is encoded our long $urlString in base64 and that is what JavaScript now sees, the encoded string. Once user clicks on the next/prev. buttons, that string gets decoded by base64_decode function.

    Of course, base64_decode is not an actual function in javascript. Here is where to get one:
    https://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_base64_decode/
    For base64_decode you will also need utf8_decode, get it here: https://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_utf8_decode/

    I hope this helps ??

    To the author: this will be a good thing to include in the next release ??

    I am not much of a php expert…could you provide more details on how to add the base64_decode code and the utf8_decode code? Or better yet, could someone (the plug-in author perhaps?) post a new version of the cal-functions.php file? I love this plugin but the Next and Previous month buttons not working is a pretty major bug.

    Thanks for the great work!

    Like mm911, I’ would also appreciate a hand to get this fixed. Terrific plugin though.

    Elizabeth

    Hello, and sorry for such a cryptic explanation.

    More specific instructions:

    1) Get new cal-functions.php here: https://localhostr.com/files/bc96ab/cal-functions.php

    2) Replace existing cal-functions.php with this new one

    3) Get following two files and place them into the ICS Calendar plugin directory:
    https://localhostr.com/files/44a60a/utf8_decode.js
    and
    https://localhostr.com/files/49d883/base64_decode.js

    4) Enjoy!

    Thanks very much! It works.

    I can’t get it to work even after applying those patches. Anyone else having the same problem? Thanks. -Brian

    … Ok, it’s working now, don’t know what I did wrong… anyway, thanks for the fix and God bless you. -Brian

    Thank you for the quick fix!

    Is this the same problem that is discussed here?
    https://dratulgarg.com/2008/07/29/ics-calendar-plugin/

    @grigory
    Thank you very much!
    It’s working for me.

    dolfelt

    (@dolfelt)

    I have fixed this issue and will upload v1.2 later today. The problem was with the long string in the jQuery ajax function. I am not sure why that is an issue.

    However, the way grigory fixed the problem is not ideal. What I ended up doing is modifying the PHP to print out a Javascript Object then used that in the AJAX function. This seems to have cleared up the issue without the need for extra include files.

    Enjoy:

    $calContent = '<script type="text/javascript">
    	jQuery(document).ready(function() {
    		';
    		$urlArray = '';
    		$calContent .= 'var options = {';
    		foreach($options as $k=>$o) {
    			$urlArray[] = '"'.$k.'" : \''.$o.'\'';
    		}
    		$calContent .= implode(", \n",$urlArray);
    		$calContent .= '};';
    $calContent .= '				jQuery("a.ics-nav-button").click(function() {
    			jQuery.get("' . ICSCALENDAR_URLPATH . 'ajax-load.php?showMonth="+jQuery(this).attr("month")+"", options, function(data) {
    				jQuery("#ics-calendar-uid > div").unbind();
    				jQuery().unbind("mousemove");
    				jQuery("#ics-calendar-uid").html(data);
    			});
    		});
    	});
    	//jQuery(window).resize(function(){
    	//	alert("Stop it!");
    	//});
    	';

    @dolfelt
    I tried v1.2.2 and still couldn’t get previous/next to work. But I must say thanks anyway because the plugin is exactly what I needed. (you did create it, yes?)

    @grigory
    Your method got it to work. Thanks.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Plugin: ICS Calendar] unterminated string literal’ is closed to new replies.