Opened 12 years ago

Closed 11 years ago

#2085 closed Bug (invalid)

Error in JS with unknown function at time of unload.

Reported by: Phil Collins Owned by:
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version: SVN (FCKeditor) - Retired
Keywords: Pending WorksForMe Cc:

Description

In FCKeditor.body.php there is a javascript condition to remove an event listener. The problem is you are removing a call to a function before the function has been declared. This causes an error in FF.

The original code:

// Remove the mwSetupToolbar onload hook to avoid a JavaScript error with FF.
if ( window.removeEventListener )
	window.removeEventListener( 'load', mwSetupToolbar, false ) ;
else if ( window.detachEvent )
	window.detachEvent( 'onload', mwSetupToolbar ) ;

mwSetupToolbar = function() { return false ; } ;

As you can see the call to define mwSetupToolbar is below the condition to remove the event listener which would call the function. At the time of checking the condition the browser knows nothing of the function.

The amended code:

mwSetupToolbar = function() { return false ; } ;

// Remove the mwSetupToolbar onload hook to avoid a JavaScript error with FF.
if ( window.removeEventListener )
	window.removeEventListener( 'load', mwSetupToolbar, false ) ;
else if ( window.detachEvent )
	window.detachEvent( 'onload', mwSetupToolbar ) ;

The new code produces no errors and now allows the FCKeditor to be built correctly.

Kind regards and many thanks,

Phil Collins phil@…

Change History (8)

comment:1 Changed 12 years ago by Wojciech Olchawa

Keywords: Confirmed HasPatch added
Version: SVN

comment:2 Changed 12 years ago by Wiktor Walc

Keywords: Pending WorksForMe added; Confirmed HasPatch removed

Everything seems to work fine on my computer (MW 1.12 + Monobook skin + latest version FCKeditor extension)

After moving mwSetupToolbar code as suggested I get in FF 2.0.0.13:

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: http://127.0.0.1/mw12/skins/common/wikibits.js?116 :: mwSetupToolbar :: line 378"  data: no]
http://127.0.0.1/mw12/skins/common/wikibits.js?116
Line 378

what version of MediaWiki are you using and what skin? What error exactly do you get?

comment:3 Changed 12 years ago by Phil Collins

Hi there,

I'm using MediaWiki 1.11.2 with a monobook skin for testing (same error on all other skins) on FF 2.0.0.13. I am running one other extension - TopTenPages but apart from that my install of MediaWiki and FCKEditor is vanilla.

The error I receive if I run the original code is :

mwSetupToolbar is not defined window.removeEventListener( 'load', mwSetupToolbar, false ) ;

This error disappears and the FCKEditor appears in place of the standard MediaWiki editor if the call to define the mwSetupToolbar is placed above the condition within which the eventlistener is removed - as per the amended code.

I receive no errors if I run the amended code.

comment:4 Changed 12 years ago by Phil Collins

Oh, and I downloaded the latest build of FKCEditor extension as it was yesterday (02/04)

comment:5 Changed 12 years ago by Wiktor Walc

Did you change anything in LocalSettings.php? I tried 1.11.2 with TopTenPages, vanilla 1.10.3, 1.12.0 and everything works fine.

I'm leaving this as opened, because moving that line caused errors on my MediaWiki installation.

There must be something that we are missing here...

One more question: do you see this error whebn you open our Sandbox? http://mediawiki.fckeditor.net/Sandbox

comment:6 Changed 12 years ago by Phil Collins

I can confirm that I do not see any error when I look at the sandbox.

The changes I have made to the LocalSettings.php (other than the usual sitename, email address etc;) are as follows:

$wgDefaultSkin (we use a modified version of Fratman_enhanced. $wgUseAjax = true; (this was suggested as a possible fix to the issues I was having with the FCKeditor)

then we have the include for the TopTenPages.php extension and the require_once call for the FCKeditor. I have posted the full file below.

<?php

# This file was automatically generated by the MediaWiki installer.
# If you make manual changes, please keep track in case you need to
# recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.

# If you customize your file layout, set $IP to the directory that contains
# the other MediaWiki files. It will be used as a base to locate files.
if( defined( 'MW_INSTALL_PATH' ) ) {
	$IP = MW_INSTALL_PATH;
} else {
	$IP = dirname( __FILE__ );
}

$path = array( $IP, "$IP/includes", "$IP/languages" );
set_include_path( implode( PATH_SEPARATOR, $path ) );

require_once( "includes/DefaultSettings.php" );

# If PHP's memory limit is very low, some operations may fail.
# ini_set( 'memory_limit', '20M' );

if ( $wgCommandLineMode ) {
	if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
		die( "This script must be run from the command line\n" );
	}
} elseif ( empty( $wgNoOutputBuffer ) ) {
	## Compress output if the browser supports it
	if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
}

$wgSitename         = "User Guide";
$wgScriptPath	      = "/guide";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";

## For more information on customizing the URLs please see:
## http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url
## If using PHP as a CGI module, the ?title= style usually must be used.
$wgArticlePath      = "$wgScript/$1";
# $wgArticlePath      = "$wgScript?title=$1";

$wgStylePath        = "$wgScriptPath/skins";
$wgStyleDirectory   = "$IP/skins";
$wgLogo             = "$wgStylePath/common/images/wiki.png";
$wgFavicon 	    = "/guide/wikipedia.ico";

$wgUploadPath       = "$wgScriptPath/images";
$wgUploadDirectory  = "$IP/images";

$wgEnableEmail = true;
$wgEnableUserEmail = false;

$wgEmergencyContact = "[removed]";
$wgPasswordSender	= "[removed]";

## For a detailed description of the following switches see
## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
## There are many more options for fine tuning available see
## /includes/DefaultSettings.php
## UPO means: this is also a user preference option
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

$wgDBserver         = "localhost";
$wgDBname           = "[removed for security]";
$wgDBuser           = "[removed for security]";
$wgDBpassword       = "[removed for security]";
$wgDBprefix         = "";
$wgDBtype           = "mysql";

# Experimental charset support for MySQL 4.1/5.0.
$wgDBmysql5 = false;

## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = array();

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads		= true;
$wgUseImageResize		= true;
# $wgUseImageMagick = true;
# $wgImageMagickConvertCommand = "/usr/bin/convert";

## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
# $wgHashedUploadDirectory = false;

## If you have the appropriate support software installed
## you can enable inline LaTeX equations:
$wgUseTeX	         = false;
$wgMathPath         = "{$wgUploadPath}/math";
$wgMathDirectory    = "{$wgUploadDirectory}/math";
$wgTmpDirectory     = "{$wgUploadDirectory}/tmp";

$wgLocalInterwiki   = $wgSitename;

$wgLanguageCode = "en";

$wgProxyKey = "151a078547cdd09d455b84986ad82001170c27204ee20cf3503bbee043ded188";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
$wgDefaultSkin = 'fratman_enhanced';

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
# $wgEnableCreativeCommonsRdf = true;
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# $wgRightsCode = ""; # Not yet used

$wgDiff3 = "";

# When you make changes to this configuration file, this will make
# sure that cached pages are cleared.
$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) );
$wgCacheEpoch = max( $wgCacheEpoch, $configdate );

# Group permissions - added by Phil
$wgGroupPermissions['*']['edit'] = false;
$wgDefaultUserOptions ['editsection'] = false;

$wgUseAjax = true;

# Added all extension includes below here for safetys' sake
include("extensions/TopTenPages.php");
require_once $IP . "/extensions/FCKeditor/FCKeditor.php";
?>

comment:7 Changed 12 years ago by Wiktor Walc

Ok, I think I've got it.

Did you add this code by yourself in your skin?

<?php $this->html('headscripts') ?>

It must be placed below this line (with "wikibits.js"):

<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"></script>

comment:8 Changed 11 years ago by Frederico Caldeira Knabben

Resolution: invalid
Status: newclosed

Expired.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy