Opened 12 years ago

Closed 9 years ago

#442 closed defect (fixed)

remove alert "Your Document is not well formed..."

Reported by: mharrisonline Owned by: gogo
Priority: normal Milestone: 0.95
Component: Xinha Core Version: trunk
Severity: normal Keywords: stability, interface design
Cc:

Description

I would propose that the current error handling function:

HTMLArea.getHTML = function(root, outputRoot, editor){
    try{
        return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
    }
    catch(e){
        alert(HTMLArea._lc('Your Document is not well formed. Check JavaScript console for details.'));
        return editor._iframe.contentWindow.document.body.innerHTML;
    }
}

is far too easy to trigger. It's great that it catches the error, but it presents an annoying alert message the typical Xinha user will understand as:

"Are you the loser that created this page? Well, it really stinks! Now watch, I'm going to completely screw it up as soon as you click ok. Check your coffee writing spaceship control panel if you want to understand anything at all."

Alerts like this are considered poor interface design:

Would you like your harddrive to be reformatted immediately? Check your baltazor 000012 after your C drive is destroyed

  <OK button>

.. because they are about to do something the user doesn't want, it uses language the user won't understand, there is no cancel option, and we shouldn't bothering the user about this in the first place.

Also, I have never seen the error result in more desireable code. In fact, the best scenario is probably that Xinha should mind its own business, assume the user really wants the code to be that way, and do its job.

It is all too easy and likely for users to be interupted by this error if they are loading legacy HTML into Xinha that was developed in a different editor. The error, especially if they were editing a full HTML document, can result in a disasterous change in the code, eliminating links to stylesheets, etc. that were in the head of the document.

So, I propose that the function work behind the scenes, never send an "alert of death" to the user, and just take care of business:

HTMLArea.getHTML = function(root, outputRoot, editor){
    try{
        return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
    }
    catch(e){
	 return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
    }
}

I've been testing this,and it seems to make Xinha more stable. I've never seen any other editor interact with the user the way HTMLArea.getHTML makes Xinha; I think Xinha should just edit the existing code and be quiet about it.

Change History (7)

comment:1 Changed 12 years ago by mharrisonline

  • Version set to trunk

Also, even after the alert has been acknowledged by the user and Xinha has replaced the HTML with

return editor._iframe.contentWindow.document.body.innerHTML;

the alert can continue to endlessly pop up each time the user attempts to click into the editor, preventing the editor from being used at all.

comment:2 Changed 12 years ago by niko

"coffee writing spaceship control panel" *ggg*

about the code you suggested... i haven't tested it - but it looks like you try calling getHTMLWarapper and if an error raises you just do it again - which then results in a real, not catched error!

wouldn't something like this make more sense?

HTMLArea.getHTML = function(root, outputRoot, editor){
    try{
        return HTMLArea.getHTMLWrapper(root,outputRoot,editor);
    }
    catch(e){
        return editor._iframe.contentWindow.document.body.innerHTML;
    }
}

...so just removing the alert

comment:3 Changed 12 years ago by mharrisonline

Well, it's true that the alert wouldn't come up, which is a good thing. But, now the HTML is changed. I use Xinha in full-page mode only, and this removes the head, etc.

I've tried the code I posted with HTML that was previously creating errors, and it worked fine for me. It edited the code, didn't change the document in any drastic way, and that's all I needed it to do.

comment:4 Changed 12 years ago by mharrisonline

...so, your code would be fine for someone not in full page mode.

comment:5 Changed 12 years ago by gogo

I agree with niko, your code traps an error in getHTMLWrapper (remember the exception is thrown and execution halts long before you get anything to return), then ignore the error, try again and presumadly it throws the error again, still not returning anything (as the exception halts execution at that point). Of course, it's possible the second time you try it works.

Incidentally, I don't recall ever triggering this error, I don't see why the code in getHTML should cause an exception at all really, I suspect it would have nothing to do with well formedness.

comment:6 Changed 11 years ago by mharrisonline

I guess that I should have mentioned that you only need this if your content contains JavaScript?. The error is never triggered by Xinha itself, but by a problem in JavaScript? in the content. This allows Xinha to simply show you where your errors are (like a js file that isn't where the link should be, etc.) and recover gracefully. Without this change the JavaScript? will be removed from the HTML, and full HTML pages lose everything but the contents of the body.

I now switch out the word javascript with freezescript (and onLoad with onPlaceholder) before HTML enters Xinha (which works great!), to prevent scripts from writing into the content, so I never see those errors anymore.

comment:7 Changed 9 years ago by ray

  • Milestone set to 0.95
  • Resolution set to fixed
  • Status changed from new to closed
  • Summary changed from Improve Xinha stability and usability to remove alert "Your Document is not well formed..."

rev [943]: seems reasonable to remove the alert. It only obscures the facts and doesn't improve the situation much

Note: See TracTickets for help on using tickets.