1 2//@*// https://responsivevoice.org*@ 3 4//select text voise 5 6 7 8//function getSelectionText() { 9// var text = ""; 10// if (window.getSelection) { 11// text = window.getSelection().toString(); 12// // for Internet Explorer 8 and below. For Blogger, you should use && instead of &&. 13// } else if (document.selection && document.selection.type != "Control") { 14// text = document.selection.createRange().text; 15// } 16// return text; 17//} 18//$(document).ready(function () { // when the document has completed loading 19// $(document).mouseup(function (e) { // attach the mouseup event for all div and pre tags 20// setTimeout(function () { // When clicking on a highlighted area, the value stays highlighted until after the mouseup event, and would therefore stil be captured by getSelection. This micro-timeout solves the issue. 21// responsiveVoice.cancel(); // stop anything currently being spoken 22// responsiveVoice.speak(getSelectionText()); //speak the text as returned by getSelectionText 23// }, 1); 24// }); 25//}); 26 27 28 29 30// Function to speak the fetched text 31function txtSpeak(text) { 32 33 34 // Callback function for when voice starts 35 function voiceStartCallback() { 36 $('#volumeIcon').removeClass('bi-volume-mute').addClass('bi-volume-up'); 37 } 38 39 // Callback function for when voice ends 40 function voiceEndCallback() { 41 $('#volumeIcon').removeClass('bi-volume-up').addClass('bi-volume-mute'); 42 } 43 44 var parameters = { 45 onstart: voiceStartCallback, 46 onend: voiceEndCallback 47 }; 48 49 // Check if voice is playing 50 if (responsiveVoice.isPlaying()) { 51 responsiveVoice.cancel(); 52 $('#volumeIcon').removeClass('bi-volume-up').addClass('bi-volume-mute'); 53 } else { 54 $('#volumeIcon').removeClass('bi-volume-mute').addClass('bi-volume-up'); 55 56 // AJAX call to fetch the top 5 latest updates 57 $.ajax({
58 url: '/Home/GetTop5LatestUpdates', 59 type: 'GET', 60 dataType: 'json', 61 success: function (data) { 62 if (data.length > 0) { 63 // Construct the text to speak by concatenating titles 64 var textToSpeak = "Here are the latest updates: "; 65 for (var i = 0; i < data.length; i++) { 66 textToSpeak += data[i].title + ". "; 67 } 68 69 // Call the responsiveVoice.speak function with the fetched text 70 responsiveVoice.speak(textToSpeak, "UK English Female", parameters); 71 72 } else { 73 // Handle case when no data is returned 74 console.log("No latest updates found."); 75 } 76 }, 77 error: function (xhr, status, error) { 78 console.error(error); 79 } 80 }); 81 } 82}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.