source: trunk/html/user_data/packages/default/js/site.js @ 18562

Revision 18562, 9.5 KB checked in by kajiwara, 14 years ago (diff)

EC-CUBE Ver2.4.3 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=210

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