common.js 112 KB
Newer Older
1 2 3 4 5 6
/**
 *  ABook Viewer for WEB
 *  common package
 *
 *  Copyright (C) Agentec Co, Ltd. All rights reserved.
 */
7

Masaru Abe committed
8 9 10
//グローバルの名前空間用のオブジェクトを用意する
var COMMON = {};

11 12
COMMON.registerLogBusyFlag = false;

Masaru Abe committed
13 14 15
COMMON.resourceVersionArr = [];
COMMON.metaVersionArr = [];

16 17 18 19 20 21 22 23 24 25 26 27
COMMON.DEFAULT_IMG_OPTION_MEMO = 'img/list/icon_sticker.png';
COMMON.DEFAULT_IMG_OPTION_MARKING = 'img/list/icon_pen.png';
COMMON.DEFAULT_IMG_CONTENT_EDIT = 'img/common/band_updated.png';
COMMON.DEFAULT_IMG_CONTENT_NEW = 'img/common/band_new.png';

COMMON.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',
    Thumbnail_HtmlType :  'img/thumb_default_html.png',
28
    Thumbnail_LinkType : 'img/thumb_default_link.png'
29 30
};

Masaru Abe committed
31 32
//1メガのバイト数定数
COMMON.MB_BYTE = 1048576;
33

34 35 36
// =============================================================================================
// Constants [start]
// =============================================================================================
37
COMMON.Consts = {
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 70 71 72 73
    // Display mode: 1 -> Bookshelf
    ConstDisplayMode_BookShelf: 1,
    // Display mode: 0 -> List
    ConstDisplayMode_List: 2,

    // Order setting: 1 -> ascending
    ConstOrderSetting_Asc: 1,

    // Order setting: 0 -> descending
    ConstOrderSetting_Desc: 2,

    // Language: English
    ConstLanguage_En: "en",
    // Language: Japanese
    ConstLanguage_Ja: "ja",
    // Language: Korean
    ConstLanguage_Ko: "ko",

    // API result: success
    ConstAPI_SUCCESS: "success",
    // API result: fail
    ConstAPI_FAIL: "fail",

    // 初回ログイン時パスワード強制変更: 0:なし
    ConstServiceOption_NON: 0,
    // 初回ログイン時パスワード強制変更: 1:催促
    ConstServiceOption_REGULAR: 1,
    // 初回ログイン時パスワード強制変更: 2:強制
    ConstServiceOption_FORCE: 2,

    // Lock screen timer
    ConstLockScreenTime: 1800000
    
};

/*Content Type Keys*/
74
COMMON.ContentTypeKeys = {
75 76 77 78 79 80 81
    Type_PDF : 'pdf',
    Type_Image : 'image',
    Type_Video : 'movie',
    Type_Music : 'music',
    Type_Others : 'other',
    Type_NoFile : 'none',
    Type_Html: 'html',
82 83
    Type_Enquete : 'enquete',
    Type_Link : 'url'
84 85 86 87 88
};

/*
    Define short keys for content view
*/
89
COMMON.ShortKeys = {
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
    // Move previous: arrow left <-
    MovePrevious: 37,
    // Move next: arrow right ->
    MoveNext: 39,
    // Zoom in: ","
    ZoomIn: 188,
    // Zoom out: "."
    ZoomOut: 190,
    // Fit: Enter
    ZoomFit: 13,
    // Show, hide toolbar: "["
    ShowHideToolbar: 219,
    // Show, hide marking: "]"
    ShowHideMarking: 221,
    // Zoom out : "-"
    ZoomOutAlt: 189,
    //Zoom in: "+"
    ZoomInAlt: 187,
    //Zoom out: "-" firefox/opera
    ZoomOutAlt_Firefox: 173,
    //Zoom in : "+" firefox/opera
    ZoominAlt_Firefox: 59
};

// -------------------------------------------------
// Define all keys for local/session storage [start]
// -------------------------------------------------

118
COMMON.ScreenIds = {
119
    Login: './../login.html',
120 121 122 123 124
    Home : 'home.html?__UPDATEID__',
    ContentView : 'contentview.html?__UPDATEID__',
    Setting : 'settings.html?__UPDATEID__',
    BookmarkList : 'bookmark.html?__UPDATEID__',
    ContentSearch : 'contentsearch.html?__UPDATEID__',
Masaru Abe committed
125 126
    History: 'history.html?__UPDATEID__',
    ContentViewStreaming : 'contentview_streaming.html?__UPDATEID__',
127 128
};

129
COMMON.Keys = {
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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
    zoom_ratioPre: 'zoom_ratioPre',

    IsRefresh: 'IsRefresh',
    // Local
    BookmarkScreen: 'BookmarkScreen',
    // Local
    IsJumpBack: 'IsJumpBack',
    // Local:
    JumpQueue: 'JumpQueue',
    // Local
    ContentViewDetail: 'ContentViewDetail',
    // Session
    userInfo_userName: 'userInfo_userName',
    // Local
    ContentLogData: 'ContentLogData',
    // Session: true/false
    IsLocked: 'IsLocked',
    // Local: true/false
    IsHideToolbar: 'IsHideToolbar',
    // Local: true/false
    IsAddingMemo: 'IsAddingMemo',
    // Local: true/false
    IsAddingMarking: 'IsAddingMarking',
    // Local: true/false
    IsDisplayMarking: 'IsDisplayMarking',
    // Local: true/false
    IsDisplayMemo: 'IsDisplayMemo',
    // Local
    MarkingType: 'MarkingType',
    // Local
    ReadingContentIds: 'ReadingContentIds',
    // Local
    BookMarkData: 'BookMarkData',
    // Local
    MarkingData: 'MarkingData',
    // Local
    MemoData: 'MemoData',
    // Local
    ResourceVersion: 'ResourceVersion',
    // Local
    MetaVersion: 'MetaVersion',

    // Local :ユーザオプション(userOpt)_ログアウトモード: Interger(0:logout with backup, 1:logout without backup)
    userOpt_logoutMode: 'logoutMode',

    // Session :コンテンツ詳細情報(contentInfo)_サムネール: String (base64string)
    contentInfo_contentThumbnail: 'contentInfo_contentThumbnail',

    // Local: isChangedMemo: boolean (true: changed, false: not change)
    isChangedMemo: 'isChangedMemo',
    // Local: isChangedMakingData: boolean (true: changed, false: not change)
    isChangedMarkingData: 'isChangedMarkingData',
    // Local: isChangedBookmark: boolean (true: changed, false: not change)
    isChangedBookmark: 'isChangedBookmark',

    // Session:パスワード要変更(requirePasswordChange):String (0:不要, 1:初回, 2:定期変更)
    requirePasswordChange: 'requirePasswordChange',

    /* -------------------------------------------------------------------------------- */
    // Session:ユーザ情報(userInfo)_セッションID:String
    userInfo_sid: 'sid',
    // Session :事業者オプション(serviceOpt)_初回ログイン時パスワード強制変更:Integer(0:なし, 1:催促, 2:強制)
    serviceOpt_force_pw_change_on_login: 'force_pw_change_on_login',
    // Session :事業者オプション(serviceOpt)_定期ログイン時パスワード強制変更:Integer(0:なし, 1:催促, 2:強制)
    serviceOpt_force_pw_change_periodically: 'force_pw_change_periodically',
    // Session:事業者オプション(serviceOpt)_メモ・マーキングデータバックアップ使用:Char(Y:可能, N:不可)
    serviceOpt_user_data_backup: 'user_data_backup',
    // Session :事業者オプション(serviceOpt)_マーキング機能使用:Char(Y:可能, N:不可)
    serviceOpt_marking: 'marking',
    // No.8: do not use this value: serviceOpt_force_login_periodically
    // Session :事業者オプション(serviceOpt)_一定期間経過後アプリロック:Char(Y:可能, N:不可)
    //serviceOpt_force_login_periodically: 'force_login_periodically',
    // No.8: スクリーンロック
    // Session :事業者オプション(serviceOpt)_スクリーンロック(Web版):Char(Y:可能, N:不可)
    serviceOpt_web_screen_lock: 'web_screen_lock',
    // Session :事業者オプション(serviceOpt)_スクリーンロック待ち時間:Interger
    serviceOpt_web_screen_lock_wait: 'web_screen_lock_wait',
207
    // Session :事業者オプション(serviceOpt)_GPS使用可:Char(Y:可能, N:不可)
Masaru Abe committed
208
    serviceOpt_usable_readinglog_gps: 'usable_readinglog_gps',
209
    // Session :事業者オプション(serviceOpt)_詳細ログ使用可:Char(Y:可能, N:不可)
Masaru Abe committed
210
    serviceOpt_usable_readinglog_object: 'usable_readinglog_object',
211 212 213
    // Session :事業者オプション(serviceOpt)_カタログエディション:Char(Y:可能, N:不可)
    serviceOpt_catalog_edition: 'catalog_edition',
    // Session :事業者オプション(serviceOpt)_日比谷カスタム:Char(Y:可能, N:不可)
Masaru Abe committed
214
    serviceOpt_hibiyakadan_catalog: 'hibiyakadan_catalog',
215 216
    // Session :事業者オプション(serviceOpt)_DHカスタム:Char(Y:可能, N:不可)
    serviceOpt_daihatsu: 'daihatsu',
217 218 219 220
    // Session :事業者オプション(serviceOpt)_getits向けGPS使用可:Char(Y:可能, N:不可)
    serviceOpt_reader_usable_readinglog_gps: 'reader_usable_readinglog_gps',
    // Session :事業者オプション(serviceOpt)_getits向け詳細ログ使用可:Char(Y:可能, N:不可)
    serviceOpt_reader_readinglog_object: 'reader_readinglog_object',
Masaru Abe committed
221 222 223
    // Session :事業者オプション(serviceOpt)_コンテンツ共有モード:Interger(0:なし , 1:ABook, 2:getits)
    serviceOpt_content_share: 'content_share',
    
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 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 268 269 270 271 272 273 274 275 276
    // Session :共通(common)_コンテンツID:Integer
    common_contentId: 'common_contentId',
    // Local :共通(common)_コンテンツID:Integer
    common_preContentId: 'common_preContentId',
    // Session: 共通(common)_コンテンツデータチェックフラグ: Integer(true/false, true:メモ、マーキング、しおりを削除する処理を行える false:メモ、マーキング、しおりを削除する処理をしない)
    common_contentDataChkFlg: 'common_contentDataChkFlg',
    // Session :ページ情報データ(pageInfo)_ページNo:Integer
    pageInfo_pageNo: 'pageInfo_pageNo',
    // Local :ページ情報データ(pageInfo)_ページNo:Integer
    common_prePageNo: 'common_prePageNo',
    // Session :ページ情報データ(pageInfo)_ページテキスト:String
    pageInfo_pageText: 'pageText',
    // Session :ページ情報データ(pageInfo)_コンテンツサムネイル:Integer
    pageInfo_pageImgResrcId: 'pageImgResrcId',
    // Session :コンテンツ内リンク(linkInfo)_リンク位置のx座標:Integer
    linkInfo_linkLocationX: 'linkLocationX',
    // Session :コンテンツ内リンク(linkInfo)_リンク位置のy座標:Integer
    linkInfo_linkLocationY: 'linkLocationY',
    // Session :コンテンツ内リンク(linkInfo)_リンク領域の幅:Integer
    linkInfo_linkLocationWidth: 'linkLocationWidth',
    // Session :コンテンツ内リンク(linkInfo)_リンク領域の高さ:Integer
    linkInfo_linkLocationHeight: 'linkLocationHeight',
    // Session :コンテンツ内リンク(linkInfo)_リンクタイプ:Integer(0/1)
    linkInfo_linkKind: 'linkKind',
    // Session :コンテンツ内リンク(linkInfo)_ターゲットURI:String(0/1)
    linkInfo_destURI: 'destURI',
    // Session :コンテンツ内リンク(linkInfo)_ターゲットページNo:Integer(0/1)
    linkInfo_destPageNumber: 'linkInfo_destPageNumber',
    // Session :閲覧ログ(log)_コンテンツ閲覧開始時刻:Datetime
    log_contentStartViewDt: 'contentStartViewDt',
    // Session :コンテンツ詳細情報(contentInfo)_コンテンツID:Integer
    contentInfo_contentId: 'contentInfo_contentId',
    // Session :コンテンツ詳細情報(contentInfo)_カテゴリID:Integer
    contentInfo_categoryId: 'categoryId',
    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ名:String
    contentInfo_contentName: 'contentName',
    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ名(カナ):String
    contentInfo_contentNameKana: 'contentNameKana',
    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ詳細:String
    contentInfo_contentDetail: 'contentDetail',
    // Session :コンテンツ詳細情報(contentInfo)_公開開始日:Datetime
    contentInfo_deliveryStartDate: 'deliveryStartDate',
    // Session :コンテンツ詳細情報(contentInfo)_公開終了日:Datetime
    contentInfo_deliveryEndDate: 'deliveryEndDate',
    // Session :コンテンツ詳細情報(contentInfo)_本棚サムネール名:Interger
    contentInfo_thumbnailName: 'thumbnailName',
    // Session :コンテンツ詳細情報(contentInfo)_詳細画面サムネール名:Interger
    contentInfo_thumbnailBigName: 'thumbnailBigName',
    // Session :コンテンツ詳細情報(contentInfo)_メタ更新バージョン:Interger
    contentInfo_metaVersion: 'contentInfo_metaVersion',
    // Session :コンテンツ詳細情報(contentInfo)_リソース更新バージョン:Interger
    contentInfo_resourceVersion: 'contentInfo_resourceVersion',
    // Session :コンテンツ詳細情報(contentInfo)_PDF総ページ数:Interger
Masaru Abe committed
277
    contentInfo_allPageNum: 'contentInfo_allPageNum',
278
    // Session :(contentType):String
Masaru Abe committed
279
    contentInfo_contentType: 'contentInfo_contentType',
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
    // Session :検索条件(searchCond)_検索テキスト:String
    searchCond_searchText: 'searchText',
    // Session :検索条件(searchCond)_検索区分:Interger(1:コンテンツ検索, 2:タグ検索, 3:全文検索)
    searchCond_searchDivision: 'searchCond_searchDivision',
    // Session :検索条件(searchCond)_ソート基準:Interger(1:タイトル名, 2:タイトル名(かな), 3:公開順)
    searchCond_sortType: 'searchCond_sortType',
    // Session :検索条件(searchCond)_ソート方法:Interger(1:昇順, 2:降順)
    searchCond_sortOrder: 'sortOrder',
    // Session :検索条件(searchCond)_レコードFrom:Interger
    searchCond_recordFrom: 'recordFrom',
    // Session :検索条件(searchCond)_レコードTo:Interger
    searchCond_recordTo: 'recordTo',
    // Session :検索条件(searchCond)_カテゴリID:Interger
    searchCond_genreId: 'genreId',
    // Session :検索条件(searchCond)_グループID:Interger
    searchCond_groupId: 'groupId',
    // Session :通知情報(pushInfo)_新着件数:Interger
    pushInfo_newMsgNumber: 'pushInfo_newMsgNumber',
    // Local :ペン書式設定(penOpt)_色:String
    penOpt_color: 'penOpt_color',
    // Local :ペン書式設定(penOpt)_サイズ:Interger
    penOpt_size: 'penOpt_size',
    // Local :マーカ書式設定(maker)_色:String
    maker_color: 'maker_color',
    // Local :マーカ書式設定(maker)_サイズ:Interger
    maker_size: 'maker_size',
    // Local :消しゴム書式設定(erase)_色:String
    erase_color: 'erase_color',
    // Local :消しゴム書式設定(erase)_サイズ:Interger
    erase_size: 'erase_size',
    // Local :ユーザ情報(userInfo)_ログインID:String
    userInfo_loginId: 'loginId',
    // Local :ユーザ情報(userInfo)_アカウントパス:String
    userInfo_accountPath: 'accountPath',
    // Local :ユーザ情報(userInfo)_アカウント情報記憶フラグ:Char(Y:可能, N:不可)
    userInfo_rememberLogin: 'rememberLogin',
    // Local :ユーザ情報(userInfo)_最終ログイン日時:Datetime
    userInfo_lastLoginTime: 'lastLoginTime',
    // Local :ユーザ情報(userInfo)_パスワードスキップ日時:Datetime
    userInfo_pwdSkipDt: 'pwdSkipDt',
    // Local :ユーザオプション(userOpt)_動画繰り返しフラグ:Interger(0: 繰り返しなし, 1: 繰り返しあり)
    userOpt_videoMode: 'videoMode',
    // Local :ユーザオプション(userOpt)_音楽繰り返しフラグ:Interger(0: 繰り返しなし, 1: 繰り返しあり)
    userOpt_musicMode: 'musicMode',
    // Local :ユーザオプション(userOpt)_マーキング表示設定:Interger(0:表示しない, 1:表示する)
    userOpt_makingDsp: 'makingDsp',
    // Local :ユーザオプション(userOpt)_アラート表示設定:Interger(0:表示しない, 1:表示する)
    userOpt_closeOrRefreshAlert: 'userOpt_closeOrRefreshAlert',
    // Local :ユーザオプション(userOpt)_バックアップ確認フラグ:Interger(0:する, 1:しない)
    userOpt_bkConfirmFlg: 'bkConfirmFlg',
    // Local :並び順(sortOpt)_表示モード:Interger(0:本棚, 1:リスト)
    sortOpt_viewMode: 'viewMode',
    // Local :並び順(sortOpt)_表示区分:Interger(0:ジャンル, 1:グループ)
    sortOpt_viewType: 'viewType',
    // Local :並び順(sortOpt)_ソート基準:Interger(1:コンテンツ検索, 2:タグ検索, 3:全文検索)
    sortOpt_searchDivision: 'sortOpt_searchDivision',
    // Local: 並び順(sortOpt)_ソート方法:Interger(1:タイトル名, 2:タイトル名(かな), 3:公開順)
    sortOpt_sortType: 'sortOpt_sortType',
    // Local :しおりデータ(bookmark)_ページNo:Interger
    bookmark_pageNo: 'bookmark_pageNo',
    // Local :メモデータ(memo)_コンテンツID:Interger
    memo_contentNo: 'memo_contentNo',
    // Local :メモデータ(memo)_ページNo:Interger
    memo_pageNo: 'memo_pageNo',
    // Local :メモ(memo)_CopyText:String
    memo_copyText: 'memo_copyText',
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_マーキング:Interger
    userOpt_bkMakingFlag: 'userOpt_bkMakingFlag',
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_メモ:Interger
    userOpt_bkMemoFlag: 'userOpt_bkMemoFlag',
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_しおり:Interger
    userOpt_bkShioriFlag: 'userOpt_bkShioriFlag',
	// Local :ユーザオプション(userOpt)_ビューのアニメーション種類:Interger
    userOpt_pageTransition: 'userOpt_pageTransition',
	// Local :ユーザオプション(userOpt)_アニメーション時間:Float
Masaru Abe committed
355 356 357
    userOpt_pageTransitionPeriod: 'userOpt_pageTransitionPeriod',
	
	isGetitsMode: 'isGetitsMode',
Masaru Abe committed
358
	isStreamingMode: 'isStreamingMode',
Masaru Abe committed
359 360
	conf_apiUrl: 'conf_apiUrl',
	conf_apiLoginUrl: 'conf_apiLoginUrl',
Masaru Abe committed
361
	conf_apiResourceDlUrl: 'conf_apiResourceDlUrl',
362
	
Masaru Abe committed
363
	latitude: 'latitude',
Masaru Abe committed
364 365 366 367 368
	longitude: 'longitude',
	//ダイハツカスタム グループ認証コード
	authCode: 'authCode',
	authGroupName: 'authGroupName',
	authGroupId: 'authGroupId'
369 370 371 372 373 374 375 376 377 378 379 380 381 382
    /* -------------------------------------------------------------------------------- */
    
};

// Entity for Bookmark
function BookMarkEntity() {
    this.contentid = "";
    this.pageNo = 0;
    // More info
    this.contentTitle = "";
    this.contentTitleKana = "";
    this.registerDate = new Date();
	
	//Add for phase2
Masaru Abe committed
383
	this.bookmarkid = "";
384 385 386 387 388 389 390 391 392 393 394
};

// Entity for Memo
function MemoEntity() {
    this.contentid=  "";
    this.pageNo = 0;
    this.posX = -1;
    this.posY = -1;
    this.Text = "";
	
	//Add for phase2
Masaru Abe committed
395
	this.memoid = "";
396 397 398 399 400 401 402 403 404 405
	this.registerDate = new Date();
};

// Entity for marking
function MarkingEntity() {
    this.contentid = "";
    this.pageNo = -1;
    this.content = "";
	
	//Add for phase2
Masaru Abe committed
406
	this.markingid = "";
407 408 409 410 411 412 413 414 415
	this.registerDate = new Date();
};
// Entity for log
function LogEntity() {
    this.contentid = "";
    this.readingStartDate = new Date();
    this.readingEndDate = null;
    this.readingTime = 0;
    this.deviceTypeId = 4;
Masaru Abe committed
416 417 418
    //GPS
    this.latitude = '';
    this.longitude = '';
419 420 421 422 423 424 425 426 427 428 429 430
    //ページログ配列
    this.pageLogArray = [];
    //詳細ログ配列
    this.objectLogArray = [];
};
// Entity for PageLog
function PageLogEntity(){
    this.contentid = "";
    this.pageNo = 1;
    this.readingStartDate = new Date();
    this.readingEndDate = null;
    this.readingTime = 0;
431
};
Masaru Abe committed
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
// Entity for ObjectLog
function ObjectLogEntity(){
    this.contentid = "";
    this.actionDate = new Date();
    this.pageNo = 1;
    this.objectId = "";
    this.resourceId = "";
    this.mediaType = "";
    this.actionType = "";
    this.actionValue = "";
    this.actionTime = "0";
    this.locationX = "";
    this.locationY = "";
    this.locationHeight = "";
    this.locationWidth = "";
};
448

449 450 451
/*
 * Extract memo data from result of API and merge with local memo
 */
Masaru Abe committed
452
COMMON.getDataMemo = function(jsonString) {
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
    var memoDataFromServer = jsonString.data;

    var arrLocalMemo = ClientData.MemoData();
    
    for (var i = 0; i < memoDataFromServer.length; i++) {
        var objServerMemo = new MemoEntity();
        objServerMemo.contentid = memoDataFromServer[i].contentid;
        objServerMemo.pageNo = memoDataFromServer[i].pageNo;
        objServerMemo.posX = memoDataFromServer[i].posX;
        objServerMemo.posY = memoDataFromServer[i].posY;
        objServerMemo.Text = memoDataFromServer[i].Text;

        //Add for phase2
        objServerMemo.memoid = memoDataFromServer[i].memoid;  // UUID
        objServerMemo.registerDate = memoDataFromServer[i].registerDate;  // UTC+0

        // Searching memoid in local that is matching with memo of server
        var nIndexFoundLocalMemo = -1;
        for (var nIndexLocalMemo = 0; nIndexLocalMemo < arrLocalMemo.length; nIndexLocalMemo++) {
            if (arrLocalMemo[nIndexLocalMemo].memoid == objServerMemo.memoid) {
                nIndexFoundLocalMemo = nIndexLocalMemo;
                break;
            }
        }
        // Found local memo that has memoid = memoid of server memo
        if (nIndexFoundLocalMemo >= 0) {

            // Local date is older than server date -> restore
            if (arrLocalMemo[nIndexFoundLocalMemo].registerDate < objServerMemo.registerDate) {

                arrLocalMemo[nIndexFoundLocalMemo].contentid = objServerMemo.contentid;
                arrLocalMemo[nIndexFoundLocalMemo].pageNo = objServerMemo.pageNo;
                arrLocalMemo[nIndexFoundLocalMemo].posX = objServerMemo.posX;
                arrLocalMemo[nIndexFoundLocalMemo].posY = objServerMemo.posY;
                arrLocalMemo[nIndexFoundLocalMemo].Text = objServerMemo.Text;
                arrLocalMemo[nIndexFoundLocalMemo].registerDate = objServerMemo.registerDate;
            }

        } else {    // Not found: [local memo].memoid = [server memo].memoid
            // Merge server memo to local
            arrLocalMemo.push(objServerMemo);
        }

    }
    ClientData.MemoData(arrLocalMemo);
};

/*
 * Extract marking data from result of API and replace to local marking
 */
Masaru Abe committed
503
COMMON.getDataMarking = function(jsonString) {
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
    var data = jsonString.data;
    var arr = ClientData.MarkingData();
    arr.clear();
    ClientData.MarkingData(arr);

    var arrMarking = [];
    for (var nIndex1 = 0; nIndex1 < data.length; nIndex1++) {
        var obj = new MarkingEntity();
        obj.contentid = data[nIndex1].contentid;
        obj.pageNo = data[nIndex1].pageNo;
        obj.content = data[nIndex1].content;

        //Add for phase2
        obj.markingid = data[nIndex1].markingid;
        obj.registerDate = data[nIndex1].registerDate;

        // Add object to client
        arrMarking.push(obj);
    }
    ClientData.MarkingData(arrMarking);
};

/*
 * Extract bookmark data from result of API and replace to local bookmark
 */
Masaru Abe committed
529
COMMON.getDataBookmark = function(jsonString) {
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
    var data = jsonString.data;
    var arr = ClientData.BookMarkData();
    arr.clear();
    ClientData.BookMarkData(arr);

    var arrBookmark = [];
    for (var nIndex1 = 0; nIndex1 < data.length; nIndex1++) {
        var obj = new BookMarkEntity();
        obj.contentid = data[nIndex1].contentid;
        obj.pageNo = data[nIndex1].pageNo;
        obj.contentTitle = data[nIndex1].contentTitle;
        obj.contentTitleKana = data[nIndex1].contentTitleKana;
        obj.registerDate = data[nIndex1].registerDate;

        //Add for phase2
        obj.bookmarkid = data[nIndex1].bookmarkid;

        // Add object to client
        arrBookmark.push(obj);
    }
    ClientData.BookMarkData(arrBookmark);
};

/*
Get data from localstorage and sessionstorage synchronization
If has any param (args.length > 0) -> setter
If has not param (args.length = 0) -> getter
. Get from session:
+ if it existed and key existed in localstorage -> return result
+ else: 
* set value from local to sessionstorage -> return value of sessionstorage if value is not empty, 
otherwise, return default result.

*/
Masaru Abe committed
564
COMMON.operateData = function(args, strKey, returnDefaultData) {
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

    if (args.length > 0) {
        var data = args[0];
        LocalStorageUtils.set(strKey, data);
        SessionStorageUtils.set(strKey, JSON.stringify(data));
    } else {
        if (SessionStorageUtils.get(strKey) != 'undefined'
            && SessionStorageUtils.get(strKey) != undefined
            && SessionStorageUtils.get(strKey) != ''
            && SessionStorageUtils.get(strKey) != null
            && SessionStorageUtils.get(strKey) != 'null') {
            if (LocalStorageUtils.existKey(strKey) == true) {
                return JSON.parse(SessionStorageUtils.get(strKey));
            }
            else {
                return returnDefaultData;
            }
        }
        else {
            if (LocalStorageUtils.existKey(strKey) == true) {
                SessionStorageUtils.set(strKey, JSON.stringify(LocalStorageUtils.get(strKey)));
                return JSON.parse(SessionStorageUtils.get(strKey));
            }
            return returnDefaultData;
        }
    }
};
var ClientData = {
    zoom_ratioPre: function (data) {
        if (arguments.length > 0) {
595
            SessionStorageUtils.set(COMMON.Keys.zoom_ratioPre, JSON.stringify(data));
596
        } else {
597 598 599 600 601 602
            if (SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre) != 'undefined'
                && SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre) != undefined
                && SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre) != ''
                && SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre) != null
                && SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre) != 'null') {
                return JSON.parse(SessionStorageUtils.get(COMMON.Keys.zoom_ratioPre));
603 604 605 606 607 608 609
            }
            return 1;
        }
    },
    // Local :ユーザ情報(userInfo)_アカウントパス:String
    userInfo_accountPath: function (data) {
        if (arguments.length > 0) {
610
        	AVWEB.avwUserSetting().set(COMMON.Keys.userInfo_accountPath, data);
611
        } else {
612
            return AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_accountPath);
613 614 615 616 617
        }
    },
    // Local: ユーザ情報(userInfo)_セッションID:String
    userInfo_sid_local: function (data) {
        if (arguments.length > 0) {
618
        	AVWEB.avwUserSetting().set(COMMON.Keys.userInfo_sid, data);
619
        } else {
620
            return AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_sid);
621 622 623 624 625
        }
    },
    // Local :ユーザ情報(userInfo)_ログインID:String
    userInfo_loginId: function (data) {
        if (arguments.length > 0) {
626
        	AVWEB.avwUserSetting().set(COMMON.Keys.userInfo_loginId, data);
627
        } else {
628
            return AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_loginId);
629 630 631 632 633
        }
    },
    // Local :ユーザ情報(userInfo)_アカウント情報記憶フラグ:Char(Y:可能, N:不可)
    userInfo_rememberLogin: function (data) {
        if (arguments.length > 0) {
634
        	AVWEB.avwUserSetting().set(COMMON.Keys.userInfo_rememberLogin, data);
635
        } else {
636
            return AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_rememberLogin);
637 638 639 640 641 642
        }
    },

    // Local 
    JumpQueue: function (data) {
        if (arguments.length > 0) {
643
            COMMON.operateData(arguments, COMMON.Keys.JumpQueue, []);
644 645
        }
        else {
646
            return COMMON.operateData(arguments, COMMON.Keys.JumpQueue, []);
647 648 649 650 651
        }
    },
    // Local
    ResourceVersion: function (data) {
        if (arguments.length > 0) {
652
            COMMON.operateData(arguments, COMMON.Keys.ResourceVersion, []);
653 654
        }
        else {
655
            return COMMON.operateData(arguments, COMMON.Keys.ResourceVersion, []);
656 657 658 659 660
        }
    },
    // Local
    ContentViewDetail: function (data) {
        if (arguments.length > 0) {
661
            COMMON.operateData(arguments, COMMON.Keys.ContentViewDetail, []);
662 663
        }
        else {
664
            return COMMON.operateData(arguments, COMMON.Keys.ContentViewDetail, []);
665 666 667 668 669
        }
    },
    // Local
    MetaVersion: function (data) {
        if (arguments.length > 0) {
670
            COMMON.operateData(arguments, COMMON.Keys.MetaVersion, []);
671 672
        }
        else {
673
            return COMMON.operateData(arguments, COMMON.Keys.MetaVersion, []);
674 675 676 677 678 679
        }
    },

    // Local
    ReadingContentIds: function (data) {
        if (arguments.length > 0) {
680
            COMMON.operateData(arguments, COMMON.Keys.ReadingContentIds, []);
681 682
        }
        else {
683
            return COMMON.operateData(arguments, COMMON.Keys.ReadingContentIds, []);
684 685 686 687 688 689
        }
    },

    // Local: Bookmark collection
    BookMarkData: function (data) {
        if (arguments.length > 0) {
690
            COMMON.operateData(arguments, COMMON.Keys.BookMarkData, []);
691 692
        }
        else {
693
            return COMMON.operateData(arguments, COMMON.Keys.BookMarkData, []);
694 695 696 697 698
        }
    },
    // Local: Marking collection
    MarkingData: function (data) {
        if (arguments.length > 0) {
699
            COMMON.operateData(arguments, COMMON.Keys.MarkingData, []);
700 701
        }
        else {
702
            return COMMON.operateData(arguments, COMMON.Keys.MarkingData, []);
703 704 705 706 707 708
        }
    },

    // Local: content log collection
    ContentLogData: function (data) {
        if (arguments.length > 0) {
709
            COMMON.operateData(arguments, COMMON.Keys.ContentLogData, []);
710 711
        }
        else {
712
            return COMMON.operateData(arguments, COMMON.Keys.ContentLogData, []);
713 714 715 716 717
        }
    },
    // Local: Memo collection
    MemoData: function (data) {
        if (arguments.length > 0) {
718
            COMMON.operateData(arguments, COMMON.Keys.MemoData, []);
719 720
        }
        else {
721
            return COMMON.operateData(arguments, COMMON.Keys.MemoData, []);
722 723 724 725 726
        }
    },
    // Local
    IsJumpBack: function (data) {
        if (arguments.length > 0) {
727
            COMMON.operateData(arguments, COMMON.Keys.IsJumpBack, undefined);
728 729
        }
        else {
730
            return COMMON.operateData(arguments, COMMON.Keys.IsJumpBack, undefined);
731 732 733 734 735
        }
    },
    // Local
    IsHideToolbar: function (data) {
        if (arguments.length > 0) {
736
            COMMON.operateData(arguments, COMMON.Keys.IsHideToolbar, undefined);
737 738
        }
        else {
739
            return COMMON.operateData(arguments, COMMON.Keys.IsHideToolbar, undefined);
740 741 742 743 744
        }
    },
    // Local
    IsAddingMarking: function (data) {
        if (arguments.length > 0) {
745
            COMMON.operateData(arguments, COMMON.Keys.IsAddingMarking, undefined);
746 747
        }
        else {
748
            return COMMON.operateData(arguments, COMMON.Keys.IsAddingMarking, undefined);
749 750 751 752 753
        }
    },
    // Local
    IsAddingMemo: function (data) {
        if (arguments.length > 0) {
754
            COMMON.operateData(arguments, COMMON.Keys.IsAddingMemo, undefined);
755 756
        }
        else {
757
            return COMMON.operateData(arguments, COMMON.Keys.IsAddingMemo, undefined);
758 759 760 761 762
        }
    },
    // Local
    IsDisplayMarking: function (data) {
        if (arguments.length > 0) {
763
            COMMON.operateData(arguments, COMMON.Keys.IsDisplayMarking, undefined);
764 765
        }
        else {
766
            return COMMON.operateData(arguments, COMMON.Keys.IsDisplayMarking, undefined);
767 768 769 770 771
        }
    },
    // Local
    IsDisplayMemo: function (data) {
        if (arguments.length > 0) {
772
            COMMON.operateData(arguments, COMMON.Keys.IsDisplayMemo, undefined);
773 774
        }
        else {
775
            return COMMON.operateData(arguments, COMMON.Keys.IsDisplayMemo, undefined);
776 777 778 779 780 781
        }
    },

    // Local
    MarkingType: function (data) {
        if (arguments.length > 0) {
782
            COMMON.operateData(arguments, COMMON.Keys.MarkingType, undefined);
783 784
        }
        else {
785
            return COMMON.operateData(arguments, COMMON.Keys.MarkingType, undefined);
786 787 788 789 790
        }
    },
    // Local :ユーザオプション(userOpt)_ログアウトモード: Interger(0:logout with backup, 1:logout without backup)
    userOpt_logoutMode: function (data) {
        if (arguments.length > 0) {
791
            COMMON.operateData(arguments, COMMON.Keys.userOpt_logoutMode, undefined);
792 793
        }
        else {
794
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_logoutMode, undefined);
795 796 797 798 799
        }
    },
    // Local
    BookmarkScreen: function (data) {
        if (arguments.length > 0) {
800
            COMMON.operateData(arguments, COMMON.Keys.BookmarkScreen, undefined);
801 802
        }
        else {
803
            return COMMON.operateData(arguments, COMMON.Keys.BookmarkScreen, undefined);
804 805 806 807 808
        }
    },
    // Local: isChangedMemo:  boolean (true: changed, false: not change)
    isChangedMemo: function (data) {
        if (arguments.length > 0) {
809
            COMMON.operateData(arguments, COMMON.Keys.isChangedMemo, undefined);
810 811
        }
        else {
812
            return COMMON.operateData(arguments, COMMON.Keys.isChangedMemo, undefined);
813 814 815 816 817
        }
    },
    // Local: isChangedMakingData:  boolean (true: changed, false: not change)
    isChangedMarkingData: function (data) {
        if (arguments.length > 0) {
818
            COMMON.operateData(arguments, COMMON.Keys.isChangedMarkingData, undefined);
819 820
        }
        else {
821
            return COMMON.operateData(arguments, COMMON.Keys.isChangedMarkingData, undefined);
822 823 824 825 826 827
        }
    },

    // Local: isChangedBookmark:  boolean (true: changed, false: not change)
    isChangedBookmark: function (data) {
        if (arguments.length > 0) {
828
            COMMON.operateData(arguments, COMMON.Keys.isChangedBookmark, undefined);
829 830
        }
        else {
831
            return COMMON.operateData(arguments, COMMON.Keys.isChangedBookmark, undefined);
832 833 834 835 836 837
        }
    },

    // Local :共通(common)_コンテンツID:Integer
    common_preContentId: function (data) {
        if (arguments.length > 0) {
838
            COMMON.operateData(arguments, COMMON.Keys.common_preContentId, undefined);
839 840
        }
        else {
841
            return COMMON.operateData(arguments, COMMON.Keys.common_preContentId, undefined);
842 843 844 845 846
        }
    },
    // Local :ページ情報データ(common)_ページNo:Integer
    common_prePageNo: function (data) {
        if (arguments.length > 0) {
847
            COMMON.operateData(arguments, COMMON.Keys.common_prePageNo, undefined);
848 849
        }
        else {
850
            return COMMON.operateData(arguments, COMMON.Keys.common_prePageNo, undefined);
851 852 853 854 855
        }
    },
    // Local :ペン書式設定(penOpt)_色:String
    penOpt_color: function (data) {
        if (arguments.length > 0) {
856
            COMMON.operateData(arguments, COMMON.Keys.penOpt_color, undefined);
857 858
        }
        else {
859
            return COMMON.operateData(arguments, COMMON.Keys.penOpt_color, undefined);
860 861 862 863 864 865
        }
    },

    // Local :ペン書式設定(penOpt)_サイズ:Interger
    penOpt_size: function (data) {
        if (arguments.length > 0) {
866
            COMMON.operateData(arguments, COMMON.Keys.penOpt_size, undefined);
867 868
        }
        else {
869
            return COMMON.operateData(arguments, COMMON.Keys.penOpt_size, undefined);
870 871 872 873 874 875
        }
    },

    // Local :マーカ書式設定(maker)_色:String
    maker_color: function (data) {
        if (arguments.length > 0) {
876
            COMMON.operateData(arguments, COMMON.Keys.maker_color, undefined);
877 878
        }
        else {
879
            return COMMON.operateData(arguments, COMMON.Keys.maker_color, undefined);
880 881 882 883 884 885
        }
    },

    // Local :マーカ書式設定(maker)_サイズ:Interger
    maker_size: function (data) {
        if (arguments.length > 0) {
886
            COMMON.operateData(arguments, COMMON.Keys.maker_size, undefined);
887 888
        }
        else {
889
            return COMMON.operateData(arguments, COMMON.Keys.maker_size, undefined);
890 891 892 893 894 895
        }
    },

    // Local :消しゴム書式設定(erase)_色:String
    erase_color: function (data) {
        if (arguments.length > 0) {
896
            COMMON.operateData(arguments, COMMON.Keys.erase_color, undefined);
897 898
        }
        else {
899
            return COMMON.operateData(arguments, COMMON.Keys.erase_color, undefined);
900 901 902 903 904 905
        }
    },

    // Local :消しゴム書式設定(erase)_サイズ:Interger
    erase_size: function (data) {
        if (arguments.length > 0) {
906
            COMMON.operateData(arguments, COMMON.Keys.erase_size, undefined);
907 908
        }
        else {
909
            return COMMON.operateData(arguments, COMMON.Keys.erase_size, undefined);
910 911 912 913 914
        }
    },
    // Local :ユーザ情報(userInfo)_最終ログイン日時:Datetime
    userInfo_lastLoginTime: function (data) {
        if (arguments.length > 0) {
915
            COMMON.operateData(arguments, COMMON.Keys.userInfo_lastLoginTime, undefined);
916 917
        }
        else {
918
            return COMMON.operateData(arguments, COMMON.Keys.userInfo_lastLoginTime, undefined);
919 920 921 922 923 924
        }
    },

    // Local :ユーザ情報(userInfo)_パスワードスキップ日時:Datetime
    userInfo_pwdSkipDt: function (data) {
        if (arguments.length > 0) {
925
            COMMON.operateData(arguments, COMMON.Keys.userInfo_pwdSkipDt, undefined);
926 927
        }
        else {
928
            return COMMON.operateData(arguments, COMMON.Keys.userInfo_pwdSkipDt, undefined);
929 930 931 932 933
        }
    },
    // Local :ユーザオプション(userOpt)_動画繰り返しフラグ:Interger(0: 繰り返しなし, 1: 繰り返しあり)
    userOpt_videoMode: function (data) {
        if (arguments.length > 0) {
934
            COMMON.operateData(arguments, COMMON.Keys.userOpt_videoMode, undefined);
935 936
        }
        else {
937
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_videoMode, undefined);
938 939 940 941 942
        }
    },
    // Local :ユーザオプション(userOpt)_音楽繰り返しフラグ:Interger(0: 繰り返しなし, 1: 繰り返しあり)
    userOpt_musicMode: function (data) {
        if (arguments.length > 0) {
943
            COMMON.operateData(arguments, COMMON.Keys.userOpt_musicMode, undefined);
944 945
        }
        else {
946
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_musicMode, undefined);
947 948 949 950 951 952
        }
    },

    // Local :ユーザオプション(userOpt)_マーキング表示設定:Interger(0:表示しない, 1:表示する)
    userOpt_makingDsp: function (data) {
        if (arguments.length > 0) {
953
            COMMON.operateData(arguments, COMMON.Keys.userOpt_makingDsp, undefined);
954 955
        }
        else {
956
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_makingDsp, undefined);
957 958 959 960 961
        }
    },
    // Local :ユーザオプション(userOpt)_アラート表示設定:Interger(0:表示しない, 1:表示する)
    userOpt_closeOrRefreshAlert: function (data) {
        if (arguments.length > 0) {
962
            COMMON.operateData(arguments, COMMON.Keys.userOpt_closeOrRefreshAlert, undefined);
963 964
        }
        else {
965
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_closeOrRefreshAlert, undefined);
966 967 968 969 970
        }
    },
    // Local :ユーザオプション(userOpt)_バックアップ確認フラグ:Interger(0:する, 1:しない)
    userOpt_bkConfirmFlg: function (data) {
        if (arguments.length > 0) {
971
            COMMON.operateData(arguments, COMMON.Keys.userOpt_bkConfirmFlg, undefined);
972 973
        }
        else {
974
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_bkConfirmFlg, undefined);
975 976 977 978 979
        }
    },
    // Local :並び順(sortOpt)_表示モード:Interger(0:本棚, 1:リスト)
    sortOpt_viewMode: function (data) {
        if (arguments.length > 0) {
980
            COMMON.operateData(arguments, COMMON.Keys.sortOpt_viewMode, undefined);
981 982
        }
        else {
983
            return COMMON.operateData(arguments, COMMON.Keys.sortOpt_viewMode, undefined);
984 985 986 987 988 989
        }
    },

    // Local :並び順(sortOpt)_表示区分:Interger(0:ジャンル, 1:グループ)
    sortOpt_viewType: function (data) {
        if (arguments.length > 0) {
990
            COMMON.operateData(arguments, COMMON.Keys.sortOpt_viewType, undefined);
991 992
        }
        else {
993
            return COMMON.operateData(arguments, COMMON.Keys.sortOpt_viewType, undefined);
994 995 996 997 998 999
        }
    },

    // Local :並び順(sortOpt)_ソート基準:Interger(1:コンテンツ検索, 2:タグ検索, 3:全文検索)
    sortOpt_searchDivision: function (data) {
        if (arguments.length > 0) {
1000
            COMMON.operateData(arguments, COMMON.Keys.sortOpt_searchDivision, undefined);
1001 1002
        }
        else {
1003
            return COMMON.operateData(arguments, COMMON.Keys.sortOpt_searchDivision, undefined);
1004 1005 1006 1007 1008 1009
        }
    },

    // Local: 並び順(sortOpt)_ソート方法:Interger(1:タイトル名, 2:タイトル名(かな), 3:公開順)
    sortOpt_sortType: function (data) {
        if (arguments.length > 0) {
1010
            COMMON.operateData(arguments, COMMON.Keys.sortOpt_sortType, undefined);
1011 1012
        }
        else {
1013
            return COMMON.operateData(arguments, COMMON.Keys.sortOpt_sortType, undefined);
1014 1015 1016 1017 1018
        }
    },
    // Local :しおりデータ(bookmark)_ページNo:Interger
    bookmark_pageNo: function (data) {
        if (arguments.length > 0) {
1019
            COMMON.operateData(arguments, COMMON.Keys.bookmark_pageNo, undefined);
1020 1021
        }
        else {
1022
            return COMMON.operateData(arguments, COMMON.Keys.bookmark_pageNo, undefined);
1023 1024 1025 1026 1027 1028
        }
    },

    // Local :メモデータ(memo)_コンテンツID:Interger
    memo_contentNo: function (data) {
        if (arguments.length > 0) {
1029
            COMMON.operateData(arguments, COMMON.Keys.memo_contentNo, undefined);
1030 1031
        }
        else {
1032
            return COMMON.operateData(arguments, COMMON.Keys.memo_contentNo, undefined);
1033 1034 1035 1036 1037 1038
        }
    },

    // Local :メモデータ(memo)_ページNo:Interger
    memo_pageNo: function (data) {
        if (arguments.length > 0) {
1039
            COMMON.operateData(arguments, COMMON.Keys.memo_pageNo, undefined);
1040 1041
        }
        else {
1042
            return COMMON.operateData(arguments, COMMON.Keys.memo_pageNo, undefined);
1043 1044 1045 1046 1047 1048
        }
    },
	
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_マーキング:Interger
    userOpt_bkMakingFlag: function (data) {
        if (arguments.length > 0) {
1049
            COMMON.operateData(arguments, COMMON.Keys.userOpt_bkMakingFlag, undefined);
1050 1051
        }
        else {
1052
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_bkMakingFlag, undefined);
1053 1054 1055 1056 1057 1058
        }
    },
	
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_メモ:Interger
    userOpt_bkMemoFlag: function (data) {
        if (arguments.length > 0) {
1059
            COMMON.operateData(arguments, COMMON.Keys.userOpt_bkMemoFlag, undefined);
1060 1061
        }
        else {
1062
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_bkMemoFlag, undefined);
1063 1064 1065 1066 1067 1068
        }
    },
	
	// Local :ユーザオプション(userOpt)_バックアップデフォルト_しおり:Interger
    userOpt_bkShioriFlag: function (data) {
        if (arguments.length > 0) {
1069
            COMMON.operateData(arguments, COMMON.Keys.userOpt_bkShioriFlag, undefined);
1070 1071
        }
        else {
1072
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_bkShioriFlag, undefined);
1073 1074 1075 1076 1077 1078
        }
    },
	
	// Local :ユーザオプション(userOpt)_ビューのアニメーション種類:Interger
    userOpt_pageTransition: function (data) {
        if (arguments.length > 0) {
1079
            COMMON.operateData(arguments, COMMON.Keys.userOpt_pageTransition, undefined);
1080 1081
        }
        else {
1082
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_pageTransition, undefined);
1083 1084 1085 1086 1087 1088
        }
    },
	
	// Local :ユーザオプション(userOpt)_アニメーション時間:Float
    userOpt_pageTransitionPeriod: function (data) {
        if (arguments.length > 0) {
1089
            COMMON.operateData(arguments, COMMON.Keys.userOpt_pageTransitionPeriod, undefined);
1090 1091
        }
        else {
1092
            return COMMON.operateData(arguments, COMMON.Keys.userOpt_pageTransitionPeriod, undefined);
1093 1094 1095 1096 1097 1098
        }
    },
	
    // Session
    memo_copyText: function (data) {
        if (arguments.length > 0) {
1099
            SessionStorageUtils.set(COMMON.Keys.memo_copyText, JSON.stringify(data));
1100
        } else {
1101 1102 1103 1104 1105 1106
            if (SessionStorageUtils.get(COMMON.Keys.memo_copyText) != 'undefined'
                && SessionStorageUtils.get(COMMON.Keys.memo_copyText) != undefined
                && SessionStorageUtils.get(COMMON.Keys.memo_copyText) != ''
                && SessionStorageUtils.get(COMMON.Keys.memo_copyText) != null
                && SessionStorageUtils.get(COMMON.Keys.memo_copyText) != 'null') {
                return JSON.parse(SessionStorageUtils.get(COMMON.Keys.memo_copyText));
1107 1108 1109 1110 1111 1112 1113
            }
            return null;
        }
    },
    // Session
    IsRefresh: function (data) {
        if (arguments.length > 0) {
1114
            SessionStorageUtils.set(COMMON.Keys.IsRefresh, JSON.stringify(data));
1115
        } else {
1116 1117 1118 1119 1120 1121
            if (SessionStorageUtils.get(COMMON.Keys.IsRefresh) != 'undefined'
                && SessionStorageUtils.get(COMMON.Keys.IsRefresh) != undefined
                && SessionStorageUtils.get(COMMON.Keys.IsRefresh) != ''
                && SessionStorageUtils.get(COMMON.Keys.IsRefresh) != null
                && SessionStorageUtils.get(COMMON.Keys.IsRefresh) != 'null') {
                return JSON.parse(SessionStorageUtils.get(COMMON.Keys.IsRefresh));
1122 1123 1124 1125 1126 1127 1128
            }
            return false;
        }
    },
    // Session
    userInfo_userName: function (data) {
        if (arguments.length > 0) {
1129
            SessionStorageUtils.set(COMMON.Keys.userInfo_userName, data);
1130
        } else {
1131
            return SessionStorageUtils.get(COMMON.Keys.userInfo_userName);
1132 1133 1134 1135 1136 1137
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_サムネール: String (base64string)
    contentInfo_contentThumbnail: function (data) {
        if (arguments.length > 0) {
1138
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentThumbnail, data);
1139
        } else {
1140
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentThumbnail);
1141 1142 1143 1144 1145 1146
        }
    },

    // Session:パスワード要変更(requirePasswordChange):String (0:不要, 1:初回, 2:定期変更)
    requirePasswordChange: function (data) {
        if (arguments.length > 0) {
1147
            SessionStorageUtils.set(COMMON.Keys.requirePasswordChange, data);
1148
        } else {
1149
            return SessionStorageUtils.get(COMMON.Keys.requirePasswordChange);
1150 1151 1152 1153 1154 1155
        }
    },

    // Session:ユーザ情報(userInfo)_セッションID:String
    userInfo_sid: function (data) {
        if (arguments.length > 0) {
1156
            SessionStorageUtils.set(COMMON.Keys.userInfo_sid, data);
1157
            AVWEB.avwUserSetting().set(COMMON.Keys.userInfo_sid, data);
1158
        } else {
1159 1160
            //return AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_sid);
            if (AVWEB.avwUserSession()) {
1161
                return SessionStorageUtils.get(COMMON.Keys.userInfo_sid);
1162 1163 1164 1165 1166 1167 1168 1169
            }
            return null;
        }
    },

    // Session :事業者オプション(serviceOpt)_初回ログイン時パスワード強制変更:Integer(0:なし, 1:催促, 2:強制)
    serviceOpt_force_pw_change_on_login: function (data) {
        if (arguments.length > 0) {
1170
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_force_pw_change_on_login, data);
1171
        } else {
1172
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_force_pw_change_on_login);
1173 1174 1175 1176 1177 1178
        }
    },

    // Session :事業者オプション(serviceOpt)_定期ログイン時パスワード強制変更:Integer(0:なし, 1:催促, 2:強制)
    serviceOpt_force_pw_change_periodically: function (data) {
        if (arguments.length > 0) {
1179
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_force_pw_change_periodically, data);
1180
        } else {
1181
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_force_pw_change_periodically);
1182 1183 1184 1185 1186 1187
        }
    },

    // Session:事業者オプション(serviceOpt)_メモ・マーキングデータバックアップ使用:Char(Y:可能, N:不可)
    serviceOpt_user_data_backup: function (data) {
        if (arguments.length > 0) {
1188
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_user_data_backup, data);
1189
        } else {
1190
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_user_data_backup);
1191 1192 1193 1194 1195 1196
        }
    },

    // Session :事業者オプション(serviceOpt)_マーキング機能使用:Char(Y:可能, N:不可)
    serviceOpt_marking: function (data) {
        if (arguments.length > 0) {
1197
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_marking, data);
1198
        } else {
1199
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_marking);
1200 1201 1202 1203 1204 1205
        }
    },
    // No.8: do not use this value: serviceOpt_force_login_periodically
    // Session :事業者オプション(serviceOpt)_一定期間経過後アプリロック:Char(Y:可能, N:不可)
    //serviceOpt_force_login_periodically: function (data) {
    //    if (arguments.length > 0) {
1206
    //        SessionStorageUtils.set(COMMON.Keys.serviceOpt_force_login_periodically, data);
1207
    //    } else {
1208
    //        return SessionStorageUtils.get(COMMON.Keys.serviceOpt_force_login_periodically);
1209 1210 1211
    //    }
    //},

1212 1213 1214
    // Session :事業者オプション(serviceOpt)_GPS使用可:Char(Y:可能, N:不可)
    serviceOpt_usable_readinglog_gps: function (data) {
        if (arguments.length > 0) {
1215
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_usable_readinglog_gps, data);
1216
        } else {
1217
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_usable_readinglog_gps);
1218 1219 1220 1221 1222
        }
    },
    // Session :事業者オプション(serviceOpt)_詳細ログ使用可:Char(Y:可能, N:不可)
    serviceOpt_usable_readinglog_object: function (data) {
        if (arguments.length > 0) {
1223
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_usable_readinglog_object, data);
1224
        } else {
1225
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_usable_readinglog_object);
1226 1227
        }
    },
1228 1229 1230 1231
    
    // Session :事業者オプション(serviceOpt)_getits_GPS使用可:Char(Y:可能, N:不可)
    serviceOpt_reader_usable_readinglog_gps: function (data) {
        if (arguments.length > 0) {
1232
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_reader_usable_readinglog_gps, data);
1233
        } else {
1234
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_reader_usable_readinglog_gps);
1235 1236 1237 1238 1239
        }
    },
    // Session :事業者オプション(serviceOpt)_getits_詳細ログ使用可:Char(Y:可能, N:不可)
    serviceOpt_reader_readinglog_object: function (data) {
        if (arguments.length > 0) {
1240
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_reader_readinglog_object, data);
1241
        } else {
1242
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_reader_readinglog_object);
1243 1244 1245
        }
    },
    
Masaru Abe committed
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
    // Session :事業者オプション(serviceOpt)_コンテンツ共有モード:Interger(0:なし , 1:ABook, 2:getits)
    serviceOpt_content_share: function (data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_content_share, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_content_share);
        }
    },
    
    
1256 1257 1258
    // Session :事業者オプション(serviceOpt)_カタログエディション:Char(Y:可能, N:不可)
    serviceOpt_catalog_edition: function (data) {
        if (arguments.length > 0) {
1259
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_catalog_edition, data);
1260
        } else {
1261
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_catalog_edition);
1262 1263 1264 1265 1266
        }
    },
    // Session :事業者オプション(serviceOpt)_日比谷対応:Char(Y:可能, N:不可)
    serviceOpt_hibiyakadan_catalog: function (data) {
        if (arguments.length > 0) {
1267
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_hibiyakadan_catalog, data);
1268
        } else {
1269
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_hibiyakadan_catalog);
1270 1271
        }
    },
1272 1273 1274
    // Session :事業者オプション(serviceOpt)_DH対応:Char(Y:可能, N:不可)
    serviceOpt_daihatsu: function (data) {
        if (arguments.length > 0) {
1275
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_daihatsu, data);
1276
        } else {
1277
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_daihatsu);
1278 1279
        }
    },
1280

1281 1282 1283
    // Session :共通(common)_コンテンツID:Integer
    common_contentId: function (data) {
        if (arguments.length > 0) {
1284
            SessionStorageUtils.set(COMMON.Keys.common_contentId, data);
1285
        } else {
1286
            return SessionStorageUtils.get(COMMON.Keys.common_contentId);
1287 1288 1289 1290 1291 1292
        }
    },

    // Session: 共通(common)_コンテンツデータチェックフラグ: Integer(true/false, true:メモ、マーキング、しおりを削除する処理を行える false:メモ、マーキング、しおりを削除する処理をしない)
    common_contentDataChkFlg: function (data) {
        if (arguments.length > 0) {
1293
            SessionStorageUtils.set(COMMON.Keys.common_contentDataChkFlg, data);
1294
        } else {
1295
            return SessionStorageUtils.get(COMMON.Keys.common_contentDataChkFlg);
1296 1297 1298 1299 1300
        }
    },
    // Session :ページ情報データ(pageInfo)_ページNo:Integer
    pageInfo_pageNo: function (data) {
        if (arguments.length > 0) {
1301
            SessionStorageUtils.set(COMMON.Keys.pageInfo_pageNo, data);
1302
        } else {
1303
            return SessionStorageUtils.get(COMMON.Keys.pageInfo_pageNo);
1304 1305 1306 1307 1308 1309
        }
    },

    // Session :ページ情報データ(pageInfo)_ページテキスト:String
    pageInfo_pageText: function (data) {
        if (arguments.length > 0) {
1310
            SessionStorageUtils.set(COMMON.Keys.pageInfo_pageText, data);
1311
        } else {
1312
            return SessionStorageUtils.get(COMMON.Keys.pageInfo_pageText);
1313 1314 1315 1316 1317 1318
        }
    },

    // Session :ページ情報データ(pageInfo)_コンテンツサムネイル:Integer
    pageInfo_pageImgResrcId: function (data) {
        if (arguments.length > 0) {
1319
            SessionStorageUtils.set(COMMON.Keys.pageInfo_pageImgResrcId, data);
1320
        } else {
1321
            return SessionStorageUtils.get(COMMON.Keys.pageInfo_pageImgResrcId);
1322 1323 1324 1325 1326 1327
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_リンク位置のx座標:Integer
    linkInfo_linkLocationX: function (data) {
        if (arguments.length > 0) {
1328
            SessionStorageUtils.set(COMMON.Keys.linkInfo_linkLocationX, data);
1329
        } else {
1330
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_linkLocationX);
1331 1332 1333 1334 1335 1336
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_リンク位置のy座標:Integer
    linkInfo_linkLocationY: function (data) {
        if (arguments.length > 0) {
1337
            SessionStorageUtils.set(COMMON.Keys.linkInfo_linkLocationY, data);
1338
        } else {
1339
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_linkLocationY);
1340 1341 1342 1343 1344 1345
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_リンク領域の幅:Integer
    linkInfo_linkLocationWidth: function (data) {
        if (arguments.length > 0) {
1346
            SessionStorageUtils.set(COMMON.Keys.linkInfo_linkLocationWidth, data);
1347
        } else {
1348
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_linkLocationWidth);
1349 1350 1351 1352 1353 1354
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_リンク領域の高さ:Integer
    linkInfo_linkLocationHeight: function (data) {
        if (arguments.length > 0) {
1355
            SessionStorageUtils.set(COMMON.Keys.linkInfo_linkLocationHeight, data);
1356
        } else {
1357
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_linkLocationHeight);
1358 1359 1360 1361 1362 1363
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_リンクタイプ:Integer(0/1)
    linkInfo_linkKind: function (data) {
        if (arguments.length > 0) {
1364
            SessionStorageUtils.set(COMMON.Keys.linkInfo_linkKind, data);
1365
        } else {
1366
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_linkKind);
1367 1368 1369 1370 1371 1372
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_ターゲットURI:String(0/1)
    linkInfo_destURI: function (data) {
        if (arguments.length > 0) {
1373
            SessionStorageUtils.set(COMMON.Keys.linkInfo_destURI, data);
1374
        } else {
1375
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_destURI);
1376 1377 1378 1379 1380 1381
        }
    },

    // Session :コンテンツ内リンク(linkInfo)_ターゲットページNo:Integer(0/1)
    linkInfo_destPageNumber: function (data) {
        if (arguments.length > 0) {
1382
            SessionStorageUtils.set(COMMON.Keys.linkInfo_destPageNumber, data);
1383
        } else {
1384
            return SessionStorageUtils.get(COMMON.Keys.linkInfo_destPageNumber);
1385 1386 1387 1388 1389 1390
        }
    },

    // Session :閲覧ログ(log)_コンテンツ閲覧開始時刻:Datetime
    log_contentStartViewDt: function (data) {
        if (arguments.length > 0) {
1391
            SessionStorageUtils.set(COMMON.Keys.log_contentStartViewDt, data);
1392
        } else {
1393
            return SessionStorageUtils.get(COMMON.Keys.log_contentStartViewDt);
1394 1395 1396 1397 1398 1399
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_コンテンツID:Integer
    contentInfo_contentId: function (data) {
        if (arguments.length > 0) {
1400
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentId, data);
1401
        } else {
1402
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentId);
1403 1404 1405 1406 1407 1408
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_カテゴリID:Integer
    contentInfo_categoryId: function (data) {
        if (arguments.length > 0) {
1409
            SessionStorageUtils.set(COMMON.Keys.contentInfo_categoryId, data);
1410
        } else {
1411
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_categoryId);
1412 1413 1414 1415 1416 1417
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ名:String
    contentInfo_contentName: function (data) {
        if (arguments.length > 0) {
1418
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentName, data);
1419
        } else {
1420
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentName);
1421 1422 1423 1424 1425 1426
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ名(カナ):String
    contentInfo_contentNameKana: function (data) {
        if (arguments.length > 0) {
1427
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentNameKana, data);
1428
        } else {
1429
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentNameKana);
1430 1431 1432 1433 1434 1435
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_コンテンツ詳細:String
    contentInfo_contentDetail: function (data) {
        if (arguments.length > 0) {
1436
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentDetail, data);
1437
        } else {
1438
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentDetail);
1439 1440 1441 1442 1443 1444
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_公開開始日:Datetime
    contentInfo_deliveryStartDate: function (data) {
        if (arguments.length > 0) {
1445
            SessionStorageUtils.set(COMMON.Keys.contentInfo_deliveryStartDate, data);
1446
        } else {
1447
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_deliveryStartDate);
1448 1449 1450 1451 1452 1453
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_公開終了日:Datetime
    contentInfo_deliveryEndDate: function (data) {
        if (arguments.length > 0) {
1454
            SessionStorageUtils.set(COMMON.Keys.contentInfo_deliveryEndDate, data);
1455
        } else {
1456
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_deliveryEndDate);
1457 1458 1459 1460 1461 1462
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_本棚サムネール名:Interger
    contentInfo_thumbnailName: function (data) {
        if (arguments.length > 0) {
1463
            SessionStorageUtils.set(COMMON.Keys.contentInfo_thumbnailName, data);
1464
        } else {
1465
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_thumbnailName);
1466 1467 1468 1469 1470 1471
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_詳細画面サムネール名:Interger
    contentInfo_thumbnailBigName: function (data) {
        if (arguments.length > 0) {
1472
            SessionStorageUtils.set(COMMON.Keys.contentInfo_thumbnailBigName, data);
1473
        } else {
1474
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_thumbnailBigName);
1475 1476 1477 1478 1479 1480
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_メタ更新バージョン:Interger
    contentInfo_metaVersion: function (data) {
        if (arguments.length > 0) {
1481
            SessionStorageUtils.set(COMMON.Keys.contentInfo_metaVersion, data);
1482
        } else {
1483
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_metaVersion);
1484 1485 1486 1487 1488 1489
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_リソース更新バージョン:Interger
    contentInfo_resourceVersion: function (data) {
        if (arguments.length > 0) {
1490
            SessionStorageUtils.set(COMMON.Keys.contentInfo_resourceVersion, data);
1491
        } else {
1492
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_resourceVersion);
1493 1494 1495 1496 1497 1498
        }
    },

    // Session :コンテンツ詳細情報(contentInfo)_PDF総ページ数:Interger
    contentInfo_allPageNum: function (data) {
        if (arguments.length > 0) {
1499
            SessionStorageUtils.set(COMMON.Keys.contentInfo_allPageNum, data);
1500
        } else {
1501
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_allPageNum);
1502 1503 1504 1505 1506 1507
        }
    },

	// Session :(contentType):String
    contentInfo_contentType: function (data) {
        if (arguments.length > 0) {
1508
            SessionStorageUtils.set(COMMON.Keys.contentInfo_contentType, data);
1509
        } else {
1510
            return SessionStorageUtils.get(COMMON.Keys.contentInfo_contentType);
1511 1512 1513 1514 1515
        }
    },
    // Session :検索条件(searchCond)_検索テキスト:String
    searchCond_searchText: function (data) {
        if (arguments.length > 0) {
1516
            SessionStorageUtils.set(COMMON.Keys.searchCond_searchText, data);
1517
        } else {
1518
            return SessionStorageUtils.get(COMMON.Keys.searchCond_searchText);
1519 1520 1521 1522 1523 1524
        }
    },

    // Session :検索条件(searchCond)_検索区分:Interger(1:コンテンツ検索, 2:タグ検索, 3:全文検索)
    searchCond_searchDivision: function (data) {
        if (arguments.length > 0) {
1525
            SessionStorageUtils.set(COMMON.Keys.searchCond_searchDivision, data);
1526
        } else {
1527
            return SessionStorageUtils.get(COMMON.Keys.searchCond_searchDivision);
1528 1529 1530 1531 1532 1533
        }
    },

    // Session :検索条件(searchCond)_ソート基準:Interger(1:タイトル名, 2:タイトル名(かな), 3:公開順)
    searchCond_sortType: function (data) {
        if (arguments.length > 0) {
1534
            SessionStorageUtils.set(COMMON.Keys.searchCond_sortType, data);
1535
        } else {
1536
            return SessionStorageUtils.get(COMMON.Keys.searchCond_sortType);
1537 1538 1539 1540 1541 1542
        }
    },

    // Session :検索条件(searchCond)_ソート方法:Interger(1:昇順, 2:降順)
    searchCond_sortOrder: function (data) {
        if (arguments.length > 0) {
1543
            SessionStorageUtils.set(COMMON.Keys.searchCond_sortOrder, data);
1544
        } else {
1545
            return SessionStorageUtils.get(COMMON.Keys.searchCond_sortOrder);
1546 1547 1548 1549 1550 1551
        }
    },

    // Session :検索条件(searchCond)_レコードFrom:Interger
    searchCond_recordFrom: function (data) {
        if (arguments.length > 0) {
1552
            SessionStorageUtils.set(COMMON.Keys.searchCond_recordFrom, data);
1553
        } else {
1554
            return SessionStorageUtils.get(COMMON.Keys.searchCond_recordFrom);
1555 1556 1557 1558 1559 1560
        }
    },

    // Session :検索条件(searchCond)_レコードTo:Interger
    searchCond_recordTo: function (data) {
        if (arguments.length > 0) {
1561
            SessionStorageUtils.set(COMMON.Keys.searchCond_recordTo, data);
1562
        } else {
1563
            return SessionStorageUtils.get(COMMON.Keys.searchCond_recordTo);
1564 1565 1566 1567 1568 1569
        }
    },

    // Session :検索条件(searchCond)_カテゴリID:Interger
    searchCond_genreId: function (data) {
        if (arguments.length > 0) {
1570
            SessionStorageUtils.set(COMMON.Keys.searchCond_genreId, data);
1571
        } else {
1572
            return SessionStorageUtils.get(COMMON.Keys.searchCond_genreId);
1573 1574 1575 1576 1577 1578
        }
    },

    // Session :検索条件(searchCond)_グループID:Interger
    searchCond_groupId: function (data) {
        if (arguments.length > 0) {
1579
            SessionStorageUtils.set(COMMON.Keys.searchCond_groupId, data);
1580
        } else {
1581
            return SessionStorageUtils.get(COMMON.Keys.searchCond_groupId);
1582 1583 1584 1585 1586 1587
        }
    },

    // Session :通知情報(pushInfo)_新着件数:Interger
    pushInfo_newMsgNumber: function (data) {
        if (arguments.length > 0) {
1588
            SessionStorageUtils.set(COMMON.Keys.pushInfo_newMsgNumber, data);
1589
        } else {
1590
            return SessionStorageUtils.get(COMMON.Keys.pushInfo_newMsgNumber);
1591 1592 1593 1594 1595 1596
        }
    },

    // Session :ユーザ情報(userInfo)_ログインID:String
    userInfo_loginId_session: function (data) {
        if (arguments.length > 0) {
1597
            SessionStorageUtils.set(COMMON.Keys.userInfo_loginId, data);
1598
        } else {
1599
            return SessionStorageUtils.get(COMMON.Keys.userInfo_loginId);
1600 1601 1602 1603 1604 1605
        }
    },

    // Session :ユーザ情報(userInfo)_アカウントパス:String
    userInfo_accountPath_session: function (data) {
        if (arguments.length > 0) {
1606
            SessionStorageUtils.set(COMMON.Keys.userInfo_accountPath, data);
1607
        } else {
1608
            return SessionStorageUtils.get(COMMON.Keys.userInfo_accountPath);
1609 1610 1611 1612 1613
        }
    },
    // Session :事業者オプション(serviceOpt)_スクリーンロック(Web版):Char(Y:可能, N:不可)
    serviceOpt_web_screen_lock: function (data) {
        if (arguments.length > 0) {
1614
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_web_screen_lock, data);
1615
        } else {
1616
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_web_screen_lock);
1617 1618 1619 1620 1621
        }
    },
	// Session :事業者オプション(serviceOpt)_スクリーンロック待ち時間:Interger
    serviceOpt_web_screen_lock_wait: function (data) {
        if (arguments.length > 0) {
1622
            SessionStorageUtils.set(COMMON.Keys.serviceOpt_web_screen_lock_wait, data);
1623
        } else {
1624
            return SessionStorageUtils.get(COMMON.Keys.serviceOpt_web_screen_lock_wait);
1625
        }
Masaru Abe committed
1626 1627 1628 1629
    },
    
    isGetitsMode: function (data) {
        if (arguments.length > 0) {
1630
            SessionStorageUtils.set(COMMON.Keys.isGetitsMode, JSON.stringify(data));
Masaru Abe committed
1631
        } else {
1632 1633 1634 1635 1636 1637
            if (SessionStorageUtils.get(COMMON.Keys.isGetitsMode) != 'undefined'
                && SessionStorageUtils.get(COMMON.Keys.isGetitsMode) != undefined
                && SessionStorageUtils.get(COMMON.Keys.isGetitsMode) != ''
                && SessionStorageUtils.get(COMMON.Keys.isGetitsMode) != null
                && SessionStorageUtils.get(COMMON.Keys.isGetitsMode) != 'null') {
                return JSON.parse(SessionStorageUtils.get(COMMON.Keys.isGetitsMode));
Masaru Abe committed
1638 1639
            }
            return false;
Masaru Abe committed
1640 1641 1642
        }
    },
    
Masaru Abe committed
1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657
    isStreamingMode: function (data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.isStreamingMode, JSON.stringify(data));
        } else {
            if (SessionStorageUtils.get(COMMON.Keys.isStreamingMode) != 'undefined'
                && SessionStorageUtils.get(COMMON.Keys.isStreamingMode) != undefined
                && SessionStorageUtils.get(COMMON.Keys.isStreamingMode) != ''
                && SessionStorageUtils.get(COMMON.Keys.isStreamingMode) != null
                && SessionStorageUtils.get(COMMON.Keys.isStreamingMode) != 'null') {
                return JSON.parse(SessionStorageUtils.get(COMMON.Keys.isStreamingMode));
            }
            return false;
        }
    },
    
Masaru Abe committed
1658 1659
    conf_apiUrl: function (data) {
        if (arguments.length > 0) {
1660
            SessionStorageUtils.set(COMMON.Keys.conf_apiUrl, data);
Masaru Abe committed
1661
        } else {
1662
            return SessionStorageUtils.get(COMMON.Keys.conf_apiUrl);
Masaru Abe committed
1663 1664 1665 1666
        }
    },
    conf_apiLoginUrl: function (data) {
        if (arguments.length > 0) {
1667
            SessionStorageUtils.set(COMMON.Keys.conf_apiLoginUrl, data);
Masaru Abe committed
1668
        } else {
1669
            return SessionStorageUtils.get(COMMON.Keys.conf_apiLoginUrl);
Masaru Abe committed
1670 1671 1672 1673
        }
    },
    conf_apiResourceDlUrl: function (data) {
        if (arguments.length > 0) {
1674
            SessionStorageUtils.set(COMMON.Keys.conf_apiResourceDlUrl, data);
Masaru Abe committed
1675
        } else {
1676
            return SessionStorageUtils.get(COMMON.Keys.conf_apiResourceDlUrl);
Masaru Abe committed
1677
        }
Masaru Abe committed
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
    },
    
    latitude: function(data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.latitude, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.latitude);
        }
    },
    
    longitude: function(data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.longitude, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.longitude);
        }
Masaru Abe committed
1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
    },
    
    authCode: function(data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.authCode, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.authCode);
        }
    },
    authGroupName: function(data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.authGroupName, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.authGroupName);
        }
    },
    authGroupId: function(data) {
        if (arguments.length > 0) {
            SessionStorageUtils.set(COMMON.Keys.authGroupId, data);
        } else {
            return SessionStorageUtils.get(COMMON.Keys.authGroupId);
        }
1716
    }
Masaru Abe committed
1717
    
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734
};

// -------------------------------------------------
// Define all keys for local/session storage [ end ]
// -------------------------------------------------

// =============================================================================================
// Constants [ end ]
// =============================================================================================

/*
* Operations for local storage
*/
var LocalStorageUtils = {
    getUniqueId: function () {
        var uniqueId = "";

1735 1736
        if (AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_accountPath)) {
            uniqueId += AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_accountPath);
1737
        }
1738 1739
        if (AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_loginId)) {
            uniqueId += "." + AVWEB.avwUserSetting().get(COMMON.Keys.userInfo_loginId);
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749
        }
        if (uniqueId != "") {
            uniqueId += ".";
        }

        return uniqueId;
    },
    get: function (strKey) {
        var key = this.getUniqueId() + strKey;

1750
        return AVWEB.avwUserSetting().get(key);
1751 1752 1753
    },
    set: function (strKey, objValue) {
        var key = this.getUniqueId() + strKey;
1754
        AVWEB.avwUserSetting().set(key, objValue);
1755 1756 1757
    },
    remove: function (strKey) {
        var key = this.getUniqueId() + strKey;
1758
        AVWEB.avwUserSetting().remove(key);
1759 1760 1761
        SessionStorageUtils.remove(strKey);
    },
    clear: function () {
1762
        var localStorageKeys = AVWEB.avwUserSetting().keys();
1763 1764 1765 1766
        for (var nIndex = 0; nIndex < localStorageKeys.length; nIndex++) {
            var strKey = localStorageKeys[nIndex];

            if ((strKey + "").contains(this.getUniqueId())) {
1767
            	AVWEB.avwUserSetting().remove(strKey);
1768 1769 1770 1771
            }
        }
    },
    existKey: function (strKey) {
1772
        var keys = AVWEB.avwUserSetting().keys();
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792
        var findKey = this.getUniqueId() + strKey;
        var isExisted = false;
        if (keys != null && keys != undefined) {
            for (var nIndex = 0; nIndex < keys.length; nIndex++) {
                if (keys[nIndex] == findKey) {
                    isExisted = true;
                    break;
                }
            }
        }
        return isExisted;
    }
};

/*
 * Operations for session storage [start]
 */

var SessionStorageUtils = {
    login: function () {
1793
        if (AVWEB.avwUserSession()) {
1794 1795 1796
            // Skip this case
        }
        else {
1797
            AVWEB.avwCreateUserSession();
1798 1799 1800
        }
    },
    get: function (strKey) {
1801
        return AVWEB.avwUserSession().get(strKey);
1802 1803
    },
    set: function (strKey, objValue) {
1804
    	AVWEB.avwUserSession().set(strKey, objValue);
1805 1806
    },
    clear: function () {
1807 1808
        if (AVWEB.avwUserSession()) {
        	AVWEB.avwUserSession().destroy();
1809 1810 1811
        }
    },
    remove: function (strKey) {
1812
    	AVWEB.avwUserSession().set(strKey, null);
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 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 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
    }
};
/*
 * Operations for session storage [ end ]
 */


// =============================================================================================
// Utils for string, date, number [start]
// =============================================================================================

/*
* Convert date to JP format date time [start]
*/

/*
YYYY/MM/DD HH:MM:SS
*/
Date.prototype.jpDateTimeString = function () {
    var strResult = "";
    var strYear = this.getFullYear() + "";
    var strMonth = (this.getMonth() + 1) + "";
    var strDayInMonth = this.getDate() + "";
    var strHour = this.getHours() + "";
    var strMinute = this.getMinutes() + "";
    var strSecond = this.getSeconds() + "";

    strResult += strYear.padLeft("0", 4) + "/" + strMonth.padLeft("0", 2) + "/" + strDayInMonth.padLeft("0", 2);
    strResult += " " + strHour.padLeft("0", 2) + ":" + strMinute.padLeft("0", 2) + ":" + strSecond.padLeft("0", 2);
    return strResult;

};
/*
YYYY-MM-DD HH:MM:SS
*/
Date.prototype.jpDateTimeString1 = function () {
    var strResult = "";
    var strYear = this.getFullYear() + "";
    var strMonth = (this.getMonth() + 1) + "";
    var strDayInMonth = this.getDate() + "";
    var strHour = this.getHours() + "";
    var strMinute = this.getMinutes() + "";
    var strSecond = this.getSeconds() + "";

    strResult += strYear.padLeft("0", 4) + "-" + strMonth.padLeft("0", 2) + "-" + strDayInMonth.padLeft("0", 2);
    strResult += " " + strHour.padLeft("0", 2) + ":" + strMinute.padLeft("0", 2) + ":" + strSecond.padLeft("0", 2);
    return strResult;

};
/*
yyyy/MM/dd
*/
Date.prototype.jpDateString = function () {
    var strResult = "";
    var strYear = this.getFullYear() + "";
    var strMonth = (this.getMonth() + 1) + "";
    var strDayInMonth = this.getDate() + "";

    strResult += strYear.padLeft("0", 4) + "/" + strMonth.padLeft("0", 2) + "/" + strDayInMonth.padLeft("0", 2);

    return strResult;

};
/*
HH:mm:ss
*/
Date.prototype.jpTimeString = function () {
    var strResult = "";
    var strHour = this.getHours() + "";
    var strMinute = this.getMinutes() + "";
    var strSecond = this.getSeconds() + "";

    strResult += " " + strHour.padLeft("0", 2) + ":" + strMinute.padLeft("0", 2) + ":" + strSecond.padLeft("0", 2);
    return strResult;

};
/*
HH:mm
*/
Date.prototype.jpShortTimeString = function () {
    var strResult = "";
    var strHour = this.getHours() + "";
    var strMinute = this.getMinutes() + "";
    var strSecond = this.getSeconds() + "";

    strResult += " " + strHour.padLeft("0", 2) + ":" + strMinute.padLeft("0", 2);
    return strResult;

};
/*
yyyyMMddHHmmss
*/
Date.prototype.toIdString = function () {
    var strResult = "";
    var strYear = this.getFullYear() + "";
    var strMonth = (this.getMonth() + 1) + "";
    var strDayInMonth = this.getDate() + "";
    var strHour = this.getHours() + "";
    var strMinute = this.getMinutes() + "";
    var strSecond = this.getSeconds() + "";
    var strMilisecond = this.getMilliseconds() + "";

    strResult += strYear.padLeft("0", 4) + strMonth.padLeft("0", 2) + strDayInMonth.padLeft("0", 2);
    strResult += strHour.padLeft("0", 2) + strMinute.padLeft("0", 2) + strSecond.padLeft("0", 2) + strMilisecond.padLeft("0", 3);
    return strResult;
};
// Subtract date to get days
Date.prototype.subtractByDays = function (targetDate) {
    var milis = Math.abs(this - targetDate);
    var days = Math.floor(milis / (60 * 60 * 24 * 1000));
    return days;
};
Date.prototype.addSeconds = function (plusSeconds) {
    var newDate = new Date(this.getTime() + plusSeconds * 1000);
    return newDate;
};

// Subtract date to get days
Date.prototype.subtractBySeconds = function (targetDate) {
    var milis = Math.abs(this - targetDate);
    var days = Math.floor(milis / 1000);
    return days;
};

/*
* Convert date to JP format date time [ end ]
*/

//trimming space from both side of the string
String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
};

//trimming space from left side of the string
String.prototype.trimLeft = function () {
    return this.replace(/^\s+/, "");
};

//trimming space from right side of the string
String.prototype.trimRight = function () {
    return this.replace(/\s+$/, "");
};

//String: pads left
String.prototype.padLeft = function (padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};

//String: pads right
String.prototype.padRight = function (padString, length) {
    var str = this;
    while (str.length < length)
        str = str + padString;
    return str;
};
// Check contain string
String.prototype.contains = function (string) {

    if (this.indexOf(string) != -1) {
        return true;
    }
    return false;
};

//Number: pads left
Number.prototype.padLeft = function (padString, length) {
    var str = this + "";
    return str.padLeft(padString, length);
};

//Number: pads right
Number.prototype.padRight = function (padString, length) {
    var str = this + "";
    return str.padRight(padString, length);
};
// Clear data of array
Array.prototype.clear = function () {
    this.splice(0, this.length);
};

/*
  Remove extension of specified name
  Ex: aaaa.mp3 -> aaa
*/
Masaru Abe committed
2000
COMMON.removeExt = function(strName) {
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139
    if (strName) {
        var arrString = strName.split('.');
        var strResult = "";
        if (arrString.length > 1) {
            var nLastIndex = strName.lastIndexOf('.');
            strResult = strName.substr(0, nLastIndex);
        }
        else {
            strResult = strName;
        }
        return strResult;
    }
    return "";
};

/*
* String utilities [ end ]
*/

// =============================================================================================
// Utils for string, date, number [ end ]
// =============================================================================================

var ValidationUtil = {

    // 必須: Text
    CheckRequiredForText: function (value) {

        if (value == null || value == '') {
            return false;
        }
        return true;
    },

    //get byte count
    GetByteCount: function (value) {
        var escapedStr = encodeURI(value);
        if (escapedStr.indexOf("%") != -1) {
            var count = escapedStr.split("%").length - 1;
            if (count == 0) count++;  //perverse case; can't happen with real UTF-8
            var tmp = escapedStr.length - (count * 3);
            count = count + tmp;
        } else {
            count = escapedStr.length;
        }
        return count;
    },

    // 最小文字数
    CheckMinLengthForByte: function (value, len) {
        if (this.GetByteCount(value) < len)
            return false;
        return true;
    },

    // 最大文字数
    CheckMaxLengthForByte: function (value, len) {

        if (this.GetByteCount(value) > len)
            return false;
        return true;
    },

    // 半数字
    IsNumber: function (value) {
        var reg = new RegExp("^[0-9]+$");
        return reg.test(value);
    },

    // 半英字
    IsAlphabet: function (value) {
        var reg = new RegExp("^[a-zA-Z]+$");
        return reg.test(value);
    },

    // 半記号
    IsSymbol: function (value) {
        var reg = new RegExp("\u005b\u005e\u0027\u0060\u0027\u007e\u0027\u0021\u0027\u0040\u0027\u0023\u0027\u0024\u0027\u0025\u0027\u005e\u0027\u0026\u0027\u002a\u0027\u0028\u0027\u0029\u0027\u005f\u0027\u002b\u0027\u003d\u0027\u007b\u0027\u007d\u0027\u007c\u0027\u003a\u0027\u0022\u0027\u003b\u0027\u0027\u0027\u003c\u0027\u003e\u0027\u003f\u0027\u002f\u0027\u002e\u0027\u002c\u005c\u002d\u005b\u005c\u005d\u005c\u005c\u005d");
        return !reg.test(value);
    },

    // メール
    CheckEmailValid: function (value) {
        //Check if string is a valid email address
        var reg = new RegExp("^[0-9a-zA-Z]+@[0-9a-zA-Z]+[\\.]{1}[0-9a-zA-Z]+[\\.]?[0-9a-zA-Z]+$");
        return reg.test(value);
    },
    // Password
    CheckPasswordValid: function (value) {
        //Check if string is a valid email address
        var reg = new RegExp("^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[#+-\\./:_]).{1,47}$");
        return reg.test(value);
    },
    // Alphabet + Nunber + Symbol
    IsAlphabetOrNumberOrSymbol: function (value) {
        //Check if string is alphabet or number or symbol
        var reg = new RegExp("\u005b\u005e\u0061\u002d\u007a\u0041\u002d\u005a\u0030\u002d\u0039\u0027\u0060\u0027\u007e\u0027\u0021\u0027\u0040\u0027\u0023\u0027\u0024\u0027\u0025\u0027\u005e\u0027\u0026\u0027\u002a\u0027\u0028\u0027\u0029\u0027\u005f\u0027\u002b\u0027\u003d\u0027\u007b\u0027\u007d\u0027\u007c\u0027\u003a\u0027\u0022\u0027\u003b\u0027\u0027\u0027\u003c\u0027\u003e\u0027\u003f\u0027\u002f\u0027\u002e\u0027\u002c\u005c\u002d\u005b\u005c\u005d\u005c\u005c\u005d");
        return !reg.test(value);
    },
    // Get the total of types in array
    CheckNumberOfTypeInString: function (value) {
        var list = new Array();
        var c;
        for (var i = 0; i < value.length; i++) {
            c = value[i];
            for (var j = i + 1; j < value.length; j++) {
                if (value[j] == c) {
                    value = value.slice(0, j) + value.slice(j + 1, value.len);
                    j = j - 1;
                }
            }
            list[i] = c;
        }
        var count = list.length;
        return count
    },
    // Special character: *
    IsCharacterSpecial: function (value) {
        for (var i = 0; i < value.length; i++) {
            if (value[i] == '*')
                return true;
        }
        return false;
    },

    // 半記号
    IsPasswordSymbol: function (value) {
        var reg = new RegExp("\u005b\u005e\u0027\u0023\u0027\u002b\u005c\u002d\u0027\u002e\u0027\u002f\u0027\u003a\u0027\u005f\u005d");
        return !reg.test(value);
    },

    // 半記号
    IsPasswordAlphabetOrNumerOrSymbol: function (value) {
        var reg = new RegExp("\u005b\u005e\u0061\u002d\u007a\u0041\u002d\u005a\u0030\u002d\u0039\u0027\u0023\u0027\u002b\u005c\u002d\u0027\u002e\u0027\u002f\u0027\u003a\u0027\u005f\u005d");
        return !reg.test(value);
    }
};

// Get format based64 string to show inline
Masaru Abe committed
2140
COMMON.getBase64Image = function(imgSource) {
2141 2142 2143 2144
    return imgSource.replace(/^data:image\/(png|jpg);base64,/, "");
};

// get time wait lockscreen
Masaru Abe committed
2145
COMMON.getTimeWaitLockScreen = function() {
2146 2147 2148
    var timeWaitLockScreen = -1;
    if (ClientData.serviceOpt_web_screen_lock() == "Y") 
    {
2149
        var sysSettings = AVWEB.avwSysSetting();
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168
        if (isNaN(ClientData.serviceOpt_web_screen_lock_wait())) {
            timeWaitLockScreen = sysSettings.screenlockTimeDefault * 60000;
        }
        else 
        {
            var temp = ClientData.serviceOpt_web_screen_lock_wait();
            timeWaitLockScreen = temp * 60000; // time unit is minute
            if (timeWaitLockScreen < 0 || temp % 1 != 0) {
                timeWaitLockScreen = sysSettings.screenlockTimeDefault * 60000;
            }
            else if (timeWaitLockScreen == 0) { // no lockscreen
                timeWaitLockScreen = -1;
            }
        }
    }    
    return timeWaitLockScreen;
};

// Do locking screen after idle time
Masaru Abe committed
2169
COMMON.LockScreen = function() {
2170
    if (AVWEB.avwUserSession()) {
2171 2172

        // no lockscreen for user anonymous
Masaru Abe committed
2173
        if (COMMON.isAnonymousLogin()) {
2174 2175
            return;
        }
2176
        //getitsでも発動しない
Masaru Abe committed
2177
		if(ClientData.isGetitsMode() == true){
2178 2179
			return;
		}
Masaru Abe committed
2180 2181 2182 2183 2184
        //ストリーミングでも発動しない
		if(ClientData.isStreamingMode() == true){
			return;
		}
		
Masaru Abe committed
2185
        var timeWaitLockScreen = COMMON.getTimeWaitLockScreen();        
2186
        if (timeWaitLockScreen > 0) {
2187
            //var message = I18N.i18nText("sysInfoScrLock01");
Masaru Abe committed
2188
            SCREENLOCK.screenLock({
2189 2190
                timeout: timeWaitLockScreen,
                html: '<img src="img/1222.png" alt="Screen Lock" /><br />', //+ message,
Masaru Abe committed
2191
                unlockFunc: COMMON.unlockFunction,
2192
                errorMessage: I18N.i18nText('msgLoginErrWrong')
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203
            });
        }

    }
};


// The function will be called at the time: loading
$(function () {

    // Init setting values 
2204
    if (AVWEB.avwUserSession()) {  // Logged
2205 2206 2207

        // View mode default
        if (ClientData.sortOpt_viewMode() == null || ClientData.sortOpt_viewMode() == undefined) {
2208
            ClientData.sortOpt_viewMode(COMMON.Consts.ConstDisplayMode_BookShelf); // Bookshelf
2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264
        }

        // 動画、音楽繰り返し
        if (ClientData.userOpt_musicMode() == null || ClientData.userOpt_musicMode() == undefined) {
            ClientData.userOpt_musicMode(1);
        }
        if (ClientData.userOpt_videoMode() == null || ClientData.userOpt_videoMode() == undefined) {
            ClientData.userOpt_videoMode(1);
        }

        // マーキング(コンテンツを開いた時に表示する)
        if (ClientData.userOpt_makingDsp() == null || ClientData.userOpt_makingDsp() == undefined) {
            ClientData.userOpt_makingDsp(1);
        }

        // 毎回ログアウトの時、バックアップするかどうかは必ず確認する
        if (ClientData.userOpt_bkConfirmFlg() == null || ClientData.userOpt_bkConfirmFlg() == undefined) {
            ClientData.userOpt_bkConfirmFlg(1);
        }

        // タブ・ブラウザ終了・F5時のアラートが表示する
        if (ClientData.userOpt_closeOrRefreshAlert() == null || ClientData.userOpt_closeOrRefreshAlert() == undefined) {
            ClientData.userOpt_closeOrRefreshAlert(1);
        }

        // Set default value for options backup: marking -> checked
        if (ClientData.userOpt_bkMakingFlag() == null || ClientData.userOpt_bkMakingFlag() == undefined) {
            ClientData.userOpt_bkMakingFlag(1);
        }
        // Set default value for options backup: memo -> checked
        if (ClientData.userOpt_bkMemoFlag() == null || ClientData.userOpt_bkMemoFlag() == undefined) {
            ClientData.userOpt_bkMemoFlag(1);
        }
        // Set default value for options backup: bookmark -> checked
        if (ClientData.userOpt_bkShioriFlag() == null || ClientData.userOpt_bkShioriFlag() == undefined) {
            ClientData.userOpt_bkShioriFlag(1);
        }

        // Set default value for logoutMode (backup auto and logout)
        if (ClientData.userOpt_logoutMode() == null || ClientData.userOpt_logoutMode() == undefined) {
            ClientData.userOpt_logoutMode(0);
        }

        // set default page transition No.4

        if (ClientData.userOpt_pageTransition() == null || ClientData.userOpt_logoutMode() == undefined) {
            ClientData.userOpt_pageTransition(0);
        }
        if (ClientData.userOpt_pageTransitionPeriod() == null || ClientData.userOpt_pageTransitionPeriod() == undefined) {
            ClientData.userOpt_pageTransitionPeriod(1);
        }

    }
});

// Unlock the locked screen by inputing password on screen to check authentication
Masaru Abe committed
2265
COMMON.unlockFunction = function(inputPass) {    
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275
    var forceUnlockFunc = arguments[1]; // added secret arguments : forceUnlockFunction
    var result = false;
    var params = {
        previousSid: ClientData.userInfo_sid(),
        loginId: ClientData.userInfo_loginId_session(),
        password: inputPass,
        urlpath: ClientData.userInfo_accountPath()
    };

    // Get url to login
2276
    //var sysSettings = AVWEB.avwSysSetting();
Masaru Abe committed
2277
    var apiLoginUrl = ClientData.conf_apiLoginUrl(); //sysSettings.apiLoginUrl;
2278
    var errorCode = '';
2279
    AVWEB.avwCmsApiSyncWithUrl(apiLoginUrl, null, 'webClientLogin', 'GET', params,
2280 2281 2282 2283 2284 2285 2286 2287 2288 2289
	        function (data) {
	            if (data.result == 'success') {
	                ClientData.userInfo_sid(data.sid);
	                result = true;
	                //forceUnlockFunc();

	                // update status wait lockscreen
	                var serviceOptionList = data.serviceOptionList;
	                $.each(serviceOptionList, function (i, option) {

Masaru Abe committed
2290
	                    if (option.serviceOptionId == 60) {
2291 2292
	                        ClientData.serviceOpt_web_screen_lock(option.value);
	                    }
Masaru Abe committed
2293
	                    else if (option.serviceOptionId == 61) {
Masaru Abe committed
2294
	                        ClientData.serviceOpt_web_screen_lock_wait(option.value);
2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306
	                    }
	                });

	            }
	        },
	        function (xhr, statusText, errorThrown) {
	            if (xhr.responseText && xhr.status != 0) {
	                errorCode = JSON.parse(xhr.responseText);
	            }
	            else {
	                errorCode = { errorMessage: "E001" };
	            }
Masaru Abe committed
2307 2308
	        }
	);
2309 2310 2311

    
    if (result == true) {
2312 2313 2314 2315 2316 2317 2318 2319 2320
    	//ビューア画面ならイベントのアンロック
    	if ($("#viewer").length) {
    		//表示状態か
    		if( $('#viewer').is(':visible')){
    			if (window.CONTENTVIEW_EVENTS) {
    				CONTENTVIEW_EVENTS.onUnlock();
    			}
    		}
    	}
2321
    }
Masaru Abe committed
2322
    return { 'result': result, 'errorCode': errorCode, 'newTimeout': COMMON.getTimeWaitLockScreen() };
2323 2324 2325 2326 2327 2328 2329
};



/*
  Set starting log for reading content
*/
Masaru Abe committed
2330
COMMON.SetStartLog = function(strContentId) {
2331

2332 2333 2334 2335 2336
    var isFound = false;
    var arrContentLogs = ClientData.ContentLogData();

    for (var nIndex = 0;  nIndex < arrContentLogs.length; nIndex++) {
        if (arrContentLogs[nIndex].contentid == strContentId) {
Masaru Abe committed
2337 2338 2339 2340 2341 2342 2343
        	
            if(!ClientData.isStreamingMode()){
            	arrContentLogs[nIndex].readingStartDate = new Date();
            	arrContentLogs[nIndex].readingEndDate = (new Date()).addSeconds(1);
            	// Reading time
            	arrContentLogs[nIndex].readingTime = arrContentLogs[nIndex].readingEndDate.subtractBySeconds(arrContentLogs[nIndex].readingStartDate);
            }
2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360
            isFound = true;
            break;
        }
    }
    if(isFound == false) {
        var curr = new Date();
        var curr1 = new Date();
        var log = new LogEntity();
        log.readingStartDate = curr;
        log.contentid = strContentId;
        
        // Set 1 second
        curr1.setSeconds(curr.getSeconds() + 1);
        log.readingEndDate = curr1;
        // Reading time
        log.readingTime = log.readingEndDate.subtractBySeconds(log.readingStartDate);
        
Masaru Abe committed
2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384
		//デバイスタイプ判定
		var deviceType = 4;
		if(ClientData.isStreamingMode()){
			if (CONTENTVIEW_GENERAL.avwUserEnvObj.os == "ipad") {
				deviceType = 1;
			} else if(CONTENTVIEW_GENERAL.avwUserEnvObj.os == "iphone"){
				deviceType = 2;
			} else if(CONTENTVIEW_GENERAL.avwUserEnvObj.os == "android"){
				deviceType = 3;
			}
		}
		log.deviceTypeId = deviceType;
		
		//GPS
		log.latitude = ClientData.latitude();
		log.longitude = ClientData.longitude();
		
		//PageLog 1ページ目セット(1レコードは必須)
		var pageLog = new PageLogEntity();
		pageLog.contentid = strContentId;
		log.pageLogArray.push(pageLog);
		
		// Add to storage
		arrContentLogs.push(log);
2385 2386 2387 2388 2389 2390
    }
    
    // Set back to storage
    ClientData.ContentLogData(arrContentLogs);
};

Masaru Abe committed
2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411
/*
Set starting log for reading content
*/
COMMON.SetGpsLog = function(strContentId) {

    var arrContentLogs = ClientData.ContentLogData();

    for (var nIndex = 0;  nIndex < arrContentLogs.length; nIndex++) {
        if (arrContentLogs[nIndex].contentid == strContentId) {
        	//GPS
        	arrContentLogs[nIndex].latitude = ClientData.latitude();
        	arrContentLogs[nIndex].longitude = ClientData.longitude();
        	break;
        }
    }
    // Set back to storage
    ClientData.ContentLogData(arrContentLogs);
    
};


2412
// Set ending log for reading content
Masaru Abe committed
2413
COMMON.SetEndLog = function(strContentId) {
2414

Masaru Abe committed
2415
    //var log = new LogEntity(); //無駄なのでコメント
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426
    var arrContentLogs = ClientData.ContentLogData();
    
    for(var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
        if(arrContentLogs[nIndex].contentid == strContentId) {
            // Found content -> set ending date
            var dateEnd = new Date();
            var dateStart = new Date(arrContentLogs[nIndex].readingStartDate);
            arrContentLogs[nIndex].readingEndDate = dateEnd;
            
            // Calculate to seconds
            arrContentLogs[nIndex].readingTime = dateEnd.subtractBySeconds(dateStart);
2427
            
2428 2429 2430 2431 2432
        }
    }
    ClientData.ContentLogData(arrContentLogs);
};

Masaru Abe committed
2433
// 1ページ分のページ閲覧ログを作成
Masaru Abe committed
2434
COMMON.SetPageLog = function(strContentId, strPageNo){
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450
	
	var arrContentLogs = ClientData.ContentLogData();
	
	for(var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
		if(arrContentLogs[nIndex].contentid == strContentId) {
			
			//PageLog追加
			var pageLog = new PageLogEntity();
			pageLog.contentid = strContentId;
			pageLog.pageNo = strPageNo + 1; //0始まりのページ番号
			arrContentLogs[nIndex].pageLogArray.push(pageLog);
			
		}
	}
	ClientData.ContentLogData(arrContentLogs);

Masaru Abe committed
2451 2452 2453 2454 2455
	//ストリーミングモード
	if(ClientData.isStreamingMode()){
		CONTENTVIEW_STREAMING.movePage(strPageNo + 1);
	}
	
Masaru Abe committed
2456
};
2457

Masaru Abe committed
2458
// 1アクションのオブジェクトログを作成
Masaru Abe committed
2459
COMMON.SetObjectLog = function(strContentId, objectLog){
Masaru Abe committed
2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471
	
	var arrContentLogs = ClientData.ContentLogData();
	
	for(var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
		if(arrContentLogs[nIndex].contentid == strContentId) {
			//ObjectLog追加
			arrContentLogs[nIndex].objectLogArray.push(objectLog);
			
		}
	}
	ClientData.ContentLogData(arrContentLogs);

Masaru Abe committed
2472
};
Masaru Abe committed
2473

Masaru Abe committed
2474
// 前回の1アクションのオブジェクトログの利用時間を設定
Masaru Abe committed
2475
COMMON.SetObjectLogActionTime = function( strContentId, objectId, actionTime ){
Masaru Abe committed
2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489
	
	var arrContentLogs = ClientData.ContentLogData();
	
	for(var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
		if(arrContentLogs[nIndex].contentid == strContentId) {
			if( arrContentLogs[nIndex].objectLogArray.length > 0 ){
				if( arrContentLogs[nIndex].objectLogArray[ arrContentLogs[nIndex].objectLogArray.length - 1].objectId == objectId ){
					arrContentLogs[nIndex].objectLogArray[ arrContentLogs[nIndex].objectLogArray.length - 1].actionTime = actionTime;
				}
			}
		}
	}
	ClientData.ContentLogData(arrContentLogs);

Masaru Abe committed
2490
};
Masaru Abe committed
2491

2492 2493 2494
/*
  Register reading log of content to server by calling api
*/
2495
COMMON.RegisterLog = function(isUnload) {
2496

2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511
	if(isUnload == null){
		isUnload = false;
	}
	
	var arrContentLogs = ClientData.ContentLogData();
	
	//ブラウザ閉じる場合は重複を回避するためログデータ先に削除
	if(isUnload){
		ClientData.ContentLogData([]);
	}
	
	var isError = false;
	for (var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
		var dateEnd = new Date(arrContentLogs[nIndex].readingEndDate);
		var dateStart = new Date(arrContentLogs[nIndex].readingStartDate);
2512

2513
		//ページログJSONデータの作成
Masaru Abe committed
2514 2515
		var pageLogJson = "";
		var objectLogJson = "";
2516 2517 2518
		
		//biz/adモードで詳細ログY か getitsでgetits詳細ログY の場合
		if((ClientData.isGetitsMode() == false && ClientData.serviceOpt_usable_readinglog_object() == 'Y') || (ClientData.isGetitsMode() == true && ClientData.serviceOpt_reader_readinglog_object() == 'Y')){
Masaru Abe committed
2519 2520
			var pageLogArray = arrContentLogs[nIndex].pageLogArray;
			//詳細ログオプションが有効ならページ閲覧ログデータ作成
2521
			if( pageLogArray != null && pageLogArray.length > 0 ){
2522
		
Masaru Abe committed
2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537
				var lines = [];
				//終了時間と閲覧時間の設定
				var pageLogStart;
				var pageLogEnd;
				//2レコード目からチェック
				for (var nIndex2 = 1; nIndex2 < pageLogArray.length; nIndex2++) {
					//一つ前のログの終了日時がnullなら次のレコードの開始日時をセット
					if( pageLogArray[nIndex2 -1].readingEndDate == null ){
						pageLogArray[nIndex2 -1].readingEndDate = pageLogArray[nIndex2].readingStartDate;
					}
					pageLogStart = new Date(pageLogArray[nIndex2 -1].readingStartDate);
					pageLogEnd = new Date(pageLogArray[nIndex2 -1].readingEndDate);
					//時間差から閲覧秒セット
					pageLogArray[nIndex2 -1].readingTime = pageLogEnd.subtractBySeconds(pageLogStart);
				
2538
				}
Masaru Abe committed
2539 2540 2541 2542 2543 2544
				//最終レコードの処理
				if( pageLogArray[pageLogArray.length - 1].readingEndDate == null ){
					pageLogArray[pageLogArray.length - 1].readingEndDate = new Date();
				}
				pageLogStart = new Date(pageLogArray[pageLogArray.length - 1].readingStartDate);
				pageLogEnd = new Date(pageLogArray[pageLogArray.length - 1].readingEndDate);
2545
				//時間差から閲覧秒セット
Masaru Abe committed
2546
				pageLogArray[pageLogArray.length -1].readingTime = pageLogEnd.subtractBySeconds(pageLogStart);
2547
			
Masaru Abe committed
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568
				//JSONデータ作成
				for (var nIndex2 = 0; nIndex2 < pageLogArray.length; nIndex2++) {
					pageLogStart = new Date(pageLogArray[nIndex2].readingStartDate);
					pageLogEnd = new Date(pageLogArray[nIndex2].readingEndDate);
					//3秒以上なら記録する
					if( pageLogArray[nIndex2].readingTime > 2 ){
						var line = [];
						line.push(pageLogArray[nIndex2].pageNo);
						line.push(pageLogStart.jpDateTimeString1());
						line.push(pageLogEnd.jpDateTimeString1());
						line.push(pageLogArray[nIndex2].readingTime);
						lines.push(line);
						//alert("PageLog Line:" + JSON.stringify( line ) );
					}
				}
				//alert("PageLog Lines:" + JSON.stringify( lines ) );
				
				if( lines.length > 0 ){
					pageLogJson = "{ header:[\"pageNo\",\"readingStartDate\",\"readingEndDate\",\"readingTime\"],lines:";
					pageLogJson = pageLogJson + JSON.stringify( lines );
					pageLogJson = pageLogJson + "}";
Masaru Abe committed
2569
					//console.log("JSON:" + pageLogJson);
Masaru Abe committed
2570
				}
2571
			}
Masaru Abe committed
2572 2573 2574
			
			var objectLogArray = arrContentLogs[nIndex].objectLogArray;
			//詳細ログオプションが有効ならページ閲覧ログデータ作成
2575
			if( objectLogArray != null && objectLogArray.length > 0 ){
Masaru Abe committed
2576 2577 2578 2579 2580 2581 2582
			
				var lines = [];
				var actionDate;
			
				//JSONデータ作成
				for (var nIndex2 = 0; nIndex2 < objectLogArray.length; nIndex2++) {
					actionDate = new Date(objectLogArray[nIndex2].actionDate);
2583
					var line = [];
2584
					
Masaru Abe committed
2585
					if( objectLogArray[nIndex2].objectId != null ){
2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597
						line.push(actionDate.jpDateTimeString1());
						line.push(objectLogArray[nIndex2].pageNo);
						line.push(objectLogArray[nIndex2].objectId);
						line.push(objectLogArray[nIndex2].resourceId);
						line.push(objectLogArray[nIndex2].mediaType);
						line.push(objectLogArray[nIndex2].actionType);
						line.push(objectLogArray[nIndex2].actionValue);
						line.push(objectLogArray[nIndex2].actionTime);
						line.push(objectLogArray[nIndex2].locationX);
						line.push(objectLogArray[nIndex2].locationY);
						line.push(objectLogArray[nIndex2].locationHeight);
						line.push(objectLogArray[nIndex2].locationWidth);
Masaru Abe committed
2598 2599 2600 2601 2602 2603
						if( objectLogArray[nIndex2].eventType != null ){
							line.push(objectLogArray[nIndex2].eventType);
						} else {
							line.push("");
						}
						
2604
						lines.push(line);
Masaru Abe committed
2605 2606
						//console.log("ObjectLog Line:" + JSON.stringify( line ) );
						
2607
					}
Masaru Abe committed
2608
				}
Masaru Abe committed
2609
				//console.log("ObjectLog Lines:" + JSON.stringify( lines ) );
Masaru Abe committed
2610 2611
			
				if( lines.length > 0 ){
Masaru Abe committed
2612
					objectLogJson = "{ header:[\"actionDate\",\"pageNo\",\"objectId\",\"resourceId\",\"mediaType\",\"actionType\",\"actionValue\",\"actionTime\",\"locationX\",\"locationY\",\"locationHeight\",\"locationWidth\",\"eventType\"],";
Masaru Abe committed
2613 2614 2615
					objectLogJson = objectLogJson + "lines:";
					objectLogJson = objectLogJson + JSON.stringify( lines );
					objectLogJson = objectLogJson + "}";
Masaru Abe committed
2616
					//console.log("JSON:" + objectLogJson);
2617
				}
Masaru Abe committed
2618
			
2619 2620 2621
			}
			
		}
Masaru Abe committed
2622
		
2623 2624 2625 2626 2627 2628
        var params = {
            sid: ClientData.userInfo_sid(),
            contentId: arrContentLogs[nIndex].contentid,
            readingStartDate: dateStart.jpDateTimeString1(),
            readingEndDate: dateEnd.jpDateTimeString1(),
            readingTime: arrContentLogs[nIndex].readingTime,
Masaru Abe committed
2629 2630 2631
            deviceTypeId: arrContentLogs[nIndex].deviceTypeId,
            latitude: arrContentLogs[nIndex].latitude,
            longitude: arrContentLogs[nIndex].longitude,
Masaru Abe committed
2632
            pageLog: pageLogJson,
Masaru Abe committed
2633 2634
            objectLog: objectLogJson,
            isStreaming: ClientData.isStreamingMode()
2635
        };
2636 2637
        //API送信結果判定
        arrContentLogs[nIndex].sendResult = false;
2638
        AVWEB.avwCmsApiSync(ClientData.userInfo_accountPath(), "contentReadingLog", 'post', params,
2639 2640 2641 2642 2643 2644
                        function (data) {
                           if (data.result == 'success') {
                               //成功したログは削除
                               arrContentLogs[nIndex].sendResult = true;
                           }
                        },
2645 2646 2647
                        function (xhr, b, c) {
                            if (xhr.status != 0) {
                                isError = true;
2648 2649 2650 2651 2652
                                var xhrData = JSON.parse(xhr.responseText);
                                if ( xhrData && xhrData.httpStatus == 500 ) {
                                   //なんらか不正なデータなので送信成功にして捨てる
                                   arrContentLogs[nIndex].sendResult = true;
                                }
2653 2654
                            }
                            else {
2655
                            	AVWEB.showSystemError();
2656
                            }
Masaru Abe committed
2657 2658
                        }
        );
2659
    };
2660
    
2661
    if (AVWEB.avwHasError()) {
2662 2663 2664 2665 2666
        return;
    }
    // Clear logs in local
    if (!isError) {
        ClientData.ContentLogData([]);
2667 2668 2669 2670 2671 2672 2673 2674 2675
    } else {
        //送信成功したログは削除
        var arrTarget = [];
        for (var nIndex = 0; nIndex < arrContentLogs.length; nIndex++) {
            if( arrContentLogs[nIndex].sendResult == false ){
                arrTarget.push(arrContentLogs[nIndex]);
            }
        }
        ClientData.ContentLogData(arrTarget);
2676
    }
2677

2678 2679 2680 2681
};


// Disable specified objects
Masaru Abe committed
2682
COMMON.disable = function() {
2683 2684 2685 2686 2687 2688 2689
    for (var nIndex = 0; nIndex < arguments.length; nIndex++) {
        if($(arguments[nIndex])) {
            $(arguments[nIndex]).attr('disabled', 'disabled');
        }
    }
};
// Enable specified objects
Masaru Abe committed
2690
COMMON.enable = function() {
2691 2692 2693 2694 2695 2696 2697 2698
    for (var nIndex = 0; nIndex < arguments.length; nIndex++) {
        if($(arguments[nIndex])) {
            $(arguments[nIndex]).removeAttr('disabled');
        }
    }
};

// Stop waiting screen
Masaru Abe committed
2699
COMMON.StopWaitProcess = function() {
2700 2701 2702 2703
    $('#avw-sys-modal-wait').hide();
};

// Show waiting screen
Masaru Abe committed
2704
COMMON.WaitProcess = function() {
2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735
    if (document.getElementById('avw-sys-modal-wait')) {
        $('#avw-sys-modal-wait').show();
    }
    else {
        var tags = '<div id="avw-sys-modal-wait"><img id="avw-sys-modal-wait-img" src="img/data_loading.gif"/></div>';
        $('body').prepend(tags);
        $('#avw-sys-modal-wait').css({
            'opacity': 0.7,
            'position': 'fixed',
            'top': '0',
            'left': '0',
            'width': $(window).width(),
            'height': $(window).height(),
            'background': '#999',
            'z-index': 100
        });

        $("#avw-sys-modal-wait-img").center();
        
        // resize error page	
        $(window).resize(function () {
            $('#avw-sys-modal-wait').css({
                'width': $(window).width(),
                'height': $(window).height()
            });
            $("#avw-sys-modal-wait-img").center();
        });
    }
};

// Hide the locking layout
Masaru Abe committed
2736
COMMON.unlockLayout = function() {
2737 2738 2739 2740
    $('#avw-sys-modal').hide();
};

// Show the locking layout
Masaru Abe committed
2741
COMMON.lockLayout = function() {
2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809
    if (document.getElementById('avw-sys-modal')) {
        $('#avw-sys-modal').show();
    }
    else {
        var tags = '<div id="avw-sys-modal"></div>';
        $('body').prepend(tags);
        $('#avw-sys-modal').css({
            'opacity': 0.7,
            'position': 'fixed',
            'top': '0',
            'left': '0',
            'width': $(window).width(),
            'height': $(window).height(),
            'background': '#999',
            'z-index': 100
        });
        // resize error page	
        $(window).resize(function () {
            $('#avw-sys-modal').css({
                'width': $(window).width(),
                'height': $(window).height()
            });
        });
    }
};

// Function to set position of object to center
jQuery.fn.center = function () {
    this.css("position", "fixed");

    this.css("top", (($(window).height() - this.height()) / 2) + "px");
    this.css("left", (($(window).width() - this.width()) / 2) + "px");

    return this;
};
// Function to set position of object to top
jQuery.fn.top = function () {
    this.css("position", "absolute");
    this.css("top", ($(window).scrollTop() + 1) + "px");

    return this;
};
// Function to set position of object to right
jQuery.fn.right = function () {
    this.css("position", "absolute");
    this.css("left", ($(window).width() - this.width() - 5) + $(window).scrollLeft() + "px");

    return this;
};
// Function to set position of object to bottom
jQuery.fn.bottom = function () {
    this.css("position", "absolute");
    this.css("top", ($(window).height() - this.height() - 5) + $(window).scrollTop() + "px");

    return this;
};
// Replace all text by new text
String.prototype.replaceAll = function (oldText, newText) {
    var strResult = this;
    while (strResult.indexOf(oldText) >= 0) {
        strResult = strResult.replace(oldText, newText);
    }
    return strResult;
};

/*
  Get string by number of lines
*/
Masaru Abe committed
2810
COMMON.getLines = function(source, number) {
2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829
    var result = "";
    var arrSource = new Array();
    arrSource = source.split('\n');
    for (var i = 0; i < number; i++) {
        if (i >= arrSource.length) {
            break;
        }
        //count \n character occured
        if (i < (source.split('\n').length) && i != 0) {
            result += "\n";
        }
        result += arrSource[i];
    }
    return result;
};

/*
Convert yyyy-MM-dd hh:mm:ss.f to Date
*/
Masaru Abe committed
2830
COMMON.convertToDate = function(input) {
2831 2832 2833 2834 2835 2836 2837 2838 2839
    var dateResult;
    var nYear = 0;
    var nMonth = 0;
    var nDay = 0;
    var nHour = 0;
    var nMinute = 0;
    var nSecond = 0;
    var strTemp = input;
    var nIndex;
Masaru Abe committed
2840
    
2841
    dateResult = new Date();
Masaru Abe committed
2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880
	try {
		
		// Get year
		nIndex = strTemp.indexOf("-");
		nYear = Number(strTemp.substr(0, nIndex));
		// Get month
		strTemp = strTemp.substr(nIndex + 1);
		nIndex = strTemp.indexOf("-");
		nMonth = Number(strTemp.substr(0, nIndex));
		// Get day
		strTemp = strTemp.substr(nIndex + 1);
		nIndex = strTemp.indexOf(" ");
		nDay = Number(strTemp.substr(0, nIndex));
		// Get hour
		strTemp = strTemp.substr(nIndex + 1);
		nIndex = strTemp.indexOf(":");
		nHour = Number(strTemp.substr(0, nIndex));
		// Get minute
		strTemp = strTemp.substr(nIndex + 1);
		nIndex = strTemp.indexOf(":");
		nMinute = Number(strTemp.substr(0, nIndex));
		// Get second
		strTemp = strTemp.substr(nIndex + 1);
		nIndex = strTemp.indexOf(".");
		nSecond = Number(strTemp.substr(0, nIndex));
		
		dateResult.setYear(nYear);
		dateResult.setMonth(nMonth-1);
		dateResult.setDate(nDay);
		dateResult.setHours(nHour);
		dateResult.setMinutes(nMinute);
		dateResult.setSeconds(nSecond);
		
	} catch(e) {
		//
	}
	
	return dateResult;
	
2881 2882 2883 2884 2885
};

/*
  Escape html
*/
Masaru Abe committed
2886
COMMON.htmlEncode = function(value) {
2887 2888 2889 2890 2891 2892
    return jQuery('<div/>').text(value || '').html();
};

/*
  Check if browser is on touch device
*/
Masaru Abe committed
2893
COMMON.isTouchDevice = function() {
2894 2895 2896 2897 2898 2899 2900 2901 2902 2903
    var is_touch_device = 'ontouchstart' in document.documentElement;
    if (is_touch_device) {
        return true;
    }
    return false;
};

/*
Get total bytes of jp chars
*/
Masaru Abe committed
2904
COMMON.getBytes = function(value) {
2905 2906
    var escapedStr = encodeURI(value);

2907
    var count;
2908
    if (escapedStr.indexOf("%") != -1) {
2909
        count = escapedStr.split("%").length - 1;
2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922
        if (count == 0) count++;   //perverse case; can't happen with real UTF-8
        var tmp = escapedStr.length - (count * 3);

        count = (count / 3) * 2 + tmp;

    } else {
        count = escapedStr.length
    }
    return count;
};
/*
Truncate by bytes
*/
Masaru Abe committed
2923
COMMON.truncateByBytes = function(value, byteCount) {
2924 2925
    var strResult = "";
    for (var nIndex = 0; nIndex < value.length; nIndex++) {
Masaru Abe committed
2926
        if (COMMON.getBytes(strResult + value[nIndex]) <= byteCount) {
2927 2928 2929 2930 2931 2932 2933 2934 2935
            strResult += value[nIndex];
        }
        else {
            break;
        }
    }
    return strResult;
};

Masaru Abe committed
2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948
COMMON.truncate = function(strInput, length){
    if (strInput.length <= length)
    {
        return strInput;
    }
    else
    {
        return strInput.substring(0, length) + "...";
    }
};

COMMON.ToogleLogoutNortice = function() {
    if (COMMON.isAnonymousLogin()) {
2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959
        return;
    }
    var isShow = false;
    if (ClientData.userOpt_closeOrRefreshAlert() == 1) {    // Checked
        isShow = true;
    }

    if (isShow == false) {
        window.onbeforeunload = null;
    }
    else {
2960
    	AVWEB.avwSetLogoutNortice();
2961 2962 2963 2964 2965 2966
    }
};

/*
Get UTC Time ( GMT + 0 )
*/
Masaru Abe committed
2967
COMMON.getUtcTime = function() {
2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979
    var curTime = new Date();

    /* get time zone */
    var timeZone = curTime.getTimezoneOffset();

    var resultTime = new Date(curTime.getTime() + (timeZone * 60000));

    return resultTime;

};

// Convert UTC time to Date object
Masaru Abe committed
2980
COMMON.convertUtcToDate = function(utcTime) {
2981 2982 2983 2984
    return new Date(Number(utcTime));
};

// Get UUID version 4
Masaru Abe committed
2985
COMMON.getUUID = function() {
2986 2987 2988 2989 2990 2991
    return uuid.v4();
};

/*
Check is anonymous user login
*/
Masaru Abe committed
2992
COMMON.isAnonymousLogin = function() {
2993
    return AVWEB.avwSysSetting().anonymousLoginFlg;
Masaru Abe committed
2994
};
2995 2996

/* Check if current browser is IE9 */
Masaru Abe committed
2997
COMMON.isIE9 = function() {
2998 2999 3000 3001 3002 3003 3004 3005 3006
    var ua = window.navigator.userAgent.toLowerCase();
    
    if (/msie 9.0/.test(ua)) {
        return true;
    }
    return false;
};

/* Check if current browser is IE10 */
Masaru Abe committed
3007
COMMON.isIE10 = function() {
3008 3009 3010 3011 3012
    var ua = window.navigator.userAgent.toLowerCase();
    if (/msie 10.0/.test(ua)) {
        return true;
    }
    return false;
3013
};
Masaru Abe committed
3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140

//Check content type is pdf content
COMMON.isPdfContent = function(contentType){
    if(!(contentType == COMMON.ContentTypeKeys.Type_PDF)){
        return false; 
    }
    else{
        return true;
    }
};

//set resource version data
COMMON.setResourceVersionData = function(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 < COMMON.resourceVersionArr.length; i++) {
        if (COMMON.resourceVersionArr[i].contentid == conId) {
            tempResource = COMMON.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
COMMON.setMetaVersionData = function(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 < COMMON.metaVersionArr.length; i++) {
        if (COMMON.metaVersionArr[i].contentid == conId) {
            tempMeta = COMMON.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);
};

//convert delivery Date
COMMON.formatDeliveryDate = function(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
COMMON.formatNormalDate = function(day, month, year) {
    var outputDate = year + '/' + (('' + month).length < 2 ? '0' : '') + month + '/' + (('' + day).length < 2 ? '0' : '') + day;

    return outputDate;
};

//format Image string
COMMON.formatStringBase64 = function(imgStr) {

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

    return outputString;
};

Masaru Abe committed
3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161
//Get param url
COMMON.getUrlParam = function(name, url){
	
	if(!url){
		url = window.location.href;
	}
	
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec(url); 
    if( results == null ){
        return "";
    }      
    else{
    	//alert("results[0]:" + results[0]);
    	//alert("results[1]:" + results[1]);
        return results[1];
    }
};