Extra whitespace in IE

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Extra whitespace in IE

Post by duclet »

I am adding a new feature to my module DLCodePress. It is kind of like an intelligent feature where I add in the PHP opening tag as the top line when someone wants to modify PHP code (mostly for the user defined tags). While it is finally doing that correctly, there is a problem in IE. It adds some empty lines at the end of the code. Works fine in Firefox as expect but IE is really bugging. Obviously, it isn't really a big problem because it doesn't harm anything, it just feels weird that is all. I want to get version 0.3 of my module out as quickly as possible since I have already fixed many of the problems that has plagued the other syntax highlighters such as EditArea. You can actually submit within the User defined tags, Templates, Stylesheets, etc without toggling the editor back to normal. If anyone has a solution for this whitespace issue, please let me know. Either way, I am planning on releasing the new version on Saturday so any solution before then would be helpful. By the way, here is the part of the code that updates the code:

Code: Select all

function DLCodePress_PHP(myeditor, remove) {
    // Only continue with this function if the the setting allows us
    if({/literal}{$DLCodePress_phplogic}{literal}) {
        var str = '<'+ '?php // DLCodePress stuff, do not modify';

        if(remove) {
            // We need to do things differently depending on the Browser
            if(!!(window.attachEvent && !window.opera)) { // IE
                myeditor.textarea.value = myeditor.textarea.value.replace(str+'\r\n', '');
            } else { // Firefox
                myeditor.textarea.value = myeditor.textarea.value.replace(str+'\n', '');
            }
        } else if((myeditor.textarea.value.match('<'+'?php') == null) && (myeditor.language == 'php')) {
            // Only add if it is PHP
            myeditor.textarea.value = str+'\n'+myeditor.textarea.value;
        }
    }
}
Post Reply

Return to “Developers Discussion”