settings.js 30.8 KB
Newer Older
1 2
/// 設定変更画面

Masaru Abe committed
3 4 5
//名前空間用のオブジェクトを用意する
var SETTINGS = {};

6 7 8
// Init function of page
$(document).ready(function () {

9
    if (!AVWEB.avwCheckLogin(COMMON.ScreenIds.Login)) return;
Masaru Abe committed
10
    COMMON.ToogleLogoutNortice();
11 12 13
    if(ClientData.serviceOpt_encryption() != 'Y') {
   	 COMMON.LockScreen();
    }
14

15
//    document.title = I18N.i18nText('dspSetting') + ' | ' + I18N.i18nText('sysAppTitle');
16 17

    // Set bookmark screen
18
    ClientData.BookmarkScreen(COMMON.ScreenIds.Setting);
19

20 21 22 23
    if((ClientData.serviceOpt_apns() == 'Y') || (ClientData.serviceOpt_usable_push_message() == 'Y')) {
    	$('#dspPushMessage').show();
    }

Masaru Abe committed
24
    SETTINGS.initScreen();
25

Masaru Abe committed
26
    $("#dspSave").click(SETTINGS.dspSave_Click);
27

28 29 30 31 32 33
    if(ClientData.serviceOpt_encryption() == 'Y') {
    	$("#dspPwdUpd").hide();
    } else {
    	$("#dspPwdUpd").click(SETTINGS.dspPwdUpd_Click);
    }

34

Masaru Abe committed
35
    $("#dspOptReset").click(SETTINGS.dspOptReset_Click);
36

Masaru Abe committed
37
    $("#dspOptBk").click(SETTINGS.dspOptBk_Click);
38

Masaru Abe committed
39
    $("#dspOptRes").click(SETTINGS.dspOptRes_Click);
40

Masaru Abe committed
41 42 43
    $("#dspPwdUpd1").click(SETTINGS.dspPwdUpd1_Click);
    $("#dspSkip").click(SETTINGS.dspSkip_Click);
    $("#dspCancel").click(SETTINGS.dspCancel_Click);
44

Masaru Abe committed
45 46
    $("#dspOptRes_OK").click(SETTINGS.dspOptRes_OK_Click);
    $("#dspOptRes_Cancel").click(SETTINGS.dspOptRes_Cancel_Click);
47

Masaru Abe committed
48 49
    $("#dspOptBk_OK").click(SETTINGS.dspOptBk_OK_Click);
    $("#dspOptBk_Cancel").click(SETTINGS.dspOptBk_Cancel_Click);
50 51 52 53 54 55 56 57

    // Check to hide/show backup button
    if (ClientData.isChangedBookmark() == true
        || ClientData.isChangedMarkingData() == true
        || ClientData.isChangedMemo() == true) {
        $("#dspOptBk").show();

        // check disabled button backup
Masaru Abe committed
58
        HEADER.checkDisabledButton('#dlgConfirmBackup .option_backup input', '#dspOptBk_OK');
59 60 61 62 63 64 65
    }
    else {
        $("#dspOptBk").hide();
    }


    // Get flag to determine must change password
66
    AVWEB.avwCmsApi(ClientData.userInfo_accountPath(), "requirePasswordChange", 'GET', { sid: ClientData.userInfo_sid() },
Masaru Abe committed
67 68
    		SETTINGS.avwCmsApi_requirePasswordChange_success,
    		null
69 70 71 72 73 74 75 76 77 78 79 80
    );

    // In case: user_data_backup = "Y" -> backup
    if (ClientData.serviceOpt_user_data_backup() != "Y") {

        $("#dspOptBk").css('visibility', 'hidden');
        $("#dspOptRes").css('visibility', 'hidden');

        $("#chkOptBkCfm").css('visibility', 'hidden');
        $("#txtOptBkCfm").css('visibility', 'hidden');
        $("#txtBkResCap").css('visibility', 'hidden');
        $('#regionOptionBackup').css('visibility', 'hidden');
81
        $('#backup_default').css('visibility', 'hidden');
82 83 84 85 86
    }
    else {

        // check show restore button No.17

Masaru Abe committed
87 88 89
        var isExistMarking = SETTINGS.IsExistBackupFile('Marking.json', 2);
        var isExistContentMemo = SETTINGS.IsExistBackupFile('ContentMemo.json', 1);
        var isExistBookmark = SETTINGS.IsExistBackupFile('Bookmark.json', 4);
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

        if (isExistMarking || isExistContentMemo || isExistBookmark) {
            $("#dspOptRes").css('visibility', '');

            if (!isExistMarking) {
                $('#chkopResMarking').attr('disabled', 'disabled').removeAttr('checked');
            }
            else {
                $('#chkopResMarking').removeAttr('disabled');
            }

            if (!isExistContentMemo) {
                $('#chkopResMemo').attr('disabled', 'disabled').removeAttr('checked');
            }
            else {
                $('#chkopResMemo').removeAttr('disabled');
            }

            if (!isExistBookmark) {
                $('#chkopResShiori').attr('disabled', 'disabled').removeAttr('checked');
            }
            else {
                $('#chkopResShiori').removeAttr('disabled');
            }

            // check disabled button restore
Masaru Abe committed
116
            HEADER.checkDisabledButton('#dlgConfirmRestore .option_backup input', '#dspOptRes_OK');
117 118 119 120 121 122 123 124 125 126 127

        }
        else {
            $("#dspOptRes").css('visibility', 'hidden');
        }
    }
});

/*
  event of changing language
*/
128
function changeLanguageCallBackFunction() {
129
//    document.title = I18N.i18nText('dspSetting') + ' | ' + I18N.i18nText('sysAppTitle');
130 131 132 133 134 135 136
};


/*
Check backup file exists or not for No.17
*/

Masaru Abe committed
137
SETTINGS.IsExistBackupFile = function(file,type) {
138
    var isExisted = false;
139
    var params = { "sid": ClientData.userInfo_sid(), "filename": file, fileType: type }; //, deviceType: '4'
140
    // Get list of files
141
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post", params,
142 143 144 145 146 147 148 149 150 151
                    function (data) {
                        if (data) {
                            isExisted = true;
                        }
                    },
                    function (xhr, b, c) {
                        if (xhr.status != 0) {
                            isExisted = false;
                        }
                        else {
152
                        	AVWEB.showSystemError();
153 154 155 156 157 158
                        }
                    });
    return isExisted;
};

// Event success
Masaru Abe committed
159
SETTINGS.avwCmsApi_requirePasswordChange_success = function(data) {
160 161 162 163 164 165 166 167

    ClientData.requirePasswordChange(0);
    if (data.requirePasswordChange == 1) {
        if (ClientData.serviceOpt_force_pw_change_on_login() == 0) { // No need to change password
            // Skip this case
        }
        else if (ClientData.serviceOpt_force_pw_change_on_login() == 1) {  // Recommend to change password
            var pwdSkipDt = ClientData.userInfo_pwdSkipDt();
168

169 170 171 172 173
            if (pwdSkipDt) {
                // Check 30 days
                var currDate = new Date();
                var skipDate = new Date(pwdSkipDt);
                var numDay = currDate.subtractByDays(skipDate);
174

175 176 177 178 179
                if (numDay <= 30) {
                    // Do not show dialog to change password
                }
                else if (numDay > 30) {
                    // Show dialog to change password
Masaru Abe committed
180
                	SETTINGS.openChangePassword();
181 182 183 184 185 186

                    $("#dspSkip").show();
                    $("#dspCancel").hide();
                }
            }
            else {
187

188
                //alert('pwdSkipDt=null');
Masaru Abe committed
189
            	SETTINGS.openChangePassword();
190 191 192 193 194 195 196

                $("#dspSkip").show();
                $("#dspCancel").hide();
            }
        }
        else if (ClientData.serviceOpt_force_pw_change_on_login() == 2) {  // Force to change password
        	ClientData.requirePasswordChange(1);
Masaru Abe committed
197
        	SETTINGS.openChangePassword();
198

199 200 201 202 203 204 205
            $("#dspSkip").hide();
            $("#dspCancel").hide();
            //$("#dspPwdUpd1").css('margin', $("#dspCancel").css('margin'));
            //$("#dspPwdUpd1").css('margin', '-27px 97px 0 0');
            $("#txtChangePassComment").css('visibility', 'hidden');

        }
206

207 208 209 210 211 212 213 214 215 216 217 218 219 220
    }
    else if (data.requirePasswordChange == 2) {

        if (ClientData.serviceOpt_force_pw_change_periodically() == 0) { // No need to change password
            // Skip this case
        }
        else if (ClientData.serviceOpt_force_pw_change_periodically() == 1) {  // Recommend to change password
            var pwdSkipDt = ClientData.userInfo_pwdSkipDt();

            if (pwdSkipDt) {
                // Check 30 days
                var currDate = new Date();
                var skipDate = new Date(pwdSkipDt);
                var numDay = currDate.subtractByDays(skipDate);
221

222 223 224 225 226
                if (numDay <= 30) {
                    // Do not show dialog to change password
                }
                else if (numDay > 30) {
                    // Show dialog to change password
Masaru Abe committed
227
                	SETTINGS.openChangePassword();
228 229 230 231 232 233 234

                    $("#dspSkip").show();
                    $("#dspCancel").hide();
                }
            }
            else {
                //alert('pwdSkipDt=null');
235

Masaru Abe committed
236
            	SETTINGS.openChangePassword();
237 238 239 240 241 242 243 244 245

                $("#dspSkip").show();
                $("#dspCancel").hide();
            }


        }
        else if (ClientData.serviceOpt_force_pw_change_periodically() == 2) {  // Force to change password
        	ClientData.requirePasswordChange(1);
Masaru Abe committed
246
        	SETTINGS.openChangePassword();
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

            $("#dspSkip").hide();
            $("#dspCancel").hide();
            //$("#dspPwdUpd1").css('margin', '-27px 97px 0 0');
            $("#txtChangePassComment").css('visibility', 'hidden');
        }
    }
    else if (data.requirePasswordChange == 0) {
        // Skip this case
    }
};

/*
----------------------------------------------------------------------------
Event groups [start]
----------------------------------------------------------------------------
*/

// OK for backup
Masaru Abe committed
266
SETTINGS.dspOptBk_OK_Click = function(e) {
267 268 269 270 271 272 273 274
    e.preventDefault();

    // check button is disabled
    if ($(this).hasClass('disabled'))
        return;

    // ----------------------------
    // Process backup here
275
    // ----------------------------
276 277 278 279 280 281 282 283 284
    // Bakup memo/marking/bookmark
    // backup data for No.17

    var isBackupMarking = $('#chkopBkMarking').attr('checked') == 'checked';
    var isBackupMemo = $('#chkopBkMemo').attr('checked') == 'checked';
    var isBackupBookmark = $('#chkopBkShiori').attr('checked') == 'checked';

    if (!isBackupMarking && !isBackupMemo && !isBackupBookmark)
    {
Masaru Abe committed
285
    	SETTINGS.closeBackup();
286 287 288 289
        return;
    }

    // call backup file at header
Masaru Abe committed
290
    HEADER.DoBackup(isBackupMarking, isBackupMemo, isBackupBookmark, false,
291 292 293
    function () {

        // Check to hide/show backup button
Masaru Abe committed
294
    	SETTINGS.setStatusButtonBackup();
295 296 297 298 299 300 301 302 303 304 305 306

        // update check box restore
        if (isBackupMarking && !ClientData.isChangedMarkingData()) {
            $('#chkopResMarking').removeAttr('disabled');
        }
        if (isBackupMemo && !ClientData.isChangedMemo()) {
            $('#chkopResMemo').removeAttr('disabled');
        }
        if (isBackupBookmark && !ClientData.isChangedBookmark()) {
            $('#chkopResShiori').removeAttr('disabled');
        }

Masaru Abe committed
307
        SETTINGS.closeBackup();
308

309
    });
310 311 312
};

// set status button backup and checkbox option
Masaru Abe committed
313
SETTINGS.setStatusButtonBackup = function() {
314 315 316 317 318 319 320 321 322 323 324 325 326 327
    if (ClientData.isChangedBookmark() == true || ClientData.isChangedMarkingData() == true || ClientData.isChangedMemo() == true) {

        if (ClientData.isChangedBookmark() != true) {
            $('#chkopBkShiori').attr('disabled', 'disabled').removeAttr('checked');
        }
        if (ClientData.isChangedMarkingData() != true) {
            $('#chkopBkMarking').attr('disabled', 'disabled').removeAttr('checked');
        }
        if (ClientData.isChangedMemo() != true) {
            $('#chkopBkMemo').attr('disabled', 'disabled').removeAttr('checked');
        }
        $("#dspOptBk").show();
    }
    else {
328

329 330 331 332 333
        $("#dspOptBk").hide();
    }
};

// Cancel for backup
Masaru Abe committed
334
SETTINGS.dspOptBk_Cancel_Click = function(e) {
335
    e.preventDefault();
Masaru Abe committed
336
    SETTINGS.closeBackup(true);
337 338 339
};

// OK for restore
Masaru Abe committed
340
SETTINGS.dspOptRes_OK_Click = function(e) {
341 342 343 344 345 346
    e.preventDefault();
    // ----------------------------
    // Process restore
    // ----------------------------

    // check button is disabled
Masaru Abe committed
347
    if ($(this).hasClass('disabled')){
348
        return;
Masaru Abe committed
349
    }
350 351 352 353 354 355 356

    // Restore data for No.17

    var isRestoreMarking = $('#chkopResMarking').attr('checked') == 'checked';
    var isRestoreMemo = $('#chkopResMemo').attr('checked') == 'checked';
    var isRestoreBookmark = $('#chkopResShiori').attr('checked') == 'checked';
    if (!isRestoreMarking && !isRestoreMemo && !isRestoreBookmark) {
Masaru Abe committed
357
    	SETTINGS.closeRestore();
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
        return;
    }

        $().toastmessage({ position: 'middle-center' });
        $().toastmessage('showToast', {
            type: '',
            sticky: true,
            text: '',
            customMessages: 'divResultMessage'
        });
        $('#divResultMessage').append("<div class='toast-item-loading'></div>"); // show item loading

        setTimeout(function () {

            if (isRestoreMarking) {

                // restore Marking Data
Masaru Abe committed
375
                var res = SETTINGS.restoreMarkingData();
376
                if (!res) {
377
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkMarking') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
378 379
                }
                else {
380
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkMarking') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
381 382 383 384 385
                }
            }
            if (isRestoreMemo) {

                // restore Memo data
Masaru Abe committed
386
                var res = SETTINGS.restoreMemoData();
387
                if (!res) {
388
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkMemo') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
389 390
                }
                else {
391
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkMemo') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
392 393 394 395 396
                }
            }
            if (isRestoreBookmark) {

                // restore Bookmark data
Masaru Abe committed
397
                var res = SETTINGS.restoreBookmarkData();
398
                if (!res) {
399
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkShiori') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
400 401
                }
                else {
402
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkShiori') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
403 404 405 406
                }
            }

            // set status button backup
Masaru Abe committed
407
            //SETTINGS.setStatusButtonBackup();
408 409 410 411 412 413 414

            // show message result restore

            // hide item loading
            $('#divResultMessage .toast-item-loading').hide();

            // active close toast button
415
            $('.toast-item-close').click(function () { $().toastmessage('removeToast', $('#divResultMessage'), null); });
416 417
        }, 1000);

Masaru Abe committed
418
        SETTINGS.closeRestore();
419 420 421 422 423
};

/*
 * Call api to restore bookmark data
 */
Masaru Abe committed
424
SETTINGS.restoreBookmarkData = function()
425 426
{
    var result = false;
427
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
428 429
                { sid: ClientData.userInfo_sid(), filename: "Bookmark.json" }, // deviceType: '4',
                    function (data) {
430
                        if (data) {
Masaru Abe committed
431
                            COMMON.getDataBookmark(data);
432 433 434 435 436 437 438 439 440 441 442 443 444 445
                            ClientData.isChangedBookmark(false);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
};

/*
 * Call api to restore memo data
 */
Masaru Abe committed
446
SETTINGS.restoreMemoData = function() {
447
    var result = false;
448
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
449
                { sid: ClientData.userInfo_sid(), filename: "ContentMemo.json" }, //deviceType: '4',
450 451
                    function (data) {
                        if (data) {
Masaru Abe committed
452
                            COMMON.getDataMemo(data);
453 454 455 456 457 458 459 460 461 462 463 464 465 466
                            //ClientData.isChangedMemo(true);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
};

/*
 * Call api to restore marking data
 */
467
SETTINGS.restoreMarkingData = function()
468 469
{
    var result = false;
470
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
471
                { sid: ClientData.userInfo_sid(), filename: "Marking.json" }, // deviceType: '4',
472 473
                    function (data) {
                        if (data) {
Masaru Abe committed
474
                            COMMON.getDataMarking(data);
475 476 477 478 479 480 481 482 483
                            ClientData.isChangedMarkingData(false);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
Masaru Abe committed
484
};
485 486 487


// Cancel for restore
Masaru Abe committed
488
SETTINGS.dspOptRes_Cancel_Click = function(e) {
489
    e.preventDefault();
Masaru Abe committed
490
    SETTINGS.closeRestore(true);
491 492 493
};

// Cancel to change password
Masaru Abe committed
494
SETTINGS.dspCancel_Click = function(e) {
495 496 497
    e.preventDefault();
    var msgError = $('#dialog-error-message');
    msgError.html('');
Masaru Abe committed
498
    SETTINGS.closeChangePassword(true);
499 500 501
};

// Save setting
Masaru Abe committed
502
SETTINGS.dspSave_Click = function(e) {
503 504 505 506
    e.preventDefault();

    // 最初の画面を選択
    if ($("#rdoOpt001").attr('checked') == 'checked') {
507
        ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_BookShelf); // Bookshelf
508 509
    }
    else {
510
        ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_List); // List
511 512 513 514 515 516 517 518 519 520 521 522
    }
    // 動画、音楽繰り返し
    if ($("#chkOpt002").attr('checked') == 'checked') {
        ClientData.userOpt_musicMode(1);
        ClientData.userOpt_videoMode(1);
    }
    else {
        ClientData.userOpt_musicMode(0);
        ClientData.userOpt_videoMode(0);
    }
    // マーキング(コンテンツを開いた時に表示する)
    if ($("#chkOpt003").attr('checked') == 'checked') {
523
        ClientData.userOpt_makingDsp(1);
524 525 526 527 528 529 530
    }
    else {
        ClientData.userOpt_makingDsp(0);
    }
    // Show/not show alert when press F5.close tab.broswer.
    if ($("#chkOpt005").attr('checked') == 'checked') {
        ClientData.userOpt_closeOrRefreshAlert(1);
Masaru Abe committed
531
        COMMON.ToogleLogoutNortice();
532 533 534
    }
    else {
        ClientData.userOpt_closeOrRefreshAlert(0);
Masaru Abe committed
535
        COMMON.ToogleLogoutNortice();
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
    }
    // 毎回ログアウトの時、バックアップするかどうかは必ず確認する
    if ($("#chkOptBkCfm").attr('checked') == 'checked') {
        ClientData.userOpt_bkConfirmFlg(1);
    }
    else {
        ClientData.userOpt_bkConfirmFlg(0);
    }


    // save options backup No.17
    if ($("#chkBkMarking").attr('checked') == 'checked') {
        ClientData.userOpt_bkMakingFlag(1);
    }
    else {
        ClientData.userOpt_bkMakingFlag(0);
    }

    if ($("#chkBkMemo").attr('checked') == 'checked') {
        ClientData.userOpt_bkMemoFlag(1);
    }
    else {
        ClientData.userOpt_bkMemoFlag(0);
    }

    if ($("#chkBkShiori").attr('checked') == 'checked') {
        ClientData.userOpt_bkShioriFlag(1);
    }
    else {
        ClientData.userOpt_bkShioriFlag(0);
    }

    // save config page transition No.4

    ClientData.userOpt_pageTransition($('#cboAnimation').val());

    var timeAnimation = $('#txtValueAnimation').val();

    if (isNaN(timeAnimation) || timeAnimation < 0.1 || timeAnimation.length == 2 || timeAnimation.length > 3 || timeAnimation.indexOf('.')==0) {
        timeAnimation = 0.1;
    }
    else if (timeAnimation > 9.9) {
        timeAnimation = 9.9;
    }

    ClientData.userOpt_pageTransitionPeriod(timeAnimation);
    $('#txtValueAnimation').val(timeAnimation);


    /* show messages */
    $().toastmessage({ position: 'middle-center' });
    $().toastmessage('showToast', {
        type: 'success',
        sticky: true,
590
        text: I18N.i18nText('msgSaveOk')
591
    });
592 593 594 595

};

// Skip to change password
Masaru Abe committed
596
SETTINGS.dspSkip_Click = function(e) {
597 598 599 600 601
    e.preventDefault();
    var msgError = $('#dialog-error-message');
    msgError.html('');
    // Update パスワードスキップ日時
    ClientData.userInfo_pwdSkipDt(new Date());
Masaru Abe committed
602
    SETTINGS.closeChangePassword();
603 604
};

Masaru Abe committed
605
SETTINGS.openChangePassword = function() {
606 607
    //$("#dlgChangePassword").dialog("open");
    //$(".ui-dialog-titlebar").hide();
608

609 610 611 612 613
    // Clear all input values
    $("#txtPwdCur").val('');
    $("#txtPwdNew").val('');
    $("#txtPwdNewRe").val('');

614
    COMMON.lockLayout();
615 616 617 618 619
    $("#dlgChangePassword").show();
    $("#dlgChangePassword").center();

};

Masaru Abe committed
620
SETTINGS.closeChangePassword = function(skip) {
621 622
    //$("#dlgChangePassword").dialog("close");
    $("#dlgChangePassword").hide();
Masaru Abe committed
623
    COMMON.unlockLayout();
624 625 626
};

// Want to change password
Masaru Abe committed
627
SETTINGS.dspPwdUpd_Click = function(e) {
628 629 630 631 632
    e.preventDefault();
    $("#dspCancel").show();
    $("#dspSkip").hide();
    $("#txtChangePassComment").css('visibility', 'hidden');
    //$("#dspPwdUpd1").css('margin', '-27px 97px 0 0');
633

634
    // Show dialog
Masaru Abe committed
635
    SETTINGS.openChangePassword();
636 637 638
};

// Reset setting
Masaru Abe committed
639
SETTINGS.dspOptReset_Click = function(e) {
640 641 642 643 644
    e.preventDefault();

    // 最初の画面を選択
    $("#rdoOpt001").attr('checked', 'checked');
    // 動画、音楽繰り返し
645 646 647 648 649 650 651 652 653
	if( AVWEB.avwSysSetting().optMusicMode != undefined){
		if(AVWEB.avwSysSetting().optMusicMode == 1){
			$("#chkOpt002").attr('checked', 'checked');
		} else {
			$("#chkOpt002").removeAttr('checked');
		}
	} else {
		$("#chkOpt002").attr('checked', 'checked');
	}
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
    // マーキング(コンテンツを開いた時に表示する)
    $("#chkOpt003").attr('checked', 'checked');
    // Show alert when press F5.close tab.broswer
    $("#chkOpt005").attr('checked', 'checked');
    // 毎回ログアウトの時、バックアップするかどうかは必ず確認する
    $("#chkOptBkCfm").attr('checked', 'checked');

    // set default backup marking
    $('#chkBkMarking').attr('checked', 'checked');
    // set default backup memo
    $('#chkBkMemo').attr('checked', 'checked');
    // set default backup bookmark
    $('#chkBkShiori').attr('checked', 'checked');

    // reset page transition no.4
    $('#txtValueAnimation').val(1);
    $('#cboAnimation').val(0);
    $('#slidebar-animation').slider('value', 1);

};

// Backup
Masaru Abe committed
676
SETTINGS.dspOptBk_Click = function(e) {
677 678 679 680
    e.preventDefault();

    // set options backup No.17

681
    if (ClientData.userOpt_bkMakingFlag() == 0)
682 683 684
    {
        $("#chkopBkMarking").removeAttr('checked');
    }
685
    else
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
    {
        $("#chkopBkMarking").attr('checked', 'checked');
    }
    if (ClientData.userOpt_bkMemoFlag() == 0) {
        $("#chkopBkMemo").removeAttr('checked');
    }
    else {
        $("#chkopBkMemo").attr('checked', 'checked');
    }

    if (ClientData.userOpt_bkShioriFlag() == 0) {
        $("#chkopBkShiori").removeAttr('checked');
    }
    else {
        $("#chkopBkShiori").attr('checked', 'checked');
    }

    // check content is changed

705
    if (!ClientData.isChangedBookmark())
706
    {
707
        $('#chkopBkShiori').attr('disabled', 'disabled').removeAttr('checked');
708 709 710 711 712 713 714 715 716 717
    }
    else {
        $('#chkopBkShiori').removeAttr('disabled');
    }

    if (!ClientData.isChangedMemo()) {
        $('#chkopBkMemo').attr('disabled', 'disabled').removeAttr('checked');
    }
    else {
        $('#chkopBkMemo').removeAttr('disabled');
718
    }
719 720 721 722 723 724 725
    if (!ClientData.isChangedMarkingData()) {
        $('#chkopBkMarking').attr('disabled', 'disabled').removeAttr('checked');
    }
    else {
        $('#chkopBkMarking').removeAttr('disabled');
    }

Masaru Abe committed
726
    HEADER.setDisabledButton('#dlgConfirmBackup .option_backup input', '#dspOptBk_OK');
727

Masaru Abe committed
728
    SETTINGS.openBackup();
729 730 731
};

// Restore
Masaru Abe committed
732
SETTINGS.dspOptRes_Click = function(e) {
733
    e.preventDefault();
Masaru Abe committed
734
    SETTINGS.openRestore();
735 736 737
};

// Process changing password
Masaru Abe committed
738
SETTINGS.dspPwdUpd1_Click = function(e) {
739 740 741 742
    e.preventDefault();
    var isOK = true;
	var msgError = $('#dialog-error-message');
    // Check validation
Masaru Abe committed
743
    if (!ValidationUtil.CheckRequiredForText(SETTINGS.getCurrentPassword())) {
744
        isOK = false;
745
	    msgError.html(I18N.i18nText('msgPwdEmpty'));
746
    	msgError.show();
747

748 749
    }
    else {
Masaru Abe committed
750
        if (!ValidationUtil.CheckRequiredForText(SETTINGS.getNewPassword())) {
751
            isOK = false;
752
    	    msgError.html(I18N.i18nText('msgPwdEmpty'));
753 754 755
	    	msgError.show();
        }
        else {
Masaru Abe committed
756
            if (SETTINGS.getNewPassword() != SETTINGS.getNewPasswordRe()) {
757
                isOK = false;
758
                msgError.html(I18N.i18nText('msgPwdNotMatch'));
759 760 761 762 763 764 765 766 767
    			msgError.show();
            }

        }
    }

    if (isOK) {

        // Check max length
Masaru Abe committed
768
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getCurrentPassword(), 16)) {
769 770
            isOK = false;
        }
Masaru Abe committed
771
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getNewPassword(), 16)) {
772 773
            isOK = false;
        }
Masaru Abe committed
774
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getNewPasswordRe(), 16)) {
775 776 777
            isOK = false;
        }
        // Data type
Masaru Abe committed
778
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getCurrentPassword())) {
779 780
            isOK = false;
        }
Masaru Abe committed
781
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getNewPassword())) {
782 783
            isOK = false;
        }
Masaru Abe committed
784
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getNewPasswordRe())) {
785 786
            isOK = false;
        }
Kang Donghun committed
787 788 789 790 791 792 793 794
        // 連続3文字以上チェック
        if (!ValidationUtil.HasSeqChar(SETTINGS.getNewPassword())) {
        	isOK = false;
        }
        // 前回と4文字連続一致
        if (!ValidationUtil.ContainSameSeqChar(SETTINGS.getCurrentPassword(), SETTINGS.getNewPassword(), 4)) {
        	isOK = false;
        }
Masaru Abe committed
795
        var str = SETTINGS.getCurrentPassword() + "";
796 797 798 799 800 801 802

    }

    // Do changing password
    var params = {
        sid: ClientData.userInfo_sid(),
        loginId: ClientData.userInfo_loginId_session(),
Masaru Abe committed
803 804
        password: SETTINGS.getCurrentPassword(),
        newPassword: SETTINGS.getNewPassword(),
805 806
        appId: 4
    };
807

808 809
    if (isOK) {

810
    	AVWEB.avwCmsApi(ClientData.userInfo_accountPath(), "passwordChange", "GET", params,
Masaru Abe committed
811 812
    			SETTINGS.avwCmsApi_passwordChange_success,
    			SETTINGS.avwCmsApi_passwordChange_fail);
813 814 815 816 817 818
    }
    else {
        //alert('error');
    }
};

Masaru Abe committed
819
SETTINGS.avwCmsApi_passwordChange_success = function(data) {
820 821 822 823
    // OK
	var msgError = $('#dialog-error-message');
    if (data.result != undefined && data.result != null) {

824
        if (data.result != COMMON.Consts.ConstAPI_SUCCESS) {
825
       	    msgError.html(I18N.i18nText('msgPwdChangeNG'));
826 827 828 829 830
			msgError.show();
        }
        else {
        	ClientData.requirePasswordChange(0);
        	msgError.html('');
Masaru Abe committed
831
        	SETTINGS.closeChangePassword();
832 833 834 835 836
            /* show messages */
            $().toastmessage({ position: 'middle-center' });
            $().toastmessage('showToast', {
                type: 'success',
                sticky: true,
837
                text: I18N.i18nText('msgPwdChangeOK')
838 839 840 841
            });
        }
    }
};
Masaru Abe committed
842
SETTINGS.avwCmsApi_passwordChange_fail = function(xhr, b, c) {
843 844 845 846
    if (xhr.responseText && xhr.status != 0) {
        /* show error messages */
        var msgError = $('#dialog-error-message');

847
        //msgError.html(I18N.i18nText('msgPwdChangeNG'));
848 849 850 851
        msgError.html(JSON.parse(xhr.responseText).errorMessage);
        msgError.show();
    }
    else {
852
    	AVWEB.showSystemError();
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873
    }
};


/*
----------------------------------------------------------------------------
Event groups [ end ]
----------------------------------------------------------------------------
*/

// Setting dialog
$(function () {
    $('#dlgChangePassword').center();
    $('#dlgConfirmBackup').center();
    $('#dlgConfirmRestore').center();

    $('#dlgChangePassword').hide();
    $('#dlgConfirmBackup').hide();
    $('#dlgConfirmRestore').hide();
});

Masaru Abe committed
874
SETTINGS.openBackup = function() {
875

876
    COMMON.lockLayout();
877 878 879 880 881
    $("#dlgConfirmBackup").show();
    $("#dlgConfirmBackup").center();

};

Masaru Abe committed
882
SETTINGS.closeBackup = function(cancel) {
883 884 885 886 887
    if (cancel != undefined || cancel == true) {
        //alert('you cancelled');
    }
    //$("#dlgConfirmBackup").dialog("close");
    $("#dlgConfirmBackup").hide();
Masaru Abe committed
888
    COMMON.unlockLayout();
889 890
};

Masaru Abe committed
891
SETTINGS.openRestore = function() {
892
    // check avaliable restore no.17
893
    COMMON.lockLayout();
894 895 896 897
    $("#dlgConfirmRestore").show();
    $("#dlgConfirmRestore").center();
};

Masaru Abe committed
898
SETTINGS.closeRestore = function(cancel) {
899 900 901 902 903
    if (cancel != undefined || cancel == true) {
        //alert('you cancelled');
    }
    //$("#dlgConfirmRestore").dialog("close");
    $("#dlgConfirmRestore").hide();
Masaru Abe committed
904
    COMMON.unlockLayout();
905 906 907
};

// Get input current password
Masaru Abe committed
908
SETTINGS.getCurrentPassword = function() {
909 910 911
    return $("#txtPwdCur").val();
};
// Get input new password
Masaru Abe committed
912
SETTINGS.getNewPassword = function() {
913 914
    return $("#txtPwdNew").val();
};
915
// Get input new password
Masaru Abe committed
916
SETTINGS.getNewPasswordRe = function() {
917 918 919 920
    return $("#txtPwdNewRe").val();
};

// Initalize screen
Masaru Abe committed
921
SETTINGS.initScreen = function() {
922 923 924 925 926 927 928 929 930 931 932 933

    // ログインID
    $("#txtLoginId").text(ClientData.userInfo_loginId_session());
    // アカウントパス
    $("#txtLoginPath").text(ClientData.userInfo_accountPath_session());

    // 最終ログイン時間
    $("#txtLastLoginTime").text(ClientData.userInfo_lastLoginTime());
    //alert(getLastLoginDate());


    // 最初の画面を選択
934
    if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953
        $("#rdoOpt0011").attr('checked', 'checked');
    }
    else {
        $("#rdoOpt001").attr('checked', 'checked');
    }

    // 動画、音楽繰り返し
    if (ClientData.userOpt_musicMode() == 0) {
        $("#chkOpt002").removeAttr('checked');
    }
    else {
        $("#chkOpt002").attr('checked', 'checked');
    }

    // マーキング(コンテンツを開いた時に表示する)
    if (ClientData.userOpt_makingDsp() == 0) {
        $("#chkOpt003").removeAttr('checked');
    }
    else {
954

955 956
        $("#chkOpt003").attr('checked', 'checked');
    }
957 958
	// Show alert when press F5.close tab.broswer
	if (ClientData.userOpt_closeOrRefreshAlert() == 0) {
959 960
        $("#chkOpt005").removeAttr('checked');
    }
961
    else {
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
        $("#chkOpt005").attr('checked', 'checked');
    }
    // 毎回ログアウトの時、バックアップするかどうかは必ず確認する
    if (ClientData.userOpt_bkConfirmFlg() == 0) {
        $("#chkOptBkCfm").removeAttr('checked');
    }
    else {
        $("#chkOptBkCfm").attr('checked', 'checked');
    }

    // options backup No.17

    if (ClientData.userOpt_bkMakingFlag() == 0) {
        $("#chkBkMarking").removeAttr('checked');
    }
    else {
        $("#chkBkMarking").attr('checked', 'checked');
    }

    if (ClientData.userOpt_bkMemoFlag() == 0) {
        $("#chkBkMemo").removeAttr('checked');
    }
    else {
        $("#chkBkMemo").attr('checked', 'checked');
    }

    if (ClientData.userOpt_bkShioriFlag() == 0) {
        $("#chkBkShiori").removeAttr('checked');
    }
    else {
        $("#chkBkShiori").attr('checked', 'checked');
    }

    // load config page transition & page transition period  No.4

    $('#cboAnimation').val(ClientData.userOpt_pageTransition());

    $('#txtValueAnimation').val(ClientData.userOpt_pageTransitionPeriod());

    $('#txtValueAnimation').blur(function () {

        var value = $(this).val();
        if (isNaN(value) || value < 0.1 || value.length == 2 || value.length > 3 || value.indexOf('.') == 0) {
            value = 0.1;
        }
        else if (value > 9.9) {
            value = 9.9;
        }

        $(this).val(value);
        $('#slidebar-animation').slider('value', value);
    });

    $('#slidebar-animation').slider(
        {
            min: 0.1,
            max: 9.9,
            step: 0.1,
            value: $('#txtValueAnimation').val(),
Masaru Abe committed
1021
            slide: SETTINGS.doChangeAnimationSlidebar
1022 1023 1024 1025 1026
        }
    );

};

Masaru Abe committed
1027
SETTINGS.doChangeAnimationSlidebar = function(e,obj) {
1028
    $('#txtValueAnimation').val(obj.value);
Masaru Abe committed
1029
};