1/* 2plugHostingUrl2020 : Created In CousumePlug.js 3*/ 4 5//link Active 6const linkActiveCssElement = parent.document.createElement('link'); 7linkActiveCssElement.rel = "stylesheet"; linkActiveCssElement.type = "text/css"; 8//Readable 9const readableCssElement = parent.document.createElement('link'); 10readableCssElement.rel = "stylesheet"; readableCssElement.type = "text/css"; 11//Web Color 12const webColorCssElement = parent.document.createElement('link'); 13webColorCssElement.rel = "stylesheet"; webColorCssElement.type = "text/css"; 14//Space 15const spaceCssElement = parent.document.createElement('link'); 16spaceCssElement.rel = "stylesheet"; spaceCssElement.type = "text/css"; 17//Font 18const NormalfontCssElement = parent.document.createElement('link'); 19NormalfontCssElement.rel = "stylesheet"; NormalfontCssElement.type = "text/css"; 20 21const SignfontCssElement = parent.document.createElement('link'); 22SignfontCssElement.rel = "stylesheet"; SignfontCssElement.type = "text/css"; 23 24 25const highlightTitlesCssElement = parent.document.createElement('link'); 26highlightTitlesCssElement.rel = "stylesheet"; highlightTitlesCssElement.type = "text/css"; 27 28 29const stopAnimationCssElement = parent.document.createElement('link'); 30stopAnimationCssElement.rel = "stylesheet"; stopAnimationCssElement.type = "text/css"; 31 32const textGuideCssElement = parent.document.createElement('link'); 33textGuideCssElement.rel = "stylesheet"; textGuideCssElement.type = "text/css"; 34 35//// Reading Guide 36const linkReadingsCssElement = parent.document.createElement('link'); 37linkReadingsCssElement.rel = "stylesheet"; linkReadingsCssElement.type = "text/css"; 38 39 40const textGuideJsElement = parent.document.createElement('script'); 41textGuideJsElement.type = "text/javascript"; 42 43 44const readingGuideCssElemnt = parent.document.createElement('link'); 45readingGuideCssElemnt.rel = "stylesheet"; readingGuideCssElemnt.type = "text/css"; 46 47 48 49// Initialize speech recognition 50//const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)(); 51//recognition.interimResults = true; 52//recognition.maxAlternatives = 1; 53 54function selectText() { 55 node = document.body; 56 57 if (document.body.createTextRange) { 58 const range = document.body.createTextRange(); 59 range.moveToElementText(node); 60 range.select(); 61 } else if (window.getSelection) { 62 const selection = window.getSelection(); 63 const range = document.createRange(); 64 range.selectNodeContents(node); 65 selection.removeAllRanges(); 66 selection.addRange(range); 67 } else { 68 console.warn("Could not select text in node: Unsupported browser."); 69 } 70}; 71 72function getSelectionText() { 73 var text = ""; 74 if (window.getSelection) { 75 text = window.getSelection().toString(); 76 } else if (document.selection && document.selection.type != "Control") { 77 text = document.selection.createRange().text; 78 } 79 return text; 80}; 81 82 83/// Read specific Content 84function readPageContentspeack(pagecontent) { 85 86 const content = pagecontent; 87 // Check if player exists and pause it if it does 88 if (player) { 89 player.pause(); 90 player = null; 91 return; 92 } 93 94 // Your SpeechSDK initialization 95 var SDK = window.SpeechSDK; 96 const speechConfig = SDK.SpeechConfig.fromSubscription("162bb13ff09945e99e3b8c9429a640d6", "eastus"); 97 98 // Set the language and voice based on the provided content 99 if (content.includes("ar-EG")) { 100 speechConfig.speechSynthesisLanguage = "ar-EG"; 101 speechConfig.speechSynthesisVoiceName = "ar-EG-SalmaNeural"; 102 } else { 103 speechConfig.speechSynthesisLanguage = "en-US"; 104 speechConfig.speechSynthesisVoiceName = "en-US-JennyNeural"; 105 } 106 // Create a new speaker audio destination 107 player = new SDK.SpeakerAudioDestination(); 108 109 // Create audio configuration with the speaker output 110 const audioConfig = new SDK.AudioConfig.fromSpeakerOutput(player); 111 112 // Create a new speech synthesizer with the provided speech config and audio config 113 const synthesizer = new SDK.SpeechSynthesizer(speechConfig, audioConfig); 114 115 116 // Speak the provided content 117 synthesizer.speakTextAsync(content, 118 result => { 119 if (result) { 120 synthesizer.close(); 121 return result.audioData; 122 } 123 }, 124 error => { 125 console.log(error); 126 synthesizer.close(); 127 } 128 ); 129 130 131} 132 133function speakToTextModalresultPopup() { 134 $('#speakToTextModalresult').modal('hide'); 135 $("#speakToTextModalresult").remove(); 136 137 var iFrameElement = document.getElementById('toolIFrame'); 138 iFrameElement.style.display = "block";
139 iFrameElement.contentWindow.postMessage({ funcName: "openTool" }, '*'); 140 iFrameElement.contentWindow.postMessage({ funcName: "RestsDIVGAWWidgetspeakToText" }, '*'); 141 iFrameElement.contentWindow.postMessage({ funcName: "updateYoutubeVideoLink", funcParem: youTubeVideoLink }, '*'); 142 //parent.location.reload(); 143 //location.reload(); 144} 145function addModal(data, Header) { 146 147 var html = `<div class='modal fade' id='speakToTextModalresult' tabindex='-1' 148 role='dialog' aria-labelledby='speakToTextModalresult' aria-hidden='true' 149 style='z-index: 9999999999999;'> 150 <div class='modal-dialog modal-lg' style='top: 0 !important;left: 0 !important; right: 0 !important; bottom: 0!important;'> 151 <div class='modal-content'> 152 <div class='modal-header'> 153 <button type='button' class='close' onclick="speakToTextModalresultPopup();" aria-hidden='true'>X</button> 154 <h4 class='modal-title'>`+ Header + `</h4> 155 </div> 156 <div class="modal-body"> 157 `+ data + ` 158 </div> 159 <div class='modal-footer'> 160 </div> 161 </div> 162 </div> 163 </div> 164 </div>`; 165 body = document.getElementsByTagName('body')[0]; 166 body.innerHTML += html; 167 168 $('#speakToTextModalresult').modal('show'); 169 /*$('#speakToTextModalresult').removeClass('modal fade');*/ 170 $('#speakToTextModalresult').addClass('in'); 171 172} 173 174var textToogleValue; 175var changecursor; 176var snd; 177//googleLink = 'https://texttospeech.googleapis.com/v1/text:synthesize?key=AIzaSyD-_-2_Nab8hStiQXsZtacqV_uoAB0KHsg'; 178//googleLink = 'https://texttospeech.googleapis.com/v1/text:synthesize?key=AIzaSyCXMAPwpaIIlVaMLjMtkgRPi4JQKnORSK0'; 179textToogleValue = 0; 180changecursor = false; 181requestId = 0; 182var player; 183var recognizer; /// Make it global in 3_11_2023 184 185var assistMaskOn = false; /// For Reading Guide 7_11_2023 186var lineHeight = 0; 187var maskHeight = 0; 188var speakresulteMessage; 189class ExcuteChnaged { 190 addElemntToParent(element) { 191 //parent.document.getElementsByTagName('head')[0].appendChild(element); 192 if (element.tagName.toLowerCase() === 'script') { 193 parent.document.getElementsByTagName('body')[0].appendChild(element); 194 } else { 195 parent.document.getElementsByTagName('head')[0].appendChild(element); 196 } 197 }; 198 199 readPage() { 200 if (player) { 201 player.pause(); 202 player = null; 203 return; 204 } 205 var SDK = window.SpeechSDK; 206 207 /*console.log("SpeechSDK initialized", SDK);*/ 208 const speechConfig = SDK.SpeechConfig.fromSubscription("162bb13ff09945e99e3b8c9429a640d6", "eastus"); 209 //const speechConfig = SDK.SpeechConfig.fromSubscription("162bb13ff09945e99e3b8c9429a640d6", "qatarcentral"); 210 211 var src = document.getElementById("toolIFrame").src; 212 if (src.includes("/en/")) { 213 speechConfig.speechSynthesisLanguage = "en-US"; 214 speechConfig.speechSynthesisVoiceName = "en-US-JennyNeural"; 215 } 216 else { 217 speechConfig.speechSynthesisLanguage = "ar-EG"; 218 speechConfig.speechSynthesisVoiceName = "ar-EG-SalmaNeural"; 219 } 220 221 222 player = new SDK.SpeakerAudioDestination(); 223 //player.onAudioEnd = function (s) { 224 // console.log("onAudioEnd", s); 225 //}; 226 227 const audioConfig = new SDK.AudioConfig.fromSpeakerOutput(player); 228 const synthesizer = new SDK.SpeechSynthesizer(speechConfig, audioConfig); 229 230 selectText();//document.body.innerHTML.replace(/<(?:.|\n)*?>/gm, '').trim(); 231 var content_holder = getSelectionText(); 232 if (window.getSelection) { 233 if (window.getSelection().empty) { // Chrome 234 window.getSelection().empty(); 235 } else if (window.getSelection().removeAllRanges) { // Firefox 236 window.getSelection().removeAllRanges(); 237 } 238 } else if (document.selection) { // IE? 239 document.selection.empty(); 240 } 241 242 synthesizer.speakTextAsync(content_holder, 243 result => { 244 245 if (result) { 246 synthesizer.close(); 247 return result.audioData; 248 } 249 }, 250 error => { 251 console.log(error); 252 synthesizer.close(); 253 }); 254 } 255 readPageContent(pageconts) { 256 document.getElementById('toolIFrame').style.display = "none"; 257 258 const paragraphs = document.getElementsByTagName('p'); 259 260 for (let i = 0; i < paragraphs.length; i++) { 261 paragraphs[i].addEventListener('click', function () { 262 const pageContent = this.textContent; 263 paragraphs[i].style.cursor = "pointer"; 264 readPageContentspeack(pageContent); 265 }); 266 } 267 } 268 269 speakToText(options = {}) { 270 const SpeechSDK = window.SpeechSDK; 271 if (!SpeechSDK) { 272 console.error("SpeechSDK not found on window. Ensure Azure Speech SDK is loaded."); 273 return null; 274 } 275 276 // ---------- Language ---------- 277 const html = document.documentElement; 278 const langAttr = (html.getAttribute("lang") || "").trim().toLowerCase(); 279 const dirAttr = (html.getAttribute("dir") || "").trim().toLowerCase(); 280 const isAr = 281 langAttr === "ar" || 282 langAttr.startsWith("ar-") || 283 dirAttr === "rtl" || 284 ((navigator.language || "").toLowerCase().startsWith("ar"));
285 286 const UI = isAr 287 ? { 288 title: "ØªØØ¯Ø« Ø¥ÙÙ ÙØµ", 289 help: "ØªØØ¯Ø« Ø§ÙØ¢Ùâ¦", 290 stopped: "ØªÙ Ø§ÙØ¥ÙÙØ§Ù.", 291 noMatch: "ÙÙ ÙØªÙ Ø§ÙØªØ¹Ø±Ù عÙ٠اÙÙÙØ§Ù .", 292 error: "ØØ¯Ø« خطأ.", 293 clear: "٠سØ", 294 stop: "Ø¥ÙÙØ§Ù", 295 close: "Ø¥ØºÙØ§Ù", 296 } 297 : { 298 title: "Speech to Text", 299 help: "Speak nowâ¦", 300 stopped: "Stopped.", 301 noMatch: "Speech could not be recognized.", 302 error: "An error occurred.", 303 clear: "Clear", 304 stop: "Stop", 305 close: "Close", 306 }; 307 308 // ---------- Target field ---------- 309 const active = options.targetElement || document.activeElement; 310 const isEditable = (el) => { 311 if (!el) return false; 312 const tag = (el.tagName || "").toUpperCase(); 313 return tag === "INPUT" || tag === "TEXTAREA" || !!el.isContentEditable; 314 }; 315 316 const targetEl = isEditable(active) ? active : null; 317 318 const writeToTarget = (value) => { 319 if (!targetEl) return; 320 const tag = (targetEl.tagName || "").toUpperCase(); 321 322 if (tag === "INPUT" || tag === "TEXTAREA") { 323 targetEl.value = value; 324 targetEl.dispatchEvent(new Event("input", { bubbles: true })); 325 targetEl.dispatchEvent(new Event("change", { bubbles: true })); 326 return; 327 } 328 329 if (targetEl.isContentEditable) { 330 targetEl.innerText = value; 331 targetEl.dispatchEvent(new Event("input", { bubbles: true })); 332 } 333 }; 334 335 // ---------- Ensure modal exists ---------- 336 // If you already have a modal in your widget, you can remove this "create" part and just query by IDs. 337 let modal = document.getElementById("stt-modal"); 338 if (!modal) { 339 // minimal modal CSS (only if not already injected) 340 if (!document.getElementById("stt-modal-style")) { 341 const style = document.createElement("style"); 342 style.id = "stt-modal-style"; 343 style.textContent = ` 344 #daem-stt-modal{position:fixed;inset:0;display:none;z-index:10006;background:rgba(0,0,0,.55);align-items:center;justify-content:center;padding:14px;} 345 #daem-stt-modal.daem-active{display:flex;} 346 #daem-stt-modal .daem-stt-card{width:560px;max-width:95vw;background:#fff;border-radius:14px;box-shadow:0 16px 40px rgba(0,0,0,.25);overflow:hidden;} 347 #daem-stt-modal .daem-stt-header{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;background:#2563eb;color:#fff;} 348 #daem-stt-modal .daem-stt-title{font-weight:700;} 349 #daem-stt-modal .daem-stt-close{background:transparent;border:none;color:#fff;font-size:18px;cursor:pointer;} 350 #daem-stt-modal .daem-stt-body{padding:14px;} 351 #daem-stt-modal .daem-stt-help{font-size:13px;opacity:.85;margin-bottom:8px;} 352 #daem-stt-modal .daem-stt-text{min-width: 32vw!important;width: 32vw!important; max-width: 32vw!important;box-sizing:border-box;border:1px solid #e5e7eb;border-radius:10px;padding:10px;resize:vertical;font-size:14px;outline:none;} 353 #daem-stt-modal .daem-stt-actions{display:flex;gap:10px;margin-top:10px;justify-content:flex-end;} 354 #daem-stt-modal .daem-stt-btn{border:none;border-radius:10px;padding:10px 12px;cursor:pointer;background:#f3f4f6;} 355 #daem-stt-modal .daem-stt-btn:hover{background:#e5e7eb;} 356 #daem-stt-modal.rtl{direction:rtl;} 357 `; 358 document.head.appendChild(style); 359 } 360 361 modal = document.createElement("div"); 362 modal.id = "daem-stt-modal"; 363 modal.setAttribute("aria-hidden", "true"); 364 modal.innerHTML = ` 365 <div class="daem-stt-card" role="dialog" aria-modal="true" aria-labelledby="stt-title"> 366 <div class="daem-stt-header"> 367 <div id="stt-title" class="daem-stt-title">Speech to Text</div> 368 <button id="stt-close" class="daem-stt-close" type="button" aria-label="Close">â</button> 369 </div> 370 371 <div class="daem-stt-body"> 372 <div class="daem-stt-help" id="stt-help">Speak nowâ¦</div> 373 <textarea id="stt-text" class="daem-stt-text" rows="6"> 374 </textarea> 375 <div class="daem-stt-actions"> 376 <button id="stt-clear" class="daem-stt-btn" type="button">Clear</button> 377 <button id="stt-stop" class="daem-stt-btn" type="button">Stop</button> 378 </div> 379 </div> 380 </div> 381 `; 382 document.body.appendChild(modal); 383 } 384 385 // ---------- Modal nodes ---------- 386 const titleEl = document.getElementById("stt-title"); 387 const helpEl = document.getElementById("stt-help"); 388 const textArea = document.getElementById("stt-text"); 389 const btnClose = document.getElementById("stt-close"); 390 const btnStop = document.getElementById("stt-stop"); 391 const btnClear = document.getElementById("stt-clear"); 392 393 // Localize modal 394 modal.classList.toggle("rtl", isAr); 395 titleEl.textContent = UI.title; 396 helpEl.textContent = UI.help; 397 btnStop.textContent = UI.stop; 398 btnClear.textContent = UI.clear; 399 btnClose.setAttribute("aria-label", UI.close); 400 401 // Helpers 402 let recognizer = null; 403 let isRunning = false; 404 let finalText = ""; 405 const continuous = options.continuous !== false; // default true 406 407 const setBoth = (value) => { 408 textArea.value = value; 409 writeToTarget(value); 410 }; 411 412 const openModal = () => { 413 modal.classList.add("active"); 414 modal.setAttribute("aria-hidden", "false"); 415 textArea.focus(); 416 }; 417 418 const closeModal = () => { 419 modal.classList.remove("active"); 420 modal.setAttribute("aria-hidden", "true"); 421 }; 422 423 // ---------- Azure config ---------- 424 const subscriptionKey = options.subscriptionKey || "162bb13ff09945e99e3b8c9429a640d6"; 425 const serviceRegion = options.serviceRegion || "eastus"; 426 const language = options.language || (isAr ? "ar-EG" : "en-US"); 427 428 const speechConfig = SpeechSDK.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion); 429 speechConfig.speechRecognitionLanguage = language; 430 431 const audioConfig = SpeechSDK.AudioConfig.fromDefaultMicrophoneInput(); 432 recognizer = new SpeechSDK.SpeechRecognizer(speechConfig, audioConfig); 433 434 // ---------- Stop/start ---------- 435 function stopRecognition() { 436 if (!recognizer) return; 437 438 if (continuous) { 439 if (!isRunning) return; 440 recognizer.stopContinuousRecognitionAsync( 441 () => { 442 isRunning = false; 443 helpEl.textContent = UI.stopped; 444 }, 445 (err) => { 446 console.error("stopContinuousRecognitionAsync error:", err); 447 isRunning = false; 448 helpEl.textContent = UI.error; 449 } 450 ); 451 } else { 452 // recognizeOnceAsync can't really "stop" mid-flight safely; just close UI. 453 isRunning = false; 454 helpEl.textContent = UI.stopped; 455 } 456 } 457 458 function startRecognition() { 459 if (!recognizer) return; 460 461 helpEl.textContent = UI.help; 462 463 if (continuous) { 464 if (isRunning) return; 465 isRunning = true; 466 467 // Partial (intermediate) 468 recognizer.recognizing = (s, e) => { 469 const partial = (e.result && e.result.text ? e.result.text : "").trim(); 470 const combined = (finalText ? `${finalText} ${partial}` : partial).trim(); 471 if (combined) setBoth(combined); 472 }; 473 474 // Final chunks 475 recognizer.recognized = (s, e) => { 476 if (!e.result) return; 477 478 if (e.result.reason === SpeechSDK.ResultReason.RecognizedSpeech) { 479 const chunk = (e.result.text || "").trim(); 480 if (chunk) { 481 finalText = (finalText ? `${finalText} ${chunk}` : chunk).trim(); 482 setBoth(finalText); 483 } 484 } else if (e.result.reason === SpeechSDK.ResultReason.NoMatch) { 485 helpEl.textContent = UI.noMatch; 486 } 487 }; 488 489 recognizer.canceled = (s, e) => { 490 console.log("STT canceled", e); 491 stopRecognition(); 492 }; 493 494 recognizer.sessionStopped = () => { 495 stopRecognition(); 496 }; 497 498 recognizer.startContinuousRecognitionAsync( 499 () => { }, 500 (err) => { 501 console.error("startContinuousRecognitionAsync error:", err); 502 isRunning = false; 503 helpEl.textContent = UI.error; 504 } 505 ); 506 } else { 507 // Single-shot 508 isRunning = true; 509 recognizer.recognizeOnceAsync( 510 (result) => { 511 isRunning = false; 512 513 let data = ""; 514 if (result.reason === SpeechSDK.ResultReason.RecognizedSpeech) { 515 data = (result.text || "").trim(); 516 } else if (result.reason === SpeechSDK.ResultReason.NoMatch) { 517 data = UI.noMatch; 518 } else { 519 data = result.errorDetails || UI.error; 520 console.log("Recognition failed. Error:", result.errorDetails); 521 } 522 523 // Put recognized text in both places. 524 if (result.reason === SpeechSDK.ResultReason.RecognizedSpeech) { 525 finalText = data; 526 setBoth(finalText); 527 } else { 528 helpEl.textContent = data; 529 } 530 }, 531 (err) => { 532 isRunning = false; 533 console.error("recognizeOnceAsync error:", err); 534 helpEl.textContent = UI.error; 535 } 536 ); 537 } 538 } 539 540 // ---------- Modal events ---------- 541 btnClear.onclick = () => { 542 finalText = ""; 543 setBoth(""); 544 }; 545 546 btnStop.onclick = () => stopRecognition(); 547 548 btnClose.onclick = () => { 549 stopRecognition(); 550 closeModal(); 551 }; 552 553 // Click outside closes 554 modal.onclick = (e) => { 555 if (e.target === modal) { 556 stopRecognition(); 557 closeModal(); 558 } 559 }; 560 561 // ---------- Start ---------- 562 openModal(); 563 startRecognition(); 564 565 // ---------- Controller ---------- 566 return { 567 stop: stopRecognition, 568 close: () => { 569 stopRecognition(); 570 closeModal(); 571 }, 572 getText: () => textArea.value, 573 setText: (v) => { 574 finalText = (v || "").trim(); 575 setBoth(finalText); 576 }, 577 }; 578} 579 580 speakToTextV2() { 581 let clickedInput = null; 582 const inputs = document.querySelectorAll('input[type="text"]'); 583 const textareas = document.querySelectorAll('textarea');
584 inputs.forEach((input) => { 585 input.addEventListener('click', function () { 586 587 clickedInput = input; 588 }); 589 }); 590 textareas.forEach((textarea) => { 591 textarea.addEventListener('click', function () { 592 593 clickedInput = textarea; 594 }); 595 }); 596 597 /// Stop the IFrame 598 document.getElementById('toolIFrame').style.display = "none"; 599 600 var src = document.getElementById("toolIFrame").src; 601 var lang = ''; 602 if (src.includes("/en/")) { 603 lang = "en-US"; 604 } 605 else { 606 lang = "ar-EG"; 607 } 608 609 const SDK = window.SpeechSDK; 610 const subscriptionKey = "162bb13ff09945e99e3b8c9429a640d6"; 611 const region = "eastus"; 612 613 // Create the speech configuration based on the provided language 614 const speechConfig = SDK.SpeechConfig.fromSubscription(subscriptionKey, region); 615 // Set the language for recognition (e.g., 'en-US' for US English) 616 speechConfig.speechRecognitionLanguage = "en-US"; // Set the appropriate language here 617 speechConfig.speechRecognitionLanguage = lang; // Set the appropriate language here 618 619 // Create a new recognizer "in the top of the page to use it in stop" 620 recognizer = new SDK.SpeechRecognizer(speechConfig); 621 622 // Start speech recognition 623 recognizer.startContinuousRecognitionAsync(); 624 625 // Handle recognition results 626 recognizer.recognized = function (s, e) { 627 if (e.result.reason === SDK.ResultReason.RecognizedSpeech) { 628 const recognizedText = e.result.text; 629 console.log('Recognized Speech:', recognizedText); 630 631 //// Do something with the recognized text, like displaying it in a paragraph 632 //const resultParagraph = document.createElement('span'); 633 //resultParagraph.textContent = recognizedText; 634 //document.body.appendChild(resultParagraph); 635 636 637 //const iframeWindow = document.getElementById('toolIFrame').contentWindow; 638 //console.log(iframeWindow); 639 //// Access the resultTextArea element inside the iframe 640 //const resultTextArea = iframeWindow.document.querySelector('.resultTextArea'); 641 //// Append the span element to the resultTextArea div 642 ////const resultTextArea = document.querySelector('.resultTextArea'); 643 //const spanElement = document.createElement('span'); 644 //spanElement.textContent = recognizedText; 645 646 //resultTextArea.appendChild(spanElement); 647 648 649 //if(textarea){ 650 // textarea.value += recognizedText; // Append recognized text to the textarea 651 // } 652 653 clickedInput.value += recognizedText; // Append recognized text to the clicked input or textarea 654 655 656 } 657 }; 658 659 // Handle recognition errors 660 recognizer.recognizeError = function (s, e) { 661 console.error('Speech recognition error:', e.errorDetails); 662 }; 663 664 665 } 666 /// Stop it in 667 // Stop speech recognition 3_11_2023 668 StopspeakToTextV2() { 669 if (recognizer) { 670 recognizer.stopContinuousRecognitionAsync(() => { 671 }); 672 } 673 } 674 675 AddClickCount() { 676 677 //$.ajax({ 678 // type: 'GET', 679 // url: '../ClickCounts/AddClickCount', 680 // contentType: 'application/json; charset=utf-8', 681 // data = { "Website": 'test' }, 682 // dataType = "json", 683 // //data: JSON.stringify({ 684 // // "audioConfig": { 685 // // "audioEncoding": "MP3" 686 // // }, 687 // // "input": { 688 // // "text": content_holder 689 // // }, 690 // // "voice": { 691 // // "languageCode": "ar-XA", 692 // // "name": "ar-XA-Wavenet-A", 693 // // 'ssmlGender': 'MALE' 694 // // } 695 // //}), 696 // success: function (data) { 697 698 // //swal("ÙØ¬Ø§Ø!", "ت٠ت Ø¨ÙØ¬Ø§Ø !", "success");
699 // //document.getElementById('AddToFavourit').style.color = 'red' 700 // }, 701 // error: function (Err) { 702 // //swal("Error", "ت٠ت Ø¨ÙØ¬Ø§Ø !", "success"); 703 // } 704 //}); 705 } 706 707 //Links Actives 708 links_active() { 709 //Update Url And Import 710 linkActiveCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/link-active.css"; 711 ///highlight_Titles.css 712 this.addElemntToParent(linkActiveCssElement); 713 }; 714 715 //Links Un Active 716 links_unActive() { 717 //Update Url And Import 718 linkActiveCssElement.href = ""; 719 this.addElemntToParent(linkActiveCssElement); 720 }; 721 722 //Readable Active 723 readable_active() { 724 //Update Url And Import 725 readableCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/readable.css"; 726 this.addElemntToParent(readableCssElement); 727 }; 728 729 //Readable UnActive 730 readable_unActive() { 731 //Update Url And Import 732 readableCssElement.href = ""; 733 this.addElemntToParent(readableCssElement); 734 }; 735 736 //Web Clore 1 Active 737 web_color_1() { 738 //Update Url And Import 739 webColorCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/color-2.css"; 740 this.addElemntToParent(webColorCssElement); 741 } 742 743 //Web Color 2 Active 744 web_color_2() { 745 //Update Url And Import 746 webColorCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/color-3.css"; 747 this.addElemntToParent(webColorCssElement); 748 } 749 750 //Web Color 3 Active 751 web_color_3() { 752 var iFrameElement = document.getElementById('toolIFrame'); 753 iFrameElement.contentWindow.postMessage({ funcName: "RestsDIVGAWW
753idgetscreencolor" }, '*'); 754 755 //Update Url And Import 756 webColorCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/color-1.css"; 757 this.addElemntToParent(webColorCssElement); 758 759 } 760 761 //Text Space 1 Active 762 space_1() { 763 //Update Url And Import 764 spaceCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/space-2.css"; 765 this.addElemntToParent(spaceCssElement); 766 } 767 //Text Space 2 Active 768 space_2() { 769 //Update Url And Import 770 spaceCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/space-3.css"; 771 this.addElemntToParent(spaceCssElement); 772 } 773 //Text Space 3 Active 774 space_3() { 775 var iFrameElement = document.getElementById('toolIFrame'); 776 iFrameElement.contentWindow.postMessage({ funcName: "RestsDIVGAWWidgetLettersspacing" }, '*'); 777 //Update Url And Import 778 spaceCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/space-1.css"; 779 this.addElemntToParent(spaceCssElement); 780 } 781 782 //Text Font 1 Active 783 font_1() { 784 //Update Url And Import 785 NormalfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/font-2.css"; 786 this.addElemntToParent(NormalfontCssElement); 787 } 788 789 //Text Font 2 Active 790 font_2() { 791 //Update Url And Import 792 NormalfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/font-3.css"; 793 this.addElemntToParent(NormalfontCssElement); 794 } 795 //Text Font 3 Active 796 font_3() { 797 var iFrameElement = document.getElementById('toolIFrame'); 798 iFrameElement.contentWindow.postMessage({ funcName: "RestsDIVGAWW
798idgetfontsize" }, '*'); 799 //Update Url And Import 800 NormalfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/font-1.css"; 801 this.addElemntToParent(NormalfontCssElement); 802 } 803 804 LineHeight_1() { 805 //Update Url And Import 806 //fontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/LineHeight-1.css"; 807 //this.addElemntToParent(fontCssElement); 808 const elementsToApplyEvent = document.querySelectorAll('a, p, h1, h2, h3, h4, h5,h6, span,label');//a, p, h1, h2, h3, h4, h5, span 809 elementsToApplyEvent.forEach(element => { 810 // let originalFontSize = window.getComputedStyle(element).getPropertyValue('font-size'); 811 element.style = "line-height: 50px !important;"; 812 813 }); 814 } 815 816 LineHeight_2() { 817 //Update Url And Import 818 //fontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/LineHeight-2.css"; 819 //this.addElemntToParent(fontCssElement); 820 const elementsToApplyEvent = document.querySelectorAll('a, p, h1, h2, h3, h4, h5,h6, span,label'); 821 elementsToApplyEvent.forEach(element => { 822 //let originalFontSize = window.getComputedStyle(element).getPropertyValue('font-size'); 823 element.style = "line-height: -50px !important;"; 824 }); 825 } 826 827 Signfont_1() { 828 //Update Url And Import 829 SignfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/Signfont-2.css"; 830 this.addElemntToParent(SignfontCssElement); 831 } 832 833 //Text Font 2 Active 834 Signfont_2() { 835 //Update Url And Import 836 SignfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/Signfont-2.css"; 837 this.addElemntToParent(SignfontCssElement); 838 } 839 //Text Font 3 Active 840 Signfont_3() { 841 //Update Url And Import 842 SignfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/Signfont-3.css"; 843 this.addElemntToParent(SignfontCssElement); 844 } 845 Signfont_4() { 846 //Update Url And Import 847 SignfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/Signfont-4.css"; 848 this.addElemntToParent(SignfontCssElement); 849 } 850 851 Signfont_5() { 852 //Update Url And Import 853 SignfontCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/Signfont-5.css"; 854 this.addElemntToParent(SignfontCssElement); 855 } 856 //change cursor 857 change_cursor() { 858 859 if (changecursor == false) { 860 //Update Parent cursor 861 document.getElementsByTagName('body')[0].style.cursor = "url(" + plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/img/hover.png), auto"; 862 const elementsToApplyEvent = document.querySelectorAll('*'); 863 elementsToApplyEvent.forEach(element => { 864 element.style.cursor = "url(" + plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/img/hover.png), auto"; 865 }); 866 changecursor = true; 867 } else { 868 document.getElementsByTagName('body')[0].style.cursor = ""; 869 const elementsToApplyEvent = document.querySelectorAll('*'); 870 elementsToApplyEvent.forEach(element => { 871 element.style.cursor = ""; 872 }); 873 var iFrameElement = document.getElementById('toolIFrame'); 874 iFrameElement.contentWindow.postMessage({ funcName: "RestDIVGAWWidgetcustomcursor" }, '*'); 875 changecursor = false; 876 } 877 document.getElementById('toolIFrame').style.display = "none"; 878 }; 879 880 //// 20_7_2023 881 /// Works 882 highlight() { 883 highlightTitlesCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/highlight_Titles.css"; 884 this.addElemntToParent(highlightTitlesCssElement); 885 }; 886 887 unhighlightTitles() { 888 highlightTitlesCssElement.href = ""; 889 this.addElemntToParent(highlightTitlesCssElement); 890 var iFrameElement = document.getElementById('toolIFrame'); 891 iFrameElement.contentWindow.postMessage({ funcName: "RestGAWWidgetDIVhighlightTitles" }, '*'); 892 }; 893 894 hint(typess) { 895 document.getElementById('toolIFrame').style.display = "none"; 896 let tooltipActive = false; 897 if (typess == '1') { tooltipActive = true; } else { tooltipActive = false; } 898 const tooltipContainer = document.createElement('div'); 899 tooltipContainer.id = 'tooltipContainer'; 900 document.body.appendChild(tooltipContainer); 901 document.body.addEventListener('mouseover', function (event) { 902 if (tooltipActive) { 903 // Get the type of the hovered element 904 const elementType = event.target.nodeName; 905 906 907 // Create the tooltip element 908 const tooltip = document.createElement('div'); 909 tooltip.classList.add('tooltips'); 910 if (elementType == 'IMG') { 911 912 if (event.target.getAttribute("alt") != '' && event.target.getAttribute("alt") != null) { 913 // Set the tooltip text to the element type 914 tooltip.textContent = event.target.getAttribute("alt"); 915 916 tooltip.style.position = 'fixed'; 917 tooltip.style.backgroundColor = '#f9f9f9'; 918 tooltip.style.border = '1px solid #ccc'; 919 tooltip.style.padding = '5px'; 920 tooltip.style.borderRadius = '4px'; 921 tooltip.style.cursor = "pointer"; 922 tooltip.style.cursor = "pointer"; 923 tooltip.style.zIndex = "999999999999999"; 924 925 tooltip.style.left = (event.pageX + 10) + 'px'; 926 tooltip.style.top = (event.pageY + 10) + 'px'; 927 928 // Append the tooltip to the tooltip container 929 tooltipContainer.appendChild(tooltip); 930 } 931 } 932 else if (elementType == 'BUTTON') { 933 if (event.target.getAttribute("aria-label") != '' && event.target.getAttribute("aria-label") != null) { 934 tooltip.textContent = event.target.getAttribute("aria-label"); 935 936 tooltip.style.position = 'fixed'; 937 tooltip.style.backgroundColor = '#f9f9f9'; 938 tooltip.style.border = '1px solid #ccc'; 939 tooltip.style.padding = '5px'; 940 tooltip.style.borderRadius = '4px'; 941 tooltip.style.cursor = "pointer"; 942 tooltip.style.zIndex = "999999999999999"; 943 tooltip.style.left = (event.pageX + 10) + 'px'; 944 tooltip.style.top = (event.pageY + 10) + 'px'; 945 946 // Append the tooltip to the tooltip container 947 tooltipContainer.appendChild(tooltip); 948 } 949 } 950 951 } 952 }); 953 document.body.addEventListener('mouseout', function () { 954 // Remove the tooltip element from the tooltip container 955 tooltipContainer.innerHTML = ''; 956 }); 957 } 958 959 hint_2() { 960 961 const tooltipContainer = document.getElementById('tooltipContainer'); 962 if (tooltipContainer) { 963 const parentElement = tooltipContainer.parentElement; 964 parentElement.removeChild(tooltipContainer); 965 } 966 } 967 RestGAWWidgetDIVHint() { 968 document.getElementById("tooltipContainer").remove(); 969 var iFrameElement = document.getElementById('toolIFrame'); 970 iFrameElement.contentWindow.postMessage({ funcName: "RestGAWWidgetDIVHint" }, '*'); 971 } 972 /// works tareq 973 stopAnimation() { 974 stopAnimationCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/stopAnimation_GAWWidget.css"; 975 this.addElemntToParent(stopAnimationCssElement); 976 }; 977 978 unstopAnimation() { 979 stopAnimationCssElement.href = ""; 980 this.addElemntToParent(stopAnimationCssElement); 981 }; 982 983 readingGuide() { 984 readingGuideCssElemnt.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/readingGuide.css"; 985 this.addElemntToParent(readingGuideCssElemnt); 986 // Get all paragraphs in the page 987 // const paragraphs = document.querySelectorAll('p'); 988 ///// get every thing in the page 989 const paragraphs = document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, span'); 990 991 // Apply the word-by-word hover effect to each paragraph 992 paragraphs.forEach(paragraph => { 993 const words = paragraph.textContent.trim().split(' '); 994 paragraph.innerHTML = ''; // Clear the content of the paragraph 995 996 words.forEach((word, index) => { 997 const span = document.createElement('span'); 998 span.textContent = word; 999 span.classList.add('hoverWord'); 1000 paragraph.appendChild(span); 1001
1002 // Add a space after each word (except for the last one) 1003 if (index < words.length - 1) { 1004 paragraph.appendChild(document.createTextNode(' ')); 1005 } 1006 1007 // Add event listeners to toggle the "active" class 1008 span.addEventListener('mouseenter', () => { 1009 span.classList.add('active'); 1010 }); 1011 1012 span.addEventListener('mouseleave', () => { 1013 // span.classList.remove('active'); 1014 }); 1015 }); 1016 1017 1018 }); 1019 1020 1021 } 1022 1023 stopreadingGuide() { 1024 readingGuideCssElemnt.href = ""; 1025 this.addElemntToParent(readingGuideCssElemnt); 1026 } 1027 1028 readingGuideV2() { 1029 // Hide the iframe element if it exists 1030 /* document.getElementById('toolIFrame').style.display = "none";*/ 1031 1032 linkReadingsCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/readingGuideV2.css"; 1033 this.addElemntToParent(linkReadingsCssElement); 1034 1035 setupAssistMask(); 1036 $(document).on("mousemove", function (e) { 1037 $(".assistMask").css({ 1038 top: e.clientY - maskHeight + "px", 1039 }); 1040 }); 1041 readingMaskToggle(); 1042 //$('.assistMask').css("display", "inline-block"); 1043 $('.assistMask').css("display", "block"); 1044 } 1045 1046 stopreadingGuideV2() { 1047 linkReadingsCssElement.href = ""; 1048 linkReadingsCssElement.parentNode.removeChild(linkReadingsCssElement); 1049 /* this.removeChild(linkReadingsCssElement);*/ 1050 var element = document.getElementById("GAWWidgetassistMask"); 1051 element.parentNode.removeChild(element); 1052 var iFrameElement = document.getElementById('toolIFrame'); 1053 iFrameElement.contentWindow.postMessage({ funcName: "RestGAWWidgetDIVreadingGuide" }, '*'); 1054 } 1055 /// 1056 textGuide_1() { 1057 //console.log(textGuideJsElement); 1058 1059 //// works with every thing in the Html "15_9_2023" 1060 textGuideJsElement.src = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/textguide.js"; 1061 this.addElemntToParent(textGuideJsElement); 1062 1063 textGuideCssElement.href = plugHostingUrl2020 + "/www_nti_sci_eg_version_GAW_V6/Plugs/css/textguideStyle.css"; 1064 this.addElemntToParent(textGuideCssElement); 1065 1066 document.getElementById('toolIFrame').style.display = "none"; 1067 1068 const elementsToApplyEvent = document.querySelectorAll('*'); 1069 1070 // Add event listeners for mouseover and mouseout 1071 elementsToApplyEvent.forEach(element => { 1072 let originalFontSize = window.getComputedStyle(element).getPropertyValue('font-size'); 1073 element.addEventListener('mouseover', () => { 1074 const fontSize = parseInt(originalFontSize) + 10; 1075 element.style.fontSize = fontSize + 'px'; 1076 element.style.cursor = "pointer"; 1077 // element.classList.add('activeTextGuide'); 1078 }); 1079 1080 element.addEventListener('mouseout', () => { 1081 element.style.fontSize = originalFontSize; 1082 element.style.cursor = "auto"; 1083 }); 1084 }); 1085 } 1086 1087 ResttextGuide() { 1088 //console.log(textGuideJsElement); 1089 1090 //// works with every thing in the Html "15_9_2023" 1091 textGuideJsElement.src = ""; 1092 this.addElemntToParent(textGuideJsElement); 1093 1094 textGuideCssElement.href = ""; 1095 this.addElemntToParent(textGuideCssElement); 1096 /* document.getElementById('toolIFrame').style.display = "none";*/ 1097 const elementsToApplyEvent = document.querySelectorAll('*'); 1098 elementsToApplyEvent.forEach(element => { 1099 let originalFontSize = window.getComputedStyle(element).getPropertyValue('font-size'); 1100 const fontSize = parseInt(originalFontSize); 1101 element.style.fontSize =''; 1102 element.addEventListener('mouseover', () => { 1103 element.style.fontSize =''; 1104 1105 element.style.cursor = "pointer"; 1106 // element.classList.add('activeTextGuide'); 1107 }); 1108 1109 element.addEventListener('mouseout', () => { 1110 element.style.fontSize = ''; 1111 element.style.cursor = "auto"; 1112 }); 1113 }); 1114 var iFrameElement = document.getElementById('toolIFrame'); 1115 iFrameElement.contentWindow.postMessage({ funcName: "RestDIVGAWWidgetextGuide" }, '*'); 1116 } 1117 1118 textGuide_2() { 1119 textGuideCssElement.href = ""; 1120 this.addElemntToParent(textGuideCssElement); 1121 const paragraphs = document.getElementsByTagName('p'); 1122 // Add event listeners for mouseover and mouseout 1123 for (let i = 0; i < paragraphs.length; i++) { 1124 1125 let originalFontSize = window.getComputedStyle(paragraphs[i]).getPropertyValue('font-size'); 1126 paragraphs[i].removeEventListener('mouseover', () => { 1127 paragraphs[i].style.fontSize = '30px'; 1128 paragraphs[i].style.cursor = "pointer"; 1129 // paragraphs[i].classList.add('activeTextGuide'); 1130 }); 1131 paragraphs[i].removeEventListener('mouseout', () => { 1132 //paragraphs[i].style.fontSize = '16px'; 1133 paragraphs[i].style.fontSize = originalFontSize; 1134 paragraphs[i].style.cursor = "auto"; 1135 }); 1136 } 1137 } 1138 1139 reload() { 1140 parent.location.reload(); 1141 location.reload(); 1142 } 1143 1144 ///Hide Iframe For Clinet Can Be Make Any Change In Page 1145 hide_Iframe() { 1146 debugger 1147 document.getElementById('toolIFrame').style.display = "none"; 1148 } 1149 Show_Iframe() { 1150 document.getElementById('toolIFrame').style.display = "block"; 1151 } 1152} 1153 1154let excuteChnaged = new ExcuteChnaged(); 1155 1156//Recived Message From IFrame 1157window.onmessage = (mes) => { 1158 1159 if (mes.data.funcParem !== undefined && mes.data.funcParem !== null) { 1160 excuteChnaged[mes.data.funcName](mes.data.funcParem); // Pass the received parameter to the corresponding function 1161 } else { 1162 excuteChnaged[mes.data](); // Call the function without any parameter 1163 } 1164}; 1165 1166 1167 1168//$('#video').on('show.bs.modal', function (e) { 1169// $('#video').css("display", "inline-block"); 1170//}); 1171 1172 1173 1174//function closevideoPopup() { 1175// $('#video').css("display", "none"); 1176//} 1177 1178///// Reading Guide 1179function setupAssistMask() { 1180 $("<div id=GAWWidgetassistMask>").attr({class: "assistMask",}).appendTo("body").hide(); 1181 lineHeight = $("body").css("font-size"); 1182 lineHeight = Math.floor(parseInt(lineHeight.replace("px", ""))); 1183 maskHeight = $(".assistMask").height() / 2; 1184} 1185 1186
1187function readingMaskToggle() { 1188 assistMaskOn = !assistMaskOn; 1189 if (assistMaskOn) { 1190 $(".assistMask").show(); 1191 } else { 1192 $(".assistMask").hide(); 1193 } 1194 1195} 1196
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.