1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 js/tinymce/themes/xenforo/js/code.js -> changed?

Discussion in 'Installation, Upgrade, and Import Support' started by MagnusB, Sep 4, 2012.

  1. MagnusB

    MagnusB Well-Known Member

    I upgraded to 1.1.3 shortly after it came out, however I just redownloaded the upgrade package, just to check the file above. In my fresh download the first lines read like this:
    Code:
    var CodeDialog = {
        init: function()
        {
        },
    
    However, in mine the first few lines were these:
    Code:
    var CodeDialog = {
    init: function()
    {
    alert(tinyMCEPopup.editor.windowManager.bookmark);
    },
    I also verified that the upgrade package contains the same file as the full package. Since the alert caused some problems for me when the insert code iframe was loaded, I reuploaded the code.js file, and now it fails the file health check. Any else noticed this? It is a small annoyance for me, as per this post, so I'd rather keep the "new" file.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The 1.1.3 default is:

    Code:
    var CodeDialog = {
    	init: function()
    	{
    	},
    
    	submit: function()
    	{
    		var ed = tinyMCEPopup.editor, tag, code, output;
    
    		switch ($('#ctrl_type').val())
    		{
    			case 'html': tag = 'HTML'; break;
    			case 'php':  tag = 'PHP'; break;
    			default:     tag = 'CODE';
    		}
    
    		code = $('#ctrl_code').val();
    		code = code.replace(/&/g, '&amp;').replace(/</g, '&lt;')
    			.replace(/>/g, '&gt;').replace(/"/g, '&quot;')
    			.replace(/\t/g, '    ').replace(/  /g, '&nbsp; ')
    			.replace(/\n/g, '</p>\n<p>');
    
    		output = '[' + tag + ']' + code + '[/' + tag + ']';
    		if (output.match(/\n/))
    		{
    			output = '<p>' + output + '</p>';
    		}
    
    		tinyMCEPopup.restoreSelection();
    		ed.execCommand('mceInsertContent', false, output);
    		tinyMCEPopup.close();
    
    		return false;
    	}
    };
    
    tinyMCEPopup.onInit.add(CodeDialog.init, CodeDialog);
    
    This version passes the checksum.
     
  3. MagnusB

    MagnusB Well-Known Member

    Not for me:
    Code:
    var CodeDialog = {
        init: function()
        {
        },
     
        submit: function()
        {
            var ed = tinyMCEPopup.editor, tag, code, output;
     
            switch ($('#ctrl_type').val())
            {
                case 'html': tag = 'HTML'; break;
                case 'php':  tag = 'PHP'; break;
                default:    tag = 'CODE';
            }
     
            code = $('#ctrl_code').val();
            code = code.replace(/&/g, '&amp;').replace(/</g, '&lt;')
                .replace(/>/g, '&gt;').replace(/"/g, '&quot;')
                .replace(/\t/g, '    ').replace(/  /g, '&nbsp; ')
                .replace(/\n/g, '</p>\n<p>');
     
            output = '[' + tag + ']' + code + '[/' + tag + ']';
            if (output.match(/\n/))
            {
                output = '<p>' + output + '</p>';
            }
     
            tinyMCEPopup.restoreSelection();
            ed.execCommand('mceInsertContent', false, output);
            tinyMCEPopup.close();
     
            return false;
        }
    };
     
    tinyMCEPopup.onInit.add(CodeDialog.init, CodeDialog);
    That file is uploaded from zip I downloaded a few days ago here. Filehealth results:
    filehealth.PNG

    As I said, it is more an annoyance, but still something I would like to fix.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Your code looks the same, except you have spaces instead of tabs, but that is probably from the rich editor.
     
  5. MagnusB

    MagnusB Well-Known Member

    I did not open the file it self, I just navigated to the URL and copy pasted the content. If you see here, I am not the only one having the issue, though I am not sure if anyone else tried re uploading the js file.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page