Changeset 35265 for main/trunk/model-interfaces-dev
- Timestamp:
- 2021-08-09T10:44:46+12:00 (3 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/js/asr/asr-controller.js
r35262 r35265 122 122 function insertTranscription(transcription) 123 123 { 124 // Inserta new transcription row124 // Create a new transcription row 125 125 /** @type {HTMLLIElement} */ 126 126 const clone = TRANSCRIPTION_TEMPLATE.content.firstElementChild.cloneNode(true); 127 127 128 // TODO: Give all children of the node the fileName data item.129 clone.dataset.fileName = transcription.file_name;130 131 128 const fileNameElement = clone.querySelector(".transcription__file-name"); 132 129 fileNameElement.textContent = transcription.file_name; 133 130 134 131 // Hook up the remove button 135 /** @type {HTMLButtonElement[]} */ 136 const removeButton = clone.querySelectorAll("transcription__remove-button"); 137 removeButton.forEach 138 ( 139 button => 140 { 141 button.onclick = function() { 142 143 } 144 } 145 ); 146 147 // Get the metadata list and template 148 /** @type {HTMLUListElement} */ 149 const metadataList = clone.querySelector(".metadata-list"); 150 132 /** @type {HTMLButtonElement} */ 133 const removeButton = clone.querySelector(".transcription__remove-button"); 134 removeButton.onclick = onDeleteTranscription; 135 136 loadAudioFile(transcription.file_name); 137 151 138 // Prepare the audio slider 152 loadAudioFile(transcription.file_name);153 154 139 /** @type {HTMLInputElement} */ 155 140 const audioSlider = clone.querySelector(".audio-slider"); 156 141 audioSlider.max = TRANSCRIPTION_AUDIO_ELEMENT.duration; 157 142 audioSlider.step = 0.01; 143 144 // Get the metadata list 145 /** @type {HTMLUListElement} */ 146 const metadataList = clone.querySelector(".metadata-list"); 158 147 159 148 // Insert metadata rows 160 149 for (const metadata of transcription.metadata) { 161 metadataList.appendChild(buildMetadataNode(metadata, transcription.file_name)); 162 } 150 metadataList.appendChild(buildMetadataNode(metadata)); 151 } 152 153 // Set the filename data property on every element in the clone's DOM node 154 recurseAddData(clone, "file-name", transcription.file_name); 163 155 164 156 TRANSCRIPTIONS_LIST.appendChild(clone); … … 175 167 * @returns {Node} The constructed DOM node. 176 168 */ 177 function buildMetadataNode(metadata , fileName)169 function buildMetadataNode(metadata) 178 170 { 179 171 const metadataClone = metadataTemplate.content.firstElementChild.cloneNode(true); … … 184 176 /** @type {HTMLButtonElement} */ 185 177 const button = metadataClone.querySelector("button"); 186 187 button.dataset.fileName = fileName; 178 188 179 button.onclick = function(e) 189 180 { … … 229 220 } 230 221 222 /** 223 * Removes a transcription from the DOM. 224 * 225 * @param {MouseEvent} ev The mouse click event. 226 */ 227 function onDeleteTranscription(ev) 228 { 229 const fileName = ev.target.dataset.fileName; 230 const child = document.querySelector(`.transcription__container[data-file-name='${fileName}']`); 231 232 TRANSCRIPTIONS_LIST.removeChild(child); 233 cachedAudioFileList.delete(fileName); 234 } 235 236 /** 237 * Recurses through the entire tree of a parent and adds the given data attribute. 238 * 239 * @param {HTMLElement} parent The parent node. 240 * @param {String} dataElementname The name of the data element. Must use hyphen notation, rather than camel case. 241 * @param {String} value The value of the data element. 242 */ 243 function recurseAddData(parent, dataElementName, value) 244 { 245 parent.setAttribute("data-" + dataElementName, value); 246 247 for (const child of parent.children) { 248 recurseAddData(child, dataElementName, value); 249 } 250 } 251 231 252 /** @type {HTMLTemplateElement} */ 232 253 const errorTemplate = document.querySelector("#errorTemplate"); … … 261 282 }); 262 283 263 // whenever we hover over a menu item that has a submenu264 284 $('.tooltip-parent').on('mouseover', function() { 265 285 var $menuItem = $(this), -
main/trunk/model-interfaces-dev/atea/style/asr.css
r35262 r35265 61 61 border-radius: 50%; 62 62 padding: 0.2em; 63 cursor: pointer; 63 64 64 65 -webkit-transition-duration: 0.2s; -
main/trunk/model-interfaces-dev/atea/transform/pages/asr.xsl
r35262 r35265 51 51 <div class="audio-slider__container"> 52 52 <button type="button" class="btn-fab btn-fab-small"> 53 <span class="material-icons"></span> 53 <span class="material-icons"></span> <!-- play_arrow --> 54 54 </button> 55 55 <input type="range" min="0" value="0" class="audio-slider__range" /> … … 73 73 <div class="transcription__header"> 74 74 <button class="btn-fab transcription__play-button" type="button"> 75 <span class="material-icons"></span> 75 <span class="material-icons"></span> <!-- play_arrow --> 76 76 </button> 77 77 <button class="btn-fab transcription__remove-button" type="button"> 78 <span class="material-icons"></span> 78 <span class="material-icons"></span> <!-- delete --> 79 79 </button> 80 80 <p class="transcription__file-name"></p>
Note:
See TracChangeset
for help on using the changeset viewer.