settings.js 30.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 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 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 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 1021
/// 設定変更画面

//名前空間用のオブジェクトを用意する
var SETTINGS = {};

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

    if (!AVWEB.avwCheckLogin(COMMON.ScreenIds.Login)) return;
    COMMON.ToogleLogoutNortice();
    if(ClientData.serviceOpt_encryption() != 'Y') {
   	 COMMON.LockScreen();
    }

    document.title = I18N.i18nText('dspSetting') + ' | ' + I18N.i18nText('sysAppTitle');

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

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

    SETTINGS.initScreen();

    $("#dspSave").click(SETTINGS.dspSave_Click);

    if(ClientData.serviceOpt_encryption() == 'Y') {
    	$("#dspPwdUpd").hide();
    } else {
    	$("#dspPwdUpd").click(SETTINGS.dspPwdUpd_Click);
    }


    $("#dspOptReset").click(SETTINGS.dspOptReset_Click);

    $("#dspOptBk").click(SETTINGS.dspOptBk_Click);

    $("#dspOptRes").click(SETTINGS.dspOptRes_Click);

    $("#dspPwdUpd1").click(SETTINGS.dspPwdUpd1_Click);
    $("#dspSkip").click(SETTINGS.dspSkip_Click);
    $("#dspCancel").click(SETTINGS.dspCancel_Click);

    $("#dspOptRes_OK").click(SETTINGS.dspOptRes_OK_Click);
    $("#dspOptRes_Cancel").click(SETTINGS.dspOptRes_Cancel_Click);

    $("#dspOptBk_OK").click(SETTINGS.dspOptBk_OK_Click);
    $("#dspOptBk_Cancel").click(SETTINGS.dspOptBk_Cancel_Click);

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

        // check disabled button backup
        HEADER.checkDisabledButton('#dlgConfirmBackup .option_backup input', '#dspOptBk_OK');
    }
    else {
        $("#dspOptBk").hide();
    }


    // Get flag to determine must change password
    AVWEB.avwCmsApi(ClientData.userInfo_accountPath(), "requirePasswordChange", 'GET', { sid: ClientData.userInfo_sid() },
    		SETTINGS.avwCmsApi_requirePasswordChange_success,
    		null
    );

    // 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');
        $('#backup_default').css('visibility', 'hidden');
    }
    else {

        // check show restore button No.17

        var isExistMarking = SETTINGS.IsExistBackupFile('Marking.json', 2);
        var isExistContentMemo = SETTINGS.IsExistBackupFile('ContentMemo.json', 1);
        var isExistBookmark = SETTINGS.IsExistBackupFile('Bookmark.json', 4);

        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
            HEADER.checkDisabledButton('#dlgConfirmRestore .option_backup input', '#dspOptRes_OK');

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

/*
  event of changing language
*/
function changeLanguageCallBackFunction() {
    document.title = I18N.i18nText('dspSetting') + ' | ' + I18N.i18nText('sysAppTitle');
};


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

SETTINGS.IsExistBackupFile = function(file,type) {
    var isExisted = false;
    var params = { "sid": ClientData.userInfo_sid(), "filename": file, fileType: type }; //, deviceType: '4'
    // Get list of files
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post", params,
                    function (data) {
                        if (data) {
                            isExisted = true;
                        }
                    },
                    function (xhr, b, c) {
                        if (xhr.status != 0) {
                            isExisted = false;
                        }
                        else {
                        	AVWEB.showSystemError();
                        }
                    });
    return isExisted;
};

// Event success
SETTINGS.avwCmsApi_requirePasswordChange_success = function(data) {

    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();

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

                if (numDay <= 30) {
                    // Do not show dialog to change password
                }
                else if (numDay > 30) {
                    // Show dialog to change password
                	SETTINGS.openChangePassword();

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

                //alert('pwdSkipDt=null');
            	SETTINGS.openChangePassword();

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

            $("#dspSkip").hide();
            $("#dspCancel").hide();
            //$("#dspPwdUpd1").css('margin', $("#dspCancel").css('margin'));
            //$("#dspPwdUpd1").css('margin', '-27px 97px 0 0');
            $("#txtChangePassComment").css('visibility', 'hidden');

        }

    }
    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);

                if (numDay <= 30) {
                    // Do not show dialog to change password
                }
                else if (numDay > 30) {
                    // Show dialog to change password
                	SETTINGS.openChangePassword();

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

            	SETTINGS.openChangePassword();

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


        }
        else if (ClientData.serviceOpt_force_pw_change_periodically() == 2) {  // Force to change password
        	ClientData.requirePasswordChange(1);
        	SETTINGS.openChangePassword();

            $("#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
SETTINGS.dspOptBk_OK_Click = function(e) {
    e.preventDefault();

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

    // ----------------------------
    // Process backup here
    // ----------------------------
    // 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)
    {
    	SETTINGS.closeBackup();
        return;
    }

    // call backup file at header
    HEADER.DoBackup(isBackupMarking, isBackupMemo, isBackupBookmark, false,
    function () {

        // Check to hide/show backup button
    	SETTINGS.setStatusButtonBackup();

        // 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');
        }

        SETTINGS.closeBackup();

    });
};

// set status button backup and checkbox option
SETTINGS.setStatusButtonBackup = function() {
    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 {

        $("#dspOptBk").hide();
    }
};

// Cancel for backup
SETTINGS.dspOptBk_Cancel_Click = function(e) {
    e.preventDefault();
    SETTINGS.closeBackup(true);
};

// OK for restore
SETTINGS.dspOptRes_OK_Click = function(e) {
    e.preventDefault();
    // ----------------------------
    // Process restore
    // ----------------------------

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

    // 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) {
    	SETTINGS.closeRestore();
        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
                var res = SETTINGS.restoreMarkingData();
                if (!res) {
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkMarking') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
                }
                else {
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkMarking') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
                }
            }
            if (isRestoreMemo) {

                // restore Memo data
                var res = SETTINGS.restoreMemoData();
                if (!res) {
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkMemo') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
                }
                else {
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkMemo') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
                }
            }
            if (isRestoreBookmark) {

                // restore Bookmark data
                var res = SETTINGS.restoreBookmarkData();
                if (!res) {
                    $('#divResultMessage').append("<div class='toast-item-image-error toast-item-message'>" + I18N.i18nText('txtBkShiori') + " " + I18N.i18nText('msgRestoreFailed') + "</div>");
                }
                else {
                    $('#divResultMessage').append("<div class='toast-item-image-success toast-item-message'>" + I18N.i18nText('txtBkShiori') + " " + I18N.i18nText('msgRestoreSuccess') + "</div>");
                }
            }

            // set status button backup
            //SETTINGS.setStatusButtonBackup();

            // show message result restore

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

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

        SETTINGS.closeRestore();
};

/*
 * Call api to restore bookmark data
 */
SETTINGS.restoreBookmarkData = function()
{
    var result = false;
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
                { sid: ClientData.userInfo_sid(), filename: "Bookmark.json" }, // deviceType: '4',
                    function (data) {
                        if (data) {
                            COMMON.getDataBookmark(data);
                            ClientData.isChangedBookmark(false);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
};

/*
 * Call api to restore memo data
 */
SETTINGS.restoreMemoData = function() {
    var result = false;
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
                { sid: ClientData.userInfo_sid(), filename: "ContentMemo.json" }, //deviceType: '4',
                    function (data) {
                        if (data) {
                            COMMON.getDataMemo(data);
                            //ClientData.isChangedMemo(true);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
};

/*
 * Call api to restore marking data
 */
SETTINGS.restoreMarkingData = function()
{
    var result = false;
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "getBackupFile", "post",
                { sid: ClientData.userInfo_sid(), filename: "Marking.json" }, // deviceType: '4',
                    function (data) {
                        if (data) {
                            COMMON.getDataMarking(data);
                            ClientData.isChangedMarkingData(false);
                            result = true;
                        }
                    }
                ,
                function (xhr, b, c) {
                }
    );
    return result;
};


// Cancel for restore
SETTINGS.dspOptRes_Cancel_Click = function(e) {
    e.preventDefault();
    SETTINGS.closeRestore(true);
};

// Cancel to change password
SETTINGS.dspCancel_Click = function(e) {
    e.preventDefault();
    var msgError = $('#dialog-error-message');
    msgError.html('');
    SETTINGS.closeChangePassword(true);
};

// Save setting
SETTINGS.dspSave_Click = function(e) {
    e.preventDefault();

    // 最初の画面を選択
    if ($("#rdoOpt001").attr('checked') == 'checked') {
        ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_BookShelf); // Bookshelf
    }
    else {
        ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_List); // List
    }
    // 動画、音楽繰り返し
    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') {
        ClientData.userOpt_makingDsp(1);
    }
    else {
        ClientData.userOpt_makingDsp(0);
    }
    // Show/not show alert when press F5.close tab.broswer.
    if ($("#chkOpt005").attr('checked') == 'checked') {
        ClientData.userOpt_closeOrRefreshAlert(1);
        COMMON.ToogleLogoutNortice();
    }
    else {
        ClientData.userOpt_closeOrRefreshAlert(0);
        COMMON.ToogleLogoutNortice();
    }
    // 毎回ログアウトの時、バックアップするかどうかは必ず確認する
    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,
        text: I18N.i18nText('msgSaveOk')
    });

};

// Skip to change password
SETTINGS.dspSkip_Click = function(e) {
    e.preventDefault();
    var msgError = $('#dialog-error-message');
    msgError.html('');
    // Update パスワードスキップ日時
    ClientData.userInfo_pwdSkipDt(new Date());
    SETTINGS.closeChangePassword();
};

SETTINGS.openChangePassword = function() {
    //$("#dlgChangePassword").dialog("open");
    //$(".ui-dialog-titlebar").hide();

    // Clear all input values
    $("#txtPwdCur").val('');
    $("#txtPwdNew").val('');
    $("#txtPwdNewRe").val('');

    COMMON.lockLayout();
    $("#dlgChangePassword").show();
    $("#dlgChangePassword").center();

};

SETTINGS.closeChangePassword = function(skip) {
    //$("#dlgChangePassword").dialog("close");
    $("#dlgChangePassword").hide();
    COMMON.unlockLayout();
};

// Want to change password
SETTINGS.dspPwdUpd_Click = function(e) {
    e.preventDefault();
    $("#dspCancel").show();
    $("#dspSkip").hide();
    $("#txtChangePassComment").css('visibility', 'hidden');
    //$("#dspPwdUpd1").css('margin', '-27px 97px 0 0');

    // Show dialog
    SETTINGS.openChangePassword();
};

// Reset setting
SETTINGS.dspOptReset_Click = function(e) {
    e.preventDefault();

    // 最初の画面を選択
    $("#rdoOpt001").attr('checked', 'checked');
    // 動画、音楽繰り返し
	if( AVWEB.avwSysSetting().optMusicMode != undefined){
		if(AVWEB.avwSysSetting().optMusicMode == 1){
			$("#chkOpt002").attr('checked', 'checked');
		} else {
			$("#chkOpt002").removeAttr('checked');
		}
	} else {
		$("#chkOpt002").attr('checked', 'checked');
	}
    // マーキング(コンテンツを開いた時に表示する)
    $("#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
SETTINGS.dspOptBk_Click = function(e) {
    e.preventDefault();

    // set options backup No.17

    if (ClientData.userOpt_bkMakingFlag() == 0)
    {
        $("#chkopBkMarking").removeAttr('checked');
    }
    else
    {
        $("#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

    if (!ClientData.isChangedBookmark())
    {
        $('#chkopBkShiori').attr('disabled', 'disabled').removeAttr('checked');
    }
    else {
        $('#chkopBkShiori').removeAttr('disabled');
    }

    if (!ClientData.isChangedMemo()) {
        $('#chkopBkMemo').attr('disabled', 'disabled').removeAttr('checked');
    }
    else {
        $('#chkopBkMemo').removeAttr('disabled');
    }
    if (!ClientData.isChangedMarkingData()) {
        $('#chkopBkMarking').attr('disabled', 'disabled').removeAttr('checked');
    }
    else {
        $('#chkopBkMarking').removeAttr('disabled');
    }

    HEADER.setDisabledButton('#dlgConfirmBackup .option_backup input', '#dspOptBk_OK');

    SETTINGS.openBackup();
};

// Restore
SETTINGS.dspOptRes_Click = function(e) {
    e.preventDefault();
    SETTINGS.openRestore();
};

// Process changing password
SETTINGS.dspPwdUpd1_Click = function(e) {
    e.preventDefault();
    var isOK = true;
	var msgError = $('#dialog-error-message');
    // Check validation
    if (!ValidationUtil.CheckRequiredForText(SETTINGS.getCurrentPassword())) {
        isOK = false;
	    msgError.html(I18N.i18nText('msgPwdEmpty'));
    	msgError.show();

    }
    else {
        if (!ValidationUtil.CheckRequiredForText(SETTINGS.getNewPassword())) {
            isOK = false;
    	    msgError.html(I18N.i18nText('msgPwdEmpty'));
	    	msgError.show();
        }
        else {
            if (SETTINGS.getNewPassword() != SETTINGS.getNewPasswordRe()) {
                isOK = false;
                msgError.html(I18N.i18nText('msgPwdNotMatch'));
    			msgError.show();
            }

        }
    }

    if (isOK) {

        // Check max length
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getCurrentPassword(), 16)) {
            isOK = false;
        }
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getNewPassword(), 16)) {
            isOK = false;
        }
        if (!ValidationUtil.CheckMaxLengthForByte(SETTINGS.getNewPasswordRe(), 16)) {
            isOK = false;
        }
        // Data type
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getCurrentPassword())) {
            isOK = false;
        }
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getNewPassword())) {
            isOK = false;
        }
        if (!ValidationUtil.IsAlphabetOrNumberOrSymbol(SETTINGS.getNewPasswordRe())) {
            isOK = false;
        }
        var str = SETTINGS.getCurrentPassword() + "";

    }

    // Do changing password
    var params = {
        sid: ClientData.userInfo_sid(),
        loginId: ClientData.userInfo_loginId_session(),
        password: SETTINGS.getCurrentPassword(),
        newPassword: SETTINGS.getNewPassword(),
        appId: 4
    };

    if (isOK) {

    	AVWEB.avwCmsApi(ClientData.userInfo_accountPath(), "passwordChange", "GET", params,
    			SETTINGS.avwCmsApi_passwordChange_success,
    			SETTINGS.avwCmsApi_passwordChange_fail);
    }
    else {
        //alert('error');
    }
};

SETTINGS.avwCmsApi_passwordChange_success = function(data) {
    // OK
	var msgError = $('#dialog-error-message');
    if (data.result != undefined && data.result != null) {

        if (data.result != COMMON.Consts.ConstAPI_SUCCESS) {
       	    msgError.html(I18N.i18nText('msgPwdChangeNG'));
			msgError.show();
        }
        else {
        	ClientData.requirePasswordChange(0);
        	msgError.html('');
        	SETTINGS.closeChangePassword();
            /* show messages */
            $().toastmessage({ position: 'middle-center' });
            $().toastmessage('showToast', {
                type: 'success',
                sticky: true,
                text: I18N.i18nText('msgPwdChangeOK')
            });
        }
    }
};
SETTINGS.avwCmsApi_passwordChange_fail = function(xhr, b, c) {
    if (xhr.responseText && xhr.status != 0) {
        /* show error messages */
        var msgError = $('#dialog-error-message');

        //msgError.html(I18N.i18nText('msgPwdChangeNG'));
        msgError.html(JSON.parse(xhr.responseText).errorMessage);
        msgError.show();
    }
    else {
    	AVWEB.showSystemError();
    }
};


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

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

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

SETTINGS.openBackup = function() {

    COMMON.lockLayout();
    $("#dlgConfirmBackup").show();
    $("#dlgConfirmBackup").center();

};

SETTINGS.closeBackup = function(cancel) {
    if (cancel != undefined || cancel == true) {
        //alert('you cancelled');
    }
    //$("#dlgConfirmBackup").dialog("close");
    $("#dlgConfirmBackup").hide();
    COMMON.unlockLayout();
};

SETTINGS.openRestore = function() {
    // check avaliable restore no.17
    COMMON.lockLayout();
    $("#dlgConfirmRestore").show();
    $("#dlgConfirmRestore").center();
};

SETTINGS.closeRestore = function(cancel) {
    if (cancel != undefined || cancel == true) {
        //alert('you cancelled');
    }
    //$("#dlgConfirmRestore").dialog("close");
    $("#dlgConfirmRestore").hide();
    COMMON.unlockLayout();
};

// Get input current password
SETTINGS.getCurrentPassword = function() {
    return $("#txtPwdCur").val();
};
// Get input new password
SETTINGS.getNewPassword = function() {
    return $("#txtPwdNew").val();
};
// Get input new password
SETTINGS.getNewPasswordRe = function() {
    return $("#txtPwdNewRe").val();
};

// Initalize screen
SETTINGS.initScreen = function() {

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

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


    // 最初の画面を選択
    if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
        $("#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 {

        $("#chkOpt003").attr('checked', 'checked');
    }
	// Show alert when press F5.close tab.broswer
	if (ClientData.userOpt_closeOrRefreshAlert() == 0) {
        $("#chkOpt005").removeAttr('checked');
    }
    else {
        $("#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(),
            slide: SETTINGS.doChangeAnimationSlidebar
        }
    );

};

SETTINGS.doChangeAnimationSlidebar = function(e,obj) {
    $('#txtValueAnimation').val(obj.value);
};