source: branches/feature-module-update/html/js/site.js @ 15079

Revision 15079, 8.5 KB checked in by nanasess, 17 years ago (diff)

svn:mime-type application/x-httpd-php; charset=UTF-8 設定

  • Property svn:mime-type set to application/x-httpd-php; charset=UTF-8
Line 
1/*
2 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
3 *
4 * http://www.lockon.co.jp/
5 */
6// 親ウィンドウの存在確認.
7function fnIsopener() {
8    var ua = navigator.userAgent;
9    if( !!window.opener ) {
10        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) {
11            return !window.opener.closed;
12        } else {
13            return typeof window.opener.document == 'object';
14        }
15    } else {
16        return false;
17    }
18}
19
20// 郵便番号入力呼び出し.
21function fnCallAddress(php_url, tagname1, tagname2, input1, input2) {
22    zip1 = document.form1[tagname1].value;
23    zip2 = document.form1[tagname2].value;
24   
25    if(zip1.length == 3 && zip2.length == 4) {
26        url = php_url + "?zip1=" + zip1 + "&zip2=" + zip2 + "&input1=" + input1 + "&input2=" + input2;
27        window.open(url,"nomenu","width=500,height=350,scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
28    } else {
29        alert("郵便番号を正しく入力して下さい。");
30    }
31}
32
33// 郵便番号から検索した住所を渡す.
34function fnPutAddress(input1, input2) {
35    // 親ウィンドウの存在確認。.
36    if(fnIsopener()) {
37        if(document.form1['state'].value != "") {
38            // 項目に値を入力する.
39            state_id = document.form1['state'].value;
40            town = document.form1['city'].value + document.form1['town'].value;
41            window.opener.document.form1[input1].selectedIndex = state_id;
42            window.opener.document.form1[input2].value = town;
43        }
44    } else {
45        window.close();
46    }       
47}
48
49function fnOpenNoMenu(URL) {
50    window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");
51}
52
53function fnOpenWindow(URL,name,width,height) {
54    window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");
55}
56
57function fnSetFocus(name) {
58    if(document.form1[name]) {
59        document.form1[name].focus();
60    }
61}
62
63// セレクトボックスに項目を割り当てる.
64function fnSetSelect(name1, name2, val) {
65    sele1 = document.form1[name1];
66    sele2 = document.form1[name2];
67   
68    if(sele1 && sele2) {
69        index=sele1.selectedIndex;
70       
71        // セレクトボックスのクリア
72        count=sele2.options.length
73        for(i = count; i >= 0; i--) {
74            sele2.options[i]=null;
75        }
76       
77        // セレクトボックスに値を割り当てる。
78        len = lists[index].length
79        for(i = 0; i < len; i++) {
80            sele2.options[i]=new Option(lists[index][i], vals[index][i]);
81            if(val != "" && vals[index][i] == val) {
82                sele2.options[i].selected = true;
83            }
84        }
85    }
86}
87
88// Enterキー入力をキャンセルする。(IEに対応)
89function fnCancelEnter()
90{
91    if (gCssUA.indexOf("WIN") != -1 && gCssUA.indexOf("MSIE") != -1) {
92        if (window.event.keyCode == 13)
93        {
94            return false;
95        }
96    }
97    return true;
98}
99
100// モードとキーを指定してSUBMITを行う。
101function fnModeSubmit(mode, keyname, keyid) {
102    switch(mode) {
103    case 'delete_category':
104        if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){
105            return;
106        }
107        break;
108    case 'delete':
109        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
110            return;
111        }
112        break;
113    case 'confirm':
114        if(!window.confirm('登録しても宜しいですか')){
115            return;
116        }
117        break;
118    case 'delete_all':
119        if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
120            return;
121        }
122        break;
123    default:
124        break;
125    }
126    document.form1['mode'].value = mode;
127    if(keyname != "" && keyid != "") {
128        document.form1[keyname].value = keyid;
129    }
130    document.form1.submit();
131}
132
133function fnFormModeSubmit(form, mode, keyname, keyid) {
134    switch(mode) {
135    case 'delete':
136        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
137            return;
138        }
139        break;
140    case 'confirm':
141        if(!window.confirm('登録しても宜しいですか')){
142            return;
143        }
144        break;
145    case 'regist':
146        if(!window.confirm('登録しても宜しいですか')){
147            return;
148        }
149        break;     
150    default:
151        break;
152    }
153    document.forms[form]['mode'].value = mode;
154    if(keyname != "" && keyid != "") {
155        document.forms[form][keyname].value = keyid;
156    }
157    document.forms[form].submit();
158}
159
160function fnSetFormSubmit(form, key, val) {
161    document.forms[form][key].value = val;
162    document.forms[form].submit();
163    return false;
164}
165
166function fnSetFormVal(form, key, val) {
167    document.forms[form][key].value = val;
168}
169
170function fnChangeAction(url) {
171    document.form1.action = url;
172}
173
174// ページナビで使用する。
175function fnNaviPage(pageno) {
176    document.form1['pageno'].value = pageno;
177    document.form1.submit();
178}
179
180function fnSearchPageNavi(pageno) {
181    document.form1['pageno'].value = pageno;
182    document.form1['mode'].value = 'search';
183    document.form1.submit();
184    }
185
186    function fnSubmit(){
187    document.form1.submit();
188}
189
190// ポイント入力制限。
191function fnCheckInputPoint() {
192    if(document.form1['point_check']) {
193        list = new Array(
194                        'use_point'
195                        );
196   
197        if(!document.form1['point_check'][0].checked) {
198            color = "#dddddd";
199            flag = true;
200        } else {
201            color = "";
202            flag = false;
203        }
204       
205        len = list.length
206        for(i = 0; i < len; i++) {
207            if(document.form1[list[i]]) {
208                document.form1[list[i]].disabled = flag;
209                document.form1[list[i]].style.backgroundColor = color;
210            }
211        }
212    }
213}
214
215// 別のお届け先入力制限。
216function fnCheckInputDeliv() {
217    if(!document.form1) {
218        return;
219    }
220    if(document.form1['deliv_check']) {
221        list = new Array(
222                        'deliv_name01',
223                        'deliv_name02',
224                        'deliv_kana01',
225                        'deliv_kana02',
226                        'deliv_pref',
227                        'deliv_zip01',
228                        'deliv_zip02',
229                        'deliv_addr01',
230                        'deliv_addr02',
231                        'deliv_tel01',
232                        'deliv_tel02',
233                        'deliv_tel03'
234                        );
235   
236        if(!document.form1['deliv_check'].checked) {
237            fnChangeDisabled(list, '#dddddd');
238        } else {
239            fnChangeDisabled(list, '');
240        }
241    }
242}
243
244
245// 購入時会員登録入力制限。
246function fnCheckInputMember() {
247    if(document.form1['member_check']) {
248        list = new Array(
249                        'password',
250                        'password_confirm',
251                        'reminder',
252                        'reminder_answer'
253                        );
254
255        if(!document.form1['member_check'].checked) {
256            fnChangeDisabled(list, '#dddddd');
257        } else {
258            fnChangeDisabled(list, '');
259        }
260    }
261}
262
263// 最初に設定されていた色を保存しておく。
264var g_savecolor = new Array();
265
266function fnChangeDisabled(list, color) {
267    len = list.length;
268   
269    for(i = 0; i < len; i++) {
270        if(document.form1[list[i]]) {
271            if(color == "") {
272                // 有効にする。
273                document.form1[list[i]].disabled = false;
274                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
275            } else {
276                // 無効にする。
277                document.form1[list[i]].disabled = true;
278                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
279                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; 
280            }           
281        }
282    }
283}
284
285
286// ログイン時の入力チェック
287function fnCheckLogin(formname) {
288    var lstitem = new Array();
289   
290    if(formname == 'login_mypage'){
291    lstitem[0] = 'mypage_login_email';
292    lstitem[1] = 'mypage_login_pass';
293    }else{
294    lstitem[0] = 'login_email';
295    lstitem[1] = 'login_pass';
296    }
297    var max = lstitem.length;
298    var errflg = false;
299    var cnt = 0;
300   
301    // 必須項目のチェック
302    for(cnt = 0; cnt < max; cnt++) {
303        if(document.forms[formname][lstitem[cnt]].value == "") {
304            errflg = true;
305            break;
306        }
307    }
308   
309    // 必須項目が入力されていない場合 
310    if(errflg == true) {
311        alert('メールアドレス/パスワードを入力して下さい。');
312        return false;
313    }
314}
315   
316// 時間の計測.
317function fnPassTime(){
318    end_time = new Date();
319    time = end_time.getTime() - start_time.getTime();
320    alert((time/1000));
321}
322start_time = new Date();
323
324//親ウィンドウのページを変更する.
325function fnUpdateParent(url) {
326    // 親ウィンドウの存在確認
327    if(fnIsopener()) {
328        window.opener.location.href = url;
329    } else {
330        window.close();
331    }       
332}
333
334//特定のキーをSUBMITする.
335function fnKeySubmit(keyname, keyid) {
336    if(keyname != "" && keyid != "") {
337        document.form1[keyname].value = keyid;
338    }
339    document.form1.submit();
340}
341
342//文字数をカウントする。
343//引数1:フォーム名称
344//引数2:文字数カウント対象
345//引数3:カウント結果格納対象
346function fnCharCount(form,sch,cnt) {
347    document.forms[form][cnt].value= document.forms[form][sch].value.length;
348}
349
350
351// テキストエリアのサイズを変更する.
352function ChangeSize(button, TextArea, Max, Min, row_tmp){
353   
354    if(TextArea.rows <= Min){
355        TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
356    }else{
357        TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
358    }
359}
360
Note: See TracBrowser for help on using the repository browser.