forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_algorithm.js
More file actions
45 lines (36 loc) · 1.16 KB
/
show_algorithm.js
File metadata and controls
45 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const app = require('../app');
const utils = require('../utils');
const showDescription = require('./show_description');
const addFiles = require('./add_files');
module.exports = (category, algorithm, data, requestedFile) => {
let $menu;
let category_name;
let algorithm_name;
if (utils.isScratchPaper(category)) {
$menu = $('#scratch-paper');
category_name = 'Scratch Paper';
algorithm_name = algorithm ? 'Shared' : 'Temporary';
} else {
$menu = $(`[data-category="${category}"][data-algorithm="${algorithm}"]`);
const categoryObj = app.getCategory(category);
category_name = categoryObj.name;
algorithm_name = categoryObj.list[algorithm];
}
$('.sidemenu button').removeClass('active');
$menu.addClass('active');
$('#category').html(category_name);
$('#algorithm').html(algorithm_name);
$('#tab_desc > .wrapper').empty();
$('.files_bar > .wrapper').empty();
$('#explanation').html('');
app.setLastFileUsed(null);
app.getEditor().clearContent();
const {
files
} = data;
delete data.files;
showDescription(data);
addFiles(category, algorithm, files, requestedFile);
utils.renderMathJax();
};