Disabled Code Editor - hopefully Fixed

Back to General discussions forum

acibiber     2023-11-30 13:04:34

Hi, I cannot write or paste anything to code editor. It is disabled in every problem. I have failed problem 41 and this happened after that.

gardengnome     2023-11-30 15:21:57
User avatar

Seems to be a problem for everybody ... I've reached out to Rodion.

qwerty     2023-11-30 17:55:02

Same thing for me. I found a way to fill text in code editor using JavaScript, but this is pretty cumbersome. Hopefully administrator will be able to fix this problem.

qwerty     2023-12-01 07:05:11

Still no reaction from administrator.

Let me describe my Javascript solution, then.

Open https://www.codeabbey.com/index/task_view/<some task name> in your favorite browser. Click on code editor area with right mouse button and select "Inspect" from drop-down list. Developer tools will pop out, highlighting line of HTML markup, which corresponds to inspected element.

The corresponding line should be <div id="ace-editor" style="height:400px;border:1px solid #888;"></div> We see that code editor is identified by id="ace-editor". Now search for substring "ace-editor" in source files of the site.

To search for substing in all source files, one need to type Ctrl+Shift+F in developer tools. Then you type "ace-editor" in text-box and press Enter. We see that this identifier is found in two files. One is the html file of task view, and another is _view.js file.

Open the _view.js file and you immediately see in console that there is a problem: Uncaught ReferenceError: $ is not defined at _view.js?r=1260689165:1:1 What this dollar sign in error description means? Let's google for "Uncaught ReferenceError: $ is not defined" in internet.

That is how Google describes that error: The error message "Uncaught ReferenceError: $ is not defined" indicates that the symbol "$" is being used in JavaScript code without prior definition, usually occurring when jQuery is not properly loaded or conflicts with other libraries using the same symbol. Let's check if jQuery is working, then:

$('body').append('<p>Hello World!</p>');

We see a string "Hello World!" is appended to end of page, so jQuery is working. This means that there is just some error in loading order, probably. So what can we do? Let's try to execute lines of _view.js again. The file is large, so I chose to execute only chosen lines of file:

solutionArea = ace.edit('ace-editor');
solutionArea.setShowPrintMargin(false);
solutionArea.getSession().setUseWorker(false);

Yeah! The code editor is editable again.

If you want, you can also adjust font size:

solutionArea.setFontSize(<your desired font size>);

I chose to restore work of submit button, too:

$("input[type=submit]").click(function() {
    <lots and lots of code>
});

(this is not the full code of function, take code from _view.js instead) This is how a was able to sumbit solutions again. Hopefully this helps you in the meanwhile.

Rodion (admin)     2023-12-01 07:14:29
User avatar

Friends, really sorry. I really was making some improvements to chaotic script files and obviously broken something. Few minutes please. Thanks qwerty for summoning!

UPD: seemingly fixed, please check. The issue was about the order scripts are included - custom things for solution page are in _view.js but they want jquery library be already here... I was uniting jquery, bootstrap and common js files (google insists this is necessary to improve page load speed and indexing) and missed the fact that unitied file is included after others, not before.

UPD2: please don't hesitate to click "summon" button, as I mentioned this allows to send short message to me in a way most probable to reach me fast.

P.S. about lots and lots of code - I sometimes feel horrified how all this stuff come to collect (part of it, for example, makes "silly encoding" to the code submitted to prevent server thinking that it is a hacking attempt) - so sometimes there are some weak attempt to improve things by and by...

gardengnome     2023-12-01 07:35:56
User avatar

Good morning Rodion,

Thanks for the fix. Just checking, I used the summon function yesterday afternoon before I posted here that I had reached out - did that go through?

Rodion (admin)     2023-12-01 07:47:11
User avatar

No, seemingly not :( you mean this green button below, right? I just got such notification from querty... could you please retry and I'll see whether there are any issues in the log etc?

gardengnome     2023-12-01 07:55:46
User avatar

Yes the green button below. Just tried it again.

Rodion (admin)     2023-12-01 07:56:22
User avatar

Works perfectly

10:55
Admin summoned by gardengnome to https://www.codeabbey.com/index/forum_topic/ec4dea0bdaf3d01dfd3280f65d65459e
Test by gardengnome

perhaps the summoning button itself was somehow malfunctioning temporarily due to my clumsy changes :( really sorry!

gardengnome     2023-12-01 08:06:46
User avatar

No worries at all. It worked for qwerty, so it might well be me who has to improve his press-the-button ability. Well, welcome back CodeAbbey! :)

acibiber     2023-12-01 12:36:54

Thank you. It is working again.

Please login and solve 5 problems to be able to post at forum