![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@waiverforever/waiver-widget
Advanced tools
Adding a waiver widget to your website to allow participants to sign without leaving the page.
templateId
s for the next steps.We can load the widget automatically or manually.
For automatically loading, append the following HTML snippet into the body
tag of your website:
<script src="https://cdn.waiverforever.com/qs3/ew.js?templateId=${templateId1,templateId2}"></script>
widget instance
as a global JavaScript variable named waiverWidget
(note: its initial letter is lowercase) and WF_EMBED_WAIVER
(for backward compatibility)..onReady
, which you can use to perform extra operations if needed.sdkMode=yes
to disable it:
<script src="https://cdn.waiverforever.com/qs3/ew.js?templateId=${templateId1,templateId2}&sdkMode=yes"></script>
For manually loading, append the following HTML snippet into the body
tag of your website:
<script src="https://cdn.waiverforever.com/qs3/ew.js"></script>
src
doesn't contain a specified templateId
, the script exposes the widget constructor
as a global JavaScript variable named WaiverWidget
(note: its initial letter is uppercase).widget instance
on demand. Please make sure performing any extra operations after the .onReady
hook is triggered.You could also load the widget script dynamically, e.g. The AMD way:
require(['https://cdn.waiverforever.com/qs3/ew.js'], function (WaiverWidget) {
const widget = new WaiverWidget({
templateId: `${templateId}`, // You can also pass multiple template ids as an array, they will be displayed one after signing one.
sdkMode: true
})
widget.onReady(function(){
myCustomButton.addEventListener('click', function () {
widget.toggle()
})
})
})
})
Install the widget by npm
or yarn
:
# npm
npm i --save @waiverforever/waiver-widget
# yarn
yarn add @waiverforever/waiver-widget
// app.js
const WaiverWidget = require('@waiverforever/waiver-widget')
const widget = new WaiverWidget()
WaiverWidget
as a global variable. In a module system, we could require
or import
it directly.interface WidgetOption {
templateId: string | string[]; // required, template id, or pass multiple ids
sdkMode?: boolean; // by default it is false
windowMode?: boolean; // by default it depends on the useragent (true for mobile devices, false for desktops)
stylesheetURL?: string; // specify the stylesheet URL of the embedded waiver
embed?: boolean; // by default it is false
embedTargetId?: string; // specify the target element id for the embedded waiver, by default it is 'wf-embed-waiver-target'
}
type WaiverWidgetConstructor = new (option?: WidgetOption): IWidget;
usage:
const widget = new WaiverWidget({
templateId: `${templateId}`,
})
interface IWidget {
closeEmbedWaiverModal: () => void; // Legacy API, for backward compatibility
show: () => void; // Show widget modal and hide trigger button(in non-sdk mode)
close: () => void; // Opposite operation of show()
toggle: () => void; // Toggle between show and close methods
destroy: () => void; // Destroy the current widget instance. After ensuring previous widget instance is destroyed, we can re-initialize another widget instance.
onShowed: (callback: () => void) => void; // Event registry for modal showed hook
onReady: (callback: (widget: IWidget) => void) => void; // Event registry for widget instance ready hook, an interactive widget instance will be passed to the registered hook
onLoad: (callback: (signedCount: number) => void) => void; // Event registry for waiver page loading in the SDK mode
onSigned: (callback: (signedCount: number) => void) => void; // Event registry for waiver signing success hook
onClosed: (callback: (signedCount: number) => void) => void; // Event registry for modal close hook, the registered callback will receives a boolean type argument presents whether the user signed or not
onDestroyed: (callback: () => void) => void; // Event registry for widget destroyed hook
}
If you get bored of using the callback style .onReady
hook and others, and the async/await
syntax is available in your runtime, here are some tips for you.
All of the widget APIs are thenable/awaitable
! It means you can use the widget instance
, instance methods
and event hooks
in a synchronous-like way.
Awaiting the response of the widget instance, we get a ready state (fully-interactive) instance.
// note: use in async function, or some `top-level await` syntax implemented environment
async function appDidMount () {
const widget = await new WaiverWidget({
templateId: `${templateId}`, // You can also pass multiple template ids as an array, they will be displayed one after signing one.
})
widget.show() // widget is in ready state
}
Awaiting a response of a widget method, we receive the callback payload of the method's corresponding event hook.
async function appShowWaiverInstruction () {
// `.onShowed` event has no return value
await widget.show()
sendLog('waiver showed')
}
async function appCloseWaiverInstruction () {
// We get the signed count, which is the `.onClosed` event's callback payload
const signedCount = await widget.close()
sendLog('waiver closed, with signed count: ' + signedCount)
}
A registered event handler will be triggered whenever the event occurs. An awaited event hook will only respond to the event payload for once.
async function appDidMount () {
// ... initialize widget instance ...
widget.onSigned(async function () {
// signedCount presents the number you signed successfully
const signedCount = await widget.onClosed
// Log will be sent under the condition that waiver is signed and then the modal is closed
sendLog('waiver closed, with signed count: ' + signedCount)
})
}
Actually, awaiting a response of a event hook is rarely used.
FAQs
embed waiver widget for your site
The npm package @waiverforever/waiver-widget receives a total of 1 weekly downloads. As such, @waiverforever/waiver-widget popularity was classified as not popular.
We found that @waiverforever/waiver-widget demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.