PageSourceSearch

https://www.swu.ac.jp/json/air_query/air_query.js

js swu.ac.jp collected 2026-10-01 11:29:35 UTC 8,247 bytes, 175 lines download raw bytes

1const API_PATH = "https://www.swu.ac.jp/json/air_query/air_query_api.php";
2const EVENT_NAME = "airload";
3
4class AirQueryJs {
5    json = "";
6    constructor(args = {}, callback = null) {
7        this.target = args["target"] ? args["target"] : "";
8        this.not_use_url_query = args["not_use_url_query"] ? args["not_use_url_query"] : false;
9
10        this.cache_id = args["cache_id"] ? args["cache_id"] : "";
11        this.setting_file = args["setting_file"] ? args["setting_file"] : "";
12        this.block_file = args["block_file"] ? args["block_file"] : "";
13        this.count = args["count"] ? args["count"] : "";
14        this.date_start = args["date_start"] ? args["date_start"] : "";
15        this.date_end = args["date_end"] ? args["date_end"] : "";
16        this.category__in = args["category__in"] ? args["category__in"] : [];
17        this.tag__in = args["tag__in"] ? args["tag__in"] : [];
18        this.order = args["order"] ? args["order"] : "";
19        this.pre_meta_key = args["pre_meta_key"] ? args["pre_meta_key"] : "";
20        this.pre_meta_value = args["pre_meta_value"] ? args["pre_meta_value"] : "";
21        this.pre_meta_compare = args["pre_meta_compare"] ? args["pre_meta_compare"] : "";
22        this.mode = args["mode"] ? args["mode"] : "";
23        this.result = args["result"] ? args["result"] : "html";
24        this.date_filter = args["date_filter"] ? args["date_filter"] : "";
25        this.not_ues_cache = args["not_ues_cache"] ? args["not_ues_cache"] : false;
26        this.access_url = args["access_url"] ? args["access_url"] : "";
27        this.tag_filter_condition = args["tag_filter_condition"] ? args["tag_filter_condition"] : "OR";
28        this.event_date = args["event_date"] ? args["event_date"] : "";
29
30        this.callback = callback ? callback : null;
31        this.init();
32    }
33
34    init() {
35        const self = this;
36        const event = self.makeEvent(EVENT_NAME);
37        self.loadData().then((data) => {
38            const json = JSON.parse(data);
39            if(self.result == "html") {
40                document.querySelector(self.target).innerHTML = json["html"];
41                const _cpNewsAllIcons = document.querySelector(self.target).querySelectorAll(".cp-news__icon-img");
42                _cpNewsAllIcons.forEach(element => {
43                    const dataFile = element.getAttribute("data-file");
44                    const dataAlt = element.getAttribute("data-alt");
45                    const dataStart = element.getAttribute("data-start");
46                    const dataEnd = element.getAttribute("data-end");
47                    const now = new Date();
48                    let startDate = dataStart ? new Date(dataStart) : null;
49                    let endDate = dataEnd ? new Date(`${dataEnd} 23:59:59`) : null;
50                    const isWithinRange =
51                        (!startDate || now >= startDate) && (!endDate || now <= endDate);
52                    if (isWithinRange || (!dataStart && !dataEnd)) {
53                        const img = document.createElement("img");
54                        img.src = dataFile;
55                        img.alt = dataAlt;
56                        element.replaceWith(img);
57                    }
58                });
59            }
60            if(self.callback) {
61                self.callback(json);
62            }
63            window.addEventListener('load', function() {
64                self.fireEvent(document.querySelector(self.target), event);
65            });
66        })
67        .catch((err) => {
68            console.log("error:",err);
69            window.addEventListener('load', function() {
70                self.fireEvent(document.querySelector(self.target), event);
71            });
72        });
73    }
74
75    loadData() {
76        return new Promise((resolve, reject) => {
77            const xhr = new XMLHttpRequest();
78            const url = API_PATH;
79            const fixedDatas = this.loadFormData();
80            xhr.onload = (e) => {
81                if (xhr.status === 200) {
82                    resolve(xhr.response);
83                } else {
84                    reject(JSON.parse(xhr.response));
85                }
86            }
87            xhr.open("POST", url, true);
88            xhr.withCredentials = true;
89            xhr.send(fixedDatas);
90        });
91    }
92
93    loadFormData () {
94        const fixedDatas = new FormData();
95        if(this.cache_id != "") fixedDatas.append("cache_id",  this.cache_id);
96    	if(this.setting_file != "") fixedDatas.append("setting_file", this.setting_file);
97    	if(this.block_file != "") fixedDatas.append("block_file", this.block_file);
98    	if(this.count != "") fixedDatas.append("count",  this.count);
99    	if(this.date_start != "") fixedDatas.append("date_start", this.date_start);
100    	if(this.date_end != "") fixedDatas.append("date_end", this.date_end);
101    	if(this.category__in.length > 0) fixedDatas.append("category__in",  this.category__in);
102    	if(this.tag__in.length > 0) fixedDatas.append("tag__in", this.tag__in);
103    	if(this.order != "") fixedDatas.append("order", this.order);
104    	if(this.pre_meta_key != "") fixedDatas.append("pre_meta_key",  this.pre_meta_key);
105    	if(this.pre_meta_value != "") fixedDatas.append("pre_meta_value", this.pre_meta_value);
106    	if(this.pre_meta_compare != "") fixedDatas.append("pre_meta_compare", this.pre_meta_compare);
107    	if(this.date_filter != "") fixedDatas.append("date_filter", this.date_filter);
108    	if(!this.not_use_url_query) {
109    	    const queries = this.getUrlQuery();
110        	if(queries["page"]) fixedDatas.append("page",  queries["page"]);
111        	if(queries["cats"]) fixedDatas.append("cats", queries["cats"]);
112        	if(queries["cat_classes"]) fixedDatas.append("cat_classes", queries["cat_classes"]);
113        	if(queries["tags"]) fixedDatas.append("tags", queries["tags"]);
114        	if(queries["year"]) fixedDatas.append("year",  queries["year"]);
115        	if(queries["nendo"]) fixedDatas.append("nendo", queries["nendo"]);
116        	if(queries["sender"]) fixedDatas.append("sender", queries["sender"]);
117        	if(queries["attrs"]) fixedDatas.append("attrs", queries["attrs"]);
118        	if(queries["meta_key"]) fixedDatas.append("meta_key", queries["meta_key"]);
119        	if(queries["meta_value"]) fixedDatas.append("meta_value", queries["meta_value"]);
120        	if(queries["meta_compare"]) fixedDatas.append("meta_compare", queries["meta_compare"]);
121        	if(queries["tag_filter_condition"]) fixedDatas.append("tag_filter_condition", queries["tag_filter_condition"]);
122        	if(queries["event_date"]) fixedDatas.append("event_date", queries["event_date"]);
123    	}
124    	if(this.mode != "") fixedDatas.append("mode", this.mode);
125    	if(this.result != "html") fixedDatas.append("result", this.result);
126    	if(this.not_ues_cache != true) fixedDatas.append("not_ues_cache", true);
127    	if(this.access_url != true) fixedDatas.append("access_url", this.access_url);
128    	return fixedDatas;
129    }
130
131    makeEvent(eventName) {
132        const globalUserAgent = window.navigator.userAgent.toLowerCase();
133        const globalIsIE = false;
134        if(globalUserAgent.indexOf('msie') != -1 || globalUserAgent.indexOf('trident') != -1) {
135            globalIsIE = true;
136        }
137        if(globalIsIE) {
138        const evt = document.createEvent('Event');
139            evt.initEvent(eventName, true, false);
140            return evt;
141        }
142        return new Event(eventName);
143    }
144
145    fireEvent(dom, eventObj) {
146        dom.dispatchEvent(eventObj);
147    }
148
149    getUrlQuery(){
150      query = window.location.search;
151      if(query =='' || query==null){
152        return {};
153      }
154      var query = query.substring(1,query.length);
155      var ary = query.split('&');
156      var data = {};
157      for(var i=0 ; i<ary.length ; i++){
158        var s = ary[i];
159        var prop = s.split('=');
160        if(prop[0] == "cat_classes" || prop[0] == "cats" || prop[0] == "tags" || prop[0] == "attrs") {
161          if(data[prop[0]] && prop[1] != "") {
162            data[prop[0]].push(prop[1]);
163          } else {
164            if(!data[prop[0]]) data[prop[0]] = [];
165            if(prop[1] != "") {
166              data[prop[0]].push(prop[1]);
167            }
168          }
169        } else {
170          data[prop[0]]=prop[1];
171        }
172      }
173      return data;
174  }
175}

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.