Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » JavaScript hi-jacking blog page

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2429 Views
  • Mans
    Avatar
    Community Member
    21 Posts

    JavaScript hi-jacking blog page Link to this post

    Hi all,

    Pages based on the BlogEntry template have a large lump of JavaScript code inserted right after the body tag. Where the heck does this come from?

    The code looks like this:

    <script type="text/javascript" src="http://www.XXXX.se/jsparty/behaviour.js?m=1236331738"></script><script type="text/javascript" src="http://www.typodesign.se/jsparty/prototype.js?m=1236331861"></script><script type="text/javascript" src="http://www.typodesign.se/jsparty/scriptaculous/effects.js?m=1236331863"></script><script type="text/javascript" src="http://www.typodesign.se/cms/javascript/PageCommentInterface.js?m=1236332021"></script><script type="text/javascript" src="http://www.typodesign.se/sapphire/javascript/Validator.js?m=1236331701"></script><script type="text/javascript" src="http://www.typodesign.se/jsparty/prototype_improvements.js?m=1236331862"></script><script type="text/javascript" src="http://www.typodesign.se/sapphire/javascript/i18n.js?m=1236331699"></script><script type="text/javascript" src="http://www.typodesign.se/cms/javascript/lang/en_US.js?m=1236332020"></script><script type="text/javascript" src="http://www.typodesign.se/sapphire/javascript/lang/en_US.js?m=1236331699"></script><script type="text/javascript">//<![CDATA[
    Behaviour.register({
       '#PageCommentInterface_Form_PostCommentForm': {
          validate : function(fromAnOnBlur) {
             initialiseForm(this, fromAnOnBlur);
             
             
             var error = hasHadFormError();
             if(!error && fromAnOnBlur) clearErrorMessage(fromAnOnBlur);
             
             return !error;
          },
          onsubmit : function() {
             if(typeof this.bypassValidation == 'undefined' || !this.bypassValidation) return this.validate();
          }
       },
       '#PageCommentInterface_Form_PostCommentForm input' : {
          initialise: function() {
             if(!this.old_onblur) this.old_onblur = function() { return true; }
             if(!this.old_onfocus) this.old_onfocus = function() { return true; }
          },
          onblur : function() {
             if(this.old_onblur()) {
                // Don't perform instant validation for CalendarDateField fields; it creates usability wierdness.
                if(this.parentNode.className.indexOf('calendardate') == -1 || this.value) {
                   return $('PageCommentInterface_Form_PostCommentForm').validate(this);
                } else {
                   return true;
                }
             }
          }
       },
       '#PageCommentInterface_Form_PostCommentForm select' : {
          initialise: function() {
             if(!this.old_onblur) this.old_onblur = function() { return true; }
          },
          onblur : function() {
             if(this.old_onblur()) {
                return $('PageCommentInterface_Form_PostCommentForm').validate(this);
             }
          }
       }
    });

    //]]></script>

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    Thats for the page comment form - functionality of AJAX commenting and the custom validation

  • Mans
    Avatar
    Community Member
    21 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    OK, but where does it come from? My comment form is of the simple variety - no AJAX that I know of. Do I still need it? If not, how do I get rid of it? The code seems to interfere with other JavaScript on my page.

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    AJAX commenting is on by default. You can disable it by adding this in your _config.php file.

    PageCommentInterface::set_ajax_commenting(false);

    It still might include the JS for the form validation though.

  • Mans
    Avatar
    Community Member
    21 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    Sorry, but the whole site shows up blank when I add that line. (Don't you just love php error handling!)

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    Woops got the method wrong its set_use_ajax_commenting(false) - note the set_.

    Have you got error_reporting set to all? PHP should normally come back with at least a helpful message!

  • Mans
    Avatar
    Community Member
    21 Posts

    Re: JavaScript hi-jacking blog page Link to this post

    Again sorry, but the result it the same: the pages are shown blank. I also looked for set_use_ajax_commenting (and variations thereof) here: http://api.silverstripe.com/sapphire/view/PageCommentInterface.html, but couldn't find anything.

    I apologise if I'm missing someting obvious. This is not my area of expertise.

    2429 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.