4854a.diff
src/com/goldencode/p2j/main/fwd_sdk.js 2023-09-20 09:57:11 +0000 | ||
---|---|---|
76 | 76 |
const selectElement = document.querySelector(selectElementQuery ?? '#theme-select'); |
77 | 77 |
const loginButtonNode = document.querySelector(loginButtonNodeQuery ?? '#login-button'); |
78 | 78 |
const errorNode = document.querySelector(errorNodeQuery ?? '#login-error'); |
79 |
|
|
79 | ||
80 | 80 |
const themes = JSON.parse('${themes}'); |
81 | 81 | |
82 | 82 |
loginButtonNode.onclick = function () |
... | ... | |
170 | 170 |
{ |
171 | 171 |
if (httpRequest.responseText) |
172 | 172 |
{ |
173 |
console.log('sdk messages to ' + window.top.location.origin); |
|
174 |
const launchedClientOrigin = new URL(httpRequest.responseText).origin; |
|
175 |
window.top.postMessage(launchedClientOrigin, window.top.location.origin); |
|
173 | 176 |
window.location.assign(httpRequest.responseText); |
174 | 177 |
} |
175 | 178 |
} |
176 | 179 |
else |
177 | 180 |
{ |
178 | 181 |
errorNode.textContent = httpRequest.responseText ? |
179 |
httpRequest.responseText : MSG_SDK_DEFAULT_REQUEST_ERROR; |
|
182 |
httpRequest.responseText : |
|
183 |
'The connection to the server failed. Try again later!'; |
|
180 | 184 |
} |
181 | 185 |
} |
182 | 186 |
catch (ex) |
... | ... | |
184 | 188 |
console.error(JSON.stringify(ex)); |
185 | 189 |
} |
186 | 190 |
}; |
187 |
httpRequest.open('POST', window.parent.location.href);
|
|
191 |
httpRequest.open('POST', window.top.location.href);
|
|
188 | 192 |
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
189 | 193 |
httpRequest.responseType = 'text'; |
190 | 194 |
httpRequest.send('usr=' + encodeURIComponent(usernameNode.value) + |
... | ... | |
192 | 196 |
(themes.length > 0 ? '&theme=' + encodeURIComponent(selectElement.value) : '')); |
193 | 197 |
} |
194 | 198 |
} |
195 |
|
|
199 | ||
196 | 200 |
return { |
197 | 201 |
initialize: initialize, |
198 | 202 |
} |
src/com/goldencode/p2j/main/web_landing.html 2023-09-21 08:50:34 +0000 | ||
---|---|---|
52 | 52 |
--> |
53 | 53 |
<!DOCTYPE html> |
54 | 54 |
<html> |
55 |
<head>
|
|
56 |
<title>${title}</title>
|
|
57 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
58 |
<link rel="icon" type="image/x-icon" href="/webres/favicon.ico">
|
|
59 |
<style type="text/css" media="screen">
|
|
55 |
<head> |
|
56 |
<title>${title}</title> |
|
57 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
58 |
<link rel="icon" type="image/x-icon" href="/webres/favicon.ico"> |
|
59 |
<style type="text/css" media="screen"> |
|
60 | 60 |
#main-body { |
61 | 61 |
margin: 0; /* Reset default margin */ |
62 | 62 |
} |
... | ... | |
66 | 66 |
height: 100vh; /* Viewport-relative units */ |
67 | 67 |
width: 100vw; |
68 | 68 |
} |
69 |
</style> |
|
70 |
</head> |
|
71 |
<body id="main-body"> |
|
72 |
<!-- The url for the iframe src --> |
|
73 |
<template id="spawned-client-url">${spawnedClientUrl}</template> |
|
74 |
<!-- The html for the iframe srcdoc --> |
|
75 |
<template id="html">${html}</template> |
|
76 |
|
|
77 |
<iframe id="main-iframe"></iframe> |
|
78 |
|
|
79 |
<script> |
|
80 |
'use strict'; |
|
81 |
|
|
82 |
const htmlTemplate = document.getElementById('html'); |
|
83 | ||
84 |
const spawnedClientTemplate = document.getElementById('spawned-client-url'); |
|
85 |
const spawnedClientUrl = spawnedClientTemplate.content.textContent; |
|
86 | ||
87 |
const iFrame = document.getElementById('main-iframe'); |
|
69 |
</style> |
|
70 |
</head> |
|
71 |
<body id="main-body"> |
|
72 |
<!-- The url for the iframe src --> |
|
73 |
<template id="spawned-client-url">${spawnedClientUrl}</template> |
|
74 |
<!-- The html for the iframe srcdoc --> |
|
75 |
<template id="html">${html}</template> |
|
76 | ||
77 |
<iframe id="main-iframe"></iframe> |
|
78 | ||
79 |
<script> |
|
80 |
'use strict'; |
|
81 | ||
82 |
const htmlTemplate = document.getElementById('html'); |
|
83 | ||
84 |
const spawnedClientTemplate = document.getElementById('spawned-client-url'); |
|
85 |
const spawnedClientUrl = spawnedClientTemplate.content.textContent; |
|
86 | ||
87 |
const iFrame = document.getElementById('main-iframe'); |
|
88 |
if (spawnedClientUrl) |
|
89 |
{ |
|
90 |
iFrame.src = spawnedClientUrl; |
|
91 |
} |
|
92 |
else |
|
93 |
{ |
|
94 |
iFrame.srcdoc = htmlTemplate.innerHTML; |
|
95 |
} |
|
96 | ||
97 |
htmlTemplate.remove(); |
|
98 |
spawnedClientTemplate.remove(); |
|
99 | ||
100 |
const persistentStorage = function() |
|
101 |
{ |
|
88 | 102 |
if (spawnedClientUrl) |
89 | 103 |
{ |
90 |
iFrame.src = spawnedClientUrl; |
|
104 |
// auto-login |
|
105 |
const clientOrigin = new URL(spawnedClientUrl).origin; |
|
106 |
console.log("listening for auto-login message event."); |
|
107 |
window.addEventListener('message', function (event) |
|
108 |
{ |
|
109 |
if (event.origin !== clientOrigin) |
|
110 |
{ |
|
111 |
console.log('Message received from unknown origin. Expecting web client, but found ' + |
|
112 |
event.origin); |
|
113 |
return; |
|
114 |
} |
|
115 |
console.log('message from client: ' + event.data); |
|
116 |
}); |
|
91 | 117 |
} |
92 | 118 |
else |
93 | 119 |
{ |
94 |
iFrame.srcdoc = htmlTemplate.innerHTML; |
|
95 |
} |
|
96 |
|
|
97 |
htmlTemplate.remove(); |
|
98 |
spawnedClientTemplate.remove(); |
|
99 |
</script> |
|
100 |
</body> |
|
120 |
// normal login |
|
121 |
console.log("listening for login message event."); |
|
122 |
window.addEventListener('message', function (event) |
|
123 |
{ |
|
124 |
if (event.origin !== window.origin) |
|
125 |
{ |
|
126 |
console.log('Message received from unknown origin. Expecting login, but found ' + |
|
127 |
event.origin); |
|
128 |
return; |
|
129 |
} |
|
130 |
console.log('event'); |
|
131 |
console.log(event); |
|
132 |
const origin = event.data; |
|
133 |
console.log('The launched client origin is: ' + origina); |
|
134 | ||
135 |
window.addEventListener('message', function (event) |
|
136 |
{ |
|
137 |
if (event.origin !== origin) |
|
138 |
{ |
|
139 |
console.log('Message received from unknown origin. Expecting web client, but found ' + |
|
140 |
event.origin); |
|
141 |
return; |
|
142 |
} |
|
143 |
console.log('message from client: '); |
|
144 |
console.log(event.data); |
|
145 |
}); |
|
146 |
}); |
|
147 |
} |
|
148 | ||
149 |
return { |
|
150 | ||
151 |
} |
|
152 |
}(); |
|
153 |
</script> |
|
154 |
</body> |
|
101 | 155 |
</html> |
src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2023-09-21 12:09:43 +0000 | ||
---|---|---|
2912 | 2912 |
|
2913 | 2913 |
// reset the last activity time |
2914 | 2914 |
idleTimer.reset(t1); |
2915 | ||
2916 |
console.log("sending msg to " + logoutPage); |
|
2917 |
window.top.postMessage({type: message[0], key:"key", value: "value", websocketMessage: message }, new URL(logoutPage).origin); |
|
2915 | 2918 |
|
2916 | 2919 |
switch (message[0]) |
2917 | 2920 |
{ |