PageSourceSearch

https://www.moug.net/js/util.js

js moug.net collected 2026-10-03 19:06:53 UTC 4,148 bytes, 159 lines download raw bytes

1function url(protocol) {
2    if (protocol == 'http' || protocol == 'https') {
3		return protocol + "://" + location.host;
4    } else {
5        return '';
6    }
7}
8
9function addEvent(elm,listener,fn){
10	try{
11		elm.addEventListener(listener,fn,false);
12	}catch(e){
13		elm.attachEvent("on"+listener,fn);
14	}
15}
16
17function doSearch(form) {
18	if (form == null) {
19		form = document.forms['search'];
20	}
21	if (form == null || form == undefined) {
22		return false;
23	}
24	if (form.q.value == '') {
25		alert("ŒŸõƒL[ƒ[ƒh‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B");
26		return false;
27	}
28	var type = "faq";
29	for (i=0; i< form.search_type.length; i++) {
30		if (form.search_type[i].checked) {
31			type = form.search_type[i].value;
32		}
33	}
34	// Search for Q&A
35	if (type == "faq") {
36		var sid = "";
37		if (getCookieVal("moug_sid") != "") {
38			sid = "&sid=" + getCookieVal("moug_sid");
39		}
40		var input = document.createElement("input");
41		input.type = "hidden";
42		input.name = "search_keywords";
43		input.value = form.q.value;
44		form.appendChild(input);
45		form.action = url('http') + "/faq/search.php?mode=results" + sid;
46		form.target = "";
47		return true;
48	}
49	// Search for moug by Google. 
50	else if (type == "inside") {
51		hl = document.createElement("input");
52		hl.setAttribute("name", "hl");
53		hl.setAttribute("value", "ja");
54		hl.setAttribute("type", "hidden");
55		form.appendChild(hl);
56		ie = document.createElement("input");
57		ie.setAttribute("name", "ie");
58		ie.setAttribute("value", "Shift-JIS");
59		ie.setAttribute("type", "hidden");
60		form.appendChild(ie);
61		oe = document.createElement("input");
62		oe.setAttribute("name", "oe");
63		oe.setAttribute("value", "Shift-JIS");
64		oe.setAttribute("type", "hidden");
65		form.appendChild(oe);
66		site = document.createElement("input");
67		site.setAttribute("name", "as_sitesearch");
68		site.setAttribute("value", "www.moug.net");
69		site.setAttribute("type", "hidden");
70		form.appendChild(site);
71		
72		form.method = "GET";
73		form.action = "http://www.google.co.jp/search";
74		form.target = "_blank";
75	}
76}
77
78// Get a cookie value...
79function getCookieVal(cookieName) {
80	var i, index, arr;
81    arr = document.cookie.split(";");
82    for(i = 0; i < arr.length; i++) {
83        index = arr[i].indexOf("=");
84        if(arr[i].substring(0, index) == cookieName ||
85           arr[i].substring(0, index) == " " + cookieName) {
86           arr[i] = arr[i].replace(/\+/g, "%20");
87        	return decodeURIComponent(arr[i].substring(index + 1));
88        }
89    }
90    return "";
91}
92
93function isHankaku(name) {
94	var element = document.getElementById(name);
95    var length = element.value.length;
96    if (length == jstrlen(element.value)) {
97        return true;
98    } else {
99    	alert("”¼Šp‰p”Žš‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚¢");
100    	element.value = '';
101        return false;
102    }
103}
104
105function jstrlen(str) {
106   len = 0;
107   str = escape(str);
108   for (i = 0; i < str.length; i++, len++) {
109      if (str.charAt(i) == "%") {
110         if (str.charAt(++i) == "u") {
111            i += 3;
112            len++;
113         }
114         i++;
115      }
116   }
117   return len;
118}
119
120function checkAgreement() {
121	form = document.forms['agree_form'];
122	var type = "";
123	for (i=0; i< form.agreement.length; i++) {
124		if (form.agreement[i].checked) {
125			type = form.agreement[i].value;
126		}
127	}
128	if (type == "disagree") {
129		form.action = "/";
130	}
131	return false;
132}
133
134function checkWithdraw() {
135	var form = document.forms['withdraw_form'];
136	var sid = "";
137	if (window.confirm("‘މ‚Ä‚à‚æ‚낵‚¢‚Å‚·‚©")) {
138		if (getCookieVal("moug_sid") != '') {
139            sid = "&sid=" + getCookieVal("moug_sid");
140        }
141        form.action = "/faq/login.php?logout=true" + sid;
142		form.submit();
143	}
144	return false;
145}
146
147function decodeHtmlEntity(str) {
148    str = str.replace(/&amp;/g, '&');
149    str = str.replace(/&quot;/g, '"');
150    str = str.replace(/&gt;/g, '>');
151    str = str.replace(/&lt;/g, '<');
152
153    return str;
154}
155
156function showSpcharTable() {
157    window.open('spchar_table.html', '_spchartable', 'resizable=no, scrollbars=no, status=no, HEIGHT=170, WIDTH=310');
158    return false;
159}

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.