Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

preview post extension_

124

Comments

  • I was going to propose that, but an extension tampering with core files is not such a great idea. 1. Updating will always be a problem 2. Security concers having write permissions to core files. 3. There is no three. Sorry. Out of ideas!
  • I'd guess this one needs referring to mark to see if he has any bright ideas how to get it to cut up his code properly. It does seem a little beyond the scope of an extension but you never know.
  • Well I've managed to input the code thanks to Krak and I'm not getting a parse error now.
    I can see Live Preview right underneath the comment box BUT I'm not actually getting a preview...

    giginger goes off to read the info again.
  • did you read this: http://www.36-degrees.co.uk/assets/Live/readme.txt
  • Yes, but not all the way through because I fell down on the php inserts.

    Now that that section works I finished reading it. Of course I posted BEFORE I actually read the rest of the file.
  • Maybe with the next Vanilla release this might be able to be done differently. We are all awaiting anxiously.
  • NickENickE New
    edited February 2006
    Here's an extension to enable you to preview in any format if you want: http://nick-e.cjb.cc/vanilla/PreviewPost.php.txt Uses ajax to refer back to itself and parse the text along your choice of formatting. Might be a little buggy, but so far it works as planned. I have too much time on my hands...
  • That works a treat. Thanks.
  • NickENickE New
    edited October 2005
    Whoops, already found a problem. I originally was using the Vanilla js data manager to send the info, but that utilizes the HTTP GET method, and thus wasn't able to send all of the information sometimes when there was an especially large amount. Fixed it now.
  • Damn, every just sit back and relax, SirNot is on the case.
  • That's only because I'm on Herfstvakantie, though. In about a week I'll be piled high with work again.
  • Ah, well your work is appreciated.
  • edited January 2006
    @SirNot: Great! A very useful extension! :)

    But I had a little problem with german umlauts. In your "Preview Post" extension v1.1 you might replace line 113 with this one to fix this:
    text = (encodeURIComponent) ? encodeURIComponent(document[FormName].Body.value) : escape(document[FormName].Body.value);
  • I have to press it twice to get it to work on Safari 2.02. Pretty sweet though.
  • Does anyone have a working link for this extension? I get a big fat server not found error in firefox.
  • There, try it now. Remember to put preview.js in the js/ folder.
  • Thanks SirNot, it's working a treat :)
  • edited March 2006
    Does anyone have this extension? None of the links I have found so far work. Also, I may need an older version since I am using the 9.6 build of vanilla. I found the .php file, but can't find the preview.js Thanks
  • NickENickE New
    edited March 2006
    Assuming the version you've got ahold of is 1.2, then here's preview.js:
    var Request, FormName;
    
    function CreateRequestPOST(url, params, func)
    {
    	Request = false;
    	if(window.XMLHttpRequest)
    	{
    		Request = new XMLHttpRequest();
    		if(Request.overrideMimeType) Request.overrideMimeType('text/xml');
    	}
    	else if(window.ActiveXObject)
    	{
    		try
    		{
    			Request = new ActiveXObject('Msxml2.XMLHTTP');
    		}
    		catch(error)
    		{
    			try
    			{
    				Request = new ActiveXObject('Microsoft.XMLHTTP');
    			}
    			catch(error) {}
    		}
    	}
    	
    	if(!Request) return false;
    	
    	Request.onreadystatechange = func;
    	Request.open('POST', url, true);
    	Request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    	Request.setRequestHeader('Content-length', params.length);
    	Request.setRequestHeader('Connection', 'close');
    	Request.send(params);
    	
    	return true;
    }
    
    function ShowPreviewInternal()
    {
    	if(Request.readyState == 4)
    	{
    		if(Request.status == 200)
    		{
    			document.getElementById('PreviewPost').innerHTML = Request.responseText;
    			document[FormName].btnPreview.value = 'Refresh Preview';
    		}
    	}
    }
    
    function ShowPreview(F, file)
    {
    	var text, type, i, f;
    	FormName = F;
    	
    	text = (encodeURIComponent) ? encodeURIComponent(document[FormName].Body.value) : 
    		escape(document[FormName].Body.value);
    	for(i = f = 0; i < document[FormName].FormatType.length; i++)
    	{
    		if(document[FormName].FormatType[i].checked)
    		{
    			f = 1;
    			break;
    		}
    	}
    	if(!f) i = 0;
    	type = escape(document[FormName].FormatType[i].value);
    	
    	if(!CreateRequestPOST(file, 'Data='+text+'&Type='+type, ShowPreviewInternal))
    		document.getElementById('PreviewPost').innerHTML = '[An error occured when attempting to connect to the server]';
    	
    	document.getElementById('PrePreviewPost').style.display = 'block';
    }
  • MarkMark Vanilla Staff
    Someone pointed out a bug a while back in the preview post where the plus sign disappears when previewing.

    So, I enter a math problem

    a + b = c

    And now I press Preview Post, and the preview shows me:

    a b = c

    Just thought I'd mention it.
Sign In or Register to comment.