Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
//= require rails-timeago
//= require locales/jquery.timeago.de.js
//
// lib/assets
//= require flash
//= require color_mode_picker
//
// app/assets
// --> Include some assets first, as they are used by other assets.
// --> Hence, the order specified here is important.
Expand All @@ -25,12 +21,8 @@
//= require base
// 2. Programming groups are required by "channels/synchronized_editor_channel.js"
//= require programming_groups
// 3. The turtle library is required by "editor/turtle.js"
//= require turtle
// 4. Some channels are required by "editor/editor.js.erb"
// 3. Some channels are required by "editor/editor.js.erb"
//= require_tree ./channels
// 5. Require the editor components, as needed by "./editor.js" and "./community_solution.js"
//= require_tree ./editor
//
// All remaining assets are loaded in alphabetical order
//= require_tree .
Expand Down
4 changes: 0 additions & 4 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
* lib/assets
*= require flash
*
* app/assets
*= require_tree .
*= require_self
*/
4 changes: 4 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ window.ace = ace; // Publish ace in global namespace
// Turbo
import '@hotwired/turbo-rails';
import './turbo-migration';

// Import of Rails sprocket assets with minimal changes. After the initial migration these files should
// be moved to an appropriate place after some adjustments to fit modern Rails JS.
import 'sprocket-asset-import';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorAJAX = {
export default {
ajax: function(options) {
return $.ajax(_.extend({
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
var CodeOceanEditor = {
import * as Routes from 'generated/routes';
import { CodeOceanEditorTips } from './participantsupport';

const CodeOceanEditor = {
THEME: window.getCurrentTheme() === 'dark' ? 'ace/theme/tomorrow_night' : 'ace/theme/tomorrow',

//Color-Encoding for Percentages in Progress Bars (For submissions)
Expand Down Expand Up @@ -28,8 +31,8 @@ var CodeOceanEditor = {
lastCopyText: null,

sendEvents: null,
eventURL: Routes.events_path(),
fileTypeURL: Routes.file_types_path(),
eventURL: Routes.events_path,
fileTypeURL: Routes.file_types_path,

confirmDestroy: function (event) {
event.preventDefault();
Expand Down Expand Up @@ -389,7 +392,7 @@ var CodeOceanEditor = {
updateEditorModeToFileTypeID: function (editor, fileTypeID) {
var newMode = 'ace/mode/text'

$.ajax(this.fileTypeURL + '/' + fileTypeID, {
$.ajax(this.fileTypeURL() + '/' + fileTypeID, {
dataType: 'json'
}).done(function (data) {
if (data['editor_mode'] !== null) {
Expand Down Expand Up @@ -668,7 +671,7 @@ var CodeOceanEditor = {

publishCodeOceanEvent: function (payload) {
if (this.sendEvents) {
$.ajax(this.eventURL, {
$.ajax(this.eventURL(), {
type: 'POST',
cache: false,
dataType: 'JSON',
Expand Down Expand Up @@ -1170,3 +1173,5 @@ var CodeOceanEditor = {
CodeOceanEditor.editors = [];
}
};

export default CodeOceanEditor;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorEvaluation = {
export default {
// A list of non-printable characters that are not allowed in the code output.
// Taken from https://stackoverflow.com/a/69024306
nonPrintableRegEx: /[\u0000-\u0008\u000B\u000C\u000F-\u001F\u007F-\u009F\u2000-\u200F\u2028-\u202F\u205F-\u206F\u3000\uFEFF]/g,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CodeOceanEditorWebsocket = {
import CommandSocket from './websocket'

export default {
websocket: null,
// Replace `http` with `ws` for the WebSocket connection. This also works with `https` and `wss`.
webSocketProtocol: window.location.protocol.replace(/^http/, 'ws').split(':')[0],
Expand Down
19 changes: 19 additions & 0 deletions app/javascript/sprocket-asset-import/editor/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import CodeOceanEditorAJAX from './ajax';
import CodeOceanEditor from './editor';
import CodeOceanEditorEvaluation from './evaluation';
import CodeOceanEditorWebsocket from './execution';
import { CodeOceanEditorFlowr, CodeOceanEditorRequestForComments } from './participantsupport';
import CodeOceanEditorPrompt from './prompt';
import CodeOceanEditorSubmissions from './submissions';
import CodeOceanEditorTurtle from './turtle';

// TODO: Import explicitly in Part 3 of the asset migration.
window.CodeOceanEditorAJAX = CodeOceanEditorAJAX;
window.CodeOceanEditor = CodeOceanEditor;
window.CodeOceanEditorEvaluation = CodeOceanEditorEvaluation;
window.CodeOceanEditorWebsocket = CodeOceanEditorWebsocket;
window.CodeOceanEditorFlowr = CodeOceanEditorFlowr;
window.CodeOceanEditorPrompt = CodeOceanEditorPrompt;
window.CodeOceanEditorRequestForComments = CodeOceanEditorRequestForComments;
window.CodeOceanEditorSubmissions = CodeOceanEditorSubmissions;
window.CodeOceanEditorTurtle = CodeOceanEditorTurtle;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorFlowr = {
export const CodeOceanEditorFlowr = {
flowrResultHtml:
'<div class="card mb-2">' +
'<div id="{{headingId}}" role="tab" class="card-header">' +
Expand Down Expand Up @@ -111,7 +111,7 @@ CodeOceanEditorFlowr = {
}
};

CodeOceanEditorRequestForComments = {
export const CodeOceanEditorRequestForComments = {
requestComments: function () {
const cause = $('#requestComments');
this.newSentryTransaction(cause, async () => {
Expand Down Expand Up @@ -172,7 +172,7 @@ CodeOceanEditorRequestForComments = {
}
};

CodeOceanEditorTips = {
export const CodeOceanEditorTips = {
initializeEventHandlers: function() {
const card_headers = $('#tips .card-collapse');
for (let tip of card_headers) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorPrompt = {
export default {
prompt: '#prompt',

showPrompt: function(msg) {
Expand Down Expand Up @@ -42,4 +42,4 @@ CodeOceanEditorPrompt = {
this.submitPromptInput();
}
}
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorSubmissions = {
export default {
AUTOSAVE_INTERVAL: 15 * 1000,
autosaveTimer: null,
autosaveLabel: "#statusbar #autosave",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CodeOceanEditorTurtle = {
import Turtle from '../turtle';

export default {
turtlecanvas: null,
turtlescreen: null,
resetTurtle: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CommandSocket = function(url, onOpen) {
const CommandSocket = function(url, onOpen) {
this.handlers = {};
this.websocket = new WebSocket(url);
this.websocket.onopen = onOpen;
Expand Down Expand Up @@ -120,3 +120,5 @@ CommandSocket.prototype.killWebSocket = function() {
this.websocket.flush();
this.websocket.close(1000);
};

export default CommandSocket;
5 changes: 5 additions & 0 deletions app/javascript/sprocket-asset-import/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import './flash';
import './color-mode-picker';

import './editor';
import './request-for-comments';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var height;
var width;

function Turtle(canvas) {
export default function Turtle(canvas) {
var dx, dy, xpos, ypos;
this.canvas = canvas; // jQuery object

Expand Down