home.js 91.2 KB
Newer Older
1

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

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

HOME.home_realTotalRecord = 0;

HOME.iNumberOfNextRecord = 15;
16 17
//Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new Array for function No.12.
//Thumbnail array
18
HOME.thumbnailArr = [];
19
//Content type array.
20 21 22
HOME.contentTypeArr = [];

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

HOME.allowTimerCloseSubMenu = true;
HOME.timer_subMenu;

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

42 43 44
//スクロール復帰
HOME.scrollTop = 0;

45 46 47
//==========================================================
$(document).ready(function () {

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

52
    document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
53 54

    // Set bookmark screen
55
    ClientData.BookmarkScreen(COMMON.ScreenIds.Home);
56 57 58 59

    //Check if Force Change password
    if (ClientData.requirePasswordChange() != 1) {
        // Register log
Masaru Abe committed
60
        COMMON.RegisterLog();
61 62 63 64 65

        //Sync Data
        if (ClientData.ReadingContentIds() == null || ClientData.ReadingContentIds() == 'undefined' || ClientData.ReadingContentIds().length == 0) {
            ClientData.common_contentDataChkFlg(false);
        } else {
66
            HOME.syncContentData();
67 68 69
        }

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

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

        //Toggle TreeView Disp
76
        HOME.handleTreeViewDisp();
77 78

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

        //Render Grid
82
        HOME.renderGridView();
83

84
        //Render Genre
85 86
        HOME.getDataJsonFileGenre();
        HOME.getDataJsonFileGroup();
87 88

        // Lock screen is here, because of in getDataJsonFileGroup() called click to expand speified nodes of treeview
Masaru Abe committed
89
        COMMON.LockScreen();
90 91

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

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

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

        //Open dialog
103 104 105 106
        $('.dialog').live('click', HOME.openSubMenuDialogFunction);
        //$('.dialog').live('touchstart', HOME.openSubMenuDialogFunction);
        $('.dialog').live('touchend', HOME.openSubMenuDialogFunction);
        $('.dialog').live('touchmove', function () { HOME.home_isMove = true; });
107 108

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

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

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

117
        //Button Read on dialog click event
118
        $('#dialog-read').click(HOME.readSubmenuFunction);
119 120

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

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

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

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

        //Go To Details Page
133 134 135 136
        $('.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; });
137

138 139 140 141
        //Show Share Dialog
        $('.button-share').live('click', HOME.showContentShareDlgFunction);
        $('.button-share').live('touchend', HOME.showContentShareDlgFunction);
        $('.button-share').live('touchmove', function () { HOME.home_isMove = true; });
142

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

Masaru Abe committed
145
        if (COMMON.isTouchDevice() == true) {
146 147 148
            var avwUserEnvObj = new UserEnvironment();
            if (avwUserEnvObj.os == 'ipad') {
                $('#dlgSubMenu').click(function () {
149
                    HOME.allowTimerCloseSubMenu = false;
150 151 152
                });
            }
        }
153 154

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

158
        $('body').click(HOME.bodyHomeClickFunction);
Masaru Abe committed
159
        if (COMMON.isTouchDevice() == true) {
160 161 162 163
            var avwUserEnvObj = new UserEnvironment();
            if (avwUserEnvObj.os == 'ipad') {
                $('body').bind('touchstart', function () {
                    if ($('#dlgSubMenu').css('display') != "none") {
164 165
                        HOME.allowTimerCloseSubMenu = true;
                        HOME.timer_subMenu = setTimeout("HOME.startTimerCloseMenu();", 500);
166 167 168 169
                    }
                });
            }
            else {
170
                $('body').bind('touchstart', HOME.bodyHomeClickFunction);
171 172 173 174 175 176 177 178 179 180 181 182 183
            }
        }

        $(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');
                }
            }
        });
    } else {
Masaru Abe committed
184
        HEADER.checkForceChangePassword();
185 186
    }

187 188 189 190




191 192 193 194 195 196 197
	//日比谷用設定ボタン隠す
    $('#dspHibiya').hide();

    //カタログエディション対応判定
    if( ClientData.serviceOpt_catalog_edition() == 'Y'){
        $('.tabUnit').hide();
        //センタリングするようサイズ調整
198
        $('#bookshelf-main').width(660);
199 200 201 202
    } else {
        $('.tabUnit').show();
    }

203
    // hide tab group with user anonymous
Masaru Abe committed
204
    if (COMMON.isAnonymousLogin()) {
205

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

211 212 213 214 215 216 217 218
        //日比谷対応判定
        if( ClientData.serviceOpt_hibiyakadan_catalog() == 'Y'){
            $('#dspHibiya').show();
            jQuery( '#dlgAddMemberGroup' ).dialog( {
                autoOpen: false,
                modal: true,
                width: 350
            });
219 220
            $('#dspHibiya').click(HOME.dspHibiyaClickFunction);
            $('#btnAddMemberGroupSearch').click(HOME.btnAddMemberGroupSearchClickFunction);
221
        }
222
    } else {
223
        //$('.tabUnit').show();
Masaru Abe committed
224
        $('.switchingTab .colright').show();
225
    }
226

227 228 229 230 231 232
	// 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" });
	}

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

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

248 249 250
});

//日比谷カスタム ここから
251
HOME.dspHibiyaClickFunction = function(){
252
	$( '#dlgAddMemberGroup' ).dialog( 'open' );
253
};
254
HOME.btnAddMemberGroupSearchClickFunction = function(){
255

256 257 258 259
	var addGroupName = $('#txtAddMemberGroupName').val();
	if( addGroupName == "" ){
		return;
	}
260

261
	var groupIds = HOME.getAddMemberGroupId(addGroupName);
262
	if( groupIds == "" ){
Masaru Abe committed
263
		alert("コードが不正です");
264 265
		return;
	}
266

267 268
	$( '#dlgAddMemberGroup' ).dialog( 'close' );
	ClientData.searchCond_groupId(groupIds);
269

270 271 272 273
	//画面再描画開始
    var recordFrom = 0;
    var recordTo = 0;

274 275 276
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
277
    }
278 279 280
    else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
281 282
    }
    else {
283 284
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
285 286
    }

287 288 289 290 291 292 293 294 295 296 297
    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();

    //refresh gridview
298
    HOME.refreshGrid();
299

300
    HOME.resetShowNextRecordCount();
301

302
    HOME.handleSortDisp();
303

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

306
};
307

308
HOME.getAddMemberGroupId = function(strGroupName) {
309 310 311 312 313 314

	var groupIds = "";
	var params = {
		sid: ClientData.userInfo_sid(),
		groupName: strGroupName
	};
315
	AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "addMemberGroup", 'POST', params,
316 317 318 319 320 321 322 323 324 325 326 327 328 329
		// Success
		function (data) {
			if (data.groupIds) {
				groupIds = data.groupIds;
			}
		},
		function (xmlHttpRequest, txtStatus, errorThrown) {
			//
		}
	);
	return groupIds;
};
//--日比谷カスタム ここまで

330 331 332 333
HOME.startTimerCloseMenu = function() {
    if (HOME.timer_subMenu) {
        clearTimeout(HOME.timer_subMenu);
        HOME.timer_subMenu = null;
334
    }
335
    if (HOME.allowTimerCloseSubMenu == true) {
336 337
        $('#dlgSubMenu').hide();
    }
338
};
339

340 341
HOME.subMenuHoverFunction = function() {
    HOME.isSubMenuHoverOn = true;
342 343
};

344 345
HOME.subMenuHoverOffFunction = function() {
    HOME.isSubMenuHoverOn = false;
346 347
};

348 349
HOME.bodyHomeClickFunction = function() {
    if (!HOME.isSubMenuHoverOn) {
350 351 352 353 354
        $('#dlgSubMenu').hide();
    }
};

//Toggle Genre/Group Tab
355
HOME.handleTreeViewDisp = function() {
356 357 358 359 360 361 362
    $('#lblGenre').css('display', 'block');
    $('#lnkGenre').css('display', 'none');
    $('#lnkGroup').css('display', 'block');
    $('#lblGroup').css('display', 'none');
};

//Change Display BookShelf Function
363 364
HOME.changeDispBookShelfFunction = function() {
    if (HOME.isShowBookShelf == false) {
365
        //ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_BookShelf);
366

367
        HOME.isShowBookShelf = true;
368 369 370 371 372
        var recordFrom = 0;
        var recordTo = 0;

        //Start : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
        $('body').attr('id', 'bookshelf');
373

374 375 376 377 378 379
        $('#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");
        //End : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon

380
        // if(ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_BookShelf){
381 382 383
        if (HOME.isShowBookShelf) {
            recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
            recordTo = HOME.returnNumberDispRecordForBookShelf() * HOME.showNextRecordClickNumber;
384 385
        }
        //refresh sort order
386
        HOME.refreshSortTypeOrder();
387 388 389 390 391 392 393 394 395 396

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

        //handle sort display
397
        HOME.handleSortDisp();
398 399

        //refresh Grid view
400
        HOME.refreshGrid();
401

402
        HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
403 404

        //format text disp more record
405
        HOME.formatDisplayMoreRecord();
406 407

        //Get next record will be displayed
408
        HOME.getNextRecordNumForBookShelf();
409 410 411 412
    }
};

//Change Display List Function
413 414
HOME.changeDispListFunction = function() {
    if (HOME.isShowBookShelf == true) {
415
        //ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_List);
416

417
        HOME.isShowBookShelf = false;
418 419 420 421 422
        var recordFrom = 0;
        var recordTo = 0;

        //Start : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
        $('body').attr('id', 'list');
423

424 425 426 427 428 429 430
        $('#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");
        //End : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon

        //Check VIewmode
431
        // if(ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List){
432 433 434
        if (!HOME.isShowBookShelf) {
            recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
            recordTo = HOME.returnNumberDispRecordForList() * HOME.showNextRecordClickNumber;
435 436 437
        }

        //refresh sort order
438
        HOME.refreshSortTypeOrder();
439 440 441 442 443 444 445 446 447 448

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

        //Handle Sort disp
449
        HOME.handleSortDisp();
450 451

        //refresh Grid view
452
        HOME.refreshGrid();
453

454
        HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
455 456 457
    }

    //format text disp more record
458
    HOME.formatDisplayMoreRecord();
459 460

    //Get next record will be displayed
461
    HOME.getNextRecordNumForList();
462 463 464

};

465
//Canvas Click function
466
HOME.canvasClickFunction = function(e) {
467 468 469 470
    if (e) {
        e.preventDefault();
    }

471 472
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
473 474 475 476 477
        return;
    }

    var contentId = $(this).attr('id');
    var outputId = contentId.substring(17);
478

479 480 481 482 483 484 485 486 487 488 489
    if (HOME.isShowBookShelf) {
	    LIMIT_ACCESS_CONTENT.checkLimitContent(outputId,
	        function(){
	            HOME.canvasClickFunction_callback(outputId);
	        },
	        function(){
	        }
	    );
    } else {
    	HOME.canvasClickFunction_callback(outputId);
    }
490 491
};

492
HOME.canvasClickFunction_callback = function(outputId)
493
{
494 495 496
    var date = new Date();
    var month = date.getMonth() + 1;
    var day = date.getDate();
Masaru Abe committed
497
    var outputDate = COMMON.formatNormalDate(day, month, date.getFullYear());
498
    var checkflag = false;
499
    var base64String = HOME.returnThumbnail(outputId);
500 501 502 503 504

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

506
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
507
    var contentType = HOME.returnContentType(outputId);
508 509
    ClientData.contentInfo_contentType(contentType);
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
510

511 512
    //Check Display mode to handle action

513
    if (!HOME.isShowBookShelf) {
514

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

519 520 521 522
            for (var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
                if (HOME.contentIdArray[nIndex].contentid == outputId) {
                    checkflag = true;
                    break;
523
                }
524 525
                else {
                    checkflag = false;
526 527
                }
            }
528 529

            if (!checkflag) {
530
                HOME.contentIdArray.push({ contentid: outputId, viewdate: '', originviewdate: '' });
531 532 533
            }
        }
        else {
534
            HOME.contentIdArray.push({ contentid: outputId, viewdate: '', originviewdate: '' });
535 536
        }

537 538 539
        //Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);
540

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

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

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

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

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

556 557 558 559
        //Open content Detail
        DETAIL.openContentDetail();
    }
    else {
560

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

565 566 567 568 569 570
            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;
571
                    }
572
                    break;
573
                }
574 575
                else {
                    checkflag = false;
576 577
                }
            }
578 579

            if (!checkflag) {
580
                HOME.contentIdArray.push({ contentid: outputId, viewdate: outputDate, originviewdate: date });
581
            }
582 583 584 585
        }
        else {
            HOME.contentIdArray.push({ contentid: outputId, viewdate: outputDate, originviewdate: date });
        }
586

587 588 589
        //Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);
590

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

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

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

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

603
        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : check for download content type other.
604
        if(contentType == COMMON.ContentTypeKeys.Type_Others){
605 606 607 608 609 610 611 612 613 614 615 616 617
            //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{
            //Go to Conten view page
618
        	//AVWEB.avwScreenMove(COMMON.ScreenIds.ContentView);
619

620 621 622
            HOME.drawEditImage(outputId);
        	//ビュアーに切り替え
        	HOME.showContentView();
623

624
        }
625
        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : check for download content type other.
626

627 628 629 630 631
    }

};

//function Open SubMenu Dialog
632
HOME.openSubMenuDialogFunction = function(e) {
633 634 635
    if (e) {
        e.preventDefault();
    }
636 637
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
638 639 640 641 642 643
        return;
    }

    var array = [e.clientX, e.clientY];
    var contentid = $(this).attr('contentid');

644 645 646 647 648
    if (!HOME.isShowBookShelf) {
        // Get image of selected image
        var base64String = HOME.returnThumbnail(contentid);
        ClientData.contentInfo_contentThumbnail(base64String);
        ClientData.contentInfo_contentId(contentid);
649

650 651 652 653
        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
        var contentType = HOME.returnContentType(contentid);
        ClientData.contentInfo_contentType(contentType);
        //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
654

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

659 660 661 662
            for (var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
                if (HOME.contentIdArray[nIndex].contentid == contentid) {
                    checkflag = true;
                    break;
663
                }
664 665
                else {
                    checkflag = false;
666 667
                }
            }
668 669

            if (!checkflag) {
670
                HOME.contentIdArray.push({ contentid: contentid, viewdate: '', originviewdate: '' });
671 672 673
            }
        }
        else {
674
            HOME.contentIdArray.push({ contentid: contentid, viewdate: '', originviewdate: '' });
675 676
        }

677 678 679
        //Renew ReadingContentID
        var newArray = [];
        ClientData.ReadingContentIds(newArray);
680

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

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

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

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

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

696
        DETAIL.openContentDetail();
697

698 699 700 701 702 703 704 705 706 707 708 709
    //}
    //else if (HOME.isShowBookShelf) {
    //    $('#dialog-read').attr('contentid', contentid);
    //    $('#dialog-detail').attr('contentid', contentid);
    //    //$("#dlgSubMenu").dialog({position: array, width: 130, height: 90});
    //    $("#dlgSubMenu").show();
    //    HOME.allowTimerCloseSubMenu = false;
    //    $("#dlgSubMenu").position({ my: "left bottom",
    //        at: "left-10 top",
    //        of: this,
    //        collision: "fit"
    //    });
710 711 712 713 714 715 716 717 718 719 720
    }
    else {
        $('#dialog-read').attr('contentid', contentid);
        $('#dialog-detail').attr('contentid', contentid);
        $("#dlgSubMenu").show();
        HOME.allowTimerCloseSubMenu = false;
        $("#dlgSubMenu").position({ my: "left bottom",
            at: "left-10 top",
            of: this,
            collision: "fit"
        });
721 722 723 724
    }
};

//Genre Click Function
725
HOME.genreSelectFunction = function() {
726 727 728 729 730 731 732 733 734 735 736
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');

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

    $('#all').css('font-weight', 'bold');
    $('#all').css('text-decoration', 'underline');
    var recordFrom = 0;
    var recordTo = 0;

737 738 739
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
740
    }
741 742 743
    else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
744 745
    }
    else {
746 747
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
748 749 750 751 752 753 754 755 756 757 758 759 760
    }

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

    //refresh gridview
761
    HOME.refreshGrid();
762

763
    HOME.resetShowNextRecordCount();
764

765
    HOME.handleSortDisp();
766

767
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
768 769 770
};

//Group Click Function
771
HOME.groupSelectFunction = function() {
772 773 774 775 776 777 778 779 780 781 782 783
    $('.file').css('font-weight', 'normal');
    $('.file').css('text-decoration', 'none');

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

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

784 785 786
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
787
    }
788 789 790
    else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
791 792
    }
    else {
793 794
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
795 796 797 798 799 800 801 802 803 804 805 806 807
    }

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

    //refresh gridview
808
    HOME.refreshGrid();
809

810
    HOME.resetShowNextRecordCount();
811

812
    HOME.handleSortDisp();
813

814
    HOME.renderContent(id, searchText, searchDivision, sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
815 816 817
};

//Get Data from Category Json
818
HOME.getDataJsonFileGenre = function() {
819 820 821
    var params = {
        sid: ClientData.userInfo_sid()
    };
822 823
    HOME.abapi('category', params, 'GET', function (data1) {
        HOME.dataGenre = data1.categoryList;
824 825 826
        var arrData = new Array();
        var totalCount = 0;

827
        $.each(HOME.dataGenre, function (i, value) {
828
            // Calculate total content
829 830
            totalCount += Number(HOME.dataGenre[i].contentCount);
            if (HOME.dataGenre[i].parentCategoryId == 0) {
831 832
                var node = new TreeNode();
                //node.IsCategory = true;
833 834 835 836 837
                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);
838 839
                //node.IsClosed = false; //#13200 カテゴリツリーの階層プラス・マイナスのアイコンが逆
                node.ExpandAfterBuild = true; //#14287 第一階層を開くようにする
840

841 842 843 844 845 846 847 848
                node.IsCategory = node.ChildNodes.length > 0; // Has child node

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

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

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

860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
        // 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);
                    }

                }
            }
        }
879

880 881 882 883
    });
};

//Add Children Node Category
884
HOME.AddChidrenNodeGenre = function(node1) {
885
    var dataChild = [];
886 887
    $.each(HOME.dataGenre, function (index, value) {
        if (HOME.dataGenre[index].parentCategoryId == node1.id) {
888 889 890 891

            // Check if current node is added or not
            var isChildNodeExisted = false;
            for(var nChildNodesIndex = 0; nChildNodesIndex < dataChild.length; nChildNodesIndex++) {
892
                if(dataChild[nChildNodesIndex].categoryId == HOME.dataGenre[index].categoryId) {
893 894 895 896
                    isChildNodeExisted = true;
                }
            }
            if(!isChildNodeExisted) {
897
                dataChild.push(HOME.dataGenre[index]);
898
            }
899
            //dataChild.push(HOME.dataGenre[index]);
900 901 902 903 904 905
        }
    });

    $.each(dataChild, function (i, value) {
        var item = new TreeNode();
        //item.IsCategory = true;
Masaru Abe committed
906
        item.Text = COMMON.htmlEncode(dataChild[i].categoryName);
907 908 909
        item.id = dataChild[i].categoryId;
        item.Value = dataChild[i].categoryId;
        item.ContentCount = dataChild[i].contentCount;
910
        HOME.AddChidrenNodeGenre(item);
911 912 913 914 915 916 917 918

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

        node1.ChildNodes.push(item);
    });
};

//Get Value for sort
919
HOME.AddGenre_Callback = function(selectedNode) {
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957

    $('.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();
    var recordFrom = 0;
    var recordTo = 0;
    node = selectedNode;

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

958 959 960
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
961
    }
962 963 964
    else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
965 966
    }
    else {
967 968
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
969 970 971 972 973 974 975 976 977 978 979 980 981
    }

    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
982
    HOME.refreshGrid();
983

984
    HOME.resetShowNextRecordCount();
985

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

988
    HOME.handleSortDisp();
989 990
};

991
//Get Data from Group Json
992
HOME.getDataJsonFileGroup = function() {
993 994 995
    var params = {
        sid: ClientData.userInfo_sid()
    };
996 997
    HOME.abapi('group', params, 'GET', function (data1) {
        HOME.dataGroup = data1.groupList;
998 999
        var arrData = new Array();
        var totalCount = 0;
1000
        $.each(HOME.dataGroup, function (i, value) {
1001
            // Calculate total group
1002
            totalCount += Number(HOME.dataGroup[i].contentCount);
1003

1004
            if (HOME.dataGroup[i].parentGroupId == 0 || HOME.dataGroup[i].groupLevel == "0") {
1005 1006
                var node = new TreeNode();
                node.IsCategory = true;
1007 1008 1009 1010 1011
                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);
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
                //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;
1023 1024
        if (HOME.group_totalcontent != -1) {
            tree2.TotalCount = HOME.group_totalcontent;
1025
        }
1026
        tree2.Show("branch2", arrData, "HOME.AddGroup_Callback");
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
        $("#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);
                    }

                }
            }
        }
    });
};

//Add Children Node Group
1057
HOME.AddChidrenNodeGroup = function(node1) {
1058
    var dataChild = [];
1059 1060
    $.each(HOME.dataGroup, function (index, value) {
        if (HOME.dataGroup[index].parentGroupId == node1.id) {
1061 1062 1063
            // Check if current node is added or not
            var isChildNodeExisted = false;
            for(var nChildNodesIndex = 0; nChildNodesIndex < dataChild.length; nChildNodesIndex++) {
1064
                if(dataChild[nChildNodesIndex].groupId == HOME.dataGroup[index].groupId) {
1065 1066 1067 1068
                    isChildNodeExisted = true;
                }
            }
            if(!isChildNodeExisted) {
1069
                dataChild.push(HOME.dataGroup[index]);
1070 1071 1072 1073 1074 1075 1076
            }
        }
    });

    $.each(dataChild, function (i, value) {
        var item = new TreeNode();
        //item.IsCategory = true;
Masaru Abe committed
1077
        item.Text = COMMON.htmlEncode(dataChild[i].groupName);
1078 1079 1080
        item.id = dataChild[i].groupId;
        item.Value = dataChild[i].groupId;
        item.ContentCount = dataChild[i].contentCount;
1081
        HOME.AddChidrenNodeGroup(item);
1082 1083 1084 1085 1086 1087 1088 1089

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

        node1.ChildNodes.push(item);
    });
};

//Get Value for sort
1090
HOME.AddGroup_Callback = function(selectedNode) {
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
    $('.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();
    var recordFrom = 0;
    var recordTo = 0;

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

1128 1129 1130
    if (HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
1131
    }
1132 1133 1134
    else if (!HOME.isShowBookShelf) {
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForList();
1135 1136
    }
    else {
1137 1138
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
        recordTo = HOME.returnNumberDispRecordForBookShelf();
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151
    }

    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
1152
    HOME.refreshGrid();
1153

1154
    HOME.resetShowNextRecordCount();
1155

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

1158
    HOME.handleSortDisp();
1159 1160 1161
};

//Re-render page from and total record
1162
HOME.reRenderPageNumber = function(dispRecord, dispTotal) {
Masaru Abe committed
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175

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

1176 1177 1178
};

//Call API
1179
HOME.abapi = function(name, param, method, callback) {
1180
	AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), name, method, param, callback, null);
1181 1182 1183
};

//Dialog Details Button Click
1184
HOME.detailsSubmenuFunction = function(e) {
1185 1186 1187
    if (e) {
        e.preventDefault();
    }
1188
    HOME.allowTimerCloseSubMenu = false;
1189 1190 1191

    var contentId = $(this).attr('contentid');
    // Get image of selected image
1192
    var base64String = HOME.returnThumbnail(contentId);
1193
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Set contentType of content to local storage for display details.
1194
    var contentType = HOME.returnContentType(contentId);
1195 1196 1197 1198
    ClientData.contentInfo_contentType(contentType);
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Set contentType of content to local storage for display details.
    ClientData.contentInfo_contentId(contentId);
    ClientData.contentInfo_contentThumbnail(base64String);
1199

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

1204 1205
        for (var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
            if (HOME.contentIdArray[nIndex].contentid == contentId) {
1206 1207 1208 1209 1210 1211 1212 1213 1214
                checkflag = true;
                break;
            }
            else {
                checkflag = false;
            }
        }

        if (!checkflag) {
1215
            HOME.contentIdArray.push({ contentid: contentId, viewdate: '', originviewdate: '' });
1216 1217 1218
        }
    }
    else {
1219
        HOME.contentIdArray.push({ contentid: contentId, viewdate: '', originviewdate: '' });
1220 1221 1222 1223 1224 1225 1226
    }

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

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

    //Set ResouceVersion for content
Masaru Abe committed
1230
    COMMON.setResourceVersionData(contentId);
1231 1232

    //Set MetaVersion for content
Masaru Abe committed
1233
    COMMON.setMetaVersionData(contentId);
1234 1235 1236 1237 1238

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

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

    // Show detail
Masaru Abe committed
1242
    DETAIL.openContentDetail();
1243 1244 1245
};

//Dialog Read Button CLick
1246
HOME.readSubmenuFunction = function(e) {
1247 1248 1249
    if (e) {
        e.preventDefault();
    }
1250
    HOME.allowTimerCloseSubMenu = false;
1251

1252 1253
    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
1254 1255 1256 1257 1258 1259 1260 1261
        return;
    }

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

    var contentId = $(this).attr('contentid');
    // check limit of content
Masaru Abe committed
1262
    LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
Masaru Abe committed
1263
        function()
1264
        {
1265
            HOME.readSubmenuFunction_callback(contentId);
Masaru Abe committed
1266 1267 1268 1269
        },
        function(){
        }
    );
1270 1271 1272 1273

};

//Dialog Read Button CLick callback
1274
HOME.readSubmenuFunction_callback = function(contentId)
1275
{
1276
    var contentThumbnail = HOME.returnThumbnail(contentId);
1277

1278 1279 1280 1281
    var date = new Date();
    var month = date.getMonth() + 1;
    var day = date.getDate();

Masaru Abe committed
1282
    var outputDate = COMMON.formatNormalDate(day, month, date.getFullYear());
1283 1284 1285

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

1287
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
1288
    var contentType = HOME.returnContentType(contentId);
1289 1290
    ClientData.contentInfo_contentType(contentType);
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
1291

1292 1293 1294 1295
    var checkflag = false;

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

1298 1299
        for (var nIndex = 0; nIndex < HOME.contentIdArray.length; nIndex++) {
            if (HOME.contentIdArray[nIndex].contentid == contentId) {
1300
                checkflag = true;
1301 1302 1303
                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;
1304 1305 1306 1307 1308 1309 1310 1311 1312
                }
                break;
            }
            else {
                checkflag = false;
            }
        }

        if (!checkflag) {
1313
            HOME.contentIdArray.push({ contentid: contentId, viewdate: outputDate, originviewdate: date });
1314 1315 1316
        }
    }
    else {
1317
        HOME.contentIdArray.push({ contentid: contentId, viewdate: outputDate, originviewdate: date });
1318 1319 1320 1321 1322 1323 1324
    }

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

    //Set ResouceVersion for content
Masaru Abe committed
1325
    COMMON.setResourceVersionData(contentId);
1326 1327

    //Set MetaVersion for content
Masaru Abe committed
1328
    COMMON.setMetaVersionData(contentId);
1329 1330

    //Set data for readingcontentid
1331
    ClientData.ReadingContentIds(HOME.contentIdArray);
1332 1333 1334 1335 1336 1337

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

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

    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
1340
    //For testing without other Type.
1341
    if(contentType == COMMON.ContentTypeKeys.Type_Others){
1342
        //Download content
Masaru Abe committed
1343
        HEADER.downloadResourceById(contentId);
1344
         // redraw content remove new icon
1345
        HOME.drawEditImage(contentId);
1346
    }
1347
    else if( contentType == COMMON.ContentTypeKeys.Type_Link ){
1348
        //link content
Masaru Abe committed
1349
        HEADER.viewLinkContentById(contentId);
1350
        // redraw content remove new icon
1351
        HOME.drawEditImage(contentId);
1352 1353 1354
    }
    else{
        //Go to Conten view page
1355 1356 1357
    	//AVWEB.avwScreenMove(COMMON.ScreenIds.ContentView);
        HOME.drawEditImage(contentId);
    	HOME.showContentView();
1358 1359 1360 1361 1362
    }
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Add ContentType to Storage.
};

//Handle Back To Top Button
1363
HOME.handleBackToTop = function() {
1364

1365
    if (ClientData.searchCond_recordTo() >= HOME.totalPage) {
1366 1367 1368 1369 1370 1371
        $('#control-nextrecord').css('display', 'none');
    }
    else {
        $('#control-nextrecord').css('display', 'block');
    }

1372
    if (HOME.totalPage == 0) {
1373 1374 1375 1376 1377 1378
        $('#control-nextrecord').css('display', 'none');
    }

};

//Show Next Record Function
1379
HOME.showNextRecordFunction = function() {
1380 1381 1382 1383

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

    //Count number of click
1384
    HOME.showNextRecordClickNumber = HOME.showNextRecordClickNumber + 1;
1385 1386 1387 1388 1389 1390 1391 1392 1393 1394

    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();
1395
    var totalrecord = HOME.totalPage;
1396 1397

    if (fromPage == null || fromPage == 'undefined') {
1398
        fromPage = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1399 1400 1401
    }

    if (toPage == null || toPage == 'undefined') {
1402 1403
        if (HOME.isShowBookShelf) {
            toPage = HOME.returnNumberDispRecordForBookShelf();
1404
        }
1405 1406
        else if (!HOME.isShowBookShelf) {
            toPage = HOME.returnNumberDispRecordForList();
1407 1408
        }
        else {
1409
            toPage = HOME.returnNumberDispRecordForBookShelf();
1410 1411 1412 1413 1414 1415
        }
    }

    fromPage = eval(toPage) + 1;
    var iRecordNumber = eval(totalrecord) - eval(fromPage);

1416
    if (iRecordNumber < HOME.iNumberOfNextRecord) {
1417 1418 1419
        toPage = eval(fromPage) + eval(iRecordNumber);
    }
    else {
1420
        toPage = eval(fromPage) + (eval(HOME.iNumberOfNextRecord) - 1);
1421 1422 1423 1424 1425 1426
    }

    ClientData.searchCond_recordFrom(fromPage);
    ClientData.searchCond_recordTo(toPage);

    if (fromPage <= totalrecord) {
1427
        HOME.renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);
1428 1429 1430 1431
    }
};

//Sort By Title Function
1432
HOME.sortByTitleFunction = function() {
1433 1434 1435 1436 1437 1438

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

    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
1439
    var recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1440 1441
    var recordTo = ClientData.searchCond_recordTo();
    var genreId = ClientData.searchCond_genreId();
1442
    var groupId = ClientData.searchCond_groupId();
1443

1444
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
1445
        if (sortType == 1) {
1446
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
1447 1448
        }
        else {
1449
            sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1450 1451 1452 1453
        }
        ClientData.searchCond_sortOrder(sortOrder);
    }
    else {
1454
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1455 1456 1457
        ClientData.searchCond_sortOrder(sortOrder);
    }

1458
    HEADER.setStatusSort('#control-sort-title',sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1459 1460

    if (recordFrom == null || recordFrom == 'undefined') {
1461
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1462 1463 1464 1465 1466
        ClientData.searchCond_recordFrom(recordFrom);
    }

    if (recordTo == null || recordTo == 'undefined') {

1467 1468
        if (HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1469
        }
1470 1471
        else if (!HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForList();
1472 1473
        }
        else {
1474
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1475 1476 1477 1478 1479 1480 1481 1482
        }
        ClientData.searchCond_recordFrom(recordTo);
    }

    sortType = 1;
    ClientData.searchCond_sortType(sortType);

    //refresh Gridview
1483
    HOME.refreshGrid();
1484

1485
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
1486 1487 1488
};

//Sort By Title Kana function
1489
HOME.sortByTitleKanaFunction = function() {
1490 1491 1492 1493 1494 1495

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

    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
1496
    var recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1497 1498
    var recordTo = ClientData.searchCond_recordTo();
    var genreId = ClientData.searchCond_genreId();
1499
    var groupId = ClientData.searchCond_groupId();
1500

1501
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
1502
        if (sortType == 2) {
1503
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
1504 1505
        }
        else {
1506
            sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1507 1508 1509 1510
        }
        ClientData.searchCond_sortOrder(sortOrder);
    }
    else {
1511
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1512 1513 1514
        ClientData.searchCond_sortOrder(sortOrder);
    }

1515
    HEADER.setStatusSort('#control-sort-titlekana',sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1516 1517

    if (recordFrom == null || recordFrom == 'undefined') {
1518
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1519 1520 1521 1522 1523
        ClientData.searchCond_recordFrom(recordFrom);
    }

    if (recordTo == null || recordTo == 'undefined') {

1524 1525
        if (HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1526
        }
1527 1528
        else if (!HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForList();
1529 1530
        }
        else {
1531
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1532 1533 1534 1535 1536 1537
        }
        ClientData.searchCond_recordFrom(recordTo);
    }

    sortType = 2;
    //refresh gridview
1538
    HOME.refreshGrid();
1539 1540

    ClientData.searchCond_sortType(sortType);
1541
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
1542 1543 1544 1545

};

//Sort By Release Date
1546
HOME.sortByReleaseDateFunction = function() {
1547 1548 1549 1550 1551 1552

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

    var sortOrder = ClientData.searchCond_sortOrder();
    var sortType = ClientData.searchCond_sortType();
    var sid = ClientData.userInfo_sid();
1553
    var recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1554 1555 1556 1557
    var recordTo = ClientData.searchCond_recordTo();
    var genreId = ClientData.searchCond_genreId();
    var groupId = ClientData.searchCond_groupId();

1558
    if (sortOrder == COMMON.Consts.ConstOrderSetting_Asc) {
1559
        if (sortType == 3) {
1560
            sortOrder = COMMON.Consts.ConstOrderSetting_Desc;
1561 1562
        }
        else {
1563
            sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1564
        }
1565
        ClientData.searchCond_sortOrder(sortOrder);
1566 1567
    }
    else {
1568
        sortOrder = COMMON.Consts.ConstOrderSetting_Asc;
1569 1570
        ClientData.searchCond_sortOrder(sortOrder);
    }
1571
    HEADER.setStatusSort('#control-sort-releasedate',sortOrder == COMMON.Consts.ConstOrderSetting_Asc);
1572 1573

    if (recordFrom == null || recordFrom == 'undefined') {
1574
        recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1575 1576 1577 1578 1579
        ClientData.searchCond_recordFrom(recordFrom);
    }

    if (recordTo == null || recordTo == 'undefined') {

1580 1581
        if (HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1582
        }
1583 1584
        else if (!HOME.isShowBookShelf) {
            recordTo = HOME.returnNumberDispRecordForList();
1585 1586
        }
        else {
1587
            recordTo = HOME.returnNumberDispRecordForBookShelf();
1588 1589 1590 1591 1592 1593
        }
        ClientData.searchCond_recordFrom(recordTo);
    }

    sortType = 3;
    //refresh gridview
1594
    HOME.refreshGrid();
1595 1596

    ClientData.searchCond_sortType(sortType);
1597
    HOME.renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
1598 1599 1600 1601

};

//Handle language
1602
HOME.handleLanguage = function() {
1603

Masaru Abe committed
1604
    if (I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko) {
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615
        $('#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();

1616
            HEADER.setStatusSort('#'+$('#menu_sort li.current a').attr('id'),orderSort == COMMON.Consts.ConstOrderSetting_Asc);
1617
            if (typeSort == 2) {
1618
                if (orderSort == COMMON.Consts.ConstOrderSetting_Asc) {
1619 1620 1621 1622 1623 1624 1625 1626
                }
                else {
                }
            }
        }
    }
};

1627
///Render Content
1628
HOME.renderContent = function(id, text, division, type, order, from, to, cateid, grpid) {
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
    var params = {
        sid: id,
        searchText: text,
        searchDivision: division,
        sortType: type,
        sortOrder: order,
        recordFrom: from,
        recordTo: to,
        genreId: cateid,
        groupId: grpid
    };


1642
    HOME.abapi('webContentList', params, 'POST', function (data) {
1643
        var countCnt = 0;
1644

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

Masaru Abe committed
1647
            var outputDate = COMMON.formatDeliveryDate(post.contentDeliveryDate);
1648

1649 1650 1651
            // if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_BookShelf) {
            if (HOME.isShowBookShelf) {
            	$('#content-grid').append(
1652 1653 1654 1655 1656 1657
					 '<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>'
1658
					+ '	    <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 86px; "/>'
1659
					+ '	</div>'
1660 1661 1662 1663
					+ ' <a id="title' + post.contentId + '" class="dialog name lang" lang="lblTitle" contentid="' + post.contentId + '">'
					+ '   <img src="' + HEADER.getIconTypeContent(post.contentType)+'" width="20" height="20">'
					+     COMMON.truncate(COMMON.htmlEncode(post.contentTitle), 20)
					+ ' </a>'
1664
					+ '</section>'
1665
            	);
1666

1667 1668 1669 1670 1671 1672 1673 1674
            	if ((HOME.home_realTotalRecord + i + 1) % 3 == 0) {
            		$('#bookshelf' + post.contentId).addClass('no_m_right');
            	}
            	HOME.getNextRecordNumForBookShelf();
            }
            // else if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
            else if (!HOME.isShowBookShelf) {
            	var gridHtml =  '<section class="sectionhomelist">'
1675 1676 1677 1678
					+ '	<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>'
1679
					+ '	        <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 46px; "/>'
1680 1681
					+ '		</a>'
					+ '		<div class="text">'
1682 1683 1684 1685
					+ '         <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">'
					+               COMMON.truncate(COMMON.htmlEncode(post.contentTitle), 20)
					+ '         </a>'
1686 1687
					+ '			<div class="info">'
					+ '				<ul class="date">'
1688
					+ '					<li><span class="lang" lang="txtPubDt"> </span>:' + outputDate + '</li>'
1689 1690 1691
					+ '					<li><span class="lang" lang="txtViewDt"> </span>:<span id="lblVdate' + post.contentId + '"> </span></li>'
					+ '				</ul>'
					+ '				<ul class="pic">'
1692 1693
					+ '					<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>'
1694
					+ '					<li><ul class="iconList">{share}<li><a class="read lang button-details" contentid="' + post.contentId + '" lang="txtRead">読む</a></li></ul></li>'
1695 1696 1697 1698
					+ '				</ul>'
					+ '			</div>'
					+ '		</div>'
					+ '	</div>'
1699
					+ '</section>';
1700

1701 1702 1703 1704 1705
				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);
1706

1707
				$('#content-grid').append(gridHtml);
1708

1709
				HOME.getNextRecordNumForList();
1710 1711 1712 1713 1714
            }

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

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

1720
            //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type to array to manage.
1721
            //assign content type to array
1722
            HOME.contentTypeArr.push({ contentId: post.contentId, contentType: post.contentType });
1723
            //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type to array to manage.
1724

1725
            // save alert message level
Masaru Abe committed
1726
            LIMIT_ACCESS_CONTENT.messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
1727 1728

            //Check if user has read this content or not.
1729
            HOME.checkUserHasReadContent(post.contentId, post.resourceVersion, post.metaVersion);
1730
            //assign version to array
Masaru Abe committed
1731
            COMMON.resourceVersionArr.push({ contentid: post.contentId, resourceversion: post.resourceVersion });
1732 1733

            //assign meta version to array
Masaru Abe committed
1734
            COMMON.metaVersionArr.push({ contentid: post.contentId, metaversion: post.metaVersion });
1735 1736

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

1739
            //renderViewDate
1740
            var viewdate = HOME.renderViewDate(post.contentId);
1741 1742 1743 1744 1745
            if (viewdate != null || viewdate != 'undefined') {
                $('#lblVdate' + post.contentId).html(viewdate);
            }
        });

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

        if (cateid == '' && grpid == '') {
1750 1751
            if (HOME.genre_totalcontent == -1) {
                HOME.genre_totalcontent = data.totalRecord;
1752
            }
1753 1754
            if (HOME.group_totalcontent == -1) {
                HOME.group_totalcontent = data.totalRecord;
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
            }
        }

        if (data.totalRecord < data.recordTo) {
            ClientData.searchCond_recordTo(data.totalRecord);
        } else {
            ClientData.searchCond_recordTo(data.recordTo);
        }

        ClientData.searchCond_recordFrom(data.recordFrom);
1765
        HOME.totalPage = data.totalRecord;
1766

1767
        HOME.reRenderPageNumber(ClientData.searchCond_recordTo(), HOME.totalPage);
1768 1769

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

Masaru Abe committed
1772
        //I18N.changeLanguage(ClientData.userInfo_language());
1773
        I18N.i18nReplaceText();
1774 1775 1776 1777
    });
};

//Initial Screen
1778
HOME.renderGridView = function() {
1779

1780
    var fromPage = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
1781
    var toPage = 0;
1782 1783
    var sortType = HOME.DEFAULT_SORT_TYPE;
    var sortOrder = HOME.DEFAULT_SORT_ORDER;
1784
    var searchText = '';
1785
    var searchDivision = HOME.DEFAULT_SEARCH_DIVISION;
1786 1787 1788 1789 1790 1791
    var genreId = '';
    var groupId = '';
    var sid = ClientData.userInfo_sid();

    ClientData.searchCond_recordFrom(fromPage);

1792 1793
    if (HOME.isShowBookShelf) {
        toPage = HOME.returnNumberDispRecordForBookShelf();
1794
    }
1795 1796
    else if (!HOME.isShowBookShelf) {
        toPage = HOME.returnNumberDispRecordForList();
1797 1798
    }
    else {
1799
        toPage = HOME.returnNumberDispRecordForBookShelf();
1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815
    }
    ClientData.searchCond_recordTo(toPage);

    ClientData.searchCond_sortType(sortType);

    ClientData.searchCond_sortOrder(sortOrder);

    ClientData.searchCond_searchText(searchText);

    ClientData.searchCond_searchDivision(searchDivision);

    ClientData.searchCond_genreId(genreId);

    ClientData.searchCond_groupId(groupId);

    //Language Handle
1816
    HOME.handleLanguage();
1817

1818
    //handle
1819
    HOME.handleSortDisp();
1820 1821

    //Refresh GridView
1822
    HOME.refreshGrid();
1823

1824
    HOME.resetShowNextRecordCount();
1825 1826

    //Render Gridview
1827
    HOME.renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);
1828 1829 1830
};

//Get Thumnail base on contentid
1831 1832
HOME.returnThumbnail = function(contentid) {
    var iArrCnt = HOME.thumbnailArr.length;
1833
    for (var i = 0; i < iArrCnt; i++) {
1834
        if (HOME.thumbnailArr[i].contentId == contentid) {
1835
            return HOME.thumbnailArr[i].thumbnail;
1836 1837 1838 1839 1840 1841
        }
    }
};

//Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new function to return content type of content.
//Get content type base on contentid
1842
HOME.returnContentType = function(contentid){
1843
    //Array Length
1844
    var iArrCnt = HOME.contentTypeArr.length;
1845

1846 1847
    //Get contentType in array by contentId
    for(var i = 0; i < iArrCnt; i++){
1848 1849
        if (HOME.contentTypeArr[i].contentId == contentid) {
            return HOME.contentTypeArr[i].contentType;
1850 1851 1852 1853
        }
    }
};

1854
//function createIframeForDownload(url){
1855 1856 1857 1858
//};
//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new function to return content type of content.

//Check if Content Has marking or memo
1859
HOME.checkContentMarkingMemoOption = function(contentId) {
1860

1861
    if (!HOME.isShowBookShelf) {
1862
        //Check if contentid has marking
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881
        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 {
1882
            // Check if contentid has memo
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897
            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');
                }
            }
        }

    }
};

//Check if User has read content
1898
HOME.checkUserHasReadContent = function(contId, resourceVer, metaVer) {
1899 1900

    var imgThumb = new Image();
1901
    //imgThumb.src = HOME.returnThumbnail(contId);
1902 1903

    var imgIconNew = new Image();
1904
    //imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
1905 1906

    var imgIconEdit = new Image();
1907
    //imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
1908 1909 1910 1911 1912 1913 1914 1915

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

1917
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Declare variable handle contentType and Thumbnail of content.
1918 1919
    var contentThumbnail = HOME.returnThumbnail(contId);
    var contentType = HOME.returnContentType(contId);
1920 1921 1922 1923 1924
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Declare variable handle contentType and Thumbnail of content.


    if (readArr == null || readArr <= 0 || readArr == 'undefined') {
        imgThumb.onload = function () {
1925
            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
1926 1927 1928 1929
            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 () {
1930
                    $('#content-thumbnail' + contId).fadeIn('slow');
1931 1932
                });
            };
1933
            imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
1934 1935
        };

1936 1937
        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
        if(contentThumbnail == '' || contentThumbnail == null){
Masaru Abe committed
1938
            if(!COMMON.isPdfContent(contentType)){
1939
                var src = HEADER.getThumbnailForOtherType(contentType);
1940 1941 1942
                if( src != '' ){
                    imgThumb.src = src;
                }
1943 1944 1945 1946
            }
        }else{
            imgThumb.src = contentThumbnail;
        }
1947

1948 1949 1950 1951 1952 1953 1954
        //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
    }
    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 () {
1955
                    var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
1956 1957 1958 1959 1960 1961
                    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');
                    });
                };
                //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
1962

1963
                if(contentThumbnail == '' || contentThumbnail == null){
Masaru Abe committed
1964
                    if(!COMMON.isPdfContent(contentType)){
1965
                        var src = HEADER.getThumbnailForOtherType(contentType);
1966 1967 1968
                        if( src != '' ){
                            imgThumb.src = src;
                        }
1969 1970 1971 1972
                    }
                }else{
                    imgThumb.src = contentThumbnail;
                }
1973

1974 1975 1976 1977 1978 1979
                //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                readFlg = true;
                break;
            }
            else {
                imgThumb.onload = function () {
1980
                    var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
1981 1982 1983 1984 1985 1986 1987
                    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');
                        });
                    };
1988
                    imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
1989 1990
                };
                //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
1991

1992
                if(contentThumbnail == '' || contentThumbnail == null){
Masaru Abe committed
1993
                    if(!COMMON.isPdfContent(contentType)){
1994
                        var src = HEADER.getThumbnailForOtherType(contentType);
1995 1996 1997
                        if( src != '' ){
                            imgThumb.src = src;
                        }
1998 1999 2000 2001
                    }
                }else{
                    imgThumb.src = contentThumbnail;
                }
2002

2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
                //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
            }
        }
    }

    //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 () {
2017
                            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
2018 2019 2020 2021 2022 2023 2024 2025
                            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');
                                });
                            };
2026
                            imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
2027 2028
                        };
                        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
2029

2030
                        if(contentThumbnail == '' || contentThumbnail == null){
Masaru Abe committed
2031
                            if(!COMMON.isPdfContent(contentType)){
2032
                                var src = HEADER.getThumbnailForOtherType(contentType);
2033 2034 2035
                                if( src != '' ){
                                    imgThumb.src = src;
                                }
2036 2037 2038 2039
                            }
                        }else{
                            imgThumb.src = contentThumbnail;
                        }
2040

2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054
                        //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                        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 () {
2055
                            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
2056 2057 2058 2059 2060 2061 2062
                            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');
                                });
                            };
2063
                            imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
2064 2065
                        };
                        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
2066

2067
                        if(contentThumbnail == '' || contentThumbnail == null){
Masaru Abe committed
2068
                            if(!COMMON.isPdfContent(contentType)){
2069
                                var src = HEADER.getThumbnailForOtherType(contentType);
2070 2071 2072
                                if( src != '' ){
                                    imgThumb.src = src;
                                }
2073 2074 2075 2076
                            }
                        }else{
                            imgThumb.src = contentThumbnail;
                        }
2077

2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088
                        //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                        break;
                    }
                }
            }
        }
        readFlg = false;
    }
};

//draw Edit Image
2089
HOME.drawEditImage = function(id) {
2090
    var img = new Image();
2091
    var imgSrc = HOME.returnThumbnail(id);
2092

2093
    if(imgSrc != null){
2094

2095 2096
    }
    else{
2097
        var contentType = HOME.returnContentType(id);
2098

2099
        var src = HEADER.getThumbnailForOtherType(contentType);
2100 2101 2102
        if( src != '' ){
            imgSrc = src;
        }
2103
    }
2104 2105 2106

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

2107 2108 2109 2110
    //use getContext to use the canvas for drawing
    var ctx = c.getContext('2d');
    ctx.clearRect(0, 0, c.width, c.height);
    img.onload = function () {
2111
        var resizeImg = HOME.resizeResourceThumbnail(img, c.width, c.height);
2112 2113 2114
        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');
2115
        });
2116
    };
2117

2118 2119 2120 2121
    img.src = imgSrc;
};

//Render User view date
2122
HOME.renderViewDate = function(id) {
2123 2124 2125 2126 2127 2128 2129 2130 2131

    for (var i = 0; i < ClientData.ReadingContentIds().length; i++) {
        if (ClientData.ReadingContentIds()[i].contentid == id) {
            return ClientData.ReadingContentIds()[i].viewdate;
        }
    }
};

//handle display sort direction
2132
HOME.handleSortDisp = function() {
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151
    $('#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) {
2152
                HEADER.setStatusSort('#control-sort-title',orderSort == COMMON.Consts.ConstOrderSetting_Asc);
2153 2154
            }
            else if (typeSort == 2) {
2155
                HEADER.setStatusSort('#control-sort-titlekana',orderSort == COMMON.Consts.ConstOrderSetting_Asc);
2156 2157
            }
            else if (typeSort == 3) {
2158
                HEADER.setStatusSort('#control-sort-releasedate',orderSort == COMMON.Consts.ConstOrderSetting_Asc);
2159 2160 2161 2162 2163 2164
            }
        }
    }
};

//Get Number Disp Record For List
2165
HOME.returnNumberDispRecordForBookShelf = function() {
2166
    var toPage = 0;
2167
    var sysSettings = AVWEB.avwSysSetting();
2168 2169 2170 2171 2172
    toPage = sysSettings.bookShelfCount;
    return toPage;
};

//Get Number Disp Record For List
2173
HOME.returnNumberDispRecordForList = function() {
2174
    var toPage = 0;
2175
    var sysSettings = AVWEB.avwSysSetting();
2176 2177 2178 2179 2180
    toPage = sysSettings.bookListCount;
    return toPage;
};

//Get number record disp next for list
2181 2182
HOME.getNextRecordNumForList = function() {
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForList();
2183 2184 2185
};

//Get number record disp next for bookshelf
2186 2187
HOME.getNextRecordNumForBookShelf = function() {
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForBookShelf();
2188 2189 2190
};

//refresh sort order
2191
HOME.refreshSortTypeOrder = function() {
2192 2193 2194 2195 2196 2197 2198
    $('#title-sorttype').html('');
    $('#titlekana-sorttype').html('');
    $('#rDate-sorttype').html('');
    $('#rDate-sorttype').html('');
};

//refresh GridView
2199
HOME.refreshGrid = function() {
2200 2201 2202 2203 2204 2205
    $('#control-nextrecord').hide();
    $('#content-grid').html('');
    $('.pageNumControl').css('visibility', 'hidden');
};

//format text display more record
2206
HOME.formatDisplayMoreRecord = function() {
Masaru Abe committed
2207

Masaru Abe committed
2208
    //I18N.changeLanguage(ClientData.userInfo_language());
2209
    I18N.i18nReplaceText();
2210

2211 2212
    if (HOME.isShowBookShelf) {
        $('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), HOME.returnNumberDispRecordForBookShelf()).toString());
2213
    }
2214 2215
    else if (!HOME.isShowBookShelf) {
        $('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), HOME.returnNumberDispRecordForList()));
2216 2217
    }
    else {
2218
        $('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), HOME.returnNumberDispRecordForBookShelf()));
2219
    }
2220

2221 2222 2223 2224 2225
};

/*
Check content whether existed or not
*/
2226
HOME.IsExistContent = function(strContentId) {
2227 2228 2229 2230 2231 2232
    var isExisted = true;
    var params = {
        sid: ClientData.userInfo_sid(),
        getType: '1',
        contentId: strContentId
    };
2233
    AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webGetContent", 'GET', params,
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243
                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
2244
                        AVWEB.showSystemError();
2245 2246 2247 2248 2249
                    }
                });
    return isExisted;
};

2250
HOME.syncReadingContent = function() {
2251 2252 2253 2254 2255 2256 2257
    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];

2258
        if (!HOME.IsExistContent(readContent.contentid)) {
2259

2260
            HOME.errorContent.push({ contentid: readContent.contentid });
2261 2262 2263 2264 2265
            readArr.splice(i, 1);
            metaArr.splice(i, 1);
            resourceArr.splice(i, 1);
        }
        // Do not process next
2266
        if (AVWEB.avwHasError()) {
2267 2268 2269 2270 2271 2272 2273 2274 2275
            return;
        }
    }

    ClientData.ReadingContentIds(readArr);
    ClientData.MetaVersion(metaArr);
    ClientData.ResourceVersion(resourceArr);
};

2276
HOME.syncBookmarkContent = function() {
2277 2278 2279 2280 2281
    var arrBookmark = ClientData.BookMarkData();

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

2282
        if (HOME.isErrorContent(bookmark.contentid)) {
2283 2284 2285
            arrBookmark.splice(j, 1);
        }
        else {
2286 2287
            if (!HOME.IsExistContent(bookmark.contentid)) {
                HOME.errorContent.push({ contentid: bookmark.contentid });
2288 2289 2290 2291 2292 2293 2294 2295 2296
                arrBookmark.splice(j, 1);
                ClientData.isChangedBookmark(true);
            }
        }
    }

    ClientData.BookMarkData(arrBookmark);
};

2297
HOME.syncMemoContent = function() {
2298 2299 2300 2301 2302
    var arrMemo = ClientData.MemoData();

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

2303
        if (HOME.isErrorContent(memo.contentid)) {
2304 2305 2306
            arrMemo.splice(j, 1);
        }
        else {
2307 2308
            if (!HOME.IsExistContent(memo.contentid)) {
                HOME.errorContent.push({ contentid: memo.contentid });
2309 2310 2311 2312 2313 2314 2315 2316 2317
                arrMemo.splice(j, 1);
                ClientData.isChangedMemo(true);
            }
        }
    }

    ClientData.MemoData(arrMemo);
};

2318
HOME.syncMarkingContent = function() {
2319 2320 2321 2322 2323 2324

    var arrMarking = ClientData.MarkingData();

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

2325
        if (HOME.isErrorContent(marking.contentid)) {
2326 2327 2328
            arrMarking.splice(j, 1);
        }
        else {
2329 2330
            if (!HOME.IsExistContent(marking.contentid)) {
                HOME.errorContent.push({ contentid: marking.contentid });
2331 2332 2333 2334 2335 2336 2337 2338 2339
                arrMarking.splice(j, 1);
                ClientData.isChangedMarkingData(true);
            }
        }
    }

    ClientData.MarkingData(arrMarking);
};

2340
HOME.syncContentData = function() {
2341
    if (ClientData.common_contentDataChkFlg() == 'true') {
2342
        //HOME.syncReadingContent(); //#14290 履歴画面でも取得するので省略
2343 2344 2345 2346 2347 2348
        HOME.syncBookmarkContent();
        HOME.syncMemoContent();
        HOME.syncMarkingContent();
        HOME.getExistContentPages();
        HOME.SyncMemoPages();
        HOME.SyncMarkingPages();
2349 2350 2351 2352 2353

        ClientData.common_contentDataChkFlg(false);
    }
};

2354
HOME.isErrorContent = function(contentid) {
2355
    var isError = false;
2356 2357
    for (var j = HOME.errorContent.length - 1; j >= 0; j--) {
        var contentErr = HOME.errorContent[j];
2358
        if (contentid == contentErr.contentid) {
2359 2360
        	isError = true;
        	break;
2361 2362
        }
    }
2363
    return isError;
2364 2365
};

2366
HOME.getExistContentPages = function() {
2367 2368 2369 2370 2371 2372
    var memoArr = ClientData.MemoData();
    var markingArr = ClientData.MarkingData();

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

2373
        HOME.existContent.push({ contentid: memo.contentid });
2374 2375 2376 2377 2378
    }

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

2379
        HOME.existContent.push({ contentid: marking.contentid });
2380 2381 2382
    }
};

2383
HOME.SyncMemoPages = function() {
2384
    var arrMemo = ClientData.MemoData();
2385
    for (var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {
2386 2387

        // Get one content
2388
        var oneContent = HOME.existContent[nIndex];
2389 2390 2391 2392 2393 2394 2395 2396 2397

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

        // Get all pages of content
2398
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params,
2399 2400 2401 2402 2403 2404 2405 2406 2407 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
                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);
};

2449
HOME.SyncMarkingPages = function() {
2450
    var arrMarking = ClientData.MarkingData();
2451
    for (var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {
2452 2453

        // Get one content
2454
        var oneContent = HOME.existContent[nIndex];
2455 2456 2457 2458 2459 2460 2461 2462 2463

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

        // Get all pages of content
2464
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params,
2465 2466 2467 2468 2469 2470 2471 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
                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);
};

function changeLanguageCallBackFunction() {
2516 2517
    HOME.handleLanguage();
    HOME.formatDisplayMoreRecord();
2518
    document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
2519 2520
};

2521
HOME.resizeResourceThumbnail = function(mg, width, height) {
2522 2523 2524 2525 2526

    var newWidth;
    var newHeight;
    /*if (mg.width > mg.height) {
        newWidth = width;
2527
        newHeight = (mg.height * width) / mg.width;
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542
    }
    else {
        newHeight = height;
        newWidth = (mg.width * height) / mg.height;
    }*/
    var delta=Math.min(width/mg.width,height/mg.height);

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

    var result = [newWidth, newHeight];
    return result;

};

2543 2544
HOME.resetShowNextRecordCount = function() {
    HOME.showNextRecordClickNumber = 1;
2545 2546
};

2547
HOME.setDefaultViewMode = function() {
2548
    if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_BookShelf) {
2549
        HOME.isShowBookShelf = true;
2550

2551 2552
        //Start : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
        $('body').attr('id', 'bookshelf');
2553

2554 2555 2556 2557 2558 2559
        $('#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");
        //End : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
    }
2560
    else if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
2561
        HOME.isShowBookShelf = false;
2562

2563 2564
        //Start : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
         $('body').attr('id', 'list');
2565

2566 2567 2568 2569 2570 2571 2572
        $('#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");
        //End : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
    }
    else {
2573
        HOME.isShowBookShelf = true;
2574

2575 2576
        //Start : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
        $('body').attr('id', 'bookshelf');
2577

2578 2579 2580 2581 2582 2583 2584 2585
        $('#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");
        //End : Apply new css - Editor: Long - Date : 09/03/2013 - Summary : For handle view mode icon
    }
};

2586
HOME.removeHoverCss = function() {
2587

Masaru Abe committed
2588
    if (COMMON.isTouchDevice()) {
2589 2590 2591 2592 2593
        $('#control-sort-title').removeClass('nottouchdevice');
        $('#control-sort-titlekana').removeClass('nottouchdevice');
        $('#control-sort-releasedate').removeClass('nottouchdevice');
    }
};
2594

2595 2596
//Dialog Read Button CLick
HOME.showContentShareDlgFunction = function(e) {
2597

2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608
    if (e) {
        e.preventDefault();
    }

    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }

    var contentId = $(this).attr('contentid');
    // check limit of content
Masaru Abe committed
2609
    LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
2610
        function()
2611
        {
2612 2613 2614
        	SHARE.contentId = contentId;
        	SHARE.contentTitle = "";
        	SHARE.openContentShare();
2615

2616 2617 2618 2619 2620 2621 2622 2623
        },
        function(){
        	//console.log("checkLimitContent_bbb");
        }
    );

};

2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
$(function () {
	HOME.cssInit();
});

HOME.cssInit = function(){
	$('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'
		});
};

HOME.showContentView = function(){
2650

2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664
	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);
2665

2666 2667 2668 2669
	//試験
    $("#header-ws").hide();
    $("#ws-body").hide();
    $("#topcontrol").hide();
2670

2671 2672 2673
    CONTENTVIEW_INITOBJECT.clearViewerComponent();
    CONTENTVIEW.cssInit();
    $("#viewer").show();
2674

2675 2676
	//CONTENTVIEW_FILESYSTEM.initFS(CONTENTVIEW.ready);
	CONTENTVIEW.ready();
2677

2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698
};

//Dialog Read Button CLick
HOME.downloadSubmenuFunction = function(e) {
    if (e) {
        e.preventDefault();
    }
    HOME.allowTimerCloseSubMenu = false;

    if (HOME.home_isMove == true) {
        HOME.home_isMove = false;
        return;
    }

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

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

    //Download content
    HEADER.downloadResourceById(contentId);
2699

2700 2701 2702 2703
};