Javascript Check

Javascript Check

by Barry O Reilly -
Number of replies: 3
Hi,

I want to know where in the moodle files moodle does a check to see if javascript is enabled or not. I want to disable javascript and then understand how moodle knows how to display a textarea instead of the htmleditor.

I've been looking in lib/form/htmleditor.php and then in the can_use_html_editor function in moodlelib.php but i still don't understand how it checks for javascript.

Any answer would be appreciated.

Thanks
Average of ratings: -
In reply to Barry O Reilly

Re: Javascript Check

by Mauno Korpelainen -

Hi Barry,

I try to answer your other post http://moodle.org/mod/forum/discuss.php?d=103523 as well...

First - you did not mention the version of moodle but I suppose you have moodle 1.9. If you disable javascript from browser moodle can't use any editor simply because htmlarea and the editor of moodle 2.0 (tinymce) are both using javascripts.

Function print_textarea in file lib/weblib.php loads the editor scripts and creates textarea. Usually function use_html_editor from the same file replaces that textarea (class="form-textarea) with editor (htmlarea) if can_use_html_editor has some value (this function is defined in moodlelib.php after browsers check) and $usehtmleditor is true.

$usehtmleditor is usually true if $CFG->htmleditor (the setting in site administration menu to use htmleditor site wide) and $USER->htmleditor (the setting in user profile "When editing text - Use htmlaeditor") are true.

If you set $CFG->htmleditor or $USER->htmleditor to false moodle will show only textarea. The same happens if browser check "fails" and function can_use_html_editor returns false - and that's why moodle 1.9 does not by default render editor in Safari and Opera with htmlarea.

In reply to Mauno Korpelainen

Re: Javascript Check

by Mauno Korpelainen -
Ooops - one more note/correction - Safari and Opera would not render htmlarea in any case... the latest versions of tinymce, fckeditor and xinha can if can_use_html_editor allows them to do it but that's another story...
In reply to Mauno Korpelainen

Re: Javascript Check

by Barry O Reilly -
Hi Mauno,

Thanks for the very helpful reply. I had been scouting around those areas alright to find out what those functions were doing. I understand now what is happening there. What i'd like to do is if javascript is disabled then I would like the user to be able to choose from the 4 different formats of auto-format, markdown, plaintext and html instead of only being able to use html.

Thanks again.