Skip to content

Commit

Permalink
Revert "Add toggle to enforce order of events in the demo minimal js (#…
Browse files Browse the repository at this point in the history
…203)"

This reverts commit ccc3b25.
  • Loading branch information
esme authored Aug 6, 2024
1 parent ccc3b25 commit 7630cea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
11 changes: 11 additions & 0 deletions demos/demo-minimal-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,67 +158,78 @@
/>
<p>2. Log in to the app</p>
<input
disabled
id="login"
onclick="logIn()"
type="button"
value="log in"
/>
<input
disabled
id="logout"
onclick="logOut()"
type="button"
value="log out"
/>
<p>3. Set inbound calling availability</p>
<button
disabled
id="useravailable"
onclick="userAvailable()"
type="button"
><span>available</span><span class="beta-badge">BETA</span></button>
<button
disabled
id="userunavailable"
onclick="userUnavailable()"
type="button"
><span>unavailable</span><span class="beta-badge">BETA</span></button>
<p>4. Start a call</p>
<button
disabled
id="incomingcall"
onclick="incomingCall()"
type="button"
><span>incoming call started</span><span class="beta-badge">BETA</span></button>
<input
disabled
id="outgoingcall"
onclick="outgoingCall()"
type="button"
value="outgoing call started"
/>
<input
disabled
id="answercall"
onclick="answerCall()"
type="button"
value="call answered"
/>
<p>5. End a call</p>
<input
disabled
id="endcall"
onclick="endCall()"
type="button"
value="call ended"
/>
<input
disabled
id="completecall"
onclick="completeCall()"
type="button"
value="call completed"
/>
<p class="other-events">Other events</p>
<input
disabled
id="senderror"
onclick="sendError()"
type="button"
value="send error"
/>
<input
disabled
id="resizewidget"
onclick="resizeWidget()"
type="button"
Expand Down
32 changes: 3 additions & 29 deletions demos/demo-minimal-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const state = {
toNumber: "+1234",
userAvailable: false,
userId: 0,
enforceButtonsOrder: false,
ownerId: 0,
};

Expand All @@ -35,18 +34,12 @@ const USER_AVAILABLE = "useravailable";
const USER_UNAVAILABLE = "userunavailable";

function disableButtons(ids) {
if (!state.enforceButtonsOrder) {
return;
}
ids.forEach(id => {
document.querySelector(`#${id}`).setAttribute("disabled", true);
});
}

function enableButtons(ids) {
if (!state.enforceButtonsOrder) {
return;
}
ids.forEach(id => {
document.querySelector(`#${id}`).removeAttribute("disabled");
});
Expand All @@ -56,22 +49,13 @@ const cti = new CallingExtensions({
debugMode: true,
eventHandlers: {
onReady: ({ engagementId, portalId, userId, ownerId } = {}) => {
debugger;
cti.initialized({
engagementId,
isLoggedIn: false,
sizeInfo,
});
disableButtons([
INITIALIZE,
USER_AVAILABLE,
USER_UNAVAILABLE,
OUTGOING_CALL,
INCOMING_CALL,
ANSWER_CALL,
END_CALL,
COMPLETE_CALL,
LOG_OUT,
]);
disableButtons([INITIALIZE]);
if (engagementId) {
enableButtons([ANSWER_CALL, END_CALL]);
state.engagementId = engagementId;
Expand Down Expand Up @@ -163,17 +147,7 @@ export function initialize() {
cti.initialized({
isLoggedIn: false,
});
disableButtons([
INITIALIZE,
USER_AVAILABLE,
USER_UNAVAILABLE,
OUTGOING_CALL,
INCOMING_CALL,
ANSWER_CALL,
END_CALL,
COMPLETE_CALL,
LOG_OUT,
]);
disableButtons([INITIALIZE]);
enableButtons([LOG_IN, SEND_ERROR, RESIZE_WIDGET]);
}

Expand Down
4 changes: 3 additions & 1 deletion src/IFrameManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class IFrameManager {
}

static createIFrame(iFrameOptions, onLoadCallback) {
const { src, width, height, hostElementSelector } = iFrameOptions;
const {
src, width, height, hostElementSelector,
} = iFrameOptions;

if (!src || !width || !height || !hostElementSelector) {
throw new Error(
Expand Down

0 comments on commit 7630cea

Please sign in to comment.