Not logged in. · Lost password · Register
Forum: Support Bug reports and troubleshooting RSS
JavaScript problem
Something is not working with my post editor
Page:  1  2  next 
bdanee88 #1
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
Subject: JavaScript problem
Hi! I have copied an instance of UNB to my space (here: http://vpw.extra.hu/forum/), and later I discovered, that the post editor not working. First i thought that it was the problem of Mozilla Firefobx, but not, it not works in all main web browsers (FF 2.0.0.6, IE6Sp2, Opera9.23 and Safari 3.03).

The Firefox's error console drop me this error line:
Error: syntax error
Source file: http://vpw.extra.hu/forum/unb_lib/designs/modern/js/posted…
Line: 18, Column: 1
Source code:
    if (!window.event) return true;

I checked your boards posteditor.js.php and my posteditor.js.php, and they were different only in character endings (your was CR+LF, my was LF), i copied your one, but it didn't worked, too.

Can somebody help me? I don't want to install an other forum engine, because this is what I want.
Avatar
Yves (Administrator) #2
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Sorry, but I can't see a syntax error in or around that line. No idea what your computer is doing here.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
bdanee88 #3
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
So the editor is working for you?
Avatar
Yves (Administrator) #4
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I can't get to an editor, don't have access to it. I only judged about the source code I saw.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
bdanee88 #5
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
The main problem is that the buttons (bold, image, code etc.) not working along with the character counting.
Avatar
Yves (Administrator) #6
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have registered at your forum and my Firefox gives me the same error as you described. But again, I absolutely cannot follow it. The JavaScript line is absolutely okay and works in any other forum. Sorry, I have no idea what's wrong there. Maybe some invisible characters are in the way...

You can remove the account "Yves" in your forum, when we're finished here.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
bdanee88 #7
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
Finally I find out what was the problem: my host is putting a small js application in every page, after the body tag. It appeared in the posteditor.js.php's source too:

<body><script type="text/javascript" charset="utf-8" src="http://www.extra.hu/lib/webmaster/webmaster.js?scr=1&amp;username=vpw&amp;host=vpw.extra.hu&amp;rid=-722398090"></script>// Unclassified NewsBoard
// Copyright 2003-5 by Yves Goergen
// Homepage: http://newsboard.unclassified.de
// See docs/license.txt for distribution/license details

Are there a workaround to fix this (for example including the js in an other way)?
bdanee88 #8
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
Finally I've fixed the problem. I changed the extension of js.php's to simple js, and then the browser didn't put the javascript thing on the js, rather on the page.
Avatar
Yves (Administrator) #9
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Yes, that is a solution for the problem. This file doesn't need to go through the PHP parser anyway.

Always the same with web servers injecting foreign stuff into web pages they don't really understand. In most cases this breaks more than it helps. Is that a free webhosting service? They often do such things.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
bdanee88 #10
Member since Aug 2007 · 6 posts · Location: Debrecen, Hungary
Group memberships: Members
Show profile · Link to this post
Yes, it's free, and it's the best in Hungary. There is 2gb space, no advertising frame - this is the main cause why I use that, detailed webstat and the user can use his own domain - this is the other cause. This javascript-thing was integrated not so long ago, and I had no problems with it earlier.

And by the way... The Hungarian language file what I downloaded for the UNB (version 1.6rc2) had some missing strings. I updated the file up to ver. 1.6.3 and corrected some less understandable messages. Where can I upload/send this? (sorry, I didn't want to start a new topic for this small question)
Avatar
Yves (Administrator) #11
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please just e-mail it to me (address see contact page), so I can update it on the website.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
jense #12
Member since Nov 2006 · 327 posts · Location: Dortmund
Group memberships: Members
Show profile · Link to this post
Subject: .js.php → .js
posteditor.js.php and unicodetable.js.php are delivered with the wrong content-type (text/html).  As you stated, Yves, those files do not use any PHP.

So please, can the .js.php extension finally be replaced by .js in the default installation?
Alala, Alala, Gimme three wishes - CSS
Avatar
Yves (Administrator) #13
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have done more research on this and found that the only place where PHP is used in those JavaScript files is in unicodetable.js.php, and it's quite inportant there: it sets the file character set to UTF-8. Without that, the file is possibly useless to the client and special characters handling is useless.

Simply renaming the files has the effect that they're not found by the application anymore. You'd need to change the file name that the function UnbRequireJs() in common_out.lib.php generates. Then, all JavaScript files included by a design template must be renamed this way.

So I have another suggestion. The content-type for PHP results is often text/html, which is not exactly right for JavaScript files, true. Also, the current implementation doesn't allow for caching or transfer compression. I have thus added a few PHP lines to the top of every PHP-generated JavaScript file in the past:

  1. <?php
  2. header('Content-Type: text/javascript');
  3. header('Expires: ' . date('r', time() + 3 * 3600));   // 3 hours
  4. if (function_exists('ob_get_level') && !ob_get_level()) @ob_start('ob_gzhandler');
  5. ?>

The same can be used for CSS files, with the content-type text/css.

It won't repair broken servers but it still improves the situation a lot, I think.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
jense #14
Member since Nov 2006 · 327 posts · Location: Dortmund
Group memberships: Members
Show profile · Link to this post
Quote by Yves:
I have done more research on this and found that the only place where PHP is used in those JavaScript files is in unicodetable.js.php, and it's quite inportant there: it sets the file character set to UTF-8. Without that, the file is possibly useless to the client and special characters handling is useless.
That's what 'AddCharset' is for, no?

Simply renaming the files has the effect that they're not found by the application anymore. You'd need to change the file name that the function UnbRequireJs() in common_out.lib.php generates. Then, all JavaScript files included by a design template must be renamed this way.
Well, it needs to be fixed at exactly on place.  I did it already and it works like a charm...
AFAICS, no extra plug-in uses javascript, so there are just these three files.

[... fix ...] It won't repair broken servers but it still improves the situation a lot, I think.
Indeed, however, I'm still not convinced that this is the preferred way to go. ;-)
Alala, Alala, Gimme three wishes - CSS
Avatar
Yves (Administrator) #15
User title: UNB developer & webmaster
Member since Jan 2004 · 3861 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by jense:
That's what 'AddCharset' is for, no?

You mean the Apache directive? Never used it... It may work. Requires .htaccess files to work which also doesn't seem to be the case in 99% of all cases. And it surely won't work on IIS setups, which some are using.

Well, it needs to be fixed at exactly on place.  I did it already and it works like a charm...
AFAICS, no extra plug-in uses javascript, so there are just these three files.

True, as long as you don't have other plug-ins that require PHP-generated files.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  next 
Go to forum
This board is powered by the Unclassified NewsBoard software, 20120620-dev, © 2003-2011 by Yves Goergen
Page created in 219.7 ms (173 ms) · 141 database queries in 90.2 ms
Current time: 2014-04-19, 19:17:15 (UTC +02:00)