Revize 0d554903
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/src/main/webapp/uploadFiles.jsp | ||
---|---|---|
78 | 78 |
</main> |
79 | 79 |
|
80 | 80 |
<script> |
81 |
$('.removeDiagramButton').click(function(e) { |
|
82 |
|
|
83 |
if(confirm('Are you want to delete ' + $(this).data('name') + '?')) { |
|
84 |
$.ajax({ |
|
85 |
'type': 'delete', |
|
86 |
'url': 'api/remove-diagram?diagram_id=' + $(this).data('id'), |
|
87 |
'success': function () { |
|
88 |
location.reload(true); |
|
89 |
}, |
|
90 |
'error': function (xhr) { |
|
91 |
switch (xhr.status) { |
|
92 |
case 401: |
|
93 |
alert('You are either not logged in or not an owner of this diagram.'); |
|
94 |
break; |
|
95 |
default: |
|
96 |
alert('Something went wrong.'); |
|
97 |
} |
|
98 |
}, |
|
99 |
}); |
|
100 |
} |
|
81 |
var privateDiagramList = document.getElementById('privateDiagramList'); |
|
82 |
|
|
83 |
$(privateDiagramList).on('click', '.removeDiagramButton', function(e) { |
|
84 |
if (confirm('Do you really want to delete ' + $(this).data('name') + '?')) { |
|
85 |
$.ajax({ |
|
86 |
'type': 'delete', |
|
87 |
'url': 'api/remove-diagram?diagramId=' + $(this).data('id'), |
|
88 |
'success': function () { |
|
89 |
location.reload(true); |
|
90 |
}, |
|
91 |
'error': function (xhr) { |
|
92 |
switch (xhr.status) { |
|
93 |
case 401: |
|
94 |
alert('You are either not logged in or not an owner of this diagram.'); |
|
95 |
break; |
|
96 |
default: |
|
97 |
alert('Something went wrong.'); |
|
98 |
} |
|
99 |
}, |
|
100 |
}); |
|
101 |
} |
|
102 |
}); |
|
103 |
|
|
104 |
document.addEventListener('imiger.userLoggedIn', function() { |
|
105 |
$.getJSON('api/get-private-diagrams').then(function(data) { |
|
106 |
data.forEach(function(diagram) { |
|
107 |
var openDiagramLink = document.createElement('a'); |
|
108 |
openDiagramLink.setAttribute('href', './graph?diagramId=' + diagram.id); |
|
109 |
openDiagramLink.innerText = diagram.name; |
|
110 |
|
|
111 |
var removeDiagramIcon = document.createElement('img'); |
|
112 |
removeDiagramIcon.setAttribute('src', 'images/button_cancel.png'); |
|
113 |
removeDiagramIcon.setAttribute('alt', 'odstranit'); |
|
114 |
|
|
115 |
var removeDiagramButton = document.createElement('button'); |
|
116 |
removeDiagramButton.setAttribute('class', 'removeDiagramButton'); |
|
117 |
removeDiagramButton.setAttribute('data-id', diagram.id); |
|
118 |
removeDiagramButton.setAttribute('data-name', diagram.name); |
|
119 |
removeDiagramButton.appendChild(removeDiagramIcon); |
|
120 |
|
|
121 |
var diagramListItem = document.createElement('li'); |
|
122 |
diagramListItem.appendChild(openDiagramLink); |
|
123 |
diagramListItem.appendChild(removeDiagramButton); |
|
124 |
|
|
125 |
privateDiagramList.appendChild(diagramListItem); |
|
126 |
}); |
|
127 |
}); |
|
128 |
}); |
|
129 |
|
|
130 |
document.addEventListener('imiger.userLoggedOut', function() { |
|
131 |
privateDiagramList.innerHTML = ''; |
|
101 | 132 |
}); |
102 | 133 |
</script> |
103 | 134 |
</body> |
Také k dispozici: Unified diff
modified Upload screen to dynamically display/hide user's private diagrams on log in/out