home.js 91.4 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
89 90 91
        if(ClientData.serviceOpt_encryption() != 'Y') {
          	 COMMON.LockScreen();
        }
92 93

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $(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
186
        HEADER.checkForceChangePassword();
187 188
    }

189 190 191 192




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

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

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

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

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

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

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

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

250 251 252
});

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

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

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

269 270
	$( '#dlgAddMemberGroup' ).dialog( 'close' );
	ClientData.searchCond_groupId(groupIds);
271

272 273 274 275
	//画面再描画開始
    var recordFrom = 0;
    var recordTo = 0;

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

289 290 291 292 293 294 295 296 297 298 299
    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
300
    HOME.refreshGrid();
301

302
    HOME.resetShowNextRecordCount();
303

304
    HOME.handleSortDisp();
305

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

308
};
309

310
HOME.getAddMemberGroupId = function(strGroupName) {
311 312 313 314 315 316

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

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

342 343
HOME.subMenuHoverFunction = function() {
    HOME.isSubMenuHoverOn = true;
344 345
};

346 347
HOME.subMenuHoverOffFunction = function() {
    HOME.isSubMenuHoverOn = false;
348 349
};

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

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

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

369
        HOME.isShowBookShelf = true;
370 371 372 373 374
        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');
375

376 377 378 379 380 381
        $('#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

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

        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
399
        HOME.handleSortDisp();
400 401

        //refresh Grid view
402
        HOME.refreshGrid();
403

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

        //format text disp more record
407
        HOME.formatDisplayMoreRecord();
408 409

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

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

419
        HOME.isShowBookShelf = false;
420 421 422 423 424
        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');
425

426 427 428 429 430 431 432
        $('#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
433
        // if(ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List){
434 435 436
        if (!HOME.isShowBookShelf) {
            recordFrom = HOME.DEFAULT_DISP_NUMBER_RECORD_FROM;
            recordTo = HOME.returnNumberDispRecordForList() * HOME.showNextRecordClickNumber;
437 438 439
        }

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

        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
451
        HOME.handleSortDisp();
452 453

        //refresh Grid view
454
        HOME.refreshGrid();
455

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

    //format text disp more record
460
    HOME.formatDisplayMoreRecord();
461 462

    //Get next record will be displayed
463
    HOME.getNextRecordNumForList();
464 465 466

};

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

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

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

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

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

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

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

513 514
    //Check Display mode to handle action

515
    if (!HOME.isShowBookShelf) {
516

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

629 630 631 632 633
    }

};

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

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

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

652 653 654 655
        //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.
656

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

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

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

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

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

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

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

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

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

698
        DETAIL.openContentDetail();
699

700 701 702 703 704 705 706 707 708 709 710 711
    //}
    //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"
    //    });
712 713 714 715 716 717 718 719 720 721 722
    }
    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"
        });
723 724 725 726
    }
};

//Genre Click Function
727
HOME.genreSelectFunction = function() {
728 729 730 731 732 733 734 735 736 737 738
    $('.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;

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

    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
763
    HOME.refreshGrid();
764

765
    HOME.resetShowNextRecordCount();
766

767
    HOME.handleSortDisp();
768

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

//Group Click Function
773
HOME.groupSelectFunction = function() {
774 775 776 777 778 779 780 781 782 783 784 785
    $('.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;

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

    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
810
    HOME.refreshGrid();
811

812
    HOME.resetShowNextRecordCount();
813

814
    HOME.handleSortDisp();
815

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

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

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

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

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

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

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

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

                }
            }
        }
881

882 883 884 885
    });
};

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

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

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

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

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

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

    $('.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('');

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

    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
984
    HOME.refreshGrid();
985

986
    HOME.resetShowNextRecordCount();
987

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

990
    HOME.handleSortDisp();
991 992
};

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

1006
            if (HOME.dataGroup[i].parentGroupId == 0 || HOME.dataGroup[i].groupLevel == "0") {
1007 1008
                var node = new TreeNode();
                node.IsCategory = true;
1009 1010 1011 1012 1013
                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);
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
                //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;
1025 1026
        if (HOME.group_totalcontent != -1) {
            tree2.TotalCount = HOME.group_totalcontent;
1027
        }
1028
        tree2.Show("branch2", arrData, "HOME.AddGroup_Callback");
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
        $("#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
1059
HOME.AddChidrenNodeGroup = function(node1) {
1060
    var dataChild = [];
1061 1062
    $.each(HOME.dataGroup, function (index, value) {
        if (HOME.dataGroup[index].parentGroupId == node1.id) {
1063 1064 1065
            // Check if current node is added or not
            var isChildNodeExisted = false;
            for(var nChildNodesIndex = 0; nChildNodesIndex < dataChild.length; nChildNodesIndex++) {
1066
                if(dataChild[nChildNodesIndex].groupId == HOME.dataGroup[index].groupId) {
1067 1068 1069 1070
                    isChildNodeExisted = true;
                }
            }
            if(!isChildNodeExisted) {
1071
                dataChild.push(HOME.dataGroup[index]);
1072 1073 1074 1075 1076 1077 1078
            }
        }
    });

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

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

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

//Get Value for sort
1092
HOME.AddGroup_Callback = function(selectedNode) {
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 1128 1129
    $('.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('');

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

    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
1154
    HOME.refreshGrid();
1155

1156
    HOME.resetShowNextRecordCount();
1157

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

1160
    HOME.handleSortDisp();
1161 1162 1163
};

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

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

1178 1179 1180
};

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

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

    var contentId = $(this).attr('contentid');
    // Get image of selected image
1194
    var base64String = HOME.returnThumbnail(contentId);
1195
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Set contentType of content to local storage for display details.
1196
    var contentType = HOME.returnContentType(contentId);
1197 1198 1199 1200
    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);
1201

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

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

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

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

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

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

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

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

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

    // Show detail
Masaru Abe committed
1244
    DETAIL.openContentDetail();
1245 1246 1247
};

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

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

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

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

};

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

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

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

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

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

1294 1295 1296 1297
    var checkflag = false;

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

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

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

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

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

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

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

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

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

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

//Handle Back To Top Button
1365
HOME.handleBackToTop = function() {
1366

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

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

};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    sortType = 1;
    ClientData.searchCond_sortType(sortType);

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

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

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

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

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

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

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

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

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

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

    sortType = 2;
    //refresh gridview
1540
    HOME.refreshGrid();
1541 1542

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

};

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

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

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

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

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

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

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

    sortType = 3;
    //refresh gridview
1596
    HOME.refreshGrid();
1597 1598

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

};

//Handle language
1604
HOME.handleLanguage = function() {
1605

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

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

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


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

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

Masaru Abe committed
1649
            var outputDate = COMMON.formatDeliveryDate(post.contentDeliveryDate);
1650

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

1670 1671 1672 1673 1674 1675 1676 1677
            	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">'
1678 1679 1680 1681
					+ '	<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>'
1682
					+ '	        <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 46px; "/>'
1683 1684
					+ '		</a>'
					+ '		<div class="text">'
1685 1686 1687 1688
					+ '         <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>'
1689 1690
					+ '			<div class="info">'
					+ '				<ul class="date">'
1691
					+ '					<li><span class="lang" lang="txtPubDt"> </span>:' + outputDate + '</li>'
1692 1693 1694
					+ '					<li><span class="lang" lang="txtViewDt"> </span>:<span id="lblVdate' + post.contentId + '"> </span></li>'
					+ '				</ul>'
					+ '				<ul class="pic">'
1695 1696
					+ '					<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>'
1697
					+ '					<li><ul class="iconList">{share}<li><a class="read lang button-details" contentid="' + post.contentId + '" lang="txtRead">読む</a></li></ul></li>'
1698 1699 1700 1701
					+ '				</ul>'
					+ '			</div>'
					+ '		</div>'
					+ '	</div>'
1702
					+ '</section>';
1703

1704 1705 1706 1707 1708
				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);
1709

1710
				$('#content-grid').append(gridHtml);
1711

1712
				HOME.getNextRecordNumForList();
1713 1714 1715 1716 1717
            }

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

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

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

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

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

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

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

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

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

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

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

        ClientData.searchCond_recordFrom(data.recordFrom);
1768
        HOME.totalPage = data.totalRecord;
1769

1770
        HOME.reRenderPageNumber(ClientData.searchCond_recordTo(), HOME.totalPage);
1771 1772

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

Masaru Abe committed
1775
        //I18N.changeLanguage(ClientData.userInfo_language());
1776
        I18N.i18nReplaceText();
1777 1778 1779 1780
    });
};

//Initial Screen
1781
HOME.renderGridView = function() {
1782

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

    ClientData.searchCond_recordFrom(fromPage);

1795 1796
    if (HOME.isShowBookShelf) {
        toPage = HOME.returnNumberDispRecordForBookShelf();
1797
    }
1798 1799
    else if (!HOME.isShowBookShelf) {
        toPage = HOME.returnNumberDispRecordForList();
1800 1801
    }
    else {
1802
        toPage = HOME.returnNumberDispRecordForBookShelf();
1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818
    }
    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
1819
    HOME.handleLanguage();
1820

1821
    //handle
1822
    HOME.handleSortDisp();
1823 1824

    //Refresh GridView
1825
    HOME.refreshGrid();
1826

1827
    HOME.resetShowNextRecordCount();
1828 1829

    //Render Gridview
1830
    HOME.renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);
1831 1832 1833
};

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

//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
1845
HOME.returnContentType = function(contentid){
1846
    //Array Length
1847
    var iArrCnt = HOME.contentTypeArr.length;
1848

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

1857
//function createIframeForDownload(url){
1858 1859 1860 1861
//};
//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
1862
HOME.checkContentMarkingMemoOption = function(contentId) {
1863

1864
    if (!HOME.isShowBookShelf) {
1865
        //Check if contentid has marking
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
        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 {
1885
            // Check if contentid has memo
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900
            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
1901
HOME.checkUserHasReadContent = function(contId, resourceVer, metaVer) {
1902 1903

    var imgThumb = new Image();
1904
    //imgThumb.src = HOME.returnThumbnail(contId);
1905 1906

    var imgIconNew = new Image();
1907
    //imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
1908 1909

    var imgIconEdit = new Image();
1910
    //imgIconEdit.src = COMMON.DEFAULT_IMG_CONTENT_EDIT;
1911 1912 1913 1914 1915 1916 1917 1918

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

1920
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Declare variable handle contentType and Thumbnail of content.
1921 1922
    var contentThumbnail = HOME.returnThumbnail(contId);
    var contentType = HOME.returnContentType(contId);
1923 1924 1925 1926 1927
    //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 () {
1928
            var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
1929 1930 1931 1932
            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 () {
1933
                    $('#content-thumbnail' + contId).fadeIn('slow');
1934 1935
                });
            };
1936
            imgIconNew.src = COMMON.DEFAULT_IMG_CONTENT_NEW;
1937 1938
        };

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

1951 1952 1953 1954 1955 1956 1957
        //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 () {
1958
                    var resizeImg = HOME.resizeResourceThumbnail(imgThumb, c.width, c.height);
1959 1960 1961 1962 1963 1964
                    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.
1965

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

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

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

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

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

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

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

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

//draw Edit Image
2092
HOME.drawEditImage = function(id) {
2093
    var img = new Image();
2094
    var imgSrc = HOME.returnThumbnail(id);
2095

2096
    if(imgSrc != null){
2097

2098 2099
    }
    else{
2100
        var contentType = HOME.returnContentType(id);
2101

2102
        var src = HEADER.getThumbnailForOtherType(contentType);
2103 2104 2105
        if( src != '' ){
            imgSrc = src;
        }
2106
    }
2107 2108 2109

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

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

2121 2122 2123 2124
    img.src = imgSrc;
};

//Render User view date
2125
HOME.renderViewDate = function(id) {
2126 2127 2128 2129 2130 2131 2132 2133 2134

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

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

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

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

//Get number record disp next for list
2184 2185
HOME.getNextRecordNumForList = function() {
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForList();
2186 2187 2188
};

//Get number record disp next for bookshelf
2189 2190
HOME.getNextRecordNumForBookShelf = function() {
    HOME.iNumberOfNextRecord = HOME.returnNumberDispRecordForBookShelf();
2191 2192 2193
};

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

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

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

Masaru Abe committed
2211
    //I18N.changeLanguage(ClientData.userInfo_language());
2212
    I18N.i18nReplaceText();
2213

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

2224 2225 2226 2227 2228
};

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

2253
HOME.syncReadingContent = function() {
2254 2255 2256 2257 2258 2259 2260
    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];

2261
        if (!HOME.IsExistContent(readContent.contentid)) {
2262

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

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

2279
HOME.syncBookmarkContent = function() {
2280 2281 2282 2283 2284
    var arrBookmark = ClientData.BookMarkData();

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

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

    ClientData.BookMarkData(arrBookmark);
};

2300
HOME.syncMemoContent = function() {
2301 2302 2303 2304 2305
    var arrMemo = ClientData.MemoData();

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

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

    ClientData.MemoData(arrMemo);
};

2321
HOME.syncMarkingContent = function() {
2322 2323 2324 2325 2326 2327

    var arrMarking = ClientData.MarkingData();

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

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

    ClientData.MarkingData(arrMarking);
};

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

        ClientData.common_contentDataChkFlg(false);
    }
};

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

2369
HOME.getExistContentPages = function() {
2370 2371 2372 2373 2374 2375
    var memoArr = ClientData.MemoData();
    var markingArr = ClientData.MarkingData();

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

2376
        HOME.existContent.push({ contentid: memo.contentid });
2377 2378 2379 2380 2381
    }

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

2382
        HOME.existContent.push({ contentid: marking.contentid });
2383 2384 2385
    }
};

2386
HOME.SyncMemoPages = function() {
2387
    var arrMemo = ClientData.MemoData();
2388
    for (var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {
2389 2390

        // Get one content
2391
        var oneContent = HOME.existContent[nIndex];
2392 2393 2394 2395 2396 2397 2398 2399 2400

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

        // Get all pages of content
2401
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params,
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 2449 2450 2451
                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);
};

2452
HOME.SyncMarkingPages = function() {
2453
    var arrMarking = ClientData.MarkingData();
2454
    for (var nIndex = 0; nIndex < HOME.existContent.length; nIndex++) {
2455 2456

        // Get one content
2457
        var oneContent = HOME.existContent[nIndex];
2458 2459 2460 2461 2462 2463 2464 2465 2466

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

        // Get all pages of content
2467
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "webContentPage", 'GET', params,
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 2516 2517 2518
                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() {
2519 2520
    HOME.handleLanguage();
    HOME.formatDisplayMoreRecord();
2521
    document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
2522 2523
};

2524
HOME.resizeResourceThumbnail = function(mg, width, height) {
2525 2526 2527 2528 2529

    var newWidth;
    var newHeight;
    /*if (mg.width > mg.height) {
        newWidth = width;
2530
        newHeight = (mg.height * width) / mg.width;
2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545
    }
    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;

};

2546 2547
HOME.resetShowNextRecordCount = function() {
    HOME.showNextRecordClickNumber = 1;
2548 2549
};

2550
HOME.setDefaultViewMode = function() {
2551
    if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_BookShelf) {
2552
        HOME.isShowBookShelf = true;
2553

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

2557 2558 2559 2560 2561 2562
        $('#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
    }
2563
    else if (ClientData.sortOpt_viewMode() == COMMON.Consts.ConstDisplayMode_List) {
2564
        HOME.isShowBookShelf = false;
2565

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

2569 2570 2571 2572 2573 2574 2575
        $('#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 {
2576
        HOME.isShowBookShelf = true;
2577

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

2581 2582 2583 2584 2585 2586 2587 2588
        $('#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
    }
};

2589
HOME.removeHoverCss = function() {
2590

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

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

2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611
    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
2612
    LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
2613
        function()
2614
        {
2615 2616 2617
        	SHARE.contentId = contentId;
        	SHARE.contentTitle = "";
        	SHARE.openContentShare();
2618

2619 2620 2621 2622 2623 2624 2625 2626
        },
        function(){
        	//console.log("checkLimitContent_bbb");
        }
    );

};

2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652
$(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(){
2653

2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667
	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);
2668

2669 2670 2671 2672
	//試験
    $("#header-ws").hide();
    $("#ws-body").hide();
    $("#topcontrol").hide();
2673

2674 2675 2676
    CONTENTVIEW_INITOBJECT.clearViewerComponent();
    CONTENTVIEW.cssInit();
    $("#viewer").show();
2677

2678 2679
	//CONTENTVIEW_FILESYSTEM.initFS(CONTENTVIEW.ready);
	CONTENTVIEW.ready();
2680

2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701
};

//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);
2702

2703 2704 2705 2706
};