home.js 90 KB
Newer Older
1 2 3
//名前空間用のオブジェクトを用意する
var HOME = {};

4 5 6 7 8 9
// Start Declare Variables
// ----Constant-----------//
// HOME.DEFAULT_DISP_NUMBER_RECORD_FROM = 1;
// HOME.DEFAULT_DISP_NUMBER_RECORD_TO = 15;
HOME.DEFAULT_SORT_TYPE = "3";
HOME.DEFAULT_SORT_ORDER = "2";
10 11 12 13 14
HOME.DEFAULT_SEARCH_DIVISION = 0;

HOME.home_realTotalRecord = 0;

HOME.iNumberOfNextRecord = 15;
15
// Thumbnail array
16
HOME.thumbnailArr = [];
17
// Content type array.
18 19 20
HOME.contentTypeArr = [];

HOME.contentIdArray = [];
21 22
// HOME.resourceVersionArr = [];
// HOME.metaVersionArr = [];
23 24 25 26 27 28 29 30
HOME.errorPage = [];
HOME.errorContent = [];
HOME.dataGroup;
HOME.dataGenre;
HOME.totalPage;
HOME.existContent = [];
HOME.isSubMenuHoverOn = false;
HOME.home_isMove = false;
31
HOME.isShowBookShelf = true;
32 33 34 35 36 37 38
HOME.showNextRecordClickNumber = 1;

HOME.allowTimerCloseSubMenu = true;
HOME.timer_subMenu;

HOME.genre_totalcontent = -1;
HOME.group_totalcontent = -1;
39

40
// スクロール復帰
41
HOME.scrollTop = 0;
42 43 44 45 46 47
// 閲覧履歴に保持する最大件数
HOME.historyBuffer = 100;

// ==========================================================
$(document).ready(function() {

48 49 50
    if (!AVWEB.avwCheckLogin(COMMON.ScreenIds.Login)) {
        return;
    }
51

52 53 54 55 56 57 58
    // ソート条件デフォルト設定
    if (AVWEB.avwSysSetting().sortTypeHome != undefined) {
        HOME.DEFAULT_SORT_TYPE = AVWEB.avwSysSetting().sortTypeHome;
    }
    if (AVWEB.avwSysSetting().sortOrderHome != undefined) {
        HOME.DEFAULT_SORT_ORDER = AVWEB.avwSysSetting().sortOrderHome;
    }
59

60
    document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
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
    // Set bookmark screen
    ClientData.BookmarkScreen(COMMON.ScreenIds.Home);

    // Check if Force Change password
    if (ClientData.requirePasswordChange() != 1) {
        // Register log
        COMMON.RegisterLog();

        // Sync Data
        HOME.syncContentData();

        // remove hover css if is touch device
        HOME.removeHoverCss();

        // Get default view mode for rendergrid view
        HOME.setDefaultViewMode();

        // Toggle TreeView Disp
        HOME.handleTreeViewDisp();

        // Format text display more record
        HOME.formatDisplayMoreRecord();

        // Render Grid
        HOME.renderGridView();

        // Render Genre
        HOME.getDataJsonFileGenre();
        HOME.getDataJsonFileGroup();

        // Lock screen is here, because of in getDataJsonFileGroup() called
        // click to expand speified nodes of treeview
        if (ClientData.serviceOpt_encryption() != 'Y') {
            COMMON.LockScreen();
        }

        // Change display type to bookshelf type
        $('#control-bookshelf-type').click(HOME.changeDispBookShelfFunction);

        // Change display type to list type
        $('#control-list-type').click(HOME.changeDispListFunction);

        // Go To Details Page
        $('#main-ws canvas').live('click', HOME.canvasClickFunction);
        $('#main-ws canvas').live('touchend', HOME.canvasClickFunction);
        $('#main-ws canvas').live('touchmove', function() {
            HOME.home_isMove = true;
        });

        // Open dialog
        $('.dialog').live('click', HOME.openSubMenuDialogFunction);
        // $('.dialog').live('touchstart', HOME.openSubMenuDialogFunction);
        $('.dialog').live('touchend', HOME.openSubMenuDialogFunction);
        $('.dialog').live('touchmove', function() {
            HOME.home_isMove = true;
        });

        // Render Genre TreeView
        $('#lnkbtnGenre').click(HOME.genreSelectFunction);

        // Render Group TreeView
        $('#lnkbtnGroup').click(HOME.groupSelectFunction);

        // Button details on dialog click event
        $('#dialog-detail').click(HOME.detailsSubmenuFunction);

        // Button Read on dialog click event
        $('#dialog-read').click(HOME.readSubmenuFunction);
130 131 132
        
        //Pdfコンテンツをダウンロード
        $('#downloadContent').click(HOME.downloadPdfFunction);
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

        // Show Next Record
        $('a#control-nextrecord').click(HOME.showNextRecordFunction);

        // Sort Title
        $('#control-sort-title').click(HOME.sortByTitleFunction);

        // Sort by title kana
        $('#control-sort-titlekana').click(HOME.sortByTitleKanaFunction);

        // sort by release date
        $('#control-sort-releasedate').click(HOME.sortByReleaseDateFunction);

        // Go To Details Page
        $('.button-details').live('click', HOME.readSubmenuFunction);
        // $('.button-details').live('touchstart', HOME.readSubmenuFunction);
        $('.button-details').live('touchend', HOME.readSubmenuFunction);
        $('.button-details').live('touchmove', function() {
            HOME.home_isMove = true;
        });

        // Show Share Dialog
        $('.button-share').live('click', HOME.showContentShareDlgFunction);
        $('.button-share').live('touchend', HOME.showContentShareDlgFunction);
        $('.button-share').live('touchmove', function() {
            HOME.home_isMove = true;
        });
160
        
161
        //PDF download
162 163 164
        $('.button-download').live('click', HOME.downloadPdfFunction);
        $('.button-download').live('touchend', HOME.downloadPdfFunction);
        $('.button-download').live('touchmove', function () { HOME.home_isMove = true; });
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

        $('#dlgSubMenu').hover(HOME.subMenuHoverFunction, HOME.subMenuHoverOffFunction);

        if (COMMON.isTouchDevice() == true) {
            var avwUserEnvObj = new UserEnvironment();
            if (avwUserEnvObj.os == 'ipad') {
                $('#dlgSubMenu').click(function() {
                    HOME.allowTimerCloseSubMenu = false;
                });
            }
        }

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

        $('body').click(HOME.bodyHomeClickFunction);
        if (COMMON.isTouchDevice() == true) {
            var avwUserEnvObj = new UserEnvironment();
            if (avwUserEnvObj.os == 'ipad') {
                $('body').bind('touchstart', function() {
                    if ($('#dlgSubMenu').css('display') != "none") {
                        HOME.allowTimerCloseSubMenu = true;
                        HOME.timer_subMenu = setTimeout("HOME.startTimerCloseMenu();", 500);
                    }
                });
            } else {
                $('body').bind('touchstart', HOME.bodyHomeClickFunction);
            }
        }

        $(window).resize(function() {
            if ($("#contentDetail").css("display") != "none") {
                // Refresh panel of detail to center.
                $("#contentDetail").center();
                if ($("#contentDetail").height() > $(window).height()) {
                    $("#contentDetail").css('top', '0');
                }
            }
204
            HOME.ResizeTab();
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
        });
    } else {
        HEADER.checkForceChangePassword();
    }

    // 日比谷用設定ボタン隠す
    $('#dspHibiya').hide();

    // カタログエディション対応判定
    if (ClientData.serviceOpt_catalog_edition() == 'Y') {
        $('.tabUnit').hide();
        // センタリングするようサイズ調整
        $('#bookshelf-main').width(660);
    } else {
        $('.tabUnit').show();
220 221 222 223 224
        $('.tabUnit').resizable({
            handles: 'e',
            minWidth: 280,
            maxWidth: 560
        });        
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
    }

    // hide tab group with user anonymous
    if (COMMON.isAnonymousLogin()) {

        // グループ選択隠す
        $('.switchingTab .colright').hide();
        // プッシュメッセージ隠す
        $('#dspPushMessage').hide();

        // 日比谷対応判定
        if (ClientData.serviceOpt_hibiyakadan_catalog() == 'Y') {
            $('#dspHibiya').show();
            jQuery('#dlgAddMemberGroup').dialog({
                autoOpen : false,
                modal : true,
                width : 350
            });
            $('#dspHibiya').click(HOME.dspHibiyaClickFunction);
            $('#btnAddMemberGroupSearch').click(HOME.btnAddMemberGroupSearchClickFunction);
        }
    } else {
        // $('.tabUnit').show();
        $('.switchingTab .colright').show();
        // プッシュメッセージ判定
        if (ClientData.serviceOpt_apns() == 'Y' || ClientData.serviceOpt_usable_push_message() == 'Y') {
            // プッシュメッセージ表示
            $('#dspPushMessage').show();
        } else {
            $('#dspPushMessage').hide();
        }
    }

    // set scroll for tree view with IE9 on win7
    var ua = window.navigator.userAgent.toLowerCase();
    if (/msie 9.0/.test(ua) && /windows nt 6.1/.test(ua) && !/tablet/.test(ua)) {
        $('.tab_bg_color').css({
            "overflow-x" : "scroll"
        });
    }

    // 詳細、共有表示パーツ読み込み
    $("#inc_detail").load("./inc_detail.html?__UPDATEID__", function(myData, myStatus, xhr) {
        // 読み込み完了時の処理
        I18N.i18nReplaceText();
        $('.datepicker').pickadate({
            format : 'yyyy-mm-dd'
        });
    });

    // ビューア、共有表示パーツ読み込み
    $("#viewer").load("./inc_contentview.html?__UPDATEID__", function(myData, myStatus, xhr) {
        // 読み込み完了時の処理
        I18N.i18nReplaceText();
    });
280 281
});

282 283
// 日比谷カスタム ここから
HOME.dspHibiyaClickFunction = function() {
284
    $('#dlgAddMemberGroup').dialog('open');
285
};
286
HOME.btnAddMemberGroupSearchClickFunction = function() {
287

288 289 290 291
    var addGroupName = $('#txtAddMemberGroupName').val();
    if (addGroupName == "") {
        return;
    }
292

293 294 295 296 297
    var groupIds = HOME.getAddMemberGroupId(addGroupName);
    if (groupIds == "") {
        alert("コードが不正です");
        return;
    }
298

299 300
    $('#dlgAddMemberGroup').dialog('close');
    ClientData.searchCond_groupId(groupIds);
301

302 303 304
    // 画面再描画開始
    var recordFrom = 0;
    var recordTo = 0;
305

306 307 308 309 310 311 312 313 314 315
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
    } else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
    } else {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
    }
316

317 318 319 320 321 322 323 324 325
    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    // ClientData.searchCond_groupId('');
    ClientData.searchCond_genreId('');
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();
326

327 328
    // refresh gridview
    HOME.refreshGrid();
329

330
    HOME.resetShowNextRecordCount();
331

332
    HOME.handleSortDisp();
333

334
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
335

336
};
337

338
HOME.getAddMemberGroupId = function(strGroupName) {
339

340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
    var groupIds = "";
    var params = {
        sid : ClientData.userInfo_sid(),
        groupName : strGroupName
    };
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "addMemberGroup", 'POST', params,
    // Success
    function(data) {
        if (data.groupIds) {
            groupIds = data.groupIds;
        }
    }, function(xmlHttpRequest, txtStatus, errorThrown) {
        //
    });
    return groupIds;
355
};
356
// --日比谷カスタム ここまで
357

358
HOME.startTimerCloseMenu = function() {
359 360 361 362 363 364 365
    if (HOME.timer_subMenu) {
        clearTimeout(HOME.timer_subMenu);
        HOME.timer_subMenu = null;
    }
    if (HOME.allowTimerCloseSubMenu == true) {
        $('#dlgSubMenu').hide();
    }
366
};
367

368
HOME.subMenuHoverFunction = function() {
369
    HOME.isSubMenuHoverOn = true;
370 371
};

372
HOME.subMenuHoverOffFunction = function() {
373
    HOME.isSubMenuHoverOn = false;
374 375
};

376
HOME.bodyHomeClickFunction = function() {
377 378 379
    if (!HOME.isSubMenuHoverOn) {
        $('#dlgSubMenu').hide();
    }
380 381
};

382
// Toggle Genre/Group Tab
383
HOME.handleTreeViewDisp = function() {
384 385 386 387
    $('#lblGenre').css('display', 'block');
    $('#lnkGenre').css('display', 'none');
    $('#lnkGroup').css('display', 'block');
    $('#lblGroup').css('display', 'none');
388 389
};

390
// Change Display BookShelf Function
391
HOME.changeDispBookShelfFunction = function() {
392

393 394 395 396
    if (HOME.isShowBookShelf) {
        //既に本棚表示
        return;
    }
397

398
    HOME.isShowBookShelf = true;
399

400 401 402 403 404
    $('body').attr('id', 'bookshelf');
    $('#control-bookshelf-type').parent().removeClass("thumbnail");
    $('#control-bookshelf-type').parent().addClass("thumbnail_select");
    $('#control-list-type').parent().removeClass("list_select");
    $('#control-list-type').parent().addClass("list");
405

406 407
    // ページ遷移初期化
    HOME.resetShowNextRecordCount();
408

409 410 411 412
    var recordOffset = 0;
    var recordLimit = HOME.returnNumberDispRecordForBookShelf();
    // refresh sort order
    HOME.refreshSortTypeOrder();
413

414 415 416 417 418 419 420
    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();
421

422 423
    // handle sort display
    HOME.handleSortDisp();
424

425 426
    // refresh Grid view
    HOME.refreshGrid();
427

428
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
429

430 431 432 433 434
    // format text disp more record
    HOME.formatDisplayMoreRecord();

    // Get next record will be displayed
    HOME.getNextRecordNumForBookShelf();
435
    HOME.ResizeTab();
436 437
};

438
// Change Display List Function
439
HOME.changeDispListFunction = function() {
440

441 442 443
    if (HOME.isShowBookShelf == false) {
        return;
    }
444

445
    HOME.isShowBookShelf = false;
446

447 448 449 450 451
    $('body').attr('id', 'list');
    $('#control-list-type').parent().removeClass("list");
    $('#control-list-type').parent().addClass("list_select");
    $('#control-bookshelf-type').parent().removeClass("thumbnail_select");
    $('#control-bookshelf-type').parent().addClass("thumbnail");
452

453 454
    // ページ遷移初期化
    HOME.resetShowNextRecordCount();
455

456 457 458 459 460
    // Check VIewmode
    var recordOffset = 0;
    var recordLimit = HOME.returnNumberDispRecordForList();
    // refresh sort order
    HOME.refreshSortTypeOrder();
461

462 463 464 465 466 467 468
    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();
469

470 471
    // Handle Sort disp
    HOME.handleSortDisp();
472

473 474
    // refresh Grid view
    HOME.refreshGrid();
475

476
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
477

478 479
    // format text disp more record
    HOME.formatDisplayMoreRecord();
480

481 482
    // Get next record will be displayed
    HOME.getNextRecordNumForList();
483
    HOME.ResizeTab();
484 485
};

486
HOME.ResizeTab = function() {
487

488
	var articleBody = document.getElementsByClassName("articlehome");
489 490 491 492
	var tabUnitBody = document.getElementsByClassName("tabUnit")[0].clientWidth;
	var width = 930 - tabUnitBody;
	var margin = tabUnitBody - 280;

493
    articleBody[0].style.cssText = 'width: '+ width + 'px;';
494
	$(".cnt_section_list .text .info .pic li .iconList").css("margin-right", margin);
495 496 497
	$(".sankaku_left").css("margin-left", 54 + margin*0.5);
    $(".sankaku_right").css("margin-left", 179 + margin*0.5);

498
	if(tabUnitBody > 280){
499 500 501 502 503
		$(".no_m_right").css("margin-right", "25px");
	}else{
		$(".no_m_right").css("margin-right", "0px");
	}

504
	if(tabUnitBody >= 435){
505 506 507 508
		$(".cnt_section_list .text").css("width", "199px");
		$(".cnt_section_list .text").css("margin", "0 0 0 0");
		$(".cnt_section_list .text .info .pic li .iconList").css("margin-right", 0);
		$(".cnt_section_list .text .info .pic li .iconList").css("right", 0);
509 510
        $(".cnt_section_list .text .info .pic li .iconList").css("position", "relative");
        $(".cnt_section_list .text ul.pic li").css("height", 21);
511 512 513 514
	}else{
		$(".cnt_section_list .text").css("width", "300px");
		$(".cnt_section_list .text").css("margin", "0 0 0 25px");
		$(".cnt_section_list .text .info .pic li .iconList").css("right", -145);
515
        $(".cnt_section_list .text .info .pic li .iconList").css("position", "absolute");
516 517
	}

518
	if(193 + document.getElementsByClassName("sort_area")[0].clientWidth > articleBody[0].clientWidth){
519 520 521 522
		$(".tops p").css("top", "75px");
	}else{
		$(".tops p").css("top", "40px");
	}
523
};
524

525
// Canvas Click function
526
HOME.canvasClickFunction = function(e) {
527 528 529
    if (e) {
        e.preventDefault();
    }
530

531 532 533 534
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }
535

536 537
    var contentId = $(this).attr('id');
    var outputId = contentId.substring(17);
538

539 540 541 542 543 544 545 546
    if (HOME.isShowBookShelf) {
        LIMIT_ACCESS_CONTENT.checkLimitContent(outputId, function() {
            HOME.canvasClickFunction_callback(outputId);
        }, function() {
        });
    } else {
        HOME.canvasClickFunction_callback(outputId);
    }
547 548 549
};

HOME.canvasClickFunction_callback = function(outputId) {
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
    var date = new Date();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var outputDate = COMMON.formatNormalDate(day, month, date.getFullYear());
    var checkflag = false;
    var base64String = HOME.returnThumbnail(outputId);

    // Set content id for next screen
    ClientData.contentInfo_contentThumbnail(base64String);
    // Get image of selected image
    ClientData.contentInfo_contentId(outputId);

    var contentType = HOME.returnContentType(outputId);
    ClientData.contentInfo_contentType(contentType);

    // Check Display mode to handle action
    HOME.contentIdArray = ClientData.ReadingContentIds();
    if (!HOME.isShowBookShelf) {

        // Store Content id that user has read
        if (HOME.contentIdArray.length > 0) {
            checkflag = false;
            for ( var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
                if (HOME.contentIdArray[nIndex].contentid == outputId) {
                    checkflag = true;
                    break;
                }
            }

            if (!checkflag) {
                HOME.contentIdArray.push({
                    contentid : outputId,
                    viewdate : '',
                    originviewdate : ''
                });
            }
        } else {
            HOME.contentIdArray.push({
                contentid : outputId,
                viewdate : '',
                originviewdate : ''
            });
        }

        // Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);

        // Set data for readingcontentid
        ClientData.ReadingContentIds(HOME.contentIdArray);

        // Set ResouceVersion for content
        COMMON.setResourceVersionData(outputId);

        // Set MetaVersion for content
        COMMON.setMetaVersionData(outputId);

        // Close Submenu
        $('#dlgSubMenu').hide();

        // Delete 'new' icon
        HOME.drawEditImage(outputId);

        // Open content Detail
        DETAIL.openContentDetail();
    } else {

        // Store Content id that user has read
        if (HOME.contentIdArray.length > 0) {

            checkflag = false;
            for ( var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
                if (HOME.contentIdArray[nIndex].contentid == outputId) {
                    checkflag = true;
                    if (HOME.contentIdArray[nIndex].viewdate == null || HOME.contentIdArray[nIndex].viewdate == 'undefined' || HOME.contentIdArray[nIndex].viewdate == '') {
                        HOME.contentIdArray[nIndex].viewdate = outputDate;
                        HOME.contentIdArray[nIndex].originviewdate = date;
                    }
                    break;
                }
            }

            if (!checkflag) {
                HOME.contentIdArray.push({
                    contentid : outputId,
                    viewdate : outputDate,
                    originviewdate : date
                });
            }
        } else {
            HOME.contentIdArray.push({
                contentid : outputId,
                viewdate : outputDate,
                originviewdate : date
            });
        }

        // Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);

        // Set data for readingcontentid
        ClientData.ReadingContentIds(HOME.contentIdArray);

        // Set ResouceVersion for content
        COMMON.setResourceVersionData(outputId);

        // Set MetaVersion for content
        COMMON.setMetaVersionData(outputId);

        // $('body,html').animate({ scrollTop: 0 }, 0);
        ClientData.IsRefresh(false);

        if (contentType == COMMON.ContentTypeKeys.Type_Others) {
            // Download content
            HEADER.downloadResourceById(outputId);
            // redraw content remove new icon
            HOME.drawEditImage(outputId);
        } else if (contentType == COMMON.ContentTypeKeys.Type_Link) {
            // link content
            HEADER.viewLinkContentById(outputId);
            // redraw content remove new icon
            HOME.drawEditImage(outputId);
        } else {
            HOME.drawEditImage(outputId);
            // ビュアーに切り替え
            HOME.showContentView();
        }

    }
680 681 682 683

};

// function Open SubMenu Dialog
684
HOME.openSubMenuDialogFunction = function(e) {
685 686 687 688 689 690 691 692 693 694
    if (e) {
        e.preventDefault();
    }
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }

    var array = [ e.clientX, e.clientY ];
    var contentid = $(this).attr('contentid');
695
    var printFlg = $(this).attr('printFlg');
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
    var checkflag = false;

    if (!HOME.isShowBookShelf) {
        // Get image of selected image
        var base64String = HOME.returnThumbnail(contentid);
        ClientData.contentInfo_contentThumbnail(base64String);
        ClientData.contentInfo_contentId(contentid);

        var contentType = HOME.returnContentType(contentid);
        ClientData.contentInfo_contentType(contentType);

        // Store Content id that user has read
        HOME.contentIdArray = ClientData.ReadingContentIds();
        if (HOME.contentIdArray.length > 0) {

            for ( var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
                if (HOME.contentIdArray[nIndex].contentid == contentid) {
                    checkflag = true;
                    break;
                }
            }

            if (!checkflag) {
                HOME.contentIdArray.push({
                    contentid : contentid,
                    viewdate : '',
                    originviewdate : ''
                });
            }
        } else {
            HOME.contentIdArray.push({
                contentid : contentid,
                viewdate : '',
                originviewdate : ''
            });
        }

        // Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);

        // Set data for readingcontentid
        ClientData.ReadingContentIds(HOME.contentIdArray);

        // Set ResouceVersion for content
        COMMON.setResourceVersionData(contentid);

        // Set MetaVersion for content
        COMMON.setMetaVersionData(contentid);

        // Close Submenu
        $('#dlgSubMenu').hide();

        // Delete 'new' icon
        HOME.drawEditImage(contentid);

        DETAIL.openContentDetail();

    } else {
        $('#dialog-read').attr('contentid', contentid);
        $('#dialog-detail').attr('contentid', contentid);
757 758 759 760 761 762 763
        var contentType = HOME.returnContentType(contentid);
        if(contentType == COMMON.ContentTypeKeys.Type_PDF && ClientData.serviceOpt_air_print() == 'Y' && printFlg == '1'){
        	$('#downloadContent').show();
        	$('#downloadContent').attr('contentid', contentid);
        }else{
        	$('#downloadContent').hide();
        }  
764 765 766 767 768 769 770 771 772
        $("#dlgSubMenu").show();
        HOME.allowTimerCloseSubMenu = false;
        $("#dlgSubMenu").position({
            my : "left bottom",
            at : "left-10 top",
            of : this,
            collision : "fit"
        });
    }
773 774 775
};

// Genre Click Function
776
HOME.genreSelectFunction = function() {
777 778
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');
779

780 781
    $('.folder').css('font-weight', 'normal');
    $('.folder').css('text-decoration', 'none');
782

783 784
    $('#all').css('font-weight', 'bold');
    $('#all').css('text-decoration', 'underline');
785

786 787 788 789 790 791 792
    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }
793

794 795 796 797 798 799 800 801 802
    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    ClientData.searchCond_groupId('');
    ClientData.searchCond_genreId('');
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();
803

804 805
    // refresh gridview
    HOME.refreshGrid();
806

807
    HOME.resetShowNextRecordCount();
808

809
    HOME.handleSortDisp();
810

811
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
812
    HOME.ResizeTab();
813 814 815
};

// Group Click Function
816
HOME.groupSelectFunction = function() {
817 818
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');
819

820 821
    $('.folder').css('font-weight', 'normal');
    $('.folder').css('text-decoration', 'none');
822

823 824 825
    var firstNode = $('#list_1').find('a')[0];
    $('#list_1').find(firstNode).css('text-decoration', 'underline');
    $('#list_1').find(firstNode).css('font-weight', 'bold');
826

827 828 829 830 831 832 833
    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }
834

835 836 837 838 839 840 841 842 843
    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    ClientData.searchCond_groupId('');
    ClientData.searchCond_genreId('');
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();
844

845 846
    // refresh gridview
    HOME.refreshGrid();
847

848
    HOME.resetShowNextRecordCount();
849

850
    HOME.handleSortDisp();
851

852
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
853
    HOME.ResizeTab();
854 855 856
};

// Get Data from Category Json
857
HOME.getDataJsonFileGenre = function() {
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
    var params = {
        sid : ClientData.userInfo_sid()
    };
    HOME.abapi('category', params, 'GET', function(data1) {
        HOME.dataGenre = data1.categoryList;
        var arrData = new Array();
        var totalCount = 0;

        $.each(HOME.dataGenre, function(i, value) {
            // Calculate total content
            totalCount += Number(HOME.dataGenre[i].contentCount);
            if (HOME.dataGenre[i].parentCategoryId == 0) {
                var node = new TreeNode();
                // node.IsCategory = true;
                node.Text = COMMON.htmlEncode(HOME.dataGenre[i].categoryName);
                node.id = HOME.dataGenre[i].categoryId;
                node.Value = HOME.dataGenre[i].categoryId;
                node.ContentCount = HOME.dataGenre[i].contentCount;
                HOME.AddChidrenNodeGenre(node);
                // node.IsClosed = false; //#13200 カテゴリツリーの階層プラス・マイナスのアイコンが逆
                node.ExpandAfterBuild = true; // #14287 第一階層を開くようにする

                node.IsCategory = node.ChildNodes.length > 0; // Has child node

                arrData.push(node);
            }
        });
        var tree1 = new TreeView();
        tree1.CategoryTagName = "a";
        // tree1.TotalCount = totalCount;
        if (HOME.genre_totalcontent != -1) {
            tree1.TotalCount = HOME.genre_totalcontent;
        }
        tree1.Show("branch1", arrData, "HOME.AddGenre_Callback");
        $("#branch1").treeview();

        $('#all').css('font-weight', 'bold');
        $('#all').css('text-decoration', 'underline');

        $('.treeview > li').addClass('tabCategory');

        // Expand nodes(#14287 第1階層を開くようにする)
        for ( var nIndex = 0; nIndex < tree1.ExpandNodes.length; nIndex++) {
            if ($("#" + tree1.ExpandNodes[nIndex]).parent()) {
                var objParent = $("#" + tree1.ExpandNodes[nIndex]).parent();
                var objChild = objParent.children()[0];
                if (objChild) {
                    try {
                        objChild.click();
                    } catch (err) {
                        // For safari
                        var evObj = document.createEvent('MouseEvents');
                        evObj.initMouseEvent('click', true, true, window);
                        objChild.dispatchEvent(evObj);
                    }
                }
            }
        }

    });
918 919 920
};

// Add Children Node Category
921
HOME.AddChidrenNodeGenre = function(node1) {
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
    var dataChild = [];
    $.each(HOME.dataGenre, function(index, value) {
        if (HOME.dataGenre[index].parentCategoryId == node1.id) {
            // Check if current node is added or not
            var isChildNodeExisted = false;
            for ( var nChildNodesIndex = 0; nChildNodesIndex < dataChild.length; nChildNodesIndex++) {
                if (dataChild[nChildNodesIndex].categoryId == HOME.dataGenre[index].categoryId) {
                    isChildNodeExisted = true;
                }
            }
            if (!isChildNodeExisted) {
                dataChild.push(HOME.dataGenre[index]);
            }
            // dataChild.push(HOME.dataGenre[index]);
        }
    });

    $.each(dataChild, function(i, value) {
        var item = new TreeNode();
        // item.IsCategory = true;
        item.Text = COMMON.htmlEncode(dataChild[i].categoryName);
        item.id = dataChild[i].categoryId;
        item.Value = dataChild[i].categoryId;
        item.ContentCount = dataChild[i].contentCount;
        HOME.AddChidrenNodeGenre(item);

        item.IsCategory = item.ChildNodes.length > 0; // Has child node

        node1.ChildNodes.push(item);
    });
952 953 954
};

// Get Value for sort
955
HOME.AddGenre_Callback = function(selectedNode) {
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
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');

    $('.folder').css('font-weight', 'normal');
    $('.folder').css('text-decoration', 'none');

    if (selectedNode.Id == "all") {
        var arrAllNodes = $('.root');
        for ( var nIndex = 0; nIndex < arrAllNodes.length; nIndex++) {
            var objTarget = $(arrAllNodes[nIndex]);
            // Check treeview
            if (objTarget.parent().parent().css('display') != 'none') {
                objTarget.css('font-weight', 'bold');
                objTarget.css('text-decoration', 'underline');
            }
        }
    } else {
        if (selectedNode.IsCategory == true) {
            var targetObj = $('#' + selectedNode.Id).parent().children()[1];
            $(targetObj).css('font-weight', 'bold');
            $(targetObj).css('text-decoration', 'underline');
        } else {
            $('#' + selectedNode.Id).css('font-weight', 'bold');
            $('#' + selectedNode.Id).css('text-decoration', 'underline');
        }
    }

    var node = new TreeNode();
    node = selectedNode;

    lCateId = node.Value;
    $('#content-grid').html('');

    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }

    ClientData.searchCond_genreId(lCateId);

    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();

    // refresh gridview
    HOME.refreshGrid();

    HOME.resetShowNextRecordCount();

    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);

    HOME.handleSortDisp();
1016 1017 1018
};

// Get Data from Group Json
1019
HOME.getDataJsonFileGroup = function() {
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
    var params = {
        sid : ClientData.userInfo_sid()
    };
    HOME.abapi('group', params, 'GET', function(data1) {
        HOME.dataGroup = data1.groupList;
        var arrData = new Array();
        var totalCount = 0;
        $.each(HOME.dataGroup, function(i, value) {
            // Calculate total group
            totalCount += Number(HOME.dataGroup[i].contentCount);

            if (HOME.dataGroup[i].parentGroupId == 0 || HOME.dataGroup[i].groupLevel == "0") {
                var node = new TreeNode();
                node.IsCategory = true;
                node.Text = COMMON.htmlEncode(HOME.dataGroup[i].groupName);
                node.id = HOME.dataGroup[i].groupId;
                node.Value = HOME.dataGroup[i].groupId;
                node.ContentCount = HOME.dataGroup[i].contentCount;
                HOME.AddChidrenNodeGroup(node);
                // node.IsClosed = false;
                node.ExpandAfterBuild = true;

                node.IsCategory = node.ChildNodes.length > 0; // Has child node

                arrData.push(node);
            }
        });
        var tree2 = new TreeView();
        tree2.CategoryTagName = "a";
        // tree1.TotalCount = totalCount;
        if (HOME.group_totalcontent != -1) {
            tree2.TotalCount = HOME.group_totalcontent;
        }
        tree2.Show("branch2", arrData, "HOME.AddGroup_Callback");
        $("#branch2").treeview();

        var firstNode = $('#branch2').find('a')[0];
        $('#branch2').find(firstNode).css('text-decoration', 'underline');
        $('#branch2').find(firstNode).css('font-weight', 'bold');

        $('.treeview > li').addClass('tabCategory');
        // Expand nodes
        for ( var nIndex = 0; nIndex < tree2.ExpandNodes.length; nIndex++) {
            if ($("#" + tree2.ExpandNodes[nIndex]).parent()) {
                var objParent = $("#" + tree2.ExpandNodes[nIndex]).parent();
                var objChild = objParent.children()[0];
                if (objChild) {
                    try {
                        objChild.click();
                    } catch (err) {
                        // For safari
                        var evObj = document.createEvent('MouseEvents');
                        evObj.initMouseEvent('click', true, true, window);
                        objChild.dispatchEvent(evObj);
                    }

                }
            }
        }
    });
1080 1081 1082
};

// Add Children Node Group
1083
HOME.AddChidrenNodeGroup = function(node1) {
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
    var dataChild = [];
    $.each(HOME.dataGroup, function(index, value) {
        if (HOME.dataGroup[index].parentGroupId == node1.id) {
            // Check if current node is added or not
            var isChildNodeExisted = false;
            for ( var nChildNodesIndex = 0; nChildNodesIndex < dataChild.length; nChildNodesIndex++) {
                if (dataChild[nChildNodesIndex].groupId == HOME.dataGroup[index].groupId) {
                    isChildNodeExisted = true;
                }
            }
            if (!isChildNodeExisted) {
                dataChild.push(HOME.dataGroup[index]);
            }
        }
    });

    $.each(dataChild, function(i, value) {
        var item = new TreeNode();
        // item.IsCategory = true;
        item.Text = COMMON.htmlEncode(dataChild[i].groupName);
        item.id = dataChild[i].groupId;
        item.Value = dataChild[i].groupId;
        item.ContentCount = dataChild[i].contentCount;
        HOME.AddChidrenNodeGroup(item);

        item.IsCategory = item.ChildNodes.length > 0; // Has child node

        node1.ChildNodes.push(item);
    });
1113 1114 1115
};

// Get Value for sort
1116
HOME.AddGroup_Callback = function(selectedNode) {
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');

    $('.folder').css('font-weight', 'normal');
    $('.folder').css('text-decoration', 'none');

    if (selectedNode.Id == "all") {
        var arrAllNodes = $('.root');
        for ( var nIndex = 0; nIndex < arrAllNodes.length; nIndex++) {
            var objTarget = $(arrAllNodes[nIndex]);
            // Check treeview
            if (objTarget.parent().parent().css('display') != 'none') {
                objTarget.css('font-weight', 'bold');
                objTarget.css('text-decoration', 'underline');
            }
        }
    } else {
        if (selectedNode.IsCategory == true) {
            var targetObj = $('#' + selectedNode.Id).parent().children()[1];
            $(targetObj).css('font-weight', 'bold');
            $(targetObj).css('text-decoration', 'underline');
        } else {
            $('#' + selectedNode.Id).css('font-weight', 'bold');
            $('#' + selectedNode.Id).css('text-decoration', 'underline');
        }
    }

    var node = new TreeNode();

    node = selectedNode;
    lGrpId = node.Value;
    $('#content-grid').html('');

    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }

    ClientData.searchCond_groupId(lGrpId);

    var id = ClientData.userInfo_sid();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    var groupId = ClientData.searchCond_groupId();
    var genreId = ClientData.searchCond_genreId();

    // refreshGrid
    HOME.refreshGrid();

    HOME.resetShowNextRecordCount();

    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);

    HOME.handleSortDisp();
1176 1177 1178
};

// Re-render page from and total record
1179
HOME.reRenderPageNumber = function(dispRecord, dispTotal) {
Masaru Abe committed
1180

1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191
    if (dispTotal) {
        $('#dispPage').html(dispRecord);
        $('#totalPage').html(dispTotal);
        $('#dispPage').css('visibility', 'visible');
        $('#totalPage').css('visibility', 'visible');
        $('.pageNumControl').css('visibility', 'visible');
    } else {
        $('#dispPage').css('visibility', 'hidden');
        $('#totalPage').css('visibility', 'hidden');
        $('.pageNumControl').css('visibility', 'hidden');
    }
Masaru Abe committed
1192

1193 1194
};

1195
// Call API
1196
HOME.abapi = function(name, param, method, callback) {
1197
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), name, method, param, callback, null);
1198 1199
};

1200
// Dialog Details Button Click
1201
HOME.detailsSubmenuFunction = function(e) {
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
    if (e) {
        e.preventDefault();
    }
    HOME.allowTimerCloseSubMenu = false;

    var contentId = $(this).attr('contentid');
    // Get image of selected image
    var base64String = HOME.returnThumbnail(contentId);
    var contentType = HOME.returnContentType(contentId);
    ClientData.contentInfo_contentType(contentType);
    ClientData.contentInfo_contentId(contentId);
    ClientData.contentInfo_contentThumbnail(base64String);

    var checkflag = false;
    // Store Content id that user has read
    HOME.contentIdArray = ClientData.ReadingContentIds();
    if (HOME.contentIdArray.length > 0) {

        for ( var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
            if (HOME.contentIdArray[nIndex].contentid == contentId) {
                checkflag = true;
                break;
            }
        }

        if (!checkflag) {
            HOME.contentIdArray.push({
                contentid : contentId,
                viewdate : '',
                originviewdate : ''
            });
        }
    } else {
        HOME.contentIdArray.push({
            contentid : contentId,
            viewdate : '',
            originviewdate : ''
        });
    }

    // Renew ReadingContentID
    var newArray = [];
    ClientData.ReadingContentIds(newArray);

    // Set data for readingcontentid
    ClientData.ReadingContentIds(HOME.contentIdArray);

    // Set ResouceVersion for content
    COMMON.setResourceVersionData(contentId);

    // Set MetaVersion for content
    COMMON.setMetaVersionData(contentId);

    // Close popup menu
    $('#dlgSubMenu').hide();

    // delete 'new' icon
    HOME.drawEditImage(contentId);

    // Show detail
    DETAIL.openContentDetail();
1263 1264 1265
};

// Dialog Read Button CLick
1266
HOME.readSubmenuFunction = function(e) {
1267 1268 1269 1270
    if (e) {
        e.preventDefault();
    }
    HOME.allowTimerCloseSubMenu = false;
1271

1272 1273 1274 1275
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }
1276

1277 1278
    // hide dialog sub menu
    $('#dlgSubMenu').hide();
1279

1280 1281 1282 1283 1284 1285
    var contentId = $(this).attr('contentid');
    // check limit of content
    LIMIT_ACCESS_CONTENT.checkLimitContent(contentId, function() {
        HOME.readSubmenuFunction_callback(contentId);
    }, function() {
    });
1286 1287 1288 1289 1290

};

// Dialog Read Button CLick callback
HOME.readSubmenuFunction_callback = function(contentId) {
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371
    var contentThumbnail = HOME.returnThumbnail(contentId);

    var date = new Date();
    var month = date.getMonth() + 1;
    var day = date.getDate();

    var outputDate = COMMON.formatNormalDate(day, month, date.getFullYear());

    ClientData.contentInfo_contentId(contentId);
    ClientData.contentInfo_contentThumbnail(contentThumbnail);

    var contentType = HOME.returnContentType(contentId);
    ClientData.contentInfo_contentType(contentType);

    var checkflag = false;

    // Store Content id that user has read
    HOME.contentIdArray = ClientData.ReadingContentIds();
    if (HOME.contentIdArray.length > 0) {

        for ( var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
            if (HOME.contentIdArray[nIndex].contentid == contentId) {
                checkflag = true;
                if (HOME.contentIdArray[nIndex].viewdate == '' || HOME.contentIdArray[nIndex].viewdate == null || HOME.contentIdArray[nIndex].viewdate == 'undefined') {
                    HOME.contentIdArray[nIndex].viewdate = outputDate;
                    HOME.contentIdArray[nIndex].originviewdate = date;
                }
                break;
            }
        }

        if (!checkflag) {
            HOME.contentIdArray.push({
                contentid : contentId,
                viewdate : outputDate,
                originviewdate : date
            });
        }
    } else {
        HOME.contentIdArray.push({
            contentid : contentId,
            viewdate : outputDate,
            originviewdate : date
        });
    }

    // Renew ReadingContentID
    var newArray = [];
    ClientData.ReadingContentIds(newArray);

    // Set ResouceVersion for content
    COMMON.setResourceVersionData(contentId);

    // Set MetaVersion for content
    COMMON.setMetaVersionData(contentId);

    // Set data for readingcontentid
    ClientData.ReadingContentIds(HOME.contentIdArray);

    // Close Submenu
    $('#dlgSubMenu').hide();

    // $('body,html').animate({ scrollTop: 0 }, 0);
    ClientData.IsRefresh(false);

    // For testing without other Type.
    if (contentType == COMMON.ContentTypeKeys.Type_Others) {
        // Download content
        HEADER.downloadResourceById(contentId);
        // redraw content remove new icon
        HOME.drawEditImage(contentId);
    } else if (contentType == COMMON.ContentTypeKeys.Type_Link) {
        // link content
        HEADER.viewLinkContentById(contentId);
        // redraw content remove new icon
        HOME.drawEditImage(contentId);
    } else {
        // Go to Conten view page
        HOME.drawEditImage(contentId);
        HOME.showContentView();
    }
1372 1373 1374
};

// Handle Back To Top Button
1375
HOME.handleBackToTop = function() {
1376

1377 1378 1379 1380 1381
    if (ClientData.searchCond_recordTo() >= HOME.totalPage) {
        $('#control-nextrecord').css('display', 'none');
    } else {
        $('#control-nextrecord').css('display', 'block');
    }
1382

1383 1384 1385
    if (HOME.totalPage == 0) {
        $('#control-nextrecord').css('display', 'none');
    }
1386 1387 1388

};

1389
// Show Next Record Function
1390
HOME.showNextRecordFunction = function() {
1391

1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
    $('#control-nextrecord').hide();

    // Count number of click
    HOME.showNextRecordClickNumber = HOME.showNextRecordClickNumber + 1;

    var fromPage = ClientData.searchCond_recordFrom();
    var toPage = ClientData.searchCond_recordTo();
    var sortType = ClientData.searchCond_sortType();
    var sortOrder = ClientData.searchCond_sortOrder();
    var searchText = ClientData.searchCond_searchText();
    var searchDivision = ClientData.searchCond_searchDivision();
    var genreId = ClientData.searchCond_genreId();
    var groupId = ClientData.searchCond_groupId();
    var sid = ClientData.userInfo_sid();
    var totalrecord = HOME.totalPage;

    var offsetPage = ClientData.searchCond_recordTo();
    if (offsetPage == null || offsetPage == 'undefined') {
        offsetPage = 0;
    }

    var limitPage = 0; //ClientData.searchCond_recordTo();
    if (HOME.isShowBookShelf) {
        limitPage = HOME.returnNumberDispRecordForBookShelf();
    } else {
        limitPage = HOME.returnNumberDispRecordForList();
    }

1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444
//	if (fromPage == null || fromPage == 'undefined') {
//		fromPage = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
//	}
//
//	if (toPage == null || toPage == 'undefined') {
//		if (HOME.isShowBookShelf) {
//			toPage = HOME.returnNumberDispRecordForBookShelf();
//		} else if (!HOME.isShowBookShelf) {
//			toPage = HOME.returnNumberDispRecordForList();
//		} else {
//			toPage = HOME.returnNumberDispRecordForBookShelf();
//		}
//	}
//
//	fromPage = eval(toPage) + 1;
//	var iRecordNumber = eval(totalrecord) - eval(fromPage);
//
//	if (iRecordNumber < HOME.iNumberOfNextRecord) {
//		toPage = eval(fromPage) + eval(iRecordNumber);
//	} else {
//		toPage = eval(fromPage) + (eval(HOME.iNumberOfNextRecord) - 1);
//	}
//	ClientData.searchCond_recordFrom(fromPage);
//	ClientData.searchCond_recordTo(toPage);

1445 1446 1447
    if (offsetPage <= totalrecord) {
        HOME.renderContent(sid, searchText, searchDivision, sortType, sortOrder, offsetPage, limitPage, genreId, groupId);
    }
1448
    HOME.ResizeTab();
1449 1450 1451
};

// Sort By Title Function
1452
HOME.sortByTitleFunction = function() {
1453

1454
    $('#control-nextrecord').hide();
1455

1456 1457 1458 1459 1460
    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
    var genreId = ClientData.searchCond_genreId();
    var groupId = ClientData.searchCond_groupId();
1461

1462 1463 1464 1465 1466 1467 1468
    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }
1469

1470 1471 1472 1473 1474 1475 1476 1477
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
        if (sortType == 1) {
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
        }
    } else {
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
    }
    ClientData.searchCond_sortOrder(sortOrder);
1478

1479
    HEADER.setStatusSort('#control-sort-title', sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1480

1481 1482
    sortType = 1;
    ClientData.searchCond_sortType(sortType);
1483

1484 1485
    // refresh Gridview
    HOME.refreshGrid();
1486

1487
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
1488
    HOME.ResizeTab();
1489 1490 1491
};

// Sort By Title Kana function
1492
HOME.sortByTitleKanaFunction = function() {
1493

1494
    $('#control-nextrecord').hide();
1495

1496 1497 1498 1499 1500
    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
    var genreId = ClientData.searchCond_genreId();
    var groupId = ClientData.searchCond_groupId();
1501

1502 1503 1504 1505 1506 1507 1508
    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }
1509

1510 1511 1512 1513 1514 1515 1516 1517
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
        if (sortType == 2) {
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
        }
    } else {
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
    }
    ClientData.searchCond_sortOrder(sortOrder);
1518

1519
    HEADER.setStatusSort('#control-sort-titlekana', sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1520

1521 1522 1523
    sortType = 2;
    // refresh gridview
    HOME.refreshGrid();
1524

1525 1526
    ClientData.searchCond_sortType(sortType);
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
1527
    HOME.ResizeTab();
1528 1529 1530
};

// Sort By Release Date
1531
HOME.sortByReleaseDateFunction = function() {
1532

1533 1534 1535 1536 1537 1538 1539
    $('#control-nextrecord').hide();

    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
    var genreId = ClientData.searchCond_genreId();
    var groupId = ClientData.searchCond_groupId();
1540

1541 1542 1543 1544 1545 1546 1547
    var recordOffset = 0;
    var recordLimit = 0;
    if (HOME.isShowBookShelf) {
        recordLimit = HOME.returnNumberDispRecordForBookShelf();
    } else {
        recordLimit = HOME.returnNumberDispRecordForList();
    }
1548

1549 1550 1551 1552 1553 1554 1555 1556
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
        if (sortType == 3) {
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
        }
    } else {
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
    }
    ClientData.searchCond_sortOrder(sortOrder);
1557

1558
    HEADER.setStatusSort('#control-sort-releasedate', sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1559

1560 1561 1562
    sortType = 3;
    // refresh gridview
    HOME.refreshGrid();
1563

1564 1565
    ClientData.searchCond_sortType(sortType);
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordOffset, recordLimit, genreId, groupId);
1566
    HOME.ResizeTab();
1567 1568 1569
};

// Handle language
1570
HOME.handleLanguage = function() {
1571

1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
    if (I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko) {
        $('#control-sort-titlekana').css('display', 'none');
        $('#separate').css('display', 'none');
        $('#titlekana-sorttype').html('');
    } else {
        $('#control-sort-titlekana').css('display', 'inline');
        $('#separate').css('display', 'inline');
        if (ClientData.searchCond_sortOrder() != null && ClientData.searchCond_sortOrder() != 'undefined' || ClientData.searchCond_sortType() != '') {
            var typeSort = ClientData.searchCond_sortType();
            var orderSort = ClientData.searchCond_sortOrder();
            HEADER.setStatusSort('#' + $('#menu_sort li.current a').attr('id'), orderSort == COMMON.Consts.ConstOrderSetting_Asc);
        }
    }
1585 1586 1587 1588
};

// /Render Content
HOME.renderContent = function(id, text, division, type, order, offset, limit, cateid, grpid) {
1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620
    var params = {
        sid : id,
        searchText : text,
        searchDivision : division,
        sortType : type,
        sortOrder : order,
        recordFrom : offset,
        recordTo : limit,
        genreId : cateid,
        groupId : grpid
    };

    HOME.abapi('webContentList', params, 'POST', function(data) {

        var countCnt = 0;
        var versionArr = ClientData.ResourceVersion();
        var metaArr = ClientData.MetaVersion();
        var readArr = ClientData.ReadingContentIds();

        $.each(data.contentList, function(i, post) {

            var outputDate = COMMON.formatDeliveryDate(post.contentDeliveryDate);

            if (HOME.isShowBookShelf) {
                $('#content-grid').append(
                        '<section class="sectionhomebookshelf" id="bookshelf' + post.contentId + '">'
                        + '	<div class="cnt_section_bookshelf">'
                        + '		<div class="img">'
                        + '			<canvas height="150" width="150" id="content-thumbnail' + post.contentId + '" contentid="' + post.contentId + '" style="display:none;"></canvas>'
                        + '		</div>'
                        + '	    <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 86px; "/>'
                        + '	</div>'
1621
                        + ' <a id="title' + post.contentId + '" class="name dialog lang" lang="lblTitle" contentid="' + post.contentId + '" printFlg="' + post.printFlg + '">'
1622 1623 1624 1625 1626 1627 1628 1629
                        + '		<img src="' + HEADER.getIconTypeContent(post.contentType) + '" width="20" height="20">'
                        + '		<div class="content-title" style="float:right;text-indent:0px">' + post.contentTitle + '</div>'
                        + ' </a>'
                        + '</section>'
                    );

                if ((HOME.home_realTotalRecord + i + 1) % 3 == 0) {
                    $('#bookshelf' + post.contentId).addClass('no_m_right');
1630
                    $('#bookshelf' + post.contentId).css("margin-right", "0px");
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
                }
                HOME.getNextRecordNumForBookShelf();
            } else {
                var gridHtml = '<section class="sectionhomelist">'
                    + '	<div class="cnt_section_list">'
                    + '		<a class="img">'
                    + '			<canvas height="110" width="150" id="content-thumbnail' + post.contentId + '" contentid="' + post.contentId + '" style="display:none;"></canvas>'
                    + '	        <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 46px; "/>'
                    + '		</a>'
                    + '		<div class="text">'
                    + '         <a id="title' + post.contentId + '" class="dialog name lang" lang="lblTitle" contentid="' + post.contentId + '">'
                    + '             <img class="listIcon" src="' + HEADER.getIconTypeContent(post.contentType) + '" width="20" height="20" style="float:left">'
                    + ' 			<div class="content-list" style="">' + post.contentTitle + '</div>'
                    + '         </a>'
                    + '			<div class="info">'
                    + '				<ul class="date">'
                    + '					<li><span class="lang" lang="txtPubDt"> </span>:' + outputDate + '</li>'
                    + '					<li><span class="lang" lang="txtViewDt"> </span>:<span id="lblVdate' + post.contentId + '"> </span></li>'
                    + '				</ul>'
                    + '				<ul class="pic">'
                    + '					<li><img src="' + COMMON.DEFAULT_IMG_OPTION_MEMO + '" id="imgMemo' + post.contentId + '" class="sticker"  /></li>'
                    + '					<li><img src="' + COMMON.DEFAULT_IMG_OPTION_MARKING + '" id="imgBookMark' + post.contentId + '" class="pen"  /></li>'
1653
                    + '					<li><ul class="iconList">{download}{share}<li><a class="read lang button-details" contentid="' + post.contentId + '" lang="txtRead">読む</a></li></ul></li>'
1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664
                    + '				</ul>'
                    + '			</div>'
                    + '		</div>'
                    + '	</div>'
                    + '</section>';

                var shareHtml = "";
                if (post.readerShare == '1') {
                    shareHtml = '<li><a class="read lang button-share" contentid="' + post.contentId + '" lang="txtShare">共有</a></li>';
                }
                gridHtml = gridHtml.replace(/\{share\}/g, shareHtml);
1665 1666 1667 1668 1669
                var downloadHtml = "";
				if(post.contentType == COMMON.ContentTypeKeys.Type_PDF && ClientData.serviceOpt_air_print() == 'Y' && post.printFlg == '1'){
					downloadHtml ='<li><a class="read lang button-download" contentid="' + post.contentId + '" lang="txtDownload">ダウンロード</a></li>';
				}
				gridHtml = gridHtml.replace(/\{download\}/g, downloadHtml);
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
                $('#content-grid').append(gridHtml);

                HOME.getNextRecordNumForList();
            }

            // assign thumbnail to array
            var formatThumbnail = post.contentThumbnail;
            if ((formatThumbnail != null) && (formatThumbnail != 'undefined') && (formatThumbnail != '')) {
                formatThumbnail = COMMON.formatStringBase64(formatThumbnail);
            }

            HOME.thumbnailArr.push({
                contentId : post.contentId,
                thumbnail : formatThumbnail
            });

            // assign content type to array
            HOME.contentTypeArr.push({
                contentId : post.contentId,
                contentType : post.contentType
            });

            // save alert message level
            LIMIT_ACCESS_CONTENT.messageLevel[post.contentId] = {
                alertMessageLevel : post.alertMessageLevel,
                alertMessage : post.alertMessage
            };

            // Check if user has read this content or not.
            HOME.checkUserHasReadContent(post.contentId, post.resourceVersion, post.metaVersion, versionArr, metaArr, readArr);
            // assign version to array
            COMMON.resourceVersionArr.push({
                contentid : post.contentId,
                resourceversion : post.resourceVersion
            });

            // assign meta version to array
            COMMON.metaVersionArr.push({
                contentid : post.contentId,
                metaversion : post.metaVersion
            });

            // Check if content has marking or memo
            HOME.checkContentMarkingMemoOption(post.contentId);

            // renderViewDate
            var viewdate = HOME.renderViewDate(post.contentId,readArr);
            if (viewdate != null || viewdate != 'undefined') {
                $('#lblVdate' + post.contentId).html(viewdate);
            }
        });

        HOME.home_realTotalRecord += data.contentList.length;
        // Save total record for tree:genere/group

        if (cateid == '' && grpid == '') {
            if (HOME.genre_totalcontent == -1) {
                HOME.genre_totalcontent = data.totalRecord;
            }
            if (HOME.group_totalcontent == -1) {
                HOME.group_totalcontent = data.totalRecord;
            }
        }

        ClientData.searchCond_recordFrom(data.recordFrom);
        ClientData.searchCond_recordTo(data.recordTo);
        HOME.totalPage = data.totalRecord;

        HOME.reRenderPageNumber(ClientData.searchCond_recordTo(), HOME.totalPage);

        // Toggle scroll to top Control
        HOME.handleBackToTop();

        // I18N.changeLanguage(ClientData.userInfo_language());
        I18N.i18nReplaceText();
1745 1746 1747 1748 1749 1750
        
        // TECカスタマイズ(2行表示、3点リーダー、font-sizeを設定)
        var className = HOME.isShowBookShelf ? ".content-title:visible" : ".content-list:visible";
        $(className).each(function() {
        	COMMON.fixTitleToDottedLine($(this), 11, 24);
    	});
1751
    });
1752 1753
};

1754
// Initial Screen
1755
HOME.renderGridView = function() {
1756

1757 1758 1759 1760 1761 1762 1763
    var sortType = HOME.DEFAULT_SORT_TYPE;
    var sortOrder = HOME.DEFAULT_SORT_ORDER;
    var searchText = '';
    var searchDivision = HOME.DEFAULT_SEARCH_DIVISION;
    var genreId = '';
    var groupId = '';
    var sid = ClientData.userInfo_sid();
1764

1765 1766 1767 1768 1769 1770 1771
    var offsetPage = 0;
    var limitPage = 0;
    if (HOME.isShowBookShelf) {
        limitPage = HOME.returnNumberDispRecordForBookShelf();
    } else {
        limitPage = HOME.returnNumberDispRecordForList();
    }
1772

1773 1774 1775
    //初期化
    ClientData.searchCond_recordFrom(0);
    ClientData.searchCond_recordTo(0);
1776

1777 1778 1779 1780 1781 1782
    ClientData.searchCond_sortType(sortType);
    ClientData.searchCond_sortOrder(sortOrder);
    ClientData.searchCond_searchText(searchText);
    ClientData.searchCond_searchDivision(searchDivision);
    ClientData.searchCond_genreId(genreId);
    ClientData.searchCond_groupId(groupId);
1783

1784 1785
    // Language Handle
    HOME.handleLanguage();
1786

1787 1788
    // handle
    HOME.handleSortDisp();
1789

1790 1791
    // Refresh GridView
    HOME.refreshGrid();
1792

1793
    HOME.resetShowNextRecordCount();
1794

1795 1796
    // Render Gridview
    HOME.renderContent(sid, searchText, searchDivision, sortType, sortOrder, offsetPage, limitPage, genreId, groupId);
1797
};
1798

1799 1800
// Get Thumnail base on contentid
HOME.returnThumbnail = function(contentid) {
1801 1802 1803 1804 1805 1806
    var iArrCnt = HOME.thumbnailArr.length;
    for ( var i = 0; i < iArrCnt; i++) {
        if (HOME.thumbnailArr[i].contentId == contentid) {
            return HOME.thumbnailArr[i].thumbnail;
        }
    }
1807
};
1808

1809 1810
// Get content type base on contentid
HOME.returnContentType = function(contentid) {
1811 1812
    // Array Length
    var iArrCnt = HOME.contentTypeArr.length;
1813

1814 1815 1816 1817 1818 1819
    // Get contentType in array by contentId
    for ( var i = 0; i < iArrCnt; i++) {
        if (HOME.contentTypeArr[i].contentId == contentid) {
            return HOME.contentTypeArr[i].contentType;
        }
    }
1820
};
1821

1822 1823
// Check if Content Has marking or memo
HOME.checkContentMarkingMemoOption = function(contentId) {
1824

1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854
    if (!HOME.isShowBookShelf) {
        // Check if contentid has marking
        if (ClientData.MarkingData().length == 0) {
            $('#imgBookMark' + contentId).css('visibility', 'hidden');
        } else {
            for ( var nIndex1 = 0; nIndex1 < ClientData.MarkingData().length; nIndex1++) {
                if (ClientData.MarkingData()[nIndex1].contentid == contentId) {
                    $('#imgBookMark' + contentId).css('visibility', 'visible');
                    break;
                } else {
                    $('#imgBookMark' + contentId).css('visibility', 'hidden');
                }
            }
        }

        if (ClientData.MemoData().length == 0) {
            $('#imgMemo' + contentId).css('visibility', 'hidden');
        } else {
            // Check if contentid has memo
            for ( var nIndex1 = 0; nIndex1 < ClientData.MemoData().length; nIndex1++) {
                if (ClientData.MemoData()[nIndex1].contentid == contentId) {
                    $('#imgMemo' + contentId).css('visibility', 'visible');
                    break;
                } else {
                    $('#imgMemo' + contentId).css('visibility', 'hidden');
                }
            }
        }

    }
1855 1856
};

1857 1858 1859
// Check if User has read content
HOME.checkUserHasReadContent = function(contId, resourceVer, metaVer, versionArr, metaArr, readArr) {

1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924
    var imgThumb = new Image();
    var imgIconNew = new Image();
    var imgIconEdit = new Image();

    var c = document.getElementById('content-thumbnail' + contId);
    var ctx = c.getContext('2d');

    var readFlg = false;
    //var versionArr = ClientData.ResourceVersion();
    //var metaArr = ClientData.MetaVersion();
    //var readArr = ClientData.ReadingContentIds();

    var contentThumbnail = HOME.returnThumbnail(contId);
    var contentType = HOME.returnContentType(contId);

    if (readArr <= 0) {
        imgThumb.onload = function() {
            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
            imgIconNew.onload = function() {
                ctx.drawImage(imgIconNew, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                $("#loadingIcon" + contId).fadeOut('slow', function() {
                    $('#content-thumbnail' + contId).fadeIn('slow');
                });
            };
            imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
        };

        if (contentThumbnail == '' || contentThumbnail == null) {
            if (!COMMON.isPdfContent(contentType)) {
                var src = HEADER.getThumbnailForOtherType(contentType);
                if (src != '') {
                    imgThumb.src = src;
                }
            }
        } else {
            imgThumb.src = contentThumbnail;
        }

    } else {
        // Check if user has read this content or not
        for ( var nIndex1 = 0; nIndex1 < ClientData.ReadingContentIds().length; nIndex1++) {
            if (ClientData.ReadingContentIds()[nIndex1].contentid == contId) {
                imgThumb.onload = function() {
                    var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
                    ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                    $("#loadingIcon" + contId).fadeOut('slow', function() {
                        $('#content-thumbnail' + contId).fadeIn('slow');
                    });
                };

                if (contentThumbnail == '' || contentThumbnail == null) {
                    if (!COMMON.isPdfContent(contentType)) {
                        var src = HEADER.getThumbnailForOtherType(contentType);
                        if (src != '') {
                            imgThumb.src = src;
                        }
                    }
                } else {
                    imgThumb.src = contentThumbnail;
                }

                readFlg = true;
                break;
            } else {
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
//				imgThumb.onload = function() {
//					var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
//					ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
//					imgIconNew.onload = function() {
//						ctx.drawImage(imgIconNew, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
//						$("#loadingIcon" + contId).fadeOut('slow', function() {
//							$('#content-thumbnail' + contId).fadeIn('slow');
//						});
//					};
//					imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
//				};
//				// Start Function : No.12 -- Editor : Le Long -- Date :
//				// 07/31/2013 -- Summary : Check contentType to set thumbnail.
//
//				if (contentThumbnail == '' || contentThumbnail == null) {
//					if (!COMMON.isPdfContent(contentType)) {
//						var src = HEADER.getThumbnailForOtherType(contentType);
//						if (src != '') {
//							imgThumb.src = src;
//						}
//					}
//				} else {
//					imgThumb.src = contentThumbnail;
//				}
//
//				// End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013
//				// -- Summary : Check contentType to set thumbnail.
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
            }
        }
    }

    // Check if resource version has change
    if (readFlg) {
        if (versionArr == null || versionArr <= 0 || versionArr == 'undefined') {
        } else {
            for ( var nIndex2 = 0; nIndex2 < versionArr.length; nIndex2++) {
                if (versionArr[nIndex2].contentid == contId) {
                    if (versionArr[nIndex2].resourceversion != resourceVer) {
                        imgThumb.onload = function() {
                            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
                            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                            imgIconEdit.onload = function() {
                                ctx.drawImage(imgIconEdit, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);

                                $("#loadingIcon" + contId).fadeOut('slow', function() {
                                    $('#content-thumbnail' + contId).fadeIn('slow');
                                });
                            };
                            imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
                        };

                        if (contentThumbnail == '' || contentThumbnail == null) {
                            if (!COMMON.isPdfContent(contentType)) {
                                var src = HEADER.getThumbnailForOtherType(contentType);
                                if (src != '') {
                                    imgThumb.src = src;
                                }
                            }
                        } else {
                            imgThumb.src = contentThumbnail;
                        }

                        break;
                    }
                }
            }
        }

        if (metaArr == null || metaArr <= 0 || metaArr == 'undefined') {
        } else {
            for ( var nIndex2 = 0; nIndex2 < metaArr.length; nIndex2++) {
                if (metaArr[nIndex2].contentid == contId) {
                    if (metaArr[nIndex2].metaversion != metaVer) {
                        imgThumb.onload = function() {
                            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
                            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                            imgIconEdit.onload = function() {
                                ctx.drawImage(imgIconEdit, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                                $("#loadingIcon" + contId).fadeOut('slow', function() {
                                    $('#content-thumbnail' + contId).fadeIn('slow');
                                });
                            };
                            imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
                        };

                        if (contentThumbnail == '' || contentThumbnail == null) {
                            if (!COMMON.isPdfContent(contentType)) {
                                var src = HEADER.getThumbnailForOtherType(contentType);
                                if (src != '') {
                                    imgThumb.src = src;
                                }
                            }
                        } else {
                            imgThumb.src = contentThumbnail;
                        }

                        break;
                    }
                }
            }
        }
    } else {
        imgThumb.onload = function() {
            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
            imgIconNew.onload = function() {
                ctx.drawImage(imgIconNew, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                $("#loadingIcon" + contId).fadeOut('slow', function() {
                    $('#content-thumbnail' + contId).fadeIn('slow');
                });
            };
            imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
        };

        if (contentThumbnail == '' || contentThumbnail == null) {
            if (!COMMON.isPdfContent(contentType)) {
                var src = HEADER.getThumbnailForOtherType(contentType);
                if (src != '') {
                    imgThumb.src = src;
                }
            }
        } else {
            imgThumb.src = contentThumbnail;
        }

    }
2051
};
2052

2053 2054
// draw Edit Image
HOME.drawEditImage = function(id) {
2055 2056
    var img = new Image();
    var imgSrc = HOME.returnThumbnail(id);
2057

2058 2059 2060
    if (imgSrc != null) {
    } else {
        var contentType = HOME.returnContentType(id);
2061

2062 2063 2064 2065 2066
        var src = HEADER.getThumbnailForOtherType(contentType);
        if (src != '') {
            imgSrc = src;
        }
    }
2067

2068
    var c = document.getElementById('content-thumbnail' + id);
2069

2070 2071 2072 2073 2074 2075 2076 2077 2078 2079
    // use getContext to use the canvas for drawing
    var ctx = c.getContext('2d');
    ctx.clearRect(0, 0, c.width, c.height);
    img.onload = function() {
        var resizeImg = HOME.resizeResourceThumbnail(img, c.width, c.height);
        ctx.drawImage(img, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
        $("#loadingIcon" + id).fadeOut('slow', function() {
            $('#content-thumbnail' + id).fadeIn('slow');
        });
    };
2080

2081
    img.src = imgSrc;
2082 2083
};

2084 2085
// Render User view date
HOME.renderViewDate = function(id, readArr) {
2086 2087 2088 2089 2090
    for ( var i = 0; i < readArr.length; i++) {
        if (readArr[i].contentid == id) {
            return readArr[i].viewdate;
        }
    }
2091 2092
};

2093
// handle display sort direction
2094
HOME.handleSortDisp = function() {
2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120
    $('#control-sort-title').removeClass('active_tops');
    $('#control-sort-titlekana').removeClass('active_tops');
    $('#control-sort-releasedate').removeClass('active_tops');

    var typeSort;
    var orderSort;

    if (ClientData.searchCond_sortType() == null || ClientData.searchCond_sortType() == 'undefined' || ClientData.searchCond_sortType() == '') {
        $('#title-sorttype').html('');
        $('#title-sorttype').html('');
        $('#titlekana-sorttype').html('');
        $('#rDate-sorttype').html('');
    } else {
        if (ClientData.searchCond_sortOrder() != null && ClientData.searchCond_sortOrder() != 'undefined' || ClientData.searchCond_sortType() != '') {
            typeSort = ClientData.searchCond_sortType();
            orderSort = ClientData.searchCond_sortOrder();

            if (typeSort == 1) {
                HEADER.setStatusSort('#control-sort-title', orderSort == COMMON.Consts.ConstOrderSetting_Asc);
            } else if (typeSort == 2) {
                HEADER.setStatusSort('#control-sort-titlekana', orderSort == COMMON.Consts.ConstOrderSetting_Asc);
            } else if (typeSort == 3) {
                HEADER.setStatusSort('#control-sort-releasedate', orderSort == COMMON.Consts.ConstOrderSetting_Asc);
            }
        }
    }
2121 2122 2123
};

// Get Number Disp Record For List
2124
HOME.returnNumberDispRecordForBookShelf = function() {
2125 2126 2127 2128
    var toPage = 0;
    var sysSettings = AVWEB.avwSysSetting();
    toPage = sysSettings.bookShelfCount;
    return toPage;
2129 2130
};

2131
// Get Number Disp Record For List
2132
HOME.returnNumberDispRecordForList = function() {
2133 2134 2135 2136
    var toPage = 0;
    var sysSettings = AVWEB.avwSysSetting();
    toPage = sysSettings.bookListCount;
    return toPage;
2137 2138
};

2139
// Get number record disp next for list
2140
HOME.getNextRecordNumForList = function() {
2141
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForList();
2142 2143
};

2144
// Get number record disp next for bookshelf
2145
HOME.getNextRecordNumForBookShelf = function() {
2146
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForBookShelf();
2147 2148
};

2149
// refresh sort order
2150
HOME.refreshSortTypeOrder = function() {
2151 2152 2153 2154
    $('#title-sorttype').html('');
    $('#titlekana-sorttype').html('');
    $('#rDate-sorttype').html('');
    $('#rDate-sorttype').html('');
2155 2156
};

2157
// refresh GridView
2158
HOME.refreshGrid = function() {
2159 2160 2161
    $('#control-nextrecord').hide();
    $('#content-grid').html('');
    $('.pageNumControl').css('visibility', 'hidden');
2162 2163
};

2164
// format text display more record
2165
HOME.formatDisplayMoreRecord = function() {
Masaru Abe committed
2166

2167 2168
    // I18N.changeLanguage(ClientData.userInfo_language());
    I18N.i18nReplaceText();
2169

2170 2171 2172 2173 2174
    if (HOME.isShowBookShelf) {
        $('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), HOME.returnNumberDispRecordForBookShelf()).toString());
    } else {
        $('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), HOME.returnNumberDispRecordForList()));
    }
2175

2176 2177 2178
};

/*
2179 2180
 * Check content whether existed or not
 */
2181
HOME.IsExistContent = function(strContentId) {
2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199
    var isExisted = true;
    var params = {
        sid : ClientData.userInfo_sid(),
        getType : '1',
        contentId : strContentId
    };
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webGetContent", 'GET', params, function(data) {
        isExisted = true;
    }, function(xmlHttpRequest, txtStatus, errorThrown) {
        if (xmlHttpRequest.status == 404) {
            isExisted = false;
        } else {
            // Show system error
            isExisted = true; // Mark this flag to prevent bookmarks from deleting
            AVWEB.showSystemError();
        }
    });
    return isExisted;
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
};

//HOME.syncReadingContent = function() {
//	var readArr = ClientData.ReadingContentIds();
//	var metaArr = ClientData.MetaVersion();
//	var resourceArr = ClientData.ResourceVersion();
//
//	for ( var i = readArr.length - 1; i >= 0; i--) {
//		var readContent = readArr[i];
//
//		if (!HOME.IsExistContent(readContent.contentid)) {
//
//			HOME.errorContent.push({
//				contentid : readContent.contentid
//			});
//			readArr.splice(i, 1);
//			metaArr.splice(i, 1);
//			resourceArr.splice(i, 1);
//		}
//		// Do not process next
//		if (AVWEB.avwHasError()) {
//			return;
//		}
//	}
//
//	ClientData.ReadingContentIds(readArr);
//	ClientData.MetaVersion(metaArr);
//	ClientData.ResourceVersion(resourceArr);
//};
2229

2230
HOME.syncReadingContent = function(readArr) {
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283
    //var readArr = ClientData.ReadingContentIds();
    //100件以下なら行わない
    if(readArr.length <= HOME.historyBuffer){
        //console.log("readArr.length:" + readArr.length);
        return;
    }

    var metaArr = ClientData.MetaVersion();
    var resourceArr = ClientData.ResourceVersion();

    //閲覧日順に並び替える
    var temp;
    for ( var i = 0; i < readArr.length; i++) {
        for ( var j = readArr.length - 1; j > i; j--) {
            if (readArr[j].originviewdate > readArr[j - 1].originviewdate) {
                temp = readArr[j];
                readArr[j] = readArr[j - 1];
                readArr[j - 1] = temp;
            }
        }
    }

    //後ろから100件移行捨てる
    for ( var i = readArr.length - 1; i >= HOME.historyBuffer; i--) {
        temp = readArr[i];
        readArr.splice(i, 1);

        for ( var j = metaArr.length - 1; j >= 0; j--) {
            if (metaArr[j].contentid == temp.contentid) {
                //削除
                metaArr.splice(j, 1);
            }
        }
        for ( var j = resourceArr.length - 1; j >= 0; j--) {
            if (resourceArr[j].contentid == temp.contentid) {
                //削除
                resourceArr.splice(j, 1);
            }
        }

        // Do not process next
        if (AVWEB.avwHasError()) {
            return;
        }

    }

    //console.log("readArr.length:" + readArr.length);
    //console.log("metaArr.length:" + metaArr.length);
    //console.log("resourceArr.length:" + resourceArr.length);
    ClientData.ReadingContentIds(readArr);
    ClientData.MetaVersion(metaArr);
    ClientData.ResourceVersion(resourceArr);
2284
};
2285

2286
HOME.syncBookmarkContent = function() {
2287
    var arrBookmark = ClientData.BookMarkData();
2288

2289 2290
    for ( var j = arrBookmark.length - 1; j >= 0; j--) {
        var bookmark = arrBookmark[j];
2291

2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303
        if (HOME.isErrorContent(bookmark.contentid)) {
            arrBookmark.splice(j, 1);
        } else {
            if (!HOME.IsExistContent(bookmark.contentid)) {
                HOME.errorContent.push({
                    contentid : bookmark.contentid
                });
                arrBookmark.splice(j, 1);
                ClientData.isChangedBookmark(true);
            }
        }
    }
2304

2305
    ClientData.BookMarkData(arrBookmark);
2306 2307
};

2308
HOME.syncMemoContent = function() {
2309
    var arrMemo = ClientData.MemoData();
2310

2311 2312
    for ( var j = arrMemo.length - 1; j >= 0; j--) {
        var memo = arrMemo[j];
2313

2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325
        if (HOME.isErrorContent(memo.contentid)) {
            arrMemo.splice(j, 1);
        } else {
            if (!HOME.IsExistContent(memo.contentid)) {
                HOME.errorContent.push({
                    contentid : memo.contentid
                });
                arrMemo.splice(j, 1);
                ClientData.isChangedMemo(true);
            }
        }
    }
2326

2327
    ClientData.MemoData(arrMemo);
2328 2329
};

2330
HOME.syncMarkingContent = function() {
2331

2332
    var arrMarking = ClientData.MarkingData();
2333

2334 2335
    for ( var j = arrMarking.length - 1; j >= 0; j--) {
        var marking = arrMarking[j];
2336

2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348
        if (HOME.isErrorContent(marking.contentid)) {
            arrMarking.splice(j, 1);
        } else {
            if (!HOME.IsExistContent(marking.contentid)) {
                HOME.errorContent.push({
                    contentid : marking.contentid
                });
                arrMarking.splice(j, 1);
                ClientData.isChangedMarkingData(true);
            }
        }
    }
2349

2350
    ClientData.MarkingData(arrMarking);
2351 2352
};

2353
HOME.syncContentData = function() {
2354

2355 2356 2357 2358 2359
    var readingContentIds = ClientData.ReadingContentIds();
    if(readingContentIds.length == 0){
        ClientData.common_contentDataChkFlg(false);
        return;
    }
2360

2361 2362 2363 2364 2365 2366 2367 2368
    if (ClientData.common_contentDataChkFlg() == 'true') {
        HOME.syncReadingContent(readingContentIds);
        HOME.syncBookmarkContent();
        HOME.syncMemoContent();
        HOME.syncMarkingContent();
        HOME.getExistContentPages();
        HOME.SyncMemoPages();
        HOME.SyncMarkingPages();
2369

2370 2371
        ClientData.common_contentDataChkFlg(false);
    }
2372 2373
};

2374
HOME.isErrorContent = function(contentid) {
2375 2376 2377 2378 2379 2380 2381 2382 2383
    var isError = false;
    for ( var j = HOME.errorContent.length - 1; j >= 0; j--) {
        var contentErr = HOME.errorContent[j];
        if (contentid == contentErr.contentid) {
            isError = true;
            break;
        }
    }
    return isError;
2384 2385
};

2386
HOME.getExistContentPages = function() {
2387 2388
    var memoArr = ClientData.MemoData();
    var markingArr = ClientData.MarkingData();
2389

2390 2391
    for ( var i = 0; i < memoArr.length; i++) {
        var memo = memoArr[i];
2392

2393 2394 2395 2396
        HOME.existContent.push({
            contentid : memo.contentid
        });
    }
2397

2398 2399
    for ( var i = 0; i < markingArr.length; i++) {
        var marking = markingArr[i];
2400

2401 2402 2403 2404
        HOME.existContent.push({
            contentid : marking.contentid
        });
    }
2405 2406
};

2407
HOME.SyncMemoPages = function() {
2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468
    var arrMemo = ClientData.MemoData();
    for ( var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {

        // Get one content
        var oneContent = HOME.existContent[nIndex];

        var params = {
            sid : ClientData.userInfo_sid(),
            contentId : oneContent.contentid,
            thumbnailFlg : 0
        };
        var webContentPage;

        // Get all pages of content
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params, function(data) {
            // Success
            if (data.pages) {
                webContentPage = data.pages;
            }
        }, null);

        if (webContentPage) {
            if (webContentPage.length > 0) {
                for ( var nIndex1 = arrMemo.length - 1; nIndex1 >= 0; nIndex1--) {
                    // Get one bookmar entity
                    var oneMemo = arrMemo[nIndex1];

                    // Found contentid
                    if (oneMemo.contentid == oneContent.contentid) {

                        var isFoundPage = false;
                        for ( var nIndex2 = 0; nIndex2 < webContentPage.length; nIndex2++) {
                            if (oneMemo.pageNo == webContentPage[nIndex2].pageNo) {
                                // Found pageNo
                                isFoundPage = true;
                                break;
                            }
                        }

                        if (!isFoundPage) {
                            arrMemo.splice(nIndex1, 1);
                            ClientData.isChangedMemo(true);
                        }
                    }
                }

            } else { // webContentPage.length = 0
                for ( var nIndex1 = 0; nIndex1 < arrMemo.length; nIndex1++) {
                    // Get one bookmar entity
                    var oneMemo = arrMemo[nIndex1];

                    if (oneMemo.contentid == oneContent.contentid) {
                        arrMemo.splice(nIndex1, 1);
                        ClientData.isChangedMemo(true);
                    }
                }
            }
        }
    }

    ClientData.MemoData(arrMemo);
2469 2470
};

2471
HOME.SyncMarkingPages = function() {
2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532
    var arrMarking = ClientData.MarkingData();
    for ( var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {

        // Get one content
        var oneContent = HOME.existContent[nIndex];

        var params = {
            sid : ClientData.userInfo_sid(),
            contentId : oneContent.contentid,
            thumbnailFlg : 0
        };
        var webContentPage;

        // Get all pages of content
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params, function(data) {
            // Success
            if (data.pages) {
                webContentPage = data.pages;
            }
        }, null);

        if (webContentPage) {
            if (webContentPage.length > 0) {
                for ( var nIndex1 = arrMarking.length - 1; nIndex1 >= 0; nIndex1--) {
                    // Get one bookmar entity
                    var oneMarking = arrMarking[nIndex1];

                    // Found contentid
                    if (oneMarking.contentid == oneContent.contentid) {

                        var isFoundPage = false;
                        for ( var nIndex2 = 0; nIndex2 < webContentPage.length; nIndex2++) {
                            if (oneMarking.pageNo == webContentPage[nIndex2].pageNo) {
                                // Found pageNo
                                isFoundPage = true;
                                break;
                            }
                        }

                        if (!isFoundPage) {
                            arrMarking.splice(nIndex1, 1);
                            ClientData.isChangedMarkingData(true);
                        }
                    }
                }

            } else { // webContentPage.length = 0
                for ( var nIndex1 = 0; nIndex1 < arrMarking.length; nIndex1++) {
                    // Get one bookmar entity
                    var oneMarking = arrMarking[nIndex1];

                    if (oneMarking.contentid == oneContent.contentid) {
                        arrMarking.splice(nIndex1, 1);
                        ClientData.isChangedMarkingData(true);
                    }
                }
            }
        }
    }

    ClientData.MarkingData(arrMarking);
2533 2534 2535
};

function changeLanguageCallBackFunction() {
2536 2537 2538
    HOME.handleLanguage();
    HOME.formatDisplayMoreRecord();
    document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
2539 2540
};

2541
HOME.resizeResourceThumbnail = function(mg, width, height) {
2542

2543 2544 2545 2546 2547 2548 2549 2550
    var newWidth;
    var newHeight;
    /*
     * if (mg.width > mg.height) { newWidth = width; newHeight = (mg.height *
     * width) / mg.width; } else { newHeight = height; newWidth = (mg.width *
     * height) / mg.height; }
     */
    var delta = Math.min(width / mg.width, height / mg.height);
2551

2552 2553
    newHeight = parseInt(delta * mg.height);
    newWidth = parseInt(delta * mg.width);
2554

2555 2556
    var result = [ newWidth, newHeight ];
    return result;
2557 2558 2559

};

2560
HOME.resetShowNextRecordCount = function() {
2561
    HOME.showNextRecordClickNumber = 1;
2562 2563
};

2564
HOME.setDefaultViewMode = function() {
2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
    if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_BookShelf) {
        HOME.isShowBookShelf = true;
        $('body').attr('id', 'bookshelf');
        $('#control-bookshelf-type').parent().removeClass("thumbnail");
        $('#control-bookshelf-type').parent().addClass("thumbnail_select");
        $('#control-list-type').parent().removeClass("list_select");
        $('#control-list-type').parent().addClass("list");
    } else if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
        HOME.isShowBookShelf = false;
        $('body').attr('id', 'list');
        $('#control-list-type').parent().removeClass("list");
        $('#control-list-type').parent().addClass("list_select");
        $('#control-bookshelf-type').parent().removeClass("thumbnail_select");
        $('#control-bookshelf-type').parent().addClass("thumbnail");
    } else {
        HOME.isShowBookShelf = true;
        $('body').attr('id', 'bookshelf');
        $('#control-bookshelf-type').parent().removeClass("thumbnail");
        $('#control-bookshelf-type').parent().addClass("thumbnail_select");
        $('#control-list-type').parent().removeClass("list_select");
        $('#control-list-type').parent().addClass("list");
    }
2587 2588
};

2589
HOME.removeHoverCss = function() {
2590 2591 2592 2593 2594
    if (COMMON.isTouchDevice()) {
        $('#control-sort-title').removeClass('nottouchdevice');
        $('#control-sort-titlekana').removeClass('nottouchdevice');
        $('#control-sort-releasedate').removeClass('nottouchdevice');
    }
2595
};
2596

2597
// Dialog Read Button CLick
2598
HOME.showContentShareDlgFunction = function(e) {
2599

2600 2601 2602
    if (e) {
        e.preventDefault();
    }
2603

2604 2605 2606 2607
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }
2608

2609 2610
	var contentId = $(this).attr('contentid');
	// check limit of content
2611
//	LIMIT_ACCESS_CONTENT.checkLimitContent(contentId, function() {
2612 2613 2614
		SHARE.contentId = contentId;
		SHARE.contentTitle = "";
		SHARE.openContentShare();
2615 2616 2617
//	}, function() {
//		// console.log("checkLimitContent_bbb");
//	});
2618 2619 2620

};

2621
$(function() {
2622
    HOME.cssInit();
2623 2624
});

2625
HOME.cssInit = function() {
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643
    $('html').css({
        'overflow-y' : 'scroll'
    });
    $('html,body').css({
        'height' : '100%',
        'margin' : '0',
        'padding' : '0'
    });
    $('html>body').css({
        'font-size' : '16px',
        'font-size' : '68.75%'
    });
    $('body').css({
        'font-family' : 'Verdana, helvetica, arial, sans-serif',
        'font-size' : '68.75%',
        'background' : '#fff',
        'color' : '#333'
    });
2644 2645
};

2646
HOME.showContentView = function() {
2647

2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661
    var y = 0;
    if (document.documentElement.scrollTop) {
        y = document.documentElement.scrollTop;
    }
    if (document.body.scrollTop) {
        if (y == undefined || y == 0) {
            y = document.body.scrollTop;
        }
    }
    if (y == undefined || y == null) {
        y = 0;
    }
    HOME.scrollTop = y;
    window.scrollTo(0, 0);
2662

2663 2664 2665 2666
    // 試験
    $("#header-ws").hide();
    $("#ws-body").hide();
    $("#topcontrol").hide();
2667

2668 2669 2670
    CONTENTVIEW_INITOBJECT.clearViewerComponent();
    CONTENTVIEW.cssInit();
    $("#viewer").show();
2671

2672 2673
    // CONTENTVIEW_FILESYSTEM.initFS(CONTENTVIEW.ready);
    CONTENTVIEW.ready();
2674

2675 2676
};

2677
// Dialog Read Button CLick
2678
HOME.downloadSubmenuFunction = function(e) {
2679 2680 2681 2682
    if (e) {
        e.preventDefault();
    }
    HOME.allowTimerCloseSubMenu = false;
2683

2684 2685 2686 2687
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }
2688

2689 2690
    // hide dialog sub menu
    $('#dlgSubMenu').hide();
2691

2692
    var contentId = $(this).attr('contentid');
2693

2694 2695
    // Download content
    HEADER.downloadResourceById(contentId);
2696

2697 2698
};

2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710
HOME.downloadPdfFunction = function(e){
	
	if (e) {
		e.preventDefault();
	}

	var contentId = $(this).attr('contentid');
	// Download content
	HEADER.downloadResourceById(contentId);
	
}