contentview_CallApi.js 13.7 KB
Newer Older
1

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

//Call API
6
CONTENTVIEW_CALLAPI.abapi = function(name, param, method, callback) {
7
	AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), name, method, param, callback, null);
8
};
9

10
/* get Json stored content info */
11
CONTENTVIEW_CALLAPI.getJsonContentInfo = function( doneFunc ) {
12

Masaru Abe committed
13
	//console.log("CONTENTVIEW_CALLAPI.getJsonContentInfo");
14
	AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
15 16 17 18
	     { contentId: CONTENTVIEW_GENERAL.contentID, sid: ClientData.userInfo_sid(), pageNo: 1 },
	     function (data) {
	    	CONTENTVIEW_GENERAL.pageImages = data;
	    	CONTENTVIEW_CALLAPI.getJsonContentInfoDone(doneFunc);
19 20
	     },
	     function (xmlHttpRequest, txtStatus, errorThrown) {
21
	    	 CONTENTVIEW.showErrorScreen();
22 23 24 25 26
	     }
	);
};

CONTENTVIEW_CALLAPI.getJsonContentInfoDone = function(doneFunc){
27

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	var ajax1 = CONTENTVIEW_CALLAPI.webGetContentDataWhen();
	var ajax2 = CONTENTVIEW_CALLAPI.getSearchDataFromJsonWhen();
	var ajax3 = CONTENTVIEW_CALLAPI.getJsonDataPageTitleWhen();
	var ajax4 = CONTENTVIEW_CALLAPI.getJsonDataType4When();
	var ajax5 = CONTENTVIEW_CALLAPI.getJsonDataType5When();
	var ajax6 = CONTENTVIEW_CALLAPI.getDataJsonFileWhen();
	var ajax7 = CONTENTVIEW_CALLAPI.webGetContentPageSizeWhen();
	$.when(
    	 ajax1,ajax2,ajax3,ajax4,ajax5,ajax6,ajax7
	).done(function(data1, data2, data3, data4, data5, data6, data7) {
		//console.log("done:data1:" + data1);
		//console.log("done:data2:" + data2);
		//console.log("done:data3:" + data3);
		//console.log("done:data4:" + data4);
		//console.log("done:data5:" + data5);
		//console.log("done:data6:" + data6);
		//console.log("done:data7:" + data7);
		if(data1){
			CONTENTVIEW_CALLAPI.webGetContentDataDone(data1[0]);
		}
		if(data2){
			CONTENTVIEW_CALLAPI.getSearchDataFromJsonDone(data2[0]);
		}
		if(data3){
			CONTENTVIEW_CALLAPI.getJsonDataPageTitleDone(data3[0]);
		}
		if(data4){
			CONTENTVIEW_CALLAPI.getJsonDataType4Done(data4[0]);
		}
		if(data5){
			CONTENTVIEW_CALLAPI.getJsonDataType5Done(data5[0]);
		}
		if(data6){
61
			console.log(data6[0]);
62 63 64 65 66 67 68 69 70
			CONTENTVIEW_CALLAPI.getDataJsonFileDone(data6[0]);
		}
		if(data7){
			CONTENTVIEW_CALLAPI.webGetContentPageSizeDone(data7[0]);
		}
		if(doneFunc){
			doneFunc();
		}
	});
71

72 73 74
};
//END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content

75 76
//未使用
CONTENTVIEW_CALLAPI.webGetPageImageContentSize = function() {
77

Masaru Abe committed
78 79
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
80
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
81 82
    		isStreaming: ClientData.isStreamingMode()
    };
83

84
	AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
85 86
	     "webContentPageSize",
	     "GET",
87
	     { contentId: CONTENTVIEW_GENERAL.contentID, sid: CONTENTVIEW.getSessionId() },
88
	     function (data) {
89 90
	    	 CONTENTVIEW_GENERAL.widthContentImage = data.width;
	    	 CONTENTVIEW_GENERAL.heightContentImage = data.height;
91 92 93 94
	     },
	     null);
};

95
CONTENTVIEW_CALLAPI.webGetContentPageSizeWhen = function(){
96

Masaru Abe committed
97 98
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
99
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
100 101 102
    		getType: 6,
    		isStreaming: ClientData.isStreamingMode()
    };
103

104 105 106 107 108 109
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
110

111 112 113 114 115 116 117
};

CONTENTVIEW_CALLAPI.webGetContentPageSizeDone = function(data){
	if( data.contentData.pageInfoData.pagesInfo ){
		$.each(data.contentData.pageInfoData.pagesInfo, function(i, n){
			CONTENTVIEW_GENERAL.contentPageSizeArr.push(n);
		});
118

119 120 121 122 123
		//Get Page size of firstPage
		CONTENTVIEW_CALLAPI.getPageSizeByPageNo(1);
	} else {
		CONTENTVIEW.showErrorScreen();
	}
124 125 126
};

//Get Pagesize by pageNo
127 128 129
CONTENTVIEW_CALLAPI.getPageSizeByPageNo = function(pageNo){
    for(var i = 0; i < CONTENTVIEW_GENERAL.contentPageSizeArr.length; i++){
        var page = CONTENTVIEW_GENERAL.contentPageSizeArr[i];
130 131

        if(page.pageNo == pageNo){
132
        	CONTENTVIEW_GENERAL.widthContentImage = page.pageWidth;
133
        	CONTENTVIEW_GENERAL.heightContentImage = page.pageHeight;
134 135 136 137
        }
    }
};

138
CONTENTVIEW_CALLAPI.webGetContentDataWhen = function() {
139

Masaru Abe committed
140 141
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
142
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
143 144 145
    		getType: 1,
    		isStreaming: ClientData.isStreamingMode()
    };
146

147 148 149 150 151 152
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
153

154 155 156 157
};

CONTENTVIEW_CALLAPI.webGetContentDataDone = function(data) {
	 CONTENTVIEW_GENERAL.totalPage = data.contentData.allPageNum;
158 159 160
};

/* get Json stored page title */
161
CONTENTVIEW_CALLAPI.getJsonDataPageTitleWhen = function() {
162

Masaru Abe committed
163 164
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
165
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
166 167 168
    		getType: 3,
    		isStreaming: ClientData.isStreamingMode()
    };
169

170 171 172 173 174 175
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
176

177 178 179 180 181 182 183 184 185 186 187 188 189
};

CONTENTVIEW_CALLAPI.getJsonDataPageTitleDone = function(data) {
	 CONTENTVIEW_GENERAL.dataPageTitle = [];
     for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.totalPage; nIndex++) {
    	 CONTENTVIEW_GENERAL.dataPageTitle.push("");
     }
     if (data.contentData) {

         if (data.contentData.titleInfo) {
        	 CONTENTVIEW_GENERAL.dataPageTitle = data.contentData.titleInfo;
         }
     }
190 191 192
};

/* get Json webGetContent4 */
193
CONTENTVIEW_CALLAPI.getJsonDataType4When = function() {
194

Masaru Abe committed
195 196
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
197
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
198 199 200
    		getType: 4,
    		isStreaming: ClientData.isStreamingMode()
    };
201

202 203 204 205 206 207
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
208

209 210 211 212
};

CONTENTVIEW_CALLAPI.getJsonDataType4Done = function(data) {
	 CONTENTVIEW_GENERAL.dataJsonType4 = data.contentData.linkData;
213 214 215
};

/* get Json webGetContent5 */
216
CONTENTVIEW_CALLAPI.getJsonDataType5When = function() {
217

Masaru Abe committed
218 219
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
220
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
221 222 223
    		getType: 5,
    		isStreaming: ClientData.isStreamingMode()
    };
224

225 226 227 228 229 230
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
231

232 233 234 235
};

CONTENTVIEW_CALLAPI.getJsonDataType5Done = function(data) {
	 CONTENTVIEW_GENERAL.dataJsonType5 = data.contentData.outlineData;
236 237 238
};

/* read file Json -> get page objects */
239
CONTENTVIEW_CALLAPI.getDataJsonFileWhen = function() {
240

Masaru Abe committed
241 242
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
243
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
244 245 246
    		getType: 2,
    		isStreaming: ClientData.isStreamingMode()
    };
247

248 249 250 251 252 253
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webGetContent",
    		"GET",
    		params
    );
254

255 256 257
};

CONTENTVIEW_CALLAPI.getDataJsonFileDone = function(data) {
258

259 260 261 262 263
    var JsonFile = data.contentData;
    CONTENTVIEW_GENERAL.pageObjectsData = [];
    if (JsonFile.vertical) {
        if (JsonFile.vertical.pages) {
       	 CONTENTVIEW_GENERAL.pageObjectsData = JsonFile.vertical.pages;
264 265 266

            //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
            if(data.contentDataSub != null && data.contentDataSub.length > 0){
267 268 269
                for(var i = 0; i < CONTENTVIEW_GENERAL.pageObjectsData.length; i++){
                    var obj = CONTENTVIEW_GENERAL.pageObjectsData[i];
                    obj["contentDataSub"] = data.contentDataSub;
270
                }
271 272 273 274 275 276 277
            }
            //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
        }
    }
    else if (JsonFile.horizontal) {
        if (JsonFile.horizontal.pages) {
       	 CONTENTVIEW_GENERAL.pageObjectsData = JsonFile.horizontal.pages;
278 279
            //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
            if(data.contentDataSub != null && data.contentDataSub.length > 0){
280 281 282
                for(var i = 0; i < CONTENTVIEW_GENERAL.pageObjectsData.length; i++){
                    var obj = CONTENTVIEW_GENERAL.pageObjectsData[i];
                    obj["contentDataSub"] = data.contentDataSub;
283
                }
284
            }
285
            //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
286 287 288 289 290
        }
    }
    //Start : Function : No.12 - Editor : Long - Date: 08/27/2013 - Summary : Get Page Object for content type none
    else{
   	 CONTENTVIEW_GENERAL.pageObjectsData = JsonFile.content.pages;
291 292

        if(data.contentDataSub != null && data.contentDataSub.length > 0){
293 294 295
            for(var i = 0; i < CONTENTVIEW_GENERAL.pageObjectsData.length; i++){
                var obj = CONTENTVIEW_GENERAL.pageObjectsData[i];
                obj["contentDataSub"] = data.contentDataSub;
296
            }
297 298
        }
    }
299

300 301
    //Get Data Of page to draw page
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
302

303 304 305 306 307 308
        var pageDataInfo = [];
        pageDataInfo["height"] = JsonFile.height;
        pageDataInfo["width"] = JsonFile.width;
        pageDataInfo["alpha"] = JsonFile.backgroundAlpha;
        pageDataInfo["color"] = JsonFile.backgroundColor;
        CONTENTVIEW_GENERAL.totalPage = parseInt(JsonFile.totalPageNum);
309

310 311 312
        CONTENTVIEW_GENERAL.pageImages = CONTENTVIEW_CONTENTTYPENONE.returnImageString(pageDataInfo);
        CONTENTVIEW_GENERAL.widthContentImage = JsonFile.width;
        CONTENTVIEW_GENERAL.heightContentImage = JsonFile.height;
313 314
    }

315 316 317
    //End : Function : No.12 - Editor : Long - Date: 08/27/2013 - Summary : Get Page Object for content type none

    CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
318

319
};
320 321 322

CONTENTVIEW_CALLAPI.loadDataBookmark = function(lstPageNo) {
    if (CONTENTVIEW_GENERAL.isSendingData == true) {
323

Masaru Abe committed
324 325
        var params = {
        		contentId: CONTENTVIEW_GENERAL.contentID,
326
        		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
327 328 329 330
        		pageNos: lstPageNo[0],
        		thumbnailFlg: 1,
        		isStreaming: ClientData.isStreamingMode()
        };
331

332
    	AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
333 334
		     "webContentPage",
		     "GET",
Masaru Abe committed
335
		     params,
336
		     function (data) {
337
		    	 CONTENTVIEW_GETDATA.getDataLoaded(data.pages);
338 339 340

		         //Resize Image
		         var imgTemp = new Image();
341
		         $('#img_bookmark_' + data.pages[0].pageNo).attr('src', COMMON.formatStringBase64(data.pages[0].pageThumbnail));
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357

		         imgTemp.onload = function () {

		             if (imgTemp.width > imgTemp.height) {

		                 $("img.imgbox").attr('height', '');
		                 $("img.imgbox").removeAttr('height');
		                 $("img.imgbox").attr('width', '43');
		             }
		             else {
		                 $("img.imgbox").attr('width', '');
		                 $("img.imgbox").removeAttr('width');
		                 $("img.imgbox").attr('height', '43');
		             }
		         };

358
		         imgTemp.src = COMMON.formatStringBase64(data.pages[0].pageThumbnail);
359 360 361 362 363 364

		         lstPageNo = jQuery.grep(lstPageNo, function (value) {
		             return value != lstPageNo[0];
		         });

		         if (lstPageNo.length > 0) {
365
		        	 CONTENTVIEW_CALLAPI.loadDataBookmark(lstPageNo);
366
		         } else {
367
		        	 CONTENTVIEW_GENERAL.isSendingData = false;
368 369 370 371 372 373 374
		         }
		     },
		     null);
    }
};

/* get data using for search */
375
CONTENTVIEW_CALLAPI.getSearchDataFromJsonWhen = function() {
376 377 378
    //get data from JSON file

    var arrPageNo = '';
379
    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.totalPage; nIndex++) {
380 381 382 383 384 385
        if (nIndex == 0) {
            arrPageNo += (nIndex + 1);
        } else {
            arrPageNo += "," + (nIndex + 1);
        }
    }
386

Masaru Abe committed
387 388
    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
389
    		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
390 391 392
    		thumbnailFlg: 0,
    		isStreaming: ClientData.isStreamingMode()
    };
393

394 395 396 397 398 399
    return AVWEB._callCmsApiWhen(
    		ClientData.userInfo_accountPath(),
    		"webContentPage",
    		"GET",
    		params
    );
400

401
};
402

403 404 405
CONTENTVIEW_CALLAPI.getSearchDataFromJsonDone = function(data) {
	CONTENTVIEW_GENERAL.contentName = data.contentTitle;
	CONTENTVIEW_GENERAL.dataWebContentPage = data;
406 407
};

408 409
CONTENTVIEW_CALLAPI.loadDataSearch = function(lstPageNo) {
    if (CONTENTVIEW_GENERAL.isSendingData == true) {
410

Masaru Abe committed
411 412
        var params = {
        		contentId: CONTENTVIEW_GENERAL.contentID,
413
        		sid: CONTENTVIEW.getSessionId(),
Masaru Abe committed
414 415 416 417
        		pageNos: lstPageNo[0],
        		thumbnailFlg: 1,
        		isStreaming: ClientData.isStreamingMode()
        };
418

419
    	AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
420 421
		     "webContentPage",
		     "GET",
Masaru Abe committed
422
		     params,
423
		     function (data) {
424
		    	 CONTENTVIEW_GETDATA.getDataLoaded(data.pages);
425 426 427

		         //Resize Image
		         var imgTemp = new Image();
428
		         $('#img_search_' + data.pages[0].pageNo).attr('src', COMMON.formatStringBase64(data.pages[0].pageThumbnail));
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444

		         imgTemp.onload = function () {

		             if (imgTemp.width > imgTemp.height) {

		                 $("img.imgbox").attr('height', '');
		                 $("img.imgbox").removeAttr('height');
		                 $("img.imgbox").attr('width', '43');
		             }
		             else {
		                 $("img.imgbox").attr('width', '');
		                 $("img.imgbox").removeAttr('width');
		                 $("img.imgbox").attr('height', '43');
		             }
		         };

445
		         imgTemp.src = COMMON.formatStringBase64(data.pages[0].pageThumbnail);
446 447 448 449 450 451

		         lstPageNo = jQuery.grep(lstPageNo, function (value) {
		             return value != lstPageNo[0];
		         });

		         if (lstPageNo.length > 0) {
452
		        	 CONTENTVIEW_CALLAPI.loadDataSearch(lstPageNo);
453
		         } else {
454
		        	 CONTENTVIEW_GENERAL.isSendingData = false;
455 456 457 458 459 460
		         }
		     },
		     null);
    }
};

461 462 463
CONTENTVIEW_CALLAPI.ready = function(){
};