contentsearch.js 62.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/// <reference path="../common/js/avweb.js" />

/// <reference path="../common/js/screenLock.js" />

/// <reference path="../common/js/common.js" />

/// <reference path="../common/js/i18n.js" />

/// <reference path="../common/js/jquery-1.8.1.min.js" />

/// <reference path="../common/js/jquery-ui-1.8.23.custom.min.js" />

/// <reference path="../common/js/jquery.toastmessage.js" />

/// <reference path="../common/js/pageViewer.js" />

/// <reference path="header.js" />

//Start Declare Variables
	//----Constant-----------//
var DEFAULT_DISP_NUMBER_RECORD_FROM = 1;
var DEFAULT_DISP_NUMBER_RECORD_TO = 15;
var DEFAULT_SORT_TYPE = '1';
var DEFAULT_SORT_ORDER = '1';
var DEFAULT_SEARCH_DIVISION = 0;

var DEFAULT_IMG_OPTION_MEMO = 'img/list/icon_sticker.png';
var DEFAULT_IMG_OPTION_MARKING = 'img/list/icon_pen.png';
var DEFAULT_IMG_CONTENT_EDIT = 'img/common/band_updated.png';
var DEFAULT_IMG_CONTENT_NEW = 'img/common/band_new.png';

var iNumberOfNextRecord = 15;
//Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new Array for function No.12.
//Thumbnail array
var thumbnailArr = [];
//Content type array.
var contentTypeArr = [];

var ThumbnailForOtherType = {
    Thumbnail_ImageType : 'img/image_type.png',
    Thumbnail_VideoType : 'img/iPad_video.png',
    Thumbnail_MusicType : 'img/thumb_default_sound.png',
    Thumbnail_OthersType : 'img/thumb_default_other.png',
    Thumbnail_NoFileType : 'img/thumb_default_none.png',
45 46
    Thumbnail_HtmlType :  'img/thumb_default_html.png',
    Thumbnail_LinkType : 'img/thumb_default_link.png',
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
};
//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new Array for function No.12.
var contentIdArray = [];
var resourceVersionArr = [];
var metaVersionArr = [];
var totalPage;
var chkSearchTextEmpty = false;
var noRecordFlg = false;
var home_isMove = false;

$(document).ready(function(){
 	
 	if (!avwCheckLogin(ScreenIds.Login)){
 		return;
 	}
 	
Masaru Abe committed
63
 	COMMON.LockScreen();
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
 	
 	document.title = i18nText('txtSearchResult') + ' | ' + i18nText('sysAppTitle');

    // Set bookmark screen
    ClientData.BookmarkScreen(ScreenIds.ContentSearch);

	//Check if Force Change password
	if(ClientData.requirePasswordChange() != 1){
		//Format text display more record
	 	formatDisplayMoreRecord();
	 	
	 	//remove hover effect when is touch device
	 	removeHoverCss();
	 	
	 	//InitScreen
	 	initialScreen();
	 	
	 	//Render Grid
	 	renderGridView();
					
		//Go To Details Page
		$('canvas').live('click', canvasClickFunction);	
		//$('canvas').live('touchstart', canvasClickFunction);
	    $('canvas').live('touchend', canvasClickFunction);
	    $('canvas').live('touchmove', function () { home_isMove = true; });
		
		//Open dialog
		$('.dialog').live('click', titleClickFunction);
		//$('.dialog').live('touchstart', titleClickFunction);
	    $('.dialog').live('touchend', titleClickFunction);
	    $('.dialog').live('touchmove', function () { home_isMove = true; });	
		
		//Show Next Record
		$('a#control-nextrecord').click(showNextRecordFunction);	
		
		//Sort Title
		$('#control-sort-title').click(sortByTitleFunction);	
		
		//Sort by title kana
		$('#control-sort-titlekana').click(sortByTitleKanaFunction);	
			
		//sort by release date
		$('#control-sort-releasedate').click(sortByReleaseDateFunction);	
			
		//Go To Details Page
		$('.button-details').live('click', readSubmenuFunction);
		//$('.button-details').live('touchstart', readSubmenuFunction);
	    $('.button-details').live('touchend', readSubmenuFunction);
	    $('.button-details').live('touchmove', function () { home_isMove = true; });	
		
		$('#main-search').click(searchEventButtonFunction);
		
		$('#txtSearch').keydown(mainSearchKeyDownFunction);
		
		$('#main-search-content').click(mainSearchContentClickFunction);
		
		$('#main-search-tag').click(mainSearchTagClickFunction);
		
		$('#main-search-body').click(mainSearchBodyClickFunction);
	
		$('#control-nextrecord').css('visibility', 'hidden');
	
		$(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{
		//Check if Force Change password
Masaru Abe committed
137
		HEADER.checkForceChangePassword();
138
	}
Masaru Abe committed
139
	
Masaru Abe committed
140
    if (COMMON.isAnonymousLogin()) {
Masaru Abe committed
141 142 143 144
        //プッシュメッセージ隠す
        $('#dspPushMessage').hide();
    }
	
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
});	


function mainSearchBodyClickFunction(){
	$('#main-body').attr('checked','checked');
	$('#main-tag').removeAttr('checked');
	$('#main-content').removeAttr('checked');
};

function mainSearchTagClickFunction(){
	$('#main-tag').attr('checked','checked');
	$('#main-body').removeAttr('checked');
	$('#main-content').removeAttr('checked');
};

function mainSearchContentClickFunction(){
	$('#main-content').attr('checked','checked');
	$('#main-tag').removeAttr('checked');
	$('#main-body').removeAttr('checked');
};


function mainSearchKeyDownFunction(e){
 	var code = (e.keyCode ? e.keyCode : e.which);
 	if(code == 13) { //Enter keycode
   		$('#main-search').click();
 	}
};

//Call API
function abapi(name, param, method, callback){		
	avwCmsApi(ClientData.userInfo_accountPath(), name, method, param, callback, null);
};

//Initial screen 
function initialScreen(){
	var searchText = ClientData.searchCond_searchText();
	var searchDivision = ClientData.searchCond_searchDivision();
	
	$('#txtSearch').val(searchText);
	//ClientData.searchCond_searchText('');
	
	if(searchDivision == 1){
		$('#main-tag').attr('checked',false);
		$('#main-body').attr('checked',false);
		$('#main-content').attr('checked','checked');
	}
	else if(searchDivision == 2){
		$('#main-content').attr('checked',false);
		$('#main-body').attr('checked',false);
		$('#main-tag').attr('checked','checked');
	}
	else
	{
		$('#main-content').attr('checked',false);
		$('#main-tag').attr('checked',false);
		$('#main-body').attr('checked','checked');	
	}
	
	handleLanguage();
};

///Render Content 
function renderContent(id, text, division, type, order, from, to, cateid, grpid){
	var params = {
		sid: id,
		searchText: text,
		searchDivision: division,
		sortType: type,
		sortOrder: order,
		recordFrom: from,
		recordTo: to,
		genreId: cateid,
		groupId: grpid
	};

	abapi('webContentList', params, 'POST', function (data) {
	    $.each(data.contentList, function (i, post) {

	        var outputDate ="";
            if(post.contentDeliveryDate!=null&&post.contentDeliveryDate!=undefined&&post.contentDeliveryDate!='undefined')
            {
                outputDate=formatDeliveryDate(post.contentDeliveryDate);
            }

	      /* $('#content-grid').append(
					 '<section>'
					+'	<div class="cnt_section">'
					+'		<a class="img">'
					+'			<canvas height="105px" width="150px" id="content-thumbnail'+post.contentId+'" contentid="'+post.contentId+'" style="display:none;">'
					+ '			</canvas>'
                    + '	    <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding-top: 46px; padding-left: 66px"/>'
					+ '		</a>'
                    
					+'		<div class="text">'
Masaru Abe committed
240
					+'			<a id="title'+post.contentId+'" class="dialog name" contentid="'+post.contentId+'">'+ COMMON.truncate(COMMON.htmlEncode(post.contentTitle), 25)+'</a>'
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
					+'			<div class="info">'
					+'				<ul class="date">'
					+'					<li><span class="lang" lang="txtPubDt"> </span> : '+outputDate+'</li>'
					+'					<li><span class="lang" lang="txtViewDt"> </span>:<span id="lblVdate'+post.contentId+'"> </span></li>'	
					+'				</ul>'	
					+'				<ul class="pic">'
					+'					<li><img src="'+DEFAULT_IMG_OPTION_MEMO+'" id="imgMemo'+post.contentId+'" class="sticker"  /></li>'
					+'					<li><img src="'+DEFAULT_IMG_OPTION_MARKING+'" id="imgBookMark'+post.contentId+'" class="pen"  /></li>'
					+'					<li><a class="read lang button-details" contentid="' + post.contentId + '" lang="txtRead">読む</a></li>'
					+'				</ul>'					
					+'			</div>'	
					+'		</div>'
					+'	</div>'
					+'</section>'
				);	
                */

                $('#content-grid').append(
						 '<section class="sectionsearchlist">'
						+ '	<div class="cnt_section_list">'
						+ '		<a class="img">'
						+ '			<canvas height="110" width="150" id="content-thumbnail' + post.contentId + '" contentid="' + post.contentId + '" style="display:none;">'
						+ '			</canvas>'
	                    + '	        <img id="loadingIcon' + post.contentId + '" src="./img/data_loading.gif" height="25px" width="25px" style="padding: 46px; "/>'
						+ '		</a>'
						+ '		<div class="text">'
						+ '			<a id="title' + post.contentId + '" class="name dialog" contentid="' + post.contentId + '">'
Masaru Abe committed
268 269
						+ '             <img class="listIcon" src="' + HEADER.getIconTypeContent(post.contentType)+'" width="20" height="20">'
						+               COMMON.truncate(COMMON.htmlEncode(post.contentTitle), 20) 
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
						+ '         </a>'
						+ '			<div class="info">'
						+ '				<ul class="date">'
						+ '					<li><span class="lang" lang="txtPubDt"> </span> : ' + outputDate + '</li>'
						+ '					<li><span class="lang" lang="txtViewDt"> </span>:<span id="lblVdate' + post.contentId + '"> </span></li>'
						+ '				</ul>'
						+ '				<ul class="pic">'
						+ '					<li><img src="' + DEFAULT_IMG_OPTION_MEMO + '" id="imgMemo' + post.contentId + '" class="sticker"  /></li>'
						+ '					<li><img src="' + DEFAULT_IMG_OPTION_MARKING + '" id="imgBookMark' + post.contentId + '" class="pen"  /></li>'
						+ '					<li><a class="read lang button-details" contentid="' + post.contentId + '" lang="txtRead">'+i18nText("txtRead")+'</a></li>'
						+ '				</ul>'
						+ '			</div>'
						+ '		</div>'
						+ '	</div>'
						+ '</section>'
					);
                    getNextRecordNumForList();

            //assign thumbnail to array
            var formatThumbnail = post.contentThumbnail;
            if((formatThumbnail != null) && (formatThumbnail != 'undefined') && (formatThumbnail != '')){
                formatThumbnail = formatStringBase64(formatThumbnail);
            }
            
            thumbnailArr.push({ contentId: post.contentId, thumbnail:  formatThumbnail});

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

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

	        //Check if user has read this content or not.
	        checkUserHasReadContent(post.contentId, post.resourceVersion, post.metaVersion);

	        //assign version to array
	        resourceVersionArr.push({ contentid: post.contentId, resourceversion: post.resourceVersion });

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

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

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

	    //Get Next record number for list
	    getNextRecordNumForList();
	    
	    if(data.totalRecord < data.recordTo){
	    	ClientData.searchCond_recordTo(data.totalRecord);
	    }else{
	    	 ClientData.searchCond_recordTo(data.recordTo);
	    }

	    ClientData.searchCond_recordFrom(data.recordFrom);  
	    totalPage = data.totalRecord;

	    //Render Page number
	    if(totalPage == 0){
	    	reRenderPageNumber(totalPage, totalPage);
	    }
	    else{
	    	reRenderPageNumber(ClientData.searchCond_recordTo(), totalPage);
	    }
	    
	    //Toggle scroll to top Control
	    handleBackToTop();

	    //changeLanguage(ClientData.userInfo_language());			
	    i18nReplaceText();
	});
};

//Handle Back To Top Button
function handleBackToTop(){
	if(ClientData.searchCond_recordTo() >= totalPage){
		$('#control-nextrecord').css('visibility','hidden');
	}
	else{
		$('#control-nextrecord').css('visibility','visible');
	}
	
	if(totalPage == 0){
		$('#control-nextrecord').css('visibility','hidden');
		displayResultNoRecord();
		noRecordFlg = true;
	}
    else {
        $('#msgSearchNotExist').hide();
		$('#content-grid').removeClass('lang');
		$('#content-grid').removeAttr('lang');
		enableSort();
		noRecordFlg = false;
	}
};

//Handle language
function handleLanguage(){

	//if(ClientData.userInfo_language() == Consts.ConstLanguage_En || ClientData.userInfo_language() == Consts.ConstLanguage_Ko)
    if (getCurrentLanguage() == Consts.ConstLanguage_En || getCurrentLanguage() == Consts.ConstLanguage_Ko)
	{
		$('#control-sort-titlekana').css('display','none');
		$('#separate').css('display','none');
		$("#titlekana-sorttype").html('');
	}
	else {
	    if (ClientData.searchCond_sortOrder() != null && ClientData.searchCond_sortOrder() != 'undefined' || ClientData.searchCond_sortType() != '') {
	        var typeSort = ClientData.searchCond_sortType();
	        var orderSort = ClientData.searchCond_sortOrder();

//	        if (typeSort == 2) {
//	            if (orderSort == Consts.ConstOrderSetting_Asc) {
//	                $('#titlekana-sorttype').html('');
//	                $('#titlekana-sorttype').html('▲');
//	                $('#titlekana-sorttype').css('width', '12px');
//	            }
//	            else {
//	                $('#titlekana-sorttype').html('');
//	                $('#titlekana-sorttype').html('▼');
//	                $('#titlekana-sorttype').css('width', '12px');
//	            }
//	        }
Masaru Abe committed
401
            HEADER.setStatusSort('#'+$('#menu_sort li.current a').attr('id'),orderSort == Consts.ConstOrderSetting_Asc);
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
	    }
		if(noRecordFlg){
			$('#control-sort-titlekana').css('display','block');
			$('#separate').css('display','block');
		}else{
			$('#control-sort-titlekana').css('display','block');
			$('#separate').css('display','block');
		}
	}	
};

//Initial Screen
function renderGridView(){
	
	var fromPage = DEFAULT_DISP_NUMBER_RECORD_FROM;
	var toPage = returnNumberDispRecordForList();
	var sortType = DEFAULT_SORT_TYPE;
	var sortOrder = DEFAULT_SORT_ORDER;
	var searchText = ClientData.searchCond_searchText();
	var searchDivision = ClientData.searchCond_searchDivision();
	var sid = ClientData.userInfo_sid();
		
	ClientData.searchCond_recordFrom(fromPage);
			
	ClientData.searchCond_recordTo(toPage);
	
	ClientData.searchCond_sortType(sortType);

	ClientData.searchCond_sortOrder(sortOrder);

	ClientData.searchCond_searchDivision(searchDivision);
	
	ClientData.searchCond_genreId('');
	
	ClientData.searchCond_groupId('');
	
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();
	
	//Handle display sort
	handleSortDisp();
	
	//Language Handle
	handleLanguage();
		
	//Refresh GridView
	refreshGrid();
	
	if(searchText == '' || searchText == null){
		displayResultNoRecord();
		chkSearchTextEmpty = true;
		noRecordFlg = true;
		reRenderPageNumber(0, 0);
	}
    else {
        $('#msgSearchNotExist').hide();
		chkSearchTextEmpty = false;
		//Render Gridview
		renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);
		
		$('#control-nextrecord').css('visibility','visible');
	}

};

//Canvas Click function 
function canvasClickFunction(e){
	
    if (e) {
        e.preventDefault();
    }
    if (home_isMove == true) {
        home_isMove = false;
        return;
    }
		
	var contentId = $(this).attr('id');
	var outputId = contentId.substring(17);
	var checkflag = false;

    // Set content id for screen: content detail
	ClientData.contentInfo_contentId(outputId);
	
	// Get image of selected image
	var base64String = returnThumbnail(outputId);
	ClientData.contentInfo_contentThumbnail(base64String);
	
	//Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.
	var contentType = returnContentType(outputId);
	ClientData.contentInfo_contentType(contentType);
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.
    
	//Store Content id that user has read
	if(ClientData.ReadingContentIds().length > 0){
		contentIdArray = ClientData.ReadingContentIds();
		
		for(var nIndex = 0; nIndex < contentIdArray.length; nIndex++){
			if(contentIdArray[nIndex].contentid == outputId){
				checkflag = true;
				break;
			}
			else{
				checkflag = false;
			}			
		}
		
		if(!checkflag){
			contentIdArray.push({contentid: outputId, viewdate: '', originviewdate: ''});
		}
	}
	else{
		contentIdArray.push({contentid: outputId, viewdate: '', originviewdate: ''});
	}
			
	//Renew ReadingContentID
	var newArray = [];
	ClientData.ReadingContentIds(newArray);
	
	//Set data for readingcontentid
	ClientData.ReadingContentIds(contentIdArray);
	
	//Set ResouceVersion for content
	setResourceVersionData(outputId);
	
	//Set MetaVersion for content
	setMetaVersionData(outputId);
				
	//Close Submenu
	$('#dlgSubMenu').hide();
	
	//Delete 'new' icon
	drawEditImage(outputId);

	//Open content Detail
	openContentDetail();
};

//Re-render page from and total record
function reRenderPageNumber(dispRecord, dispTotal){
Masaru Abe committed
541 542 543 544 545 546 547 548 549 550 551 552 553

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

554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
};

//Show Next Record Function
function showNextRecordFunction(){
	var fromPage = ClientData.searchCond_recordFrom();
	var toPage = ClientData.searchCond_recordTo();
	var sortType = ClientData.searchCond_sortType();
	var sortOrder = ClientData.searchCond_sortOrder();
	var searchText = ClientData.searchCond_searchText();
	var searchDivision = ClientData.searchCond_searchDivision();
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();
	var sid = ClientData.userInfo_sid();
	var totalrecord = totalPage;	
		
	if(fromPage == null || fromPage == 'undefined'){
		fromPage = DEFAULT_DISP_NUMBER_RECORD_FROM;
	}
	
	if(toPage == null || toPage == 'undefined'){
		toPage = returnNumberDispRecordForList();
	}
	
	fromPage = eval(toPage) + 1;
	var iRecordNumber = eval(totalrecord) - eval(fromPage);
	
	if(iRecordNumber < iNumberOfNextRecord)
	{
		toPage = eval(fromPage) + eval(iRecordNumber);
	}
	else
	{
		toPage = eval(fromPage) + (eval(iNumberOfNextRecord) - 1);
	}
	
	ClientData.searchCond_recordFrom(fromPage);
	ClientData.searchCond_recordTo(toPage);

	if(fromPage <= totalrecord)
	{				
		renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);				
	}
};

//Sort By Title Function
function sortByTitleFunction(){
	
//	$(this).addClass('active_tops');
//	$('#control-sort-titlekana').removeClass('active_tops');
//	$('#control-sort-releasedate').removeClass('active_tops');
	
	var sortOrder = ClientData.searchCond_sortOrder();
	var sortType = ClientData.searchCond_sortType();
	var sid = ClientData.userInfo_sid();
	var recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
	var recordTo = ClientData.searchCond_recordTo();
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();

	if(sortOrder == Consts.ConstOrderSetting_Asc)
	{
		if(sortType == '1'){
			sortOrder = Consts.ConstOrderSetting_Desc;		
//			$('#title-sorttype').html('');
//			$('#title-sorttype').html('▼');
//			$('#title-sorttype').css('width', '12px');
//			$('#titlekana-sorttype').html('');
//			$('#rDate-sorttype').html('');	
		}
		else{
			sortOrder = Consts.ConstOrderSetting_Asc;
//			$('#title-sorttype').html('');
//			$('#title-sorttype').html('▲');
//			$('#title-sorttype').css('width', '12px');
//			$('#titlekana-sorttype').html('');
//			$('#rDate-sorttype').html('');	
		}	
		ClientData.searchCond_sortOrder(sortOrder);			
	}
	else
	{	
		sortOrder = Consts.ConstOrderSetting_Asc;
//		$('#title-sorttype').html('');
//		$('#title-sorttype').html('▲');
//		$('#title-sorttype').css('width', '12px');
//		$('#titlekana-sorttype').html('');
//		$('#rDate-sorttype').html('');				
		ClientData.searchCond_sortOrder(sortOrder);	
	}			
	
Masaru Abe committed
644
    HEADER.setStatusSort('#control-sort-title',sortOrder == Consts.ConstOrderSetting_Asc);
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715

	if(recordFrom == null || recordFrom == 'undefined'){
		recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
		ClientData.searchCond_recordFrom(recordFrom);
	}

	if(recordTo == null || recordTo == 'undefined'){
		
		recordTo = returnNumberDispRecordForList();
		ClientData.searchCond_recordFrom(recordTo);
	}
	
	sortType = '1';
	ClientData.searchCond_sortType(sortType);

	//refresh Gridview
	refreshGrid();
	
	//refresh add more record
	$('#control-nextrecord').css('visibility','hidden');	
				
	renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
};

//Sort By Title Kana function
function sortByTitleKanaFunction(){
		
//	$(this).addClass('active_tops');
//	$('#control-sort-title').removeClass('active_tops');
//	$('#control-sort-releasedate').removeClass('active_tops');
		
		
	var sortOrder = ClientData.searchCond_sortOrder();
	var sortType = ClientData.searchCond_sortType();
	var sid = ClientData.userInfo_sid();
	var recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
	var recordTo = ClientData.searchCond_recordTo();
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();
	
	if(sortOrder == Consts.ConstOrderSetting_Asc)
	{	
		if(sortType == '2'){
			sortOrder = Consts.ConstOrderSetting_Desc;		
//			$('#title-sorttype').html('');
//			$('#titlekana-sorttype').html('');
//			$('#titlekana-sorttype').html('▼');
//			$('#titlekana-sorttype').css('width', '12px');
//			$('#rDate-sorttype').html('');	
		}
		else{
			sortOrder = Consts.ConstOrderSetting_Asc;
//			$('#title-sorttype').html('');
//			$('#titlekana-sorttype').html('');
//			$('#titlekana-sorttype').html('▲');
//			$('#titlekana-sorttype').css('width', '12px');
//			$('#rDate-sorttype').html('');	
		}	
		ClientData.searchCond_sortOrder(sortOrder);			
	}
	else
	{
		sortOrder = Consts.ConstOrderSetting_Asc;
//		$('#title-sorttype').html('');
//		$('#titlekana-sorttype').html('');
//		$('#titlekana-sorttype').html('▲');
//		$('#titlekana-sorttype').css('width', '12px');
//		$('#rDate-sorttype').html('');
		ClientData.searchCond_sortOrder(sortOrder);	
	}			
	
Masaru Abe committed
716
    HEADER.setStatusSort('#control-sort-titlekana',sortOrder == Consts.ConstOrderSetting_Asc);
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788

	if(recordFrom == null || recordFrom == 'undefined'){
		recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
		ClientData.searchCond_recordFrom(recordFrom);
	}
	
	if(recordTo == null || recordTo == 'undefined'){
		
		recordTo = returnNumberDispRecordForList();

		ClientData.searchCond_recordFrom(recordTo);
	}
	
	sortType = '2';
	//refresh gridview
	refreshGrid();
		
	
	//refresh add more record
	$('#control-nextrecord').css('visibility','hidden');
	
				
	ClientData.searchCond_sortType(sortType);
	renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
};

//Sort By Release Date
function sortByReleaseDateFunction(){
	
//	$(this).addClass('active_tops');
//	$('#control-sort-title').removeClass('active_tops');
//	$('#control-sort-titlekana').removeClass('active_tops');
	
	var sortOrder = ClientData.searchCond_sortOrder();
	var sortType = ClientData.searchCond_sortType();
	var sid = ClientData.userInfo_sid();
	var recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
	var recordTo = ClientData.searchCond_recordTo();
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();
	
	if(sortOrder == Consts.ConstOrderSetting_Asc)
	{
		if(sortType == '3'){
			sortOrder = Consts.ConstOrderSetting_Desc;		
//			$('#title-sorttype').html('');
//			$('#titlekana-sorttype').html('');
//			$('#rDate-sorttype').html('');
//			$('#rDate-sorttype').html('▼');
//			$('#rDate-sorttype').css('width', '12px');
		}
		else{
			sortOrder = Consts.ConstOrderSetting_Asc;	
//			$('#title-sorttype').html('');
//			$('#titlekana-sorttype').html('');
//			$('#rDate-sorttype').html('');
//			$('#rDate-sorttype').html('▲');
//			$('#rDate-sorttype').css('width', '12px');
		}
		ClientData.searchCond_sortOrder(sortOrder);			
	}
	else
	{
		sortOrder = Consts.ConstOrderSetting_Asc;	
//		$('#title-sorttype').html('');
//		$('#titlekana-sorttype').html('');
//		$('#rDate-sorttype').html('');
//		$('#rDate-sorttype').html('▲');
//		$('#rDate-sorttype').css('width', '12px');
		ClientData.searchCond_sortOrder(sortOrder);	
	}			
	
Masaru Abe committed
789
    HEADER.setStatusSort('#control-sort-releasedate',sortOrder == Consts.ConstOrderSetting_Asc);
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881

	if(recordFrom == null || recordFrom == 'undefined'){
		recordFrom = DEFAULT_DISP_NUMBER_RECORD_FROM;
		ClientData.searchCond_recordFrom(recordFrom);
	}
	
	if(recordTo == null || recordTo == 'undefined'){
		
		recordTo = returnNumberDispRecordForList();

		ClientData.searchCond_recordFrom(recordTo);
	}
	
	sortType = '3';
	//refresh gridview
	refreshGrid();
		
	//refresh add more record
	$('#control-nextrecord').css('visibility','hidden');
		
	ClientData.searchCond_sortType(sortType);	
	renderContent(sid, ClientData.searchCond_searchText(), ClientData.searchCond_searchDivision(), sortType, sortOrder, recordFrom, recordTo, genreId, groupId);
};

//Get Thumnail base on contentid
function returnThumbnail(contentid){
	
	for(var i = 0; i < thumbnailArr.length; i++){
		if(thumbnailArr[i].contentId == contentid){
			return thumbnailArr[i].thumbnail;
		}
	}
};

//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
function returnContentType(contentid){
    //Array Length
    var iArrCnt = contentTypeArr.length;
    
    //Get contentType in array by contentId
    for(var i = 0; i < iArrCnt; i++){
        if (contentTypeArr[i].contentId == contentid) {
            return contentTypeArr[i].contentType;
        }
    }
};

//Check content type is pdf content
function isPdfContent(contentType){
    if(!(contentType == ContentTypeKeys.Type_PDF)){
        return false; 
    }
    else{
        return true;
    }
};
////Get resource Id of content
//function downloadResourceById(contentId){
//    var params = {
//        sid: ClientData.userInfo_sid(),
//        contentId: contentId,
//        getType: '2',
//    };
//    
//    var resourceUrl;
//    
//    abapi('webGetContent', params, 'GET', function (data) {
//        var resourceId;
//        
//        $.each(data.contentData , function(i, n){
//            if(typeof n == "object"){
//                resourceId = n.resourceId;                
//            }                        
//        });
//      
//       //Get resource
//       resourceUrl = getResourceByIdFromAPI(resourceId);
//             
//       window.open(resourceUrl, "_blank");

//       // redraw content remove new icon
//       drawEditImage(contentId);
//         
//    });           
//};

////Download resource
//function getResourceByIdFromAPI(resourceId){
//    return getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + resourceId + "&isDownload=true"; 
//};

Masaru Abe committed
882 883 884 885 886 887 888
///* get url */
//function getURL(apiName) {
//    var sysSettings = avwSysSetting();
//    var url = sysSettings.apiResourceDlUrl;
//    url = AVWEB.format(url, ClientData.userInfo_accountPath()) + '/' + apiName;
//    return url;
//};
889 890 891 892 893 894 895 896 897 898 899 900

//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Create new function to return content type of content.

//Dialog Read Button CLick
function readSubmenuFunction(e){
    if (e) {
        e.preventDefault();
    }
    if (home_isMove == true) {
        home_isMove = false;
        return;
    }    
Masaru Abe committed
901 902
    var contentId = $(this).attr('contentid');
    // check limit of content
903
    checkLimitContent(contentId,
Masaru Abe committed
904 905 906 907 908 909 910
        function()
        { 
            readSubmenuFunction_callback(contentId);
        },
        function(){
        }
    );
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978

};

// read content callback
function readSubmenuFunction_callback(contentId)
{
	var contentThumbnail = returnThumbnail(contentId);
	var date = new Date();
	var month = date.getMonth()+1;
	var day = date.getDate();
	
	var outputDate = formatNormalDate(day, month, date.getFullYear());
	
	ClientData.contentInfo_contentId(contentId);
	ClientData.contentInfo_contentThumbnail(contentThumbnail);
	
	//Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.
	var contentType = returnContentType(contentId);
    ClientData.contentInfo_contentType(contentType);
	//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.
	
	var checkflag = false;
	
	//Store Content id that user has read
	if(ClientData.ReadingContentIds().length > 0){
		contentIdArray = ClientData.ReadingContentIds();
		
		for(var nIndex = 0; nIndex < contentIdArray.length; nIndex++){
			if(contentIdArray[nIndex].contentid == contentId){
				checkflag = true;
				if(contentIdArray[nIndex].viewdate == null || contentIdArray[nIndex].viewdate == 'undefined' || contentIdArray[nIndex].viewdate == ''){
					contentIdArray[nIndex].viewdate = outputDate;
					contentIdArray[nIndex].originviewdate = date;
				}
				break;
			}
			else{
				checkflag = false;
			}			
		}
		
		if(!checkflag){
			contentIdArray.push({contentid: contentId, viewdate: outputDate, originviewdate: date});
		}
	}
	else{
		contentIdArray.push({contentid: contentId, viewdate: outputDate, originviewdate: date});
	}
	
	//Renew ReadingContentID
	var newArray = [];
	ClientData.ReadingContentIds(newArray);
	
	//Set ResouceVersion for content
	setResourceVersionData(contentId);
	
	//Set MetaVersion for content
	setMetaVersionData(contentId);
	
	//Set data for readingcontentid
	ClientData.ReadingContentIds(contentIdArray);

	ClientData.IsRefresh(false);
	
	//Start Function : No.12 -- Editor : Le Long -- Date : 08/02/2013 -- Summary : Check content type other for download.          
    //For testing without other Type.
    if(contentType == ContentTypeKeys.Type_Others){
        //Download content
Masaru Abe committed
979
        HEADER.downloadResourceById(contentId);
980 981 982 983 984
        // redraw content remove new icon
        drawEditImage(contentId);
    }
    else if( contentType == ContentTypeKeys.Type_Link ){
        //link content
Masaru Abe committed
985
        HEADER.viewLinkContentById(contentId);
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
        // redraw content remove new icon
        drawEditImage(contentId);
    }
    else{
        //Go to Conten view page
        avwScreenMove(ScreenIds.ContentView);
    }
    //End Function : No.12 -- Editor : Le Long -- Date : 08/02/2013 -- Summary : Check content type other for download. 
};

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

//Check if User has read content
function checkUserHasReadContent(contId, resourceVer, metaVer) {

    var imgThumb = new Image();
    //imgThumb.src = returnThumbnail(contId);                           

    var imgIconNew = new Image();
    //imgIconNew.src = DEFAULT_IMG_CONTENT_NEW;

    var imgIconEdit = new Image();
    //imgIconEdit.src = DEFAULT_IMG_CONTENT_EDIT;

    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();
    
    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Declare variable handle contentType and Thumbnail of content.
    var contentThumbnail = returnThumbnail(contId);
    var contentType = returnContentType(contId);
    //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 () {
            var resizeImg = resizeResourceThumbnail(imgThumb, c.width, c.height);
            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
            imgIconNew.onload = function () {
                ctx.drawImage(imgIconNew, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                $("#loadingIcon" + contId).fadeOut('slow', function () {
                    $('#content-thumbnail' + contId).fadeIn('slow');                    
                });
            };
            imgIconNew.src = DEFAULT_IMG_CONTENT_NEW;
        };      
         
        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
        if(contentThumbnail == '' || contentThumbnail == null){
            if(!isPdfContent(contentType)){
1075 1076 1077 1078 1079
                var src = header.getThumbnailForOtherType(contentType);
                if( src != '' ){
                    imgThumb.src = src;
                }
                /*
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
                if(contentType == ContentTypeKeys.Type_Image){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_ImageType;
                }
                else if(contentType == ContentTypeKeys.Type_Music){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_MusicType;
                }
                else if(contentType == ContentTypeKeys.Type_Video){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_VideoType;
                }
                else if(contentType == ContentTypeKeys.Type_NoFile){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_NoFileType;
                }
                else if(contentType == ContentTypeKeys.Type_Others){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_OthersType;
                }
                else if(contentType == ContentTypeKeys.Type_Html){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_HtmlType;
                }
1098 1099 1100 1101
                else if(contentType == ContentTypeKeys.Type_Link){
                    imgThumb.src = ThumbnailForOtherType.Thumbnail_LinkType;
                }
                */
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
            }
        }else{
            imgThumb.src = contentThumbnail;
        }
                
        //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 () {
                    var resizeImg = resizeResourceThumbnail(imgThumb, c.width, c.height);
                    ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                    $("#loadingIcon" + contId).fadeOut('slow', function () {
                        $('#content-thumbnail' + contId).fadeIn('slow');
                    });
                };
                //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
      
                if(contentThumbnail == '' || contentThumbnail == null){
                    if(!isPdfContent(contentType)){
1124 1125 1126 1127 1128 1129
                        var src = header.getThumbnailForOtherType(contentType);
                        if( src != '' ){
                            imgThumb.src = src;
                        }
                    
                        /*
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
                        if(contentType == ContentTypeKeys.Type_Image){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_ImageType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Music){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_MusicType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Video){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_VideoType;
                        }
                        else if(contentType == ContentTypeKeys.Type_NoFile){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_NoFileType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Others){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_OthersType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Html){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_HtmlType;
                        }
1148 1149 1150 1151
                        else if(contentType == ContentTypeKeys.Type_Link){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_LinkType;
                        }
                        */
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
                    }
                }else{
                    imgThumb.src = contentThumbnail;
                }
                        
                //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                readFlg = true;
                break;
            }
            else {
                imgThumb.onload = function () {
                    var resizeImg = resizeResourceThumbnail(imgThumb, c.width, c.height);
                    ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                    imgIconNew.onload = function () {
                        ctx.drawImage(imgIconNew, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                        $("#loadingIcon" + contId).fadeOut('slow', function () {
                            $('#content-thumbnail' + contId).fadeIn('slow');
                        });
                    };
                    imgIconNew.src = DEFAULT_IMG_CONTENT_NEW;
                };
                //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
      
                if(contentThumbnail == '' || contentThumbnail == null){
                    if(!isPdfContent(contentType)){
1177 1178 1179 1180 1181
                        var src = header.getThumbnailForOtherType(contentType);
                        if( src != '' ){
                            imgThumb.src = src;
                        }
                        /*
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
                        if(contentType == ContentTypeKeys.Type_Image){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_ImageType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Music){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_MusicType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Video){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_VideoType;
                        }
                        else if(contentType == ContentTypeKeys.Type_NoFile){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_NoFileType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Others){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_OthersType;
                        }
                        else if(contentType == ContentTypeKeys.Type_Html){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_HtmlType;
                        }
1200 1201 1202 1203
                        else if(contentType == ContentTypeKeys.Type_Link){
                            imgThumb.src = ThumbnailForOtherType.Thumbnail_LinkType;
                        }
                        */
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
                    }
                }else{
                    imgThumb.src = contentThumbnail;
                }
                        
                //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 () {
                            var resizeImg = resizeResourceThumbnail(imgThumb, c.width, c.height);
                            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                            imgIconEdit.onload = function () {
                                ctx.drawImage(imgIconEdit, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);

                                $("#loadingIcon" + contId).fadeOut('slow', function () {
                                    $('#content-thumbnail' + contId).fadeIn('slow');
                                });
                            };
                            imgIconEdit.src = DEFAULT_IMG_CONTENT_EDIT;
                        };
                        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                      
                        if(contentThumbnail == '' || contentThumbnail == null){
                            if(!isPdfContent(contentType)){
1238 1239 1240 1241 1242
                                var src = header.getThumbnailForOtherType(contentType);
                                if( src != '' ){
                                    imgThumb.src = src;
                                }
                                /*
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
                                if(contentType == ContentTypeKeys.Type_Image){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_ImageType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Music){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_MusicType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Video){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_VideoType;
                                }
                                else if(contentType == ContentTypeKeys.Type_NoFile){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_NoFileType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Others){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_OthersType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Html){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_HtmlType;
                                }
1261 1262 1263 1264
                                else if(contentType == ContentTypeKeys.Type_Link){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_LinkType;
                                }
                                */
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
                            }
                        }else{
                            imgThumb.src = contentThumbnail;
                        }
                                
                        //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 () {
                            var resizeImg = resizeResourceThumbnail(imgThumb, c.width, c.height);
                            ctx.drawImage(imgThumb, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
                            imgIconEdit.onload = function () {
                                ctx.drawImage(imgIconEdit, c.width / 2 - resizeImg[0] / 2, c.height - resizeImg[1]);
                                $("#loadingIcon" + contId).fadeOut('slow', function () {
                                    $('#content-thumbnail' + contId).fadeIn('slow');
                                });
                            };
                            imgIconEdit.src = DEFAULT_IMG_CONTENT_EDIT;
                        };
                        //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
      
                        if(contentThumbnail == '' || contentThumbnail == null){
                            if(!isPdfContent(contentType)){
1298 1299 1300 1301 1302
                                var src = header.getThumbnailForOtherType(contentType);
                                if( src != '' ){
                                    imgThumb.src = src;
                                }
                                /*
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
                                if(contentType == ContentTypeKeys.Type_Image){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_ImageType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Music){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_MusicType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Video){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_VideoType;
                                }
                                else if(contentType == ContentTypeKeys.Type_NoFile){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_NoFileType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Others){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_OthersType;
                                }
                                else if(contentType == ContentTypeKeys.Type_Html){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_HtmlType;
                                }
1321 1322 1323 1324
                                else if(contentType == ContentTypeKeys.Type_Link){
                                    imgThumb.src = ThumbnailForOtherType.Thumbnail_LinkType;
                                }
                                */
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
                            }
                        }else{
                            imgThumb.src = contentThumbnail;
                        }
                                
                        //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Check contentType to set thumbnail.
                        break;
                    }
                }
            }
        }
        readFlg = false;
    }
};

//draw Edit Image
function drawEditImage(id) {
    var img = new Image();
    var imgSrc = returnThumbnail(id);
    
    if(imgSrc != null){
        
    }
    else{
        var contentType = returnContentType(id);
        
1351 1352 1353 1354 1355
        var src = header.getThumbnailForOtherType(contentType);
        if( src != '' ){
            imgSrc = src;
        }
        /*
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
        if(contentType == ContentTypeKeys.Type_Image){
            imgSrc = ThumbnailForOtherType.Thumbnail_ImageType;
        }
        else if(contentType == ContentTypeKeys.Type_Music){
            imgSrc = ThumbnailForOtherType.Thumbnail_MusicType;
        }
        else if(contentType == ContentTypeKeys.Type_Video){
            imgSrc = ThumbnailForOtherType.Thumbnail_VideoType;
        }
        else if(contentType == ContentTypeKeys.Type_NoFile){
            imgSrc = ThumbnailForOtherType.Thumbnail_NoFileType;
        }
        else if(contentType == ContentTypeKeys.Type_Others){
            imgSrc = ThumbnailForOtherType.Thumbnail_OthersType;
        }
        else if(contentType == ContentTypeKeys.Type_Html){
            imgSrc = ThumbnailForOtherType.Thumbnail_HtmlType;
        }       
1374 1375 1376 1377
        else if(contentType == ContentTypeKeys.Type_Link){
            imgSrc = ThumbnailForOtherType.Thumbnail_LinkType;
        }
        */
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589
    }
       
    var c = document.getElementById('content-thumbnail' + id);              
    
    //use getContext to use the canvas for drawing
    var ctx = c.getContext('2d');
    ctx.clearRect(0, 0, c.width, c.height);
    img.onload = function () {
        var resizeImg = resizeResourceThumbnail(img, c.width, c.height);
        ctx.drawImage(img, (c.width / 2) - (resizeImg[0] / 2) + 4, c.height - resizeImg[1] + 4, resizeImg[0], resizeImg[1]);
        $("#loadingIcon" + id).fadeOut('slow', function () {
            $('#content-thumbnail' + id).fadeIn('slow');
        });               
    };
    
    img.src = imgSrc;
};

//Search Function
function searchEventButtonFunction(){
	
	var fromPage = DEFAULT_DISP_NUMBER_RECORD_FROM;
	var toPage = returnNumberDispRecordForList();
	var sortType = DEFAULT_SORT_TYPE;
	var sortOrder = DEFAULT_SORT_ORDER;
	var searchText = $('#txtSearch').val();
	var searchDivision;
	var content = $('#main-content').attr('checked');
	var tag = $('#main-tag').attr('checked');
	var body = $('#main-body').attr('checked');
	
	
	if(content == 'checked')
	{
		searchDivision = $('#searchbox-content').val();
	}
	if(tag == 'checked')
	{
		searchDivision = $('#searchbox-tag').val();
	}
	if(body == 'checked')
	{
		searchDivision = $('#searchbox-body').val();
	}
	
	var genreId = ClientData.searchCond_genreId();
	var groupId = ClientData.searchCond_groupId();
	var sid = ClientData.userInfo_sid();
	ClientData.searchCond_sortOrder(sortOrder);
	ClientData.searchCond_sortType(sortType);
	ClientData.searchCond_searchText(searchText);
	ClientData.searchCond_searchDivision(searchDivision);
	//refresh grid
	refreshGrid();
	
	//Handle display sort
	handleSortDisp();
	
	
	if(searchText == '' || searchText == null){
		displayResultNoRecord();
		chkSearchTextEmpty = true;
		noRecordFlg = true;
		reRenderPageNumber(0, 0);
	}
    else {
        $('#msgSearchNotExist').hide();
        $('#control-nextrecord').css('visibility','hidden');
		//Render Gridview
		chkSearchTextEmpty = false;
		renderContent(sid, searchText, searchDivision, sortType, sortOrder, fromPage, toPage, genreId, groupId);
		//$('#control-nextrecord').css('visibility','visible');
	}
};

//Render User view date
function renderViewDate(id){

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

//set resource version data
function setResourceVersionData(conId){	
	var tempResourceArr;
	var tempResource;
	//check if insert new or edit
	var flag = false;
	
	if(ClientData.ResourceVersion().length <= 0 || ClientData.ResourceVersion() == null || ClientData.ResourceVersion() == 'undefined'){
		tempResourceArr = [];
	}
	else{
		tempResourceArr = ClientData.ResourceVersion();
	}
		
	for(var i = 0; i < resourceVersionArr.length; i++){
		if(resourceVersionArr[i].contentid == conId){
			tempResource = resourceVersionArr[i].resourceversion;
			break;
		}
	}
	
	if(tempResourceArr.length > 0){
		for(var j = 0; j < tempResourceArr.length; j++){
			if(tempResourceArr[j].contentid == conId){
				tempResourceArr[j].resourceversion = tempResource;			
				flag = true;
				break;
			}
			else{
				flag = false;
			}
		}
		
		if(!flag){
			tempResourceArr.push({contentid: conId, resourceversion: tempResource});
		}
		
	}else{
		tempResourceArr.push({contentid: conId, resourceversion: tempResource});
	}
			
	ClientData.ResourceVersion(tempResourceArr);
};

//set meta Version Data
function setMetaVersionData(conId){
	
	var tempMetaArr;
	var tempMeta;
	//check if insert new or edit
	var flag = false;
	
	if(ClientData.MetaVersion().length <= 0 || ClientData.MetaVersion() == null || ClientData.MetaVersion() == 'undefined'){
		tempMetaArr = [];
	}
	else{
		tempMetaArr = ClientData.MetaVersion();
	}
		
	for(var i = 0; i < metaVersionArr.length; i++){
		if(metaVersionArr[i].contentid == conId){
			tempMeta = metaVersionArr[i].metaversion;
			break;
		}
	}
	
	if(tempMetaArr.length > 0){
		for(var j = 0; j < tempMetaArr.length; j++){
			if(tempMetaArr[j].contentid == conId){
				tempMetaArr[j].metaversion = tempMeta;			
				flag = true;
				break;
			}
			else{
				flag = false;
			}
		}
		
		if(!flag){
			tempMetaArr.push({contentid: conId, metaversion: tempMeta});
		}
		
	}else{
		tempMetaArr.push({contentid: conId, metaversion: tempMeta});
	}
			
	ClientData.MetaVersion(tempMetaArr);
};

//handle display sort direction
function handleSortDisp(){
//	$('#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){	
//				if(orderSort == Consts.ConstOrderSetting_Asc){
//					$('#title-sorttype').html('');
//					$('#title-sorttype').html('▲');
//					$('#title-sorttype').css('width', '12px');
//					$('#titlekana-sorttype').html('');
//					$('#rDate-sorttype').html('');
//				}
//				else{
//					$('#title-sorttype').html('');
//					$('#title-sorttype').html('▼');
//					$('#title-sorttype').css('width', '12px');
//					$('#titlekana-sorttype').html('');
//					$('#rDate-sorttype').html('');
//				}
//				
//				$('#control-sort-title').addClass('active_tops');

Masaru Abe committed
1590
                HEADER.setStatusSort('#control-sort-title',orderSort == Consts.ConstOrderSetting_Asc);
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611

			}
			else if(typeSort == 2){
				
//				if(orderSort == Consts.ConstOrderSetting_Asc){
//					$('#title-sorttype').html('');
//					$('#titlekana-sorttype').html('');
//					$('#titlekana-sorttype').html('▲');
//					$('#titlekana-sorttype').css('width', '12px');
//					$('#rDate-sorttype').html('');
//				}
//				else{
//					$('#title-sorttype').html('');
//					$('#titlekana-sorttype').html('');
//					$('#titlekana-sorttype').html('▼');
//					$('#titlekana-sorttype').css('width', '12px');
//					$('#rDate-sorttype').html('');
//				}
//				
//				$('#control-sort-titlekana').addClass('active_tops');

Masaru Abe committed
1612
                HEADER.setStatusSort('#control-sort-titlekana',orderSort == Consts.ConstOrderSetting_Asc);
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632

			}
			else if(typeSort == 3){
//				if(orderSort == Consts.ConstOrderSetting_Asc){
//					$('#title-sorttype').html('');
//					$('#titlekana-sorttype').html('');
//					$('#rDate-sorttype').html('');
//					$('#rDate-sorttype').html('▲');
//					$('#rDate-sorttype').css('width', '12px');
//				}
//				else{
//					$('#title-sorttype').html('');
//					$('#titlekana-sorttype').html('');
//					$('#rDate-sorttype').html('');
//					$('#rDate-sorttype').html('▼');
//					$('#rDate-sorttype').css('width', '12px');
//				}
//				
//				$('#control-sort-releasedate').addClass('active_tops');

Masaru Abe committed
1633
                HEADER.setStatusSort('#control-sort-releasedate',orderSort == Consts.ConstOrderSetting_Asc);
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
			}
		}			
	}
};

//convert delivery Date
function formatDeliveryDate(date){
	
	var day = date.date;
	var month = eval(date.month) + 1;
	var year = eval(date.year) + 1900;
	
	var outputDate = year + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;

	return outputDate;
};

//convert view Date
function formatNormalDate(day, month, year){
	var outputDate = year + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;
	
	return outputDate;
};

//format Image string
function formatStringBase64(imgStr){

	var outputString = 'data:image/jpeg;base64,'+imgStr;

	return outputString;
};

//function Open SubMenu Dialog
function titleClickFunction(e){
    if (e) {
        e.preventDefault();
    }
    if (home_isMove == true) {
        home_isMove = false;
        return;
    }
    var checkflag = false;
	var contentid = $(this).attr('contentid');
	// Get image of selected image
	var base64String = returnThumbnail(contentid);
	ClientData.contentInfo_contentThumbnail(base64String);
	ClientData.contentInfo_contentId(contentid);

    //Start Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.
    var contentType = returnContentType(contentid);
    ClientData.contentInfo_contentType(contentType);
    //End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type of content.

	//Store Content id that user has read
	if(ClientData.ReadingContentIds().length > 0){
		contentIdArray = ClientData.ReadingContentIds();
		
		for(var nIndex = 0; nIndex < contentIdArray.length; nIndex++){
			if(contentIdArray[nIndex].contentid == contentid){
				checkflag = true;
				break;
			}
			else{
				checkflag = false;
			}			
		}
		
		if(!checkflag){
			contentIdArray.push({contentid: contentid, viewdate: '', originviewdate: ''});
		}
	}
	else{
		contentIdArray.push({contentid: contentid, viewdate: '', originviewdate: ''});
	}
			
	//Renew ReadingContentID
	var newArray = [];
	ClientData.ReadingContentIds(newArray);
	
	//Set data for readingcontentid
	ClientData.ReadingContentIds(contentIdArray);
	
	//Set ResouceVersion for content
	setResourceVersionData(contentid);
	
	//Set MetaVersion for content
	setMetaVersionData(contentid);
				
	//Close Submenu
	$('#dlgSubMenu').hide();
	
	//Delete 'new' icon
	drawEditImage(contentid);

	//Open content Detail
	openContentDetail();
};

//Get Number Disp Record For List
function returnNumberDispRecordForList() {
    var toPage = 0;
    var sysSettings = avwSysSetting();
    toPage = sysSettings.bookListCount;
    return toPage;
};

//Get number record disp next for list
function getNextRecordNumForList(){
	iNumberOfNextRecord = returnNumberDispRecordForList();
};

//refresh sort order
function refreshSortTypeOrder(){
	$('#title-sorttype').html('');
	$('#titlekana-sorttype').html('');
	$('#rDate-sorttype').html('');
	$('#rDate-sorttype').html('');
};

//refresh GridView
function refreshGrid(){
	$('#control-nextrecord').css('visibility','hidden');
	$('#content-grid').html('');
	$('.pageNumControl').css('visibility','hidden');
};

//format text display more record
function formatDisplayMoreRecord(){
    i18nReplaceText();
	//changeLanguage(ClientData.userInfo_language());
Masaru Abe committed
1764
	$('#control-nextrecord').html(AVWEB.format(i18nText('dspViewMore'), returnNumberDispRecordForList()));
1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813
	
};

function changeLanguageCallBackFunction(){
	handleLanguage();
    
	formatDisplayMoreRecord();
	
	if(chkSearchTextEmpty){
		displayResultNoRecord();
    } else 
    {
        if(!noRecordFlg)
		{
            $('#control-nextrecord').css('visibility','visible');
        }
		enableSort();
	}
	
	document.title = i18nText('txtSearchResult') + ' | ' + i18nText('sysAppTitle');
};

function displayResultNoRecord(){
	i18nReplaceText();
	//$('#content-grid').html(i18nText('msgSearchNotExist'));
	//$('#content-grid').css({ 'text-align': 'left', 'margin-top': '20px', 'clear': 'both' });
	$('#content-grid').html('');
	$('#msgSearchNotExist').show();
	$('#msgSearchNotExist').css({ 'text-align': 'left', 'margin-top': '20px', 'clear': 'both' });

	$('#control-nextrecord').css('visibility','hidden');
	$('.control_sort_on').hide();
	$('.control_sort_off').show();
	if(getCurrentLanguage() == Consts.ConstLanguage_En || getCurrentLanguage() == Consts.ConstLanguage_Ko){
		/*$('#control-sort-titlekana').hide();*/
		$('#separate').hide();
        $('#control-sort-titlekana').hide();
	}
};

function enableSort(){
	$('.control_sort_on').show();
	$('.control_sort_off').hide();
	if(getCurrentLanguage() == Consts.ConstLanguage_En || getCurrentLanguage() == Consts.ConstLanguage_Ko){
		$('#control-sort-titlekana').hide();
		$('#separate').hide();
	}
};

Masaru Abe committed
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823
//function truncate(strInput, length){
//    if (strInput.length <= length)
//    {
//        return strInput;
//    }
//    else
//    {
//        return strInput.substring(0, length) + "...";
//    }
//};
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848

function resizeResourceThumbnail(mg, width, height) {
	var newWidth;
	var newHeight;
	/*if(mg.width > mg.height) {
		newWidth = width;
		newHeight = (mg.height * width)/mg.width;
	}
	else {
	
		newHeight = height;
		newWidth = (mg.width * height)/mg.height;
	}*/
    var delta=Math.min(width/mg.width,height/mg.height);

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

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

};

function removeHoverCss(){
	
Masaru Abe committed
1849
	if(COMMON.isTouchDevice()){
1850 1851 1852 1853 1854
		$('#control-sort-title').removeClass('nottouchdevice');
		$('#control-sort-titlekana').removeClass('nottouchdevice');
		$('#control-sort-releasedate').removeClass('nottouchdevice');
	}
};