forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_files.js
More file actions
33 lines (27 loc) · 912 Bytes
/
add_files.js
File metadata and controls
33 lines (27 loc) · 912 Bytes
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
'use strict';
const Server = require('../server');
const {
each
} = $;
const addFileToDOM = (category, algorithm, file, explanation) => {
var $file = $('<button>')
.append(file)
.attr('data-file', file)
.click(function () {
Server.loadFile(category, algorithm, file, explanation);
$('.files_bar > .wrapper > button').removeClass('active');
$(this).addClass('active');
});
$('.files_bar > .wrapper').append($file);
return $file;
};
module.exports = (category, algorithm, files, requestedFile) => {
$('.files_bar > .wrapper').empty();
each(files, (file, explanation) => {
var $file = addFileToDOM(category, algorithm, file, explanation);
$file.addClass('tab_button');
if (requestedFile && requestedFile == file) $file.click();
});
if (!requestedFile) $('.files_bar > .wrapper > button').first().click();
$('.files_bar > .wrapper').scroll();
};