This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
A Passible Advertising WebIDL
shawngao5 edited this page Sep 4, 2014
·
50 revisions
interface xwalk {
attribute Experimental experimental;
}
interface experimental {
attribute Advertising ad;
}
ad of type Advertising, readonly
- The object that exposes the Advertising functionality.
The Advertising interface exposes the Advertising functionality.
interface Advertising {
Promise create (RequestOptions requestOptions);
};
create
- This method creates an ad.
- Parameter: options
- Type: RequestOptions
- Nullable: N
- Optinal: N
- Return type: Promise
- Create a View with input options. Banner or Interstitial.
- Return a new
Promise
object. - If an error occurs call promise's
error
method. - When the method has been successfully completed, call
success
method of the promise.
interface Advertise {
Promise destroy ();
Promise show (boolean show);
attribute EventHandler onopen;
attribute EventHandler onclose;
};
onopen
- Handles the
touch
event, fired when an ad is opened by user.
onclose
- Handles the
close
event, fired when an ad is closed by user.
destroy
- This method destroys a view.
- No parameters.
- Return type: Promise
show
- This method controls the ad be shown and hidden.
- Parameter: bShow
- Type: boolean
- Nullable: N
- Optinal: N
- Return type: Promise
- Destroy the ad.
- Return a new
Promise
object. - If an error occurs call promise's
error
method. - When the method has been successfully completed, call
success
method of the promise.
- request an ad from server.
- Return a new
Promise
object. - If an error occurs call promise's
error
method. - When the method has been successfully completed, call
success
method of the promise.
- Show ad when
show
is true. Hide ad whenshow
is false. - Return a new
Promise
object. - If an error occurs call promise's
error
method. - When the method has been successfully completed, call
success
method of the promise.
The Advertising interface exposes the Advertising functionality.
interface RequestOptions {
attribute DOMString publisherId;
attribute DOMString type;
attribute DOMString size;
optional attribute boolean bannerAtTop;
optional attribute boolean overlap;
}
publisherId
of type DOMString
- Represents a unique identifier of the publisher.
type
of type DOMString
- Represents the type of ad. Currently, "banner" and "interstitial" are available.
size
of type DOMString
- Represents the size of ad.
bannerAtTop
of type boolean
- Represents Whether or not the ad should be positioned at top or bottom of screen.
overlap
of type boolean
- Represents Whether or not the banner will overlap the webview instead of push it up or down.
xwalk.experimental.ad.create({
"publisherId" : "ca-app-pub-xxx/4806197152",
"type" : "banner",
"size" : "SMART_BANNER",
"bannerAtTop" : false,
"overlap" : false
}).then(
function(ad) {
ad.addEventListene("open", function(evt) {
console.log("Ad is opened");
ad.show(true);
})
ad.addEventListene("close", function(evt) {
console.log("Ad is closeed");
})
},
function(err) {
console.log("Failed to create ad")
}
);