Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
cd300e10
Commit
cd300e10
authored
Feb 03, 2021
by
Lee Munkyeong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
コードレビュー対応。
parent
a368af94
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
244 additions
and
245 deletions
+244
-245
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/RoomListJSON.java
+28
-29
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ChatMessageDto.java
+3
-4
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ChatRoomDto.java
+3
-3
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/CollaborationDetailDto.java
+3
-3
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ShopMemberDto.java
+3
-3
ABVJE_Launcher_Android/assets/chat/public/js/chat.js
+204
-203
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/RoomListJSON.java
View file @
cd300e10
...
...
@@ -39,40 +39,39 @@ public class RoomListJSON extends AcmsCommonJSON {
protected
void
parse
(
JSONObject
json
)
throws
JSONValidationException
{
// ルーム一覧情報を取得
if
(
json
.
has
(
Body
))
{
JSONArray
roomListJsonArray
=
json
.
getJSONObject
(
Body
).
getJSONArray
(
ChatRoomInfoList
);
if
(
roomListJsonArray
!=
null
)
{
roomList
=
new
ArrayList
<
ChatRoomDto
>();
for
(
int
listCount
=
0
;
listCount
<
roomListJsonArray
.
length
();
listCount
++)
{
if
(
roomListJsonArray
.
getJSONObject
(
listCount
).
length
()
==
0
)
{
break
;
}
ChatRoomDto
chatRoomDto
=
new
ChatRoomDto
();
ChatMessageDto
chatMessageDto
=
new
ChatMessageDto
();
if
(!
json
.
has
(
Body
))
{
return
;
}
chatRoomDto
.
chatRoomId
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
RoomId
);
chatRoomDto
.
chatRoomName
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getString
(
RoomName
);
chatRoomDto
.
type
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
RoomType
);
chatRoomDto
.
unreadCount
=
roomListJsonArray
.
getJSONObject
(
listCount
).
has
(
UnreadCount
)
?
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
UnreadCount
)
:
0
;
chatRoomDto
.
userCount
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getJSONArray
(
AttendUsers
).
length
();
JSONArray
roomListJsonArray
=
json
.
getJSONObject
(
Body
).
getJSONArray
(
ChatRoomInfoList
);
if
(
roomListJsonArray
==
null
)
{
return
;
}
//最後メッセージ情報がある場合の処理
JSONObject
lastMessageInfoJSON
=
roomListJsonArray
.
getJSONObject
(
listCount
).
has
(
LastMessageInfo
)
?
roomListJsonArray
.
getJSONObject
(
listCount
).
getJSONObject
(
LastMessageInfo
)
:
null
;
if
(
lastMessageInfoJSON
!=
null
&&
lastMessageInfoJSON
.
has
(
MessageId
)
)
{
chatMessageDto
.
chatRoomId
=
chatRoomDto
.
chatRoomId
;
chatMessageDto
.
message
=
lastMessageInfoJSON
.
getString
(
Message
);
chatMessageDto
.
messageType
=
lastMessageInfoJSON
.
getInt
(
MessageType
);
if
(
lastMessageInfoJSON
.
has
(
InsertDate
))
{
chatMessageDto
.
insertDate
=
DateTimeUtil
.
millToDateString
(
lastMessageInfoJSON
.
getJSONObject
(
InsertDate
).
getLong
(
Time
));
}
chatMessageDto
.
shopMemberId
=
lastMessageInfoJSON
.
getInt
(
ShopMemberId
);
chatMessageDto
.
chatMessageId
=
lastMessageInfoJSON
.
getInt
(
MessageId
);
chatRoomDto
.
lastMessageInfo
=
chatMessageDto
;
}
roomList
=
new
ArrayList
<
ChatRoomDto
>();
for
(
int
listCount
=
0
;
listCount
<
roomListJsonArray
.
length
();
listCount
++)
{
if
(
roomListJsonArray
.
getJSONObject
(
listCount
).
length
()
==
0
)
{
break
;
}
ChatRoomDto
chatRoomDto
=
new
ChatRoomDto
(
);
ChatMessageDto
chatMessageDto
=
new
ChatMessageDto
();
chatRoomDto
.
chatRoomId
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
RoomId
);
chatRoomDto
.
chatRoomName
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getString
(
RoomName
);
chatRoomDto
.
type
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
RoomType
);
chatRoomDto
.
unreadCount
=
roomListJsonArray
.
getJSONObject
(
listCount
).
has
(
UnreadCount
)
?
roomListJsonArray
.
getJSONObject
(
listCount
).
getInt
(
UnreadCount
)
:
0
;
chatRoomDto
.
userCount
=
roomListJsonArray
.
getJSONObject
(
listCount
).
getJSONArray
(
AttendUsers
).
length
();
roomList
.
add
(
chatRoomDto
);
//最後メッセージ情報がある場合の処理
JSONObject
lastMessageInfoJSON
=
roomListJsonArray
.
getJSONObject
(
listCount
).
has
(
LastMessageInfo
)
?
roomListJsonArray
.
getJSONObject
(
listCount
).
getJSONObject
(
LastMessageInfo
)
:
null
;
if
(
lastMessageInfoJSON
!=
null
&&
lastMessageInfoJSON
.
has
(
MessageId
))
{
chatMessageDto
.
chatRoomId
=
chatRoomDto
.
chatRoomId
;
chatMessageDto
.
message
=
lastMessageInfoJSON
.
getString
(
Message
);
chatMessageDto
.
messageType
=
lastMessageInfoJSON
.
getInt
(
MessageType
);
if
(
lastMessageInfoJSON
.
has
(
InsertDate
))
{
chatMessageDto
.
insertDate
=
DateTimeUtil
.
millToDateString
(
lastMessageInfoJSON
.
getJSONObject
(
InsertDate
).
getLong
(
Time
));
}
chatMessageDto
.
shopMemberId
=
lastMessageInfoJSON
.
getInt
(
ShopMemberId
);
chatMessageDto
.
chatMessageId
=
lastMessageInfoJSON
.
getInt
(
MessageId
);
chatRoomDto
.
lastMessageInfo
=
chatMessageDto
;
}
roomList
.
add
(
chatRoomDto
);
}
}
}
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ChatMessageDto.java
View file @
cd300e10
...
...
@@ -15,18 +15,17 @@ public class ChatMessageDto extends AbstractDto {
@Override
public
Object
[]
getInsertValues
()
{
Object
[]
test
=
new
Object
[]{
chatMessageId
,
chatRoomId
,
shopMemberId
,
message
,
messageType
,
imageName
,
downloadFileName
,
savePath
,
insertDate
};
return
new
Object
[]{
chatMessageId
,
chatRoomId
,
shopMemberId
,
message
,
messageType
,
imageName
,
downloadFileName
,
savePath
,
insertDate
};
return
new
Object
[]
{
chatMessageId
,
chatRoomId
,
shopMemberId
,
message
,
messageType
,
imageName
,
downloadFileName
,
savePath
,
insertDate
};
}
@Override
public
Object
[]
getUpdateValues
()
{
return
new
Object
[]
{
chatRoomId
,
shopMemberId
,
message
,
messageType
,
imageName
,
downloadFileName
,
savePath
,
insertDate
,
chatMessageId
};
return
new
Object
[]
{
chatRoomId
,
shopMemberId
,
message
,
messageType
,
imageName
,
downloadFileName
,
savePath
,
insertDate
,
chatMessageId
};
}
@Override
public
String
[]
getKeyValues
()
{
return
new
String
[]{
""
+
chatMessageId
};
return
new
String
[]{
""
+
chatMessageId
};
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ChatRoomDto.java
View file @
cd300e10
...
...
@@ -18,17 +18,17 @@ public class ChatRoomDto extends AbstractDto {
@Override
public
Object
[]
getInsertValues
()
{
return
new
Object
[]
{
chatRoomId
,
chatRoomName
,
type
,
unreadCount
,
userCount
,
favoriteRegisterDate
};
return
new
Object
[]
{
chatRoomId
,
chatRoomName
,
type
,
unreadCount
,
userCount
,
favoriteRegisterDate
};
}
@Override
public
Object
[]
getUpdateValues
()
{
return
new
Object
[]
{
favoriteRegisterDate
,
chatRoomName
,
type
,
unreadCount
,
userCount
,
chatRoomId
};
return
new
Object
[]
{
favoriteRegisterDate
,
chatRoomName
,
type
,
unreadCount
,
userCount
,
chatRoomId
};
}
@Override
public
String
[]
getKeyValues
()
{
return
new
String
[]
{
""
+
chatRoomId
};
return
new
String
[]
{
""
+
chatRoomId
};
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/CollaborationDetailDto.java
View file @
cd300e10
...
...
@@ -8,17 +8,17 @@ public class CollaborationDetailDto extends AbstractDto {
@Override
public
Object
[]
getInsertValues
()
{
return
new
Object
[]
{
collaborationDetialId
,
collaborationId
,
collaborationType
,
collaborationDuration
};
return
new
Object
[]
{
collaborationDetialId
,
collaborationId
,
collaborationType
,
collaborationDuration
};
}
@Override
public
Object
[]
getUpdateValues
()
{
return
new
Object
[]
{
collaborationDuration
,
collaborationId
,
collaborationType
,
collaborationDetialId
};
return
new
Object
[]
{
collaborationDuration
,
collaborationId
,
collaborationType
,
collaborationDetialId
};
}
@Override
public
String
[]
getKeyValues
()
{
return
new
String
[]{
""
+
collaborationDetialId
};
return
new
String
[]{
""
+
collaborationDetialId
};
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/dto/ShopMemberDto.java
View file @
cd300e10
...
...
@@ -10,17 +10,17 @@ public class ShopMemberDto extends AbstractDto {
@Override
public
Object
[]
getInsertValues
()
{
return
new
Object
[]
{
shopMemberId
,
shopMemberName
,
profileUrl
,
favoriteRegisterDate
};
return
new
Object
[]
{
shopMemberId
,
shopMemberName
,
profileUrl
,
favoriteRegisterDate
};
}
@Override
public
Object
[]
getUpdateValues
()
{
return
new
Object
[]
{
shopMemberName
,
profileUrl
,
favoriteRegisterDate
,
shopMemberId
};
return
new
Object
[]
{
shopMemberName
,
profileUrl
,
favoriteRegisterDate
,
shopMemberId
};
}
@Override
public
String
[]
getKeyValues
()
{
return
new
String
[]{
""
+
shopMemberId
};
return
new
String
[]{
""
+
shopMemberId
};
}
}
ABVJE_Launcher_Android/assets/chat/public/js/chat.js
View file @
cd300e10
...
...
@@ -9,228 +9,228 @@ CHAT.globalIsInvite = false;
CHAT
.
globalLoginParameter
;
CHAT
.
saveRoomInfo
=
function
(
roomId
,
roomName
)
{
CHAT
.
globalLoginParameter
.
roomId
=
roomId
;
CHAT
.
globalLoginParameter
.
roomName
=
roomName
;
if
(
CHAT_UTIL
.
isIOS
())
{
webkit
.
messageHandlers
.
roomInfosaveMessageHandlerId
.
postMessage
({
"roomId"
:
roomId
,
"roomName"
:
roomName
});
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
if
(
roomId
==
undefined
&&
roomName
==
undefined
)
{
android
.
saveVisitRoomInfo
(
''
,
''
);
}
else
{
android
.
saveVisitRoomInfo
(
roomId
,
roomName
);
}
}
CHAT
.
globalLoginParameter
.
roomId
=
roomId
;
CHAT
.
globalLoginParameter
.
roomName
=
roomName
;
if
(
CHAT_UTIL
.
isIOS
())
{
webkit
.
messageHandlers
.
roomInfosaveMessageHandlerId
.
postMessage
({
"roomId"
:
roomId
,
"roomName"
:
roomName
});
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
if
(
roomId
==
undefined
&&
roomName
==
undefined
)
{
android
.
saveVisitRoomInfo
(
''
,
''
);
}
else
{
android
.
saveVisitRoomInfo
(
roomId
,
roomName
);
}
}
}
// #36170 画像パスが存在しない場合はデフォルトの画像を返す
// 存在する場合はプロフィール画像取得用APIのURLを生成して返す
CHAT
.
getProfileImgUrl
=
function
(
path
)
{
if
(
path
==
undefined
||
path
==
""
)
{
return
ASSET_PATH
+
'images/user-profile.png'
;
}
else
{
var
userInfo
=
path
.
split
(
"/"
).
reverse
();
return
CMS_SERVER_URL
+
'/file/getProfileImage?profileFileName='
+
userInfo
[
0
]
+
'&profileGetLoginId='
+
userInfo
[
1
];
}
if
(
path
==
undefined
||
path
==
""
)
{
return
ASSET_PATH
+
'images/user-profile.png'
;
}
else
{
var
userInfo
=
path
.
split
(
"/"
).
reverse
();
return
CMS_SERVER_URL
+
'/file/getProfileImage?profileFileName='
+
userInfo
[
0
]
+
'&profileGetLoginId='
+
userInfo
[
1
];
}
}
// Video のサムネイルファイル生成する
CHAT
.
createVideoThumbnailAndUpload
=
function
(
sourceImage
,
callback
)
{
var
fileReader
=
new
FileReader
();
fileReader
.
onload
=
function
()
{
var
blob
=
new
Blob
([
fileReader
.
result
],
{
type
:
sourceImage
.
type
});
var
url
=
URL
.
createObjectURL
(
blob
);
var
video
=
document
.
createElement
(
'video'
);
var
timeupdate
=
function
()
{
if
(
snapImage
())
{
video
.
removeEventListener
(
'timeupdate'
,
timeupdate
);
video
.
pause
();
}
};
video
.
addEventListener
(
'loadeddata'
,
function
()
{
if
(
snapImage
())
{
video
.
removeEventListener
(
'timeupdate'
,
timeupdate
);
}
});
var
snapImage
=
function
()
{
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
video
.
videoWidth
;
canvas
.
height
=
video
.
videoHeight
;
canvas
.
getContext
(
'2d'
).
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
fetch
(
canvas
.
toDataURL
(
"image/jpeg"
))
.
then
(
function
(
res
)
{
return
res
.
arrayBuffer
();
})
.
then
(
function
(
buf
)
{
// 回転された画像をFormDataに保存
const
newFile
=
new
File
([
buf
],
sourceImage
.
name
,
{
type
:
"image/jpeg"
});
callback
(
newFile
,
true
);
// ajax End
}).
catch
((
error
)
=>
{
// fetch Error catch Block
if
(
error
)
{
console
.
log
(
error
)
}
});
return
true
;
};
video
.
addEventListener
(
'timeupdate'
,
timeupdate
);
video
.
preload
=
'metadata'
;
video
.
src
=
url
;
// Load video in Safari / IE11
video
.
muted
=
true
;
video
.
playsInline
=
true
;
video
.
play
();
};
fileReader
.
readAsArrayBuffer
(
sourceImage
);
var
fileReader
=
new
FileReader
();
fileReader
.
onload
=
function
()
{
var
blob
=
new
Blob
([
fileReader
.
result
],
{
type
:
sourceImage
.
type
});
var
url
=
URL
.
createObjectURL
(
blob
);
var
video
=
document
.
createElement
(
'video'
);
var
timeupdate
=
function
()
{
if
(
snapImage
())
{
video
.
removeEventListener
(
'timeupdate'
,
timeupdate
);
video
.
pause
();
}
};
video
.
addEventListener
(
'loadeddata'
,
function
()
{
if
(
snapImage
())
{
video
.
removeEventListener
(
'timeupdate'
,
timeupdate
);
}
});
var
snapImage
=
function
()
{
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
video
.
videoWidth
;
canvas
.
height
=
video
.
videoHeight
;
canvas
.
getContext
(
'2d'
).
drawImage
(
video
,
0
,
0
,
canvas
.
width
,
canvas
.
height
);
fetch
(
canvas
.
toDataURL
(
"image/jpeg"
))
.
then
(
function
(
res
)
{
return
res
.
arrayBuffer
();
})
.
then
(
function
(
buf
)
{
// 回転された画像をFormDataに保存
const
newFile
=
new
File
([
buf
],
sourceImage
.
name
,
{
type
:
"image/jpeg"
});
callback
(
newFile
,
true
);
// ajax End
}).
catch
((
error
)
=>
{
// fetch Error catch Block
if
(
error
)
{
console
.
log
(
error
)
}
});
return
true
;
};
video
.
addEventListener
(
'timeupdate'
,
timeupdate
);
video
.
preload
=
'metadata'
;
video
.
src
=
url
;
// Load video in Safari / IE11
video
.
muted
=
true
;
video
.
playsInline
=
true
;
video
.
play
();
};
fileReader
.
readAsArrayBuffer
(
sourceImage
);
}
// Ajaxでイメージをアップロードする
CHAT
.
uploadImage
=
function
(
formData
)
{
formData
.
append
(
'roomId'
,
CHAT
.
globalLoginParameter
.
roomId
);
jQuery
.
ajax
({
async
:
true
,
url
:
CMS_SERVER_URL
+
"/file/upload"
,
type
:
"post"
,
data
:
formData
,
contentType
:
false
,
processData
:
false
}).
done
(
function
(
res
)
{
// 8
var
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
fileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
var
imageName
=
res
.
fileName
// uploadFileの判断
var
extension
=
imageName
.
substr
(
imageName
.
lastIndexOf
(
'.'
)
+
1
).
toLowerCase
();
// 画像の処理
if
(
res
.
fileType
==
"jpeg"
||
res
.
fileType
==
"jpg"
||
res
.
fileType
==
"png"
)
{
if
(
res
.
thumbnailPath
&&
res
.
thumbnailPath
.
length
>
0
)
{
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
thumbImageFileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
imageName
=
res
.
thumbImageFileName
;
}
let
downloadPath
=
CMS_SERVER_URL
+
'/file/download?fileName='
+
imageName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
// アップロードが終了した後ローディング画面から離れてメッセージをメッセージを転送する
const
lightbox
=
$
(
'<a/>'
,{
href
:
imgPath
,
'data-lightbox'
:
'attachedImages'
,
'data-title'
:
imageName
});
const
image
=
$
(
'<img/>'
,{
src
:
imgPath
,
width
:
'auto'
,
style
:
'max-width:100%'
});
const
downloadIcon
=
$
(
'<a/>'
,{
href
:
downloadPath
,
class
:
'fa fa-download'
,
download
:
res
.
fileName
});
lightbox
.
append
(
image
);
lightbox
.
append
(
downloadIcon
);
let
text
=
lightbox
.
prop
(
'outerHTML'
)
let
encodedText
try
{
encodedText
=
encodeURIComponent
(
text
)
}
catch
(
e
)
{
encodedText
=
text
;
}
socket
.
emit
(
'createMessage'
,
{
text
:
encodedText
},
1
);
}
else
{
// 動画の処理
if
(
res
.
thumbnailPath
&&
res
.
thumbnailPath
.
length
>
0
)
{
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
thumbImageFileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
}
let
downloadPath
=
CMS_SERVER_URL
+
'/file/download?fileName='
+
imageName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
const
aTag
=
$
(
'<a/>'
,
{
id
:
"attachedImages"
})
const
image
=
$
(
'<img/>'
,{
src
:
imgPath
,
width
:
'auto'
,
style
:
'max-width:100%'
});
const
downloadIcon
=
$
(
'<a/>'
,{
href
:
downloadPath
,
class
:
'fa fa-download'
,
download
:
res
.
fileName
});
aTag
.
append
(
image
);
aTag
.
append
(
downloadIcon
);
let
text
=
aTag
.
prop
(
'outerHTML'
);
let
encodedText
try
{
encodedText
=
encodeURIComponent
(
text
)
}
catch
(
e
)
{
encodedText
=
text
;
}
socket
.
emit
(
'createMessage'
,
{
text
:
encodedText
},
1
);
}
$
(
'.overlay'
).
removeClass
(
'active undismissable'
);
$
(
'.loader'
).
removeClass
(
'active'
);
CHAT_UI
.
dismissLoadingIndicator
();
})
formData
.
append
(
'roomId'
,
CHAT
.
globalLoginParameter
.
roomId
);
jQuery
.
ajax
({
async
:
true
,
url
:
CMS_SERVER_URL
+
"/file/upload"
,
type
:
"post"
,
data
:
formData
,
contentType
:
false
,
processData
:
false
}).
done
(
function
(
res
)
{
// 8
var
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
fileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
var
imageName
=
res
.
fileName
// uploadFileの判断
var
extension
=
imageName
.
substr
(
imageName
.
lastIndexOf
(
'.'
)
+
1
).
toLowerCase
();
// 画像の処理
if
(
res
.
fileType
==
"jpeg"
||
res
.
fileType
==
"jpg"
||
res
.
fileType
==
"png"
)
{
if
(
res
.
thumbnailPath
&&
res
.
thumbnailPath
.
length
>
0
)
{
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
thumbImageFileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
imageName
=
res
.
thumbImageFileName
;
}
let
downloadPath
=
CMS_SERVER_URL
+
'/file/download?fileName='
+
imageName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
// アップロードが終了した後ローディング画面から離れてメッセージをメッセージを転送する
const
lightbox
=
$
(
'<a/>'
,{
href
:
imgPath
,
'data-lightbox'
:
'attachedImages'
,
'data-title'
:
imageName
});
const
image
=
$
(
'<img/>'
,{
src
:
imgPath
,
width
:
'auto'
,
style
:
'max-width:100%'
});
const
downloadIcon
=
$
(
'<a/>'
,{
href
:
downloadPath
,
class
:
'fa fa-download'
,
download
:
res
.
fileName
});
lightbox
.
append
(
image
);
lightbox
.
append
(
downloadIcon
);
let
text
=
lightbox
.
prop
(
'outerHTML'
)
let
encodedText
try
{
encodedText
=
encodeURIComponent
(
text
)
}
catch
(
e
)
{
encodedText
=
text
;
}
socket
.
emit
(
'createMessage'
,
{
text
:
encodedText
},
1
);
}
else
{
// 動画の処理
if
(
res
.
thumbnailPath
&&
res
.
thumbnailPath
.
length
>
0
)
{
imgPath
=
CMS_SERVER_URL
+
'/file/getImage?fileName='
+
res
.
thumbImageFileName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
}
let
downloadPath
=
CMS_SERVER_URL
+
'/file/download?fileName='
+
imageName
+
'&roomId='
+
CHAT
.
globalLoginParameter
.
roomId
;
const
aTag
=
$
(
'<a/>'
,
{
id
:
"attachedImages"
})
const
image
=
$
(
'<img/>'
,{
src
:
imgPath
,
width
:
'auto'
,
style
:
'max-width:100%'
});
const
downloadIcon
=
$
(
'<a/>'
,{
href
:
downloadPath
,
class
:
'fa fa-download'
,
download
:
res
.
fileName
});
aTag
.
append
(
image
);
aTag
.
append
(
downloadIcon
);
let
text
=
aTag
.
prop
(
'outerHTML'
);
let
encodedText
try
{
encodedText
=
encodeURIComponent
(
text
)
}
catch
(
e
)
{
encodedText
=
text
;
}
socket
.
emit
(
'createMessage'
,
{
text
:
encodedText
},
1
);
}
$
(
'.overlay'
).
removeClass
(
'active undismissable'
);
$
(
'.loader'
).
removeClass
(
'active'
);
CHAT_UI
.
dismissLoadingIndicator
();
})
}
// Thumbnailのファイルを生成する。
CHAT
.
createThumbnailAndUpload
=
function
(
sourceImage
,
callback
)
{
const
fileReader
=
new
FileReader
();
const
img
=
new
Image
();
fileReader
.
onloadend
=
function
()
{
img
.
src
=
fileReader
.
result
}
img
.
onload
=
function
()
{
const
elem
=
document
.
createElement
(
'canvas'
);
var
rate
var
width
=
img
.
width
var
height
=
img
.
height
if
((
img
.
width
<=
500
)
&&
(
img
.
height
<=
500
))
{
callback
(
undefined
,
false
)
return
}
if
(
img
.
width
>
img
.
height
)
{
rate
=
500
/
img
.
width
}
else
{
rate
=
500
/
img
.
height
}
elem
.
width
=
width
*
rate
;
elem
.
height
=
height
*
rate
;
const
ctx
=
elem
.
getContext
(
'2d'
)
ctx
.
drawImage
(
img
,
0
,
0
,
img
.
width
,
img
.
height
,
0
,
0
,
elem
.
width
,
elem
.
height
);
// ctx.drawImage(img, 0, 0, width, height);
fetch
(
elem
.
toDataURL
(
"image/jpeg"
))
.
then
(
function
(
res
)
{
return
res
.
arrayBuffer
();
})
.
then
(
function
(
buf
)
{
const
newFile
=
new
File
([
buf
],
sourceImage
.
name
,
{
type
:
"image/jpeg"
});
callback
(
newFile
,
true
)
}).
catch
((
error
)
=>
{
// fetch Error catch Block
if
(
error
)
{
console
.
log
(
error
)
}
});
}
fileReader
.
readAsDataURL
(
sourceImage
);
const
fileReader
=
new
FileReader
();
const
img
=
new
Image
();
fileReader
.
onloadend
=
function
()
{
img
.
src
=
fileReader
.
result
}
img
.
onload
=
function
()
{
const
elem
=
document
.
createElement
(
'canvas'
);
var
rate
var
width
=
img
.
width
var
height
=
img
.
height
if
((
img
.
width
<=
500
)
&&
(
img
.
height
<=
500
))
{
callback
(
undefined
,
false
)
return
}
if
(
img
.
width
>
img
.
height
)
{
rate
=
500
/
img
.
width
}
else
{
rate
=
500
/
img
.
height
}
elem
.
width
=
width
*
rate
;
elem
.
height
=
height
*
rate
;
const
ctx
=
elem
.
getContext
(
'2d'
)
ctx
.
drawImage
(
img
,
0
,
0
,
img
.
width
,
img
.
height
,
0
,
0
,
elem
.
width
,
elem
.
height
);
// ctx.drawImage(img, 0, 0, width, height);
fetch
(
elem
.
toDataURL
(
"image/jpeg"
))
.
then
(
function
(
res
)
{
return
res
.
arrayBuffer
();
})
.
then
(
function
(
buf
)
{
const
newFile
=
new
File
([
buf
],
sourceImage
.
name
,
{
type
:
"image/jpeg"
});
callback
(
newFile
,
true
)
}).
catch
((
error
)
=>
{
// fetch Error catch Block
if
(
error
)
{
console
.
log
(
error
)
}
});
}
fileReader
.
readAsDataURL
(
sourceImage
);
}
// 該当チャットルームに参加するためログイン情報をサーバに渡す
getLoginParameter
=
function
(
sid
,
loginId
,
shopName
,
roomId
=
undefined
,
roomName
=
undefined
,
languageCode
)
{
var
loginParam
=
new
Object
()
loginParam
.
sid
=
sid
;
loginParam
.
loginId
=
loginId
;
loginParam
.
shopName
=
shopName
;
loginParam
.
roomId
=
roomId
;
loginParam
.
roomName
=
roomName
;
var
loginParam
=
new
Object
()
loginParam
.
sid
=
sid
;
loginParam
.
loginId
=
loginId
;
loginParam
.
shopName
=
shopName
;
loginParam
.
roomId
=
roomId
;
loginParam
.
roomName
=
roomName
;
CHAT
.
globalLoginParameter
=
loginParam
;
CHAT
.
globalLoginParameter
=
loginParam
;
if
(
!
languageCode
)
{
languageCode
=
"en"
}
CHAT_UI
.
htmlElementTextInitialize
(
languageCode
)
if
(
!
languageCode
)
{
languageCode
=
"en"
}
CHAT_UI
.
htmlElementTextInitialize
(
languageCode
)
if
(
IS_ONLINE
==
'true'
)
{
if
(
IS_ONLINE
==
'true'
)
{
socket
.
emit
(
'join'
,
loginParam
,
function
(
err
)
{
if
(
err
)
{
// #36174
...
...
@@ -257,14 +257,14 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam
// loadingIndicatorを表示しない
CHAT_UI
.
dismissLoadingIndicator
();
});
}
else
{
// loadingIndicatorを表示しない
}
else
{
// loadingIndicatorを表示しない
CHAT_UI
.
dismissLoadingIndicator
();
}
}
}
CHAT
.
leaveRoom
=
function
()
{
socket
.
emit
(
'leaveRoom'
,
function
()
{
});
socket
.
emit
(
'leaveRoom'
,
function
()
{
});
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment