Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

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

JavaScript hi-jacking blog page


Go to End
Reply


7 Posts   2832 Views

Avatar
Mans

Community Member, 21 Posts

30 April 2009 at 8:19pm

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>

Avatar
Willr

Forum Moderator, 5521 Posts

30 April 2009 at 10:18pm

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

Avatar
Mans

Community Member, 21 Posts

30 April 2009 at 10:30pm

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.

Avatar
Willr

Forum Moderator, 5521 Posts

1 May 2009 at 4:14pm

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.

Avatar
Mans

Community Member, 21 Posts

4 May 2009 at 8:16pm

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

Avatar
Willr

Forum Moderator, 5521 Posts

4 May 2009 at 8:27pm

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!

Avatar
Mans

Community Member, 21 Posts

4 May 2009 at 11:45pm

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.