PageSourceSearch

https://www.madium.id/adm/assets/f7e8affb/js/search-ai-ui2.js

js madium.id collected 2026-10-08 20:19:43 UTC 5,945 bytes, 202 lines download raw bytes

1var questionAI, langAI; 
2var popoverInstance = null
3var keenSlider
4
5$(document).click(function (e) {
6    if(popoverInstance != null)
7    {
8        popoverInstance.hide()
9        var ignoringList = ['btn-info-imtel', 'search2', 'search-ai-result-body']
10        
11        var par = $(e.target).closest('div').attr('id');
12        
13        if(ignoringList.includes(e.target.id) == false){
14            if(par != 'search-ai-result-body'){
15                if(par === undefined){
16                    closeai()
17                    return
18                }
19
20                if(par.includes('sloader') == false){
21                    closeai()
22                }
23            }
24        }
25    }
26});
27
28function generatePopover(){
29    popoverInstance = new bootstrap.Popover($("#btn-info-imtel"), {
30        html: true,
31        title: infoTitle,
32        content: infotel,
33        container: 'body',
34        placement: 'left',
35        sanitize: false,
36        customClass: 'infotel'
37    });
38}
39
40function closeai(){
41
42    if(isAIOpen == true){
43        $("#search-ai-result2-container").hide('fast', function(){
44            $('#search2').val(questionAI)
45
46            isAIOpen = false
47        })
48    }
49}
50
51function showai(){
52    if(isAIOpen == false){
53        $('#search2').val('')
54        $("#search-ai-result2-container").show('fast', function(){
55            isAIOpen = true
56        })
57    }
58}
59
60async function searchAnswer(){
61    try{
62        var aiSearchUrl = window.location.origin+"/file_search/answer"
63        var response = await fetch(aiSearchUrl, {    
64            method: 'POST',
65            mode: 'same-origin',
66            headers: {"Content-Type" : "application/json", "User-Agent" : "PostmanRuntime/7.43.0"},
67            body: JSON.stringify({message: questionAI, lang: langAI})
68        })
69
70        const reader = response.body.getReader();
71        let output = "";
72        var deleteLoader = false;
73        while(true){
74            if(!deleteLoader){
75                $('#search2').val('')
76                $("#content-ai").prepend(`<div id="question-container" style="border-bottom: 0px !important;" class="mt-2 ms-2 me-2">
77                <div class="modal-header glass-effect2" style="border-radius: 8px 8px 0px 0px; padding-left: 24px; padding-right: 24px; padding-top: 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(0, 0, 0, .25) !important;">
78			    <p class="modal-title pull-left" id="question-title"><b>`+questionAI+`</b></p>
79
80                            <div class="pull-right">
81                                <a type="button" onclick="closeai()">
82                                    <span style="font-size: 24px;" aria-hidden="true">&times;</span>
83                                </a>
84                            </div> 
85                        </div>
86                    </div>`)
87
88                $("#sloader").remove()
89                deleteLoader = true;
90
91                // $("#search-ai-result").append("<div id='search-ai-result-body'></div>")
92            }
93            const {done, value} = await reader.read();
94            output += new TextDecoder().decode(value);
95
96            var html = marked.parse(output);
97
98	    $("#search-ai-result-body").html(html)
99            $("#search-ai-result-body").css('border-radius','0px 0px 8px 8px')
100            $("#search-ai-result-body").css('height','323px')
101            $("#search-ai-result-body").css({"margin-top":"0px", "margin-left":".5rem","margin-right":".5rem","padding-top":"12px","padding-bottom":"12px"})                
102         
103            $("#search-ai-result-body").stop().animate({ scrollTop: $("#search-ai-result-body")[0].scrollHeight}, 1000);
104            if(done){
105                return;
106            }
107        }
108    }catch(ex){
109        // console.log("ERR : ")
110        // console.log(ex)
111    }
112}
113
114var i = 0;
115var txt = $("#search2").attr('placeholder');
116var speed = 50;
117var runningIndex = -1;
118var maxRunningIndex = 3;
119
120function typeWriter() {
121    
122    if (i < txt.length) {
123        // $("#search2").attr('placeholder', $("#search2").attr('placeholder') + txt.charAt(i))
124        $("#search2").attr('placeholder', $("#search2").attr('placeholder') + txt.charAt(i))
125        i++;
126        setTimeout(typeWriter, speed);
127    }else{
128        setTimeout(function() {
129            i = 0
130            startTypeWriter()
131        }, 2000);
132        
133    }
134}
135
136function startTypeWriter(){
137    runningIndex++
138    if(runningIndex > maxRunningIndex){
139        runningIndex = 0;
140    }
141
142    txt = runningTextList[runningIndex]
143
144    $("#search2").attr('placeholder', '')
145    typeWriter()
146}
147
148$(document).ready(function(){
149    keenSlider = new KeenSlider('#news-slider', {
150            loop: true,
151            slides: {
152            origin: 'center',
153            perView: 1.25,
154            spacing: 16,
155        },
156        created: () => {
157            
158        },
159        breakpoints: {
160            '(min-width: 1024px)': {
161                slides: {
162                    origin: 'auto',
163                    perView: 2.25,
164                    spacing: 20,
165                },
166            },
167        },
168    })
169})
170function keenMouseIn(elem){
171    elem.classList.add("shadow-keen");
172}
173
174function keenMouseOut(elem){
175    elem.classList.remove("shadow-keen");
176}
177
178$("#btn-next-news").on('click', function(){
179    keenSlider.next()
180})
181
182$("#btn-prev-news").on('click', function(){
183    keenSlider.prev()
184})
185
186const wheelDelay = 200;
187var onKeenSlide = false;
188function keenWheel(e){
189    e.preventDefault()
190    const direction =
191        Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
192
193        setTimeout(() => {
194            if (direction > 0) {
195                keenSlider.next();
196            }
197
198            if (direction < 0) {
199                keenSlider.prev();
200            }
201        }, wheelDelay);
202}

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.