Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat_webview
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
abookCommunication
chat_webview
Commits
c5b0f5af
Commit
c5b0f5af
authored
Apr 07, 2021
by
Takatoshi Miura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iosローカルdb連動中
parent
b8c0ce73
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
198 deletions
+32
-198
public_new/archive.html
+1
-1
public_new/chat.html
+1
-1
public_new/contact.html
+1
-1
public_new/js/chat-db.js
+29
-195
No files found.
public_new/archive.html
View file @
c5b0f5af
...
...
@@ -148,7 +148,7 @@
android
.
getLoginParameter
();
android
.
getGlobalParameter
();
webkit
.
messageHandlers
.
loginInfoRequestMessageHandlerId
.
postMessage
({});
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
();
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
(
{}
);
function
getGlobalParam
(
chatServerUrl
,
cmsServerUrl
,
platform
,
isMobile
,
isOnline
)
{
CHAT_SERVER_URL
=
chatServerUrl
;
...
...
public_new/chat.html
View file @
c5b0f5af
...
...
@@ -134,7 +134,7 @@
android
.
getLoginParameter
();
android
.
getGlobalParameter
();
webkit
.
messageHandlers
.
loginInfoRequestMessageHandlerId
.
postMessage
({});
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
();
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
(
{}
);
function
getGlobalParam
(
chatServerUrl
,
cmsServerUrl
,
platform
,
isMobile
,
isOnline
)
{
CHAT_SERVER_URL
=
chatServerUrl
;
...
...
public_new/contact.html
View file @
c5b0f5af
...
...
@@ -229,7 +229,7 @@
android
.
getLoginParameter
();
android
.
getGlobalParameter
();
webkit
.
messageHandlers
.
loginInfoRequestMessageHandlerId
.
postMessage
({});
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
();
webkit
.
messageHandlers
.
getGlobalParameter
.
postMessage
(
{}
);
function
getGlobalParam
(
chatServerUrl
,
cmsServerUrl
,
platform
,
isMobile
,
isOnline
)
{
CHAT_SERVER_URL
=
chatServerUrl
;
...
...
public_new/js/chat-db.js
View file @
c5b0f5af
...
...
@@ -2,43 +2,28 @@
var
CHAT_DB
=
{};
// ios用
const
iosData
=
{
iosRoomList
:
""
,
iosMyInfo
:
""
,
iosMessages
:
""
,
iosFavoriteUsers
:
""
,
iosFavoriteGroups
:
""
,
iosMyGroupUsers
:
""
,
iosGroupInfo
:
""
,
iosNameCardData
:
""
,
iosMyGroupShopMemberByName
:
""
,
iosAllGroupShopMemberByName
:
""
,
iosGroupByName
:
""
,
iosUsersInRoom
:
""
,
iosArchiveList
:
""
,
iosSearchArchiveList
:
""
,
iosArchiveDetail
:
""
};
var
webClient
=
{
id
:
1
,
handlers
:
{},
};
webClient
.
onMessageReceive
=
(
handle
,
error
,
data
)
=>
{
if
(
error
&&
webClient
.
handlers
[
handle
].
reject
)
{
webClient
.
handlers
[
handle
].
reject
(
data
);
}
else
if
(
webClient
.
handlers
[
handle
].
resolve
){
webClient
.
handlers
[
handle
].
resolve
(
data
);
}
delete
webClient
.
handlers
[
handle
];
};
function
callNativeApp
(
iosKey
,
jsonData
)
{
console
.
log
(
"callNativeApp called"
);
var
result
;
try
{
var
key
=
iosKey
;
var
data
=
jsonData
;
var
payload
=
{
key
:
key
,
data
:
data
};
// payloadの形 {"type":"SJbridge","data":{"name":"abc","role":"dev"}}
// resにObjective-cからのレスポンスが返る
result
=
prompt
(
JSON
.
stringify
(
payload
));
console
.
log
(
result
);
}
catch
(
err
)
{
console
.
log
(
'The native context does not exist yet'
);
}
return
result
;
}
//ロカールDBからルーム一覧情報を取得
CHAT_DB
.
getRoomList
=
function
(
roomType
,
keyWord
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
return
JSON
.
parse
(
iosRoomList
);
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
return
JSON
.
parse
(
android
.
getRoomList
(
roomType
,
keyWord
));
}
...
...
@@ -46,263 +31,112 @@ CHAT_DB.getRoomList = function(roomType, keyWord) {
CHAT_DB
.
callGetRoomList
=
function
(
roomType
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
webkit
.
messageHandlers
.
getRoomList
.
postMessage
({
roomType
});
// TODO: iosからデータを受け取るまで待つ
return
JSON
.
parse
(
iosRoomList
);
return
callNativeApp
(
getRoomList
,
{
"roomType"
:
roomType
});
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getRoomList
(
roomType
));
}
}
CHAT_DB
.
getIosRoomList
=
function
(
roomList
)
{
iosRoomList
=
roomList
;
};
//ロカールDBからログインしたユーザのデータを取得する。
CHAT_DB
.
getMyInfo
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
// iosMyInfo = "";
// webkit.messageHandlers.getMyInfo.postMessage();
// return watchValue(iosData, iosMyInfo, onChange);
webClient
.
sendMessage
=
(
data
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
handle
=
'm'
+
webClient
.
id
++
;
webClient
.
handlers
[
handle
]
=
{
resolve
,
reject
};
window
.
webkit
.
messageHandlers
.
getMyInfo
.
postMessage
({
data
:
data
,
id
:
handle
});
});
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getMyInfo
());
}
};
CHAT_DB
.
getIosMyInfo
=
function
(
myInfo
)
{
iosMyInfo
=
myInfo
;
iosKey
=
"myInfo"
;
};
CHAT_DB
.
getMessages
=
function
(
roomId
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosMessages
=
""
;
webkit
.
messageHandlers
.
getMessages
.
postMessage
({
roomId
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"messages"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosMessages
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getMessageList
(
roomId
));
}
};
CHAT_DB
.
getIosMessages
=
function
(
messages
)
{
iosMessages
=
messages
;
iosKey
=
"messages"
;
};
CHAT_DB
.
getFavoriteUsers
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosFavoriteUsers
=
""
;
webkit
.
messageHandlers
.
getFavoriteUsers
.
postMessage
();
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"favoriteUsers"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosFavoriteUsers
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getFavoriteUsers
());
}
};
CHAT_DB
.
getIosFavoriteUsers
=
function
(
user
)
{
iosFavoriteUsers
=
user
;
iosKey
=
"favoriteUsers"
;
};
CHAT_DB
.
getFavoriteGroups
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosFavoriteGroups
=
""
;
webkit
.
messageHandlers
.
getFavoriteGroups
.
postMessage
();
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"favoriteGroups"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosFavoriteGroups
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getFavoriteGroups
());
}
};
CHAT_DB
.
getIosFavoriteGroups
=
function
(
groups
)
{
iosFavoriteGroups
=
groups
;
iosKey
=
"favoriteGroups"
;
};
CHAT_DB
.
getMyGroupUsers
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosMyGroupUsers
=
""
;
webkit
.
messageHandlers
.
getMyGroupUsers
.
postMessage
();
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"myGroupUsers"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosMyGroupUsers
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getMyGroupUsers
());
}
};
CHAT_DB
.
getIosMyGroupUsers
=
function
(
user
)
{
iosMyGroupUsers
=
user
;
iosKey
=
"myGroupUsers"
;
};
CHAT_DB
.
getGroupInfo
=
function
(
groupId
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosGroupInfo
=
""
;
webkit
.
messageHandlers
.
getGroupInfo
.
postMessage
({
groupId
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"groupInfo"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosGroupInfo
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getGroupInfo
(
groupId
));
}
};
CHAT_DB
.
getIosGroupInfo
=
function
(
info
)
{
iosGroupInfo
=
info
;
iosKey
=
"groupInfo"
;
};
CHAT_DB
.
getNameCardData
=
function
(
shopMemberId
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosNameCardData
=
""
;
webkit
.
messageHandlers
.
getNameCardData
.
postMessage
({
shopMemberId
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"nameCardData"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosNameCardData
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
return
JSON
.
parse
(
android
.
getNameCardData
(
shopMemberId
));
}
};
CHAT_DB
.
getIosNameCardData
=
function
(
nameCard
)
{
iosNameCardData
=
nameCard
;
iosKey
=
"nameCardData"
;
};
CHAT_DB
.
getMyGroupShopMemberByName
=
function
(
shopMemberName
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosMyGroupShopMemberByName
=
""
;
webkit
.
messageHandlers
.
getMyGroupShopMemberByName
.
postMessage
({
shopMemberName
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"myGroupShopMemberByName"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosMyGroupShopMemberByName
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getMyGroupShopMemberByName
(
shopMemberName
));
}
};
CHAT_DB
.
getIosMyGroupShopMemberByName
=
function
(
user
)
{
iosMyGroupShopMemberByName
=
user
;
iosKey
=
"myGroupShopMemberByName"
;
};
CHAT_DB
.
getAllGroupShopMemberByName
=
function
(
shopMemberName
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosAllGroupShopMemberByName
=
""
;
webkit
.
messageHandlers
.
getAllGroupShopMemberByName
.
postMessage
({
shopMemberName
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"allGroupShopMemberByName"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosAllGroupShopMemberByName
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getAllGroupShopMemberByName
(
shopMemberName
));
}
};
CHAT_DB
.
getIosAllGroupShopMemberByName
=
function
(
user
)
{
iosAllGroupShopMemberByName
=
user
;
iosKey
=
"allGroupShopMemberByName"
;
};
CHAT_DB
.
getGroupByName
=
function
(
groupName
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosGroupByName
=
""
;
webkit
.
messageHandlers
.
getGroupByName
.
postMessage
({
groupName
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"groupByName"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosGroupByName
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getGroupByName
(
groupName
));
}
};
CHAT_DB
.
getIosGroupByName
=
function
(
group
)
{
iosGroupByName
=
group
;
iosKey
=
"groupByName"
;
};
CHAT_DB
.
getUsersInRoom
=
function
(
roomId
)
{
if
(
CHAT_UTIL
.
isIOS
())
{
iosUsersInRoom
=
""
;
webkit
.
messageHandlers
.
getUsersInRoom
.
postMessage
({
roomId
});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while
(
iosKey
==
"objc-processing"
)
{};
if
(
iosKey
==
"usersInRoom"
)
{
iosKey
=
"objc-processing"
;
return
JSON
.
parse
(
iosUsersInRoom
);
}
}
else
if
(
CHAT_UTIL
.
isAndroid
())
{
//String形式をJsonに変更してReturn
return
JSON
.
parse
(
android
.
getUsersInRoom
(
roomId
));
}
}
CHAT_DB
.
getIosUsersInRoom
=
function
(
user
)
{
iosUsersInRoom
=
user
;
iosKey
=
"usersInRoom"
;
};
// アーカイブ一覧
CHAT_DB
.
getArchiveList
=
function
()
{
if
(
CHAT_UTIL
.
isIOS
())
{
...
...
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