PageSourceSearch

https://idsc.gov.eg/idsc_gov_eg_version_GAW_V2/Plugs/js/applyChange.js

js idsc.gov.eg collected 2026-10-02 04:05:29 UTC 46,215 bytes, 1,194 lines download raw bytes

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

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.