source: branches/feature-module-update/html/user_data/packages/default/js/site.js @ 16708

Revision 16708, 9.2 KB checked in by naka, 16 years ago (diff)

ユーザパッケージの移動

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 'confirm':
130        if(!window.confirm('登録しても宜しいですか')){
131            return;
132        }
133        break;
134    case 'delete_all':
135        if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
136            return;
137        }
138        break;
139    default:
140        break;
141    }
142    document.form1['mode'].value = mode;
143    if(keyname != "" && keyid != "") {
144        document.form1[keyname].value = keyid;
145    }
146    document.form1.submit();
147}
148
149function fnFormModeSubmit(form, mode, keyname, keyid) {
150    switch(mode) {
151    case 'delete':
152        if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか?')){
153            return;
154        }
155        break;
156    case 'confirm':
157        if(!window.confirm('登録しても宜しいですか')){
158            return;
159        }
160        break;
161    case 'regist':
162        if(!window.confirm('登録しても宜しいですか')){
163            return;
164        }
165        break;     
166    default:
167        break;
168    }
169    document.forms[form]['mode'].value = mode;
170    if(keyname != "" && keyid != "") {
171        document.forms[form][keyname].value = keyid;
172    }
173    document.forms[form].submit();
174}
175
176function fnSetFormSubmit(form, key, val) {
177    document.forms[form][key].value = val;
178    document.forms[form].submit();
179    return false;
180}
181
182function fnSetFormVal(form, key, val) {
183    document.forms[form][key].value = val;
184}
185
186function fnChangeAction(url) {
187    document.form1.action = url;
188}
189
190// ページナビで使用する。
191function fnNaviPage(pageno) {
192    document.form1['pageno'].value = pageno;
193    document.form1.submit();
194}
195
196function fnSearchPageNavi(pageno) {
197    document.form1['pageno'].value = pageno;
198    document.form1['mode'].value = 'search';
199    document.form1.submit();
200    }
201
202    function fnSubmit(){
203    document.form1.submit();
204}
205
206// ポイント入力制限。
207function fnCheckInputPoint() {
208    if(document.form1['point_check']) {
209        list = new Array(
210                        'use_point'
211                        );
212   
213        if(!document.form1['point_check'][0].checked) {
214            color = "#dddddd";
215            flag = true;
216        } else {
217            color = "";
218            flag = false;
219        }
220       
221        len = list.length
222        for(i = 0; i < len; i++) {
223            if(document.form1[list[i]]) {
224                document.form1[list[i]].disabled = flag;
225                document.form1[list[i]].style.backgroundColor = color;
226            }
227        }
228    }
229}
230
231// 別のお届け先入力制限。
232function fnCheckInputDeliv() {
233    if(!document.form1) {
234        return;
235    }
236    if(document.form1['deliv_check']) {
237        list = new Array(
238                        'deliv_name01',
239                        'deliv_name02',
240                        'deliv_kana01',
241                        'deliv_kana02',
242                        'deliv_pref',
243                        'deliv_zip01',
244                        'deliv_zip02',
245                        'deliv_addr01',
246                        'deliv_addr02',
247                        'deliv_tel01',
248                        'deliv_tel02',
249                        'deliv_tel03'
250                        );
251   
252        if(!document.form1['deliv_check'].checked) {
253            fnChangeDisabled(list, '#dddddd');
254        } else {
255            fnChangeDisabled(list, '');
256        }
257    }
258}
259
260
261// 購入時会員登録入力制限。
262function fnCheckInputMember() {
263    if(document.form1['member_check']) {
264        list = new Array(
265                        'password',
266                        'password_confirm',
267                        'reminder',
268                        'reminder_answer'
269                        );
270
271        if(!document.form1['member_check'].checked) {
272            fnChangeDisabled(list, '#dddddd');
273        } else {
274            fnChangeDisabled(list, '');
275        }
276    }
277}
278
279// 最初に設定されていた色を保存しておく。
280var g_savecolor = new Array();
281
282function fnChangeDisabled(list, color) {
283    len = list.length;
284   
285    for(i = 0; i < len; i++) {
286        if(document.form1[list[i]]) {
287            if(color == "") {
288                // 有効にする。
289                document.form1[list[i]].disabled = false;
290                document.form1[list[i]].style.backgroundColor = g_savecolor[list[i]];
291            } else {
292                // 無効にする。
293                document.form1[list[i]].disabled = true;
294                g_savecolor[list[i]] = document.form1[list[i]].style.backgroundColor;
295                document.form1[list[i]].style.backgroundColor = color;//"#f0f0f0"; 
296            }           
297        }
298    }
299}
300
301
302// ログイン時の入力チェック
303function fnCheckLogin(formname) {
304    var lstitem = new Array();
305   
306    if(formname == 'login_mypage'){
307    lstitem[0] = 'mypage_login_email';
308    lstitem[1] = 'mypage_login_pass';
309    }else{
310    lstitem[0] = 'login_email';
311    lstitem[1] = 'login_pass';
312    }
313    var max = lstitem.length;
314    var errflg = false;
315    var cnt = 0;
316   
317    // 必須項目のチェック
318    for(cnt = 0; cnt < max; cnt++) {
319        if(document.forms[formname][lstitem[cnt]].value == "") {
320            errflg = true;
321            break;
322        }
323    }
324   
325    // 必須項目が入力されていない場合 
326    if(errflg == true) {
327        alert('メールアドレス/パスワードを入力して下さい。');
328        return false;
329    }
330}
331   
332// 時間の計測.
333function fnPassTime(){
334    end_time = new Date();
335    time = end_time.getTime() - start_time.getTime();
336    alert((time/1000));
337}
338start_time = new Date();
339
340//親ウィンドウのページを変更する.
341function fnUpdateParent(url) {
342    // 親ウィンドウの存在確認
343    if(fnIsopener()) {
344        window.opener.location.href = url;
345    } else {
346        window.close();
347    }       
348}
349
350//特定のキーをSUBMITする.
351function fnKeySubmit(keyname, keyid) {
352    if(keyname != "" && keyid != "") {
353        document.form1[keyname].value = keyid;
354    }
355    document.form1.submit();
356}
357
358//文字数をカウントする。
359//引数1:フォーム名称
360//引数2:文字数カウント対象
361//引数3:カウント結果格納対象
362function fnCharCount(form,sch,cnt) {
363    document.forms[form][cnt].value= document.forms[form][sch].value.length;
364}
365
366
367// テキストエリアのサイズを変更する.
368function ChangeSize(button, TextArea, Max, Min, row_tmp){
369   
370    if(TextArea.rows <= Min){
371        TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
372    }else{
373        TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
374    }
375}
376
Note: See TracBrowser for help on using the repository browser.