|
Lines 339-344
function playSound( sound ) {
Link Here
|
| 339 |
document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>'; |
339 |
document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>'; |
| 340 |
} |
340 |
} |
| 341 |
|
341 |
|
|
|
342 |
/** |
| 343 |
* Truncates a given string to a specified number of characters while preserving whole words. |
| 344 |
* |
| 345 |
* @param {string} string - The input string to be truncated |
| 346 |
* @param {number} [chars=50] - The number of characters to truncate the string to |
| 347 |
* @return {string} The truncated string with whole words preserved |
| 348 |
*/ |
| 349 |
function truncateStringForDisplay(string, chars=50) { |
| 350 |
if (chars >= string.length) return string; |
| 351 |
let truncated_str = string.substring(0, chars); |
| 352 |
let last_word_boundary = truncated_str.match(/\b/gi).pop(); |
| 353 |
let last_word_boundary_index = |
| 354 |
truncated_str.lastIndexOf(last_word_boundary); |
| 355 |
return truncated_str.substring(0, last_word_boundary_index) + "..."; |
| 356 |
} |
| 357 |
|
| 342 |
// For keeping the text when navigating the search tabs |
358 |
// For keeping the text when navigating the search tabs |
| 343 |
function keep_text(clicked_index) { |
359 |
function keep_text(clicked_index) { |
| 344 |
var searchboxes = document.getElementsByClassName("head-searchbox"); |
360 |
var searchboxes = document.getElementsByClassName("head-searchbox"); |
| 345 |
- |
|
|