Revize 69457eb5
Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)
sources/src/main/webapp/js/uploadFilesApp.js | ||
---|---|---|
9 | 9 |
run() { |
10 | 10 |
console.log('running...'); |
11 | 11 |
|
12 |
let privateDiagramList = document.getElementById('privateDiagramList');
|
|
12 |
const privateDiagramList = document.getElementById('privateDiagramList');
|
|
13 | 13 |
privateDiagramList.querySelectorAll('.remove-diagram-button').forEach(button => { |
14 | 14 |
button.addEventListener('click', this._removeDiagram); |
15 | 15 |
}); |
... | ... | |
34 | 34 |
try { |
35 | 35 |
const data = await AJAX.getJSON(Constants.API.getPrivateDiagrams); |
36 | 36 |
|
37 |
data.forEach(function(diagram) { |
|
38 |
var openDiagramLink = document.createElement('a'); |
|
39 |
openDiagramLink.setAttribute('href', './graph?diagramId=' + diagram.id); |
|
40 |
openDiagramLink.innerText = diagram.name; |
|
41 |
|
|
42 |
var removeDiagramIcon = document.createElement('img'); |
|
43 |
removeDiagramIcon.setAttribute('src', 'images/button_cancel.png'); |
|
44 |
removeDiagramIcon.setAttribute('alt', 'odstranit'); |
|
45 |
|
|
46 |
var removeDiagramButton = document.createElement('button'); |
|
47 |
removeDiagramButton.setAttribute('class', 'remove-diagram-button'); |
|
48 |
removeDiagramButton.setAttribute('data-id', diagram.id); |
|
49 |
removeDiagramButton.setAttribute('data-name', diagram.name); |
|
50 |
removeDiagramButton.addEventListener('click', this._removeDiagram); |
|
51 |
removeDiagramButton.appendChild(removeDiagramIcon); |
|
52 |
|
|
53 |
var diagramListItem = document.createElement('li'); |
|
54 |
diagramListItem.appendChild(openDiagramLink); |
|
55 |
diagramListItem.appendChild(removeDiagramButton); |
|
56 |
|
|
57 |
privateDiagramList.appendChild(diagramListItem); |
|
37 |
data.forEach(diagram => { |
|
38 |
privateDiagramList.appendChild(DOM.h('li', {}, [ |
|
39 |
DOM.h('a', { |
|
40 |
href: app.homeUrl + 'graph?diagramId=' + diagram.id, |
|
41 |
innerText: diagram.name, |
|
42 |
}), |
|
43 |
DOM.h('button', { |
|
44 |
class: 'button remove-diagram-button', |
|
45 |
'data-id': diagram.id, |
|
46 |
'data-name': diagram.name, |
|
47 |
onClick: this._removeDiagram, |
|
48 |
}, [ |
|
49 |
DOM.h('img', { |
|
50 |
src: 'images/button_cancel.png', |
|
51 |
alt: 'Odstranit', |
|
52 |
}), |
|
53 |
]), |
|
54 |
])); |
|
58 | 55 |
}); |
56 |
|
|
59 | 57 |
} catch (error) { |
60 | 58 |
if (error instanceof HttpError) { |
61 | 59 |
alert('Something went wrong.'); |
Také k dispozici: Unified diff
refactored UploadFilesApp to use enhanced DOM JS class