PageSourceSearch

https://www.sinica.edu.tw/js/fu_accessibility.js?v=HyIey6byUmWRLgZk44LJrMo4ZJZVYj695AAlvda2oe0

js sinica.edu.tw collected 2026-09-24 08:27:19 UTC 17,777 bytes, 369 lines download raw bytes

1/*! fu_Accessibility v1.2 | 2019 | johnnyyang */
2window.addEventListener('load', function () {
3    //Table 補ID、Headers
4    var $page_content, th_col, th_row, col_count, col, row, $td, $th;
5    //if (0 < $("table").length) {
6    //    var $table = $("table");
7    //    for (i = 0; i < $table.length; i++)
8    //        if (void 0 == $table.eq(i).attr("id") && $table.eq(i).attr("id", "table_" + i), $th = $table.eq(i).find("th"), 0 == $th.length)
9    //            for ($td = $table.eq(i).find("td"), j = 0; j < $td.length; j++)
10    //                if (row = $td.eq(j).parent().index() + 1, col = $td.eq(j).index() + 1, col_count = 0, 1 == row) void 0 == $td.eq(j).attr("id") && $td.eq(j).attr("id", "table_" + i + "_" + j);
11    //                else
12    //                    for (k = 0; k < $td.length; k++) {
13    //                        var td_row = $td.eq(k).parent().index() +
14    //                            1,
15    //                            td_col = $td.eq(k).index() + 1;
16    //                        1 == td_row && (col_count = void 0 == $td.eq(k).attr("colspan") ? Number(col_count) + Number(1) : Number(col_count) + Number($td.eq(k).attr("colspan")));
17    //                        if (col_count >= col) {
18    //                            void 0 == $td.eq(j).attr("headers") && $td.eq(j).attr("headers", $td.eq(k).attr("id"));
19    //                            break
20    //                        }
21    //                    } else {
22    //            void 0 == $table.eq(i).attr("id") && $table.eq(i).attr("id", "table_" + i);
23    //            $th = $table.eq(i).find("th");
24    //            for (j = 0; j < $th.length; j++) void 0 == $th.eq(j).attr("id") && $th.eq(j).attr("id", "table_" + i + "_" + j);
25    //            $td = $table.eq(i).find("td");
26    //            for (k =
27    //                0; k < $td.length; k++) {
28    //                row = $td.eq(k).parent().index() + 1;
29    //                col = $td.eq(k).index() + 1;
30    //                var row_count = 0;
31    //                for (l = col_count = 0; l < $th.length; l++)
32    //                    if (th_row = $th.eq(l).parent().index() + 1, th_col = $th.eq(l).index() + 1, 1 == th_row && (col_count = void 0 == $th.eq(l).attr("colspan") ? Number(col_count) + Number(1) : Number(col_count) + Number($th.eq(l).attr("colspan"))), col_count >= col) {
33    //                        void 0 == $td.eq(k).attr("headers") && $td.eq(k).attr("headers", $th.eq(l).attr("id"));
34    //                        break
35    //                    }
36    //                for (l = 0; l < $th.length; l++)
37    //                    if (th_row = $th.eq(l).parent().index() + 1, th_col =
38    //                        $th.eq(l).index() + 1, 1 == th_col && (row_count = void 0 == $th.eq(l).attr("rowspan") ? Number(row_count) + Number(1) : Number(row_count) + Number($th.eq(l).attr("rowspan"))), row_count >= row) {
39    //                        var rowheaders = $td.eq(k).attr("headers");
40    //                        void 0 == rowheaders ? void 0 == $td.eq(k).attr("headers") && $td.eq(k).attr("headers", $th.eq(l).attr("id")) : (rowheaders = rowheaders + " " + $th.eq(l).attr("id"), void 0 == $td.eq(k).attr("headers") && $td.eq(k).attr("headers", rowheaders));
41    //                        break
42    //                    }
43    //            }
44    //        }
45    //}
46
47
48    var New_Windows_Title = "[另開新視窗]", New_Windows_LanguageSN = 12;
49    //取得語系
50    function GetLanguage() {
51        try {
52            var domain = window.location.pathname.toLowerCase();
53            if (domain.indexOf("/english") == -1 && domain.indexOf("/en") == -1) New_Windows_LanguageSN = 1;
54            else New_Windows_LanguageSN = 2
55        } catch (b) {
56            New_Windows_LanguageSN = 1
57        }
58        New_Windows_Title = 1 == New_Windows_LanguageSN ? "[另開新視窗]" : "[open a new window]"
59    }
60    GetLanguage();
61
62    //判斷另開新視窗邏輯
63    function CheckIndex(b) {
64        var a = b.indexOf("開啟");
65        if (-1 != a) return a;
66        var a = b.indexOf("視窗");
67        if (-1 != a) return a;
68        a = b.indexOf("分頁");
69        if (-1 != a) return a;
70        a = b.indexOf("另開");
71        if (-1 != a) return a;
72        a = b.indexOf("新窗");
73        if (-1 != a) return a;
74        a = b.indexOf("new window");
75        return -1 != a ? a : a = b.indexOf("window")
76    }
77
78
79    var h2value = $('title').html().trim();
80    if (h2value == null || h2value == '' || h2value.length == 0) {
81        h2value = '標題項目';
82    }
83
84    //沒有圖標題的就加標題
85    $("img:not([alt])").each(function (index) {
86        $(this).attr("alt", h2value + "_" + index);
87    });
88    //如果是null 就取代為空值
89    $("img[alt='null'], img[alt='Null'], img[alt='NULL'] , img[alt=' ']").each(function (index) {
90        $(this).attr("alt", '');
91    });
92
93    //檢查所有連結
94    $('a').each(function (index) {
95        //加入title
96        var $atitle = $(this).attr('title');
97        var titlevalue = '';
98        if ($atitle == undefined || $atitle.length == 0) {
99            if ($(this).children().length > 0) {
100                titlevalue = $(this).text();
101                if (titlevalue == '') titlevalue = h2value + "_" + index;
102                if (titlevalue == '') titlevalue = ' ';
103            }
104            else if ($(this).children().length == 0 && $(this).text() != '') {
105                titlevalue = $(this).text();
106            }
107            else {
108                titlevalue = h2value + "_" + index;
109            }
110            if (titlevalue.trim() == '' && $(this).attr('name') != undefined) titlevalue = $(this).attr('name');
111            $(this).attr('title', titlevalue.trim());
112        }
113
114        //空<a>補內容
115        if ($(this).text() == '' && $(this).children().length == 0) {
116            $(this).append('<p style="font-size:0em; opacity:0;">' + DOMPurify.sanitize($(this).attr('title')) + '</p>');
117        }
118        var domain = window.location.origin.toLowerCase();
119
120        //外連網址補 target
121        if ($(this).attr('href') != null && $(this).attr('href').toLowerCase().startsWith('http') && $(this).attr('href').indexOf(domain) == -1 && $(this).attr('href') != '#') {
122            $(this).attr('target', "_blank");
123            $(this).attr('rel', "noopener noreferrer");
124        }
125
126        //檢查是否加入新視窗
127        if ($(this).attr('target') == "_blank" && $(this).attr('data-noblank') != '1') {
128            if (CheckIndex($(this).attr('title')) == -1) {
129                $(this).attr('title', New_Windows_Title + $(this).attr('title'));
130            }
131        }
132
133        // <a> 標籤內之 IMG 替代文字為空即可 (邏輯:<a>內有圖片且子節點>1or有文字說明時,IMG之替代文字為空)
134        //if ($(this).find('img') != null && ($(this).children().length > 1) || $(this).text().trim() != '') {
135        //    $(this).find('img').attr('alt', '');
136        //}
137
138
139        ////<a>的連結強轉https
140        //if ($(this).attr('ishttp') == undefined && $(this).attr('href') != null && $(this).attr('href').toLowerCase().startsWith('http') && !$(this).attr('href').toLowerCase().startsWith('https')) {
141        //    var $href = $(this).attr('href');
142        //    $(this).attr('href', 'https' + $href.substring(4));
143        //}
144
145    });//使 a content都塞入看不到的東西 != empty
146
147    //如果有onkeypress進行移除
148    $("a[onkeypress]").each(function (index) {
149        $(this).removeAttr("onkeypress");
150    });
151
152    //回報問題隱藏
153    $(".btn-tool.btn-problem").each(function (index) {
154        $(this).attr("style", "display:none");
155    });
156
157    //移除沒用的行動版的h4 項目(會防礙無帳礙)
158    $('.base-mobile .search .in .hd .in h4').remove();
159
160    //沒有iframe沒有標題的就加標題
161    $("iframe").each(function (index) {
162        var title = '影音';
163        //console.log($(this).attr("src"));
164        if ($('div[class="photoandtext"] h4').html() != "") title = $('div[class="photoandtext"] h4').html();
165        if ($(this).attr("title") == null) $(this).attr("title", title);
166        //if ($(this).attr("title") == null && title == null && $(this).attr("src") != null && ($(this).attr("src").indexOf("youtu") > -1)) $(this).attr("title", 'youtube');
167        if ($(this).attr("title") == null && title == null && $(this).attr("data-src") != null && ($(this).attr("data-src").indexOf("youtu") > -1)) $(this).attr("title", 'youtube');
168        if ($(this).attr("title") == null && title == null && $(this).attr("data-src") != null && ($(this).attr("data-src").indexOf("Frame_PublicHearing") > -1)) $(this).attr("title", '公聽會');
169        if ($(this).attr("title") == null && title == null && $(this).attr("data-src") != null && ($(this).attr("data-src").indexOf("Frame_LiveVideo") > -1)) $(this).attr("title", '議會直播');
170        if ($(this).attr("title") == null && title == null && $(this).attr("data-src") != null && ($(this).attr("data-src").indexOf("IframeDetail") > -1)) $(this).attr("title", '本會專刊');
171        if ($(this).attr("title") == null && title == null) $(this).attr("title", 'Map');
172    });
173
174    //<font>取代成<span>   
175    //$('font').each(function () {
176    //    $(this).replaceWith('<span>' + $(this).html() + '</span>');
177    //});
178
179
180
181
182    //<center>取代成<span>    
183    //$('center').each(function () {
184    //    $(this).replaceWith('<span style="text-align:center;">' + $(this).html() + '</span>');
185    //});
186
187
188
189
190    //attr 含有 colspan 補上scope
191    $('[colspan]').eq(0).attr('scope', 'col');
192
193    //attr 含有 rowspan 補上scope
194    $('[rowspan]').eq(0).attr('scope', 'row');
195
196    $('style[id*="isPasted"]').html('');
197
198    //內容區 px to em 預設 16px = 1em
199    function pxtoem(x) {
200        var y = 16; //預設 16px = 1em
201        var result = "0";
202        if (x) {
203            result = x / y;
204        }
205        var size = Math.pow(10, 4);
206        result = Math.round(result * size) / size;
207        result = result + "em";
208        return result;
209    }
210
211    function checkstyle(x) {
212        return /font-size[\s]*:[^;]+px/.test(x);
213    }
214
215    //<span>內之 style font-size px→em
216    if (0 < $("span").length) {
217        var $span = $("span");
218        for (i = 0; i < $span.length; i++) {
219            if ($span.eq(i).attr('style') != null && $span.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1 && checkstyle($span.eq(i).attr('style').toLowerCase())) {
220                var px = $span.eq(i).css('font-size').toLowerCase().replace('px', '');
221                var em = pxtoem(px);
222                if (em != "0") $span.eq(i).css('font-size', em);
223            }
224        }
225    }
226
227    //<p>內之 style font-size px→em
228    if (0 < $("p").length) {
229        var $p = $("p");
230        for (i = 0; i < $p.length; i++) {
231            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1 && checkstyle($p.eq(i).attr('style').toLowerCase())) {
232                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
233                var em = pxtoem(px);
234                if (em != "0") $p.eq(i).css('font-size', em);
235            }
236        }
237    }
238
239    //<div>內之 style font-size px→em
240    if (0 < $("div").length) {
241        var $p = $("div");
242        for (i = 0; i < $p.length; i++) {
243            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1 && checkstyle($p.eq(i).attr('style').toLowerCase())) {
244                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
245                var em = pxtoem(px);
246                if (em != "0") $p.eq(i).css('font-size', em);
247            }
248        }
249    }
250
251    //<a>內之 style font-size px→em
252    if (0 < $("a").length) {
253        var $p = $("a");
254        for (i = 0; i < $p.length; i++) {
255            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1 && checkstyle($p.eq(i).attr('style').toLowerCase())) {
256                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
257                var em = pxtoem(px);
258                if (em != "0") $p.eq(i).css('font-size', em);
259            }
260        }
261    }
262
263    //下列請自行確認是否使用
264    //<ul>內之 style font-size px→em
265    if (0 < $("ul").length) {
266        var $p = $("ul");
267        for (i = 0; i < $p.length; i++) {
268            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
269                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
270                var em = pxtoem(px);
271                if (em != "0") $p.eq(i).css('font-size', em);
272            }
273        }
274    }
275    //<li>內之 style font-size px→em
276    if (0 < $("li").length) {
277        var $p = $("li");
278        for (i = 0; i < $p.length; i++) {
279            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
280                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
281                var em = pxtoem(px);
282                if (em != "0") $p.eq(i).css('font-size', em);
283            }
284        }
285    }
286    //<dd>內之 style font-size px→em
287    if (0 < $("dd").length) {
288        var $p = $("dd");
289        for (i = 0; i < $p.length; i++) {
290            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
291                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
292                var em = pxtoem(px);
293                if (em != "0") $p.eq(i).css('font-size', em);
294            }
295        }
296    }
297    //<dt>內之 style font-size px→em
298    if (0 < $("dt").length) {
299        var $p = $("dt");
300        for (i = 0; i < $p.length; i++) {
301            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
302                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
303                var em = pxtoem(px);
304                if (em != "0") $p.eq(i).css('font-size', em);
305            }
306        }
307    }
308    //<br>內之 style font-size px→em
309    if (0 < $("br").length) {
310        var $p = $("br");
311        for (i = 0; i < $p.length; i++) {
312            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
313                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
314                var em = pxtoem(px);
315                if (em != "0") $p.eq(i).css('font-size', em);
316            }
317        }
318    }
319    //<blockquote>內之 style font-size px→em
320    if (0 < $("blockquote").length) {
321        var $p = $("blockquote");
322        for (i = 0; i < $p.length; i++) {
323            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
324                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
325                var em = pxtoem(px);
326                if (em != "0") $p.eq(i).css('font-size', em);
327            }
328        }
329    }
330
331    //<th>內之 style font-size px→em
332    if (0 < $("th").length) {
333        var $p = $("th");
334        for (i = 0; i < $p.length; i++) {
335            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
336                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
337                var em = pxtoem(px);
338                if (em != "0") $p.eq(i).css('font-size', em);
339            }
340        }
341    }
342
343    //<pre>內之 style font-size px→em
344    if (0 < $("pre").length) {
345        var $p = $("pre");
346        for (i = 0; i < $p.length; i++) {
347            if ($p.eq(i).attr('style') != null && $p.eq(i).attr('style').toLowerCase().indexOf('font-size') != -1  && checkstyle($p.eq(i).attr('style').toLowerCase())) {
348                var px = $p.eq(i).css('font-size').toLowerCase().replace('px', '');
349                var em = pxtoem(px);
350                if (em != "0") $p.eq(i).css('font-size', em);
351            }
352        }
353    }
354
355    //<style>內之 font-size 過濾
356    //if (0 < $("style").length) {
357    //    var $p = $("style");
358    //    for (i = 0; i < $p.length; i++) {
359    //        $p.eq(i).html($p.eq(i).html().replace(/font-size:.*?px/g, ''))
360    //    }
361    //}
362
363    //檔案轉檔(Temp)
364    $(".base-section > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) a").each(function () {
365        var a = DOMPurify.sanitize($(this).attr("href"));
366        if (null != a && -1 != a.indexOf('http'))
367            for (var c = ["doc", "xls", "ppt"], b = c.length - 1; 0 <= b; b--) - 1 != a.indexOf(c[b]) && $(".page-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(1)").append('<a href="' + a.replace('docx', 'pdf').replace('doc', 'pdf').replace('xlsx', 'pdf').replace('xls', 'pdf').replace('pptx', 'pdf').replace('ppt', 'pdf') + '" style="font-size: 0em; opacity:0;">' + DOMPurify.sanitize($(this).text()) + "</a>")
368    });
vendor: 3 bytes, line 369
369});

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.