WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: ICS Calendar] unterminated string literal (19 posts)

  1. sebestenyb
    Member
    Posted 6 years ago #

    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?

  2. chrisben
    Member
    Posted 6 years ago #

    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

  3. josediogenes
    Member
    Posted 6 years ago #

    So you figured out how to fix the problem ?

  4. sebestenyb
    Member
    Posted 6 years ago #

    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 :)

  5. grigory
    Member
    Posted 6 years ago #

    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:
    http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_base64_decode/
    For base64_decode you will also need utf8_decode, get it here: http://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 ;)

  6. mm911
    Member
    Posted 6 years ago #

    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!

  7. elizabethrichardson
    Member
    Posted 6 years ago #

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

    Elizabeth

  8. grigory
    Member
    Posted 6 years ago #

    Hello, and sorry for such a cryptic explanation.

    More specific instructions:

    1) Get new cal-functions.php here: http://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:
    http://localhostr.com/files/44a60a/utf8_decode.js
    and
    http://localhostr.com/files/49d883/base64_decode.js

    4) Enjoy!

  9. mm911
    Member
    Posted 6 years ago #

    Thanks very much! It works.

  10. blpiltin
    Member
    Posted 6 years ago #

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

  11. blpiltin
    Member
    Posted 6 years ago #

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

  12. opicron
    Member
    Posted 6 years ago #

    Thank you for the quick fix!

  13. oh2bWP
    Member
    Posted 6 years ago #

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

  14. anassirk
    Member
    Posted 6 years ago #

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

  15. dolfelt
    Member
    Posted 5 years ago #

    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!");
    	//});
    	';
  16. givenatelove
    Member
    Posted 5 years ago #

    @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.

  17. givenatelove
    Member
    Posted 5 years ago #

    bah.. spoke too soon. previous/next does indeed change months, but no events appear. I'm using WP 2.7-RC1

  18. dolfelt
    Member
    Posted 5 years ago #

    @givenatelove
    Try using the new version (v1.2.4). This should fix your problem as it bypasses using so many $_GET variables. It keeps all the information internal which also helps to hide your ICS file URL as well as other settings.

    Give it a try and let me know what happens.

  19. drivenmg
    Member
    Posted 5 years ago #

    ooooooookay, i've tried all the possibilities. I'm using the newest version w/ 2.7.1 - any clue on getting this fixed?

Topic Closed

This topic has been closed to new replies.

About this Topic