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 61 62 63 64 65 66 67 68 69
	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){
			CONTENTVIEW_CALLAPI.getDataJsonFileDone(data6[0]);
		}
		if(data7){
			CONTENTVIEW_CALLAPI.webGetContentPageSizeDone(data7[0]);
		}
		if(doneFunc){
			doneFunc();
		}
	});
70

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

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

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

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

94
CONTENTVIEW_CALLAPI.webGetContentPageSizeWhen = function(){
95

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

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

110 111 112 113 114 115 116
};

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

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

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

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

137
CONTENTVIEW_CALLAPI.webGetContentDataWhen = function() {
138

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

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

153 154 155 156
};

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

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

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

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

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

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;
         }
     }
189 190 191
};

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

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

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

208 209 210 211
};

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

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

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

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

231 232 233 234
};

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

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

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

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

254 255 256
};

CONTENTVIEW_CALLAPI.getDataJsonFileDone = function(data) {
257

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

            //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
            if(data.contentDataSub != null && data.contentDataSub.length > 0){
266 267 268
                for(var i = 0; i < CONTENTVIEW_GENERAL.pageObjectsData.length; i++){
                    var obj = CONTENTVIEW_GENERAL.pageObjectsData[i];
                    obj["contentDataSub"] = data.contentDataSub;
269
                }
270 271 272 273 274 275 276
            }
            //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;
277 278
            //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
            if(data.contentDataSub != null && data.contentDataSub.length > 0){
279 280 281
                for(var i = 0; i < CONTENTVIEW_GENERAL.pageObjectsData.length; i++){
                    var obj = CONTENTVIEW_GENERAL.pageObjectsData[i];
                    obj["contentDataSub"] = data.contentDataSub;
282
                }
283
            }
284
            //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
285 286 287 288 289
        }
    }
    //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;
290 291

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

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

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

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

314 315 316
    //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);
317

318
};
319 320 321

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

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

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

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

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

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

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

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

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

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

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

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

400
};
401

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

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

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

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

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

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

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

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

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

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