Skip to content

Commit

Permalink
Updating example files
Browse files Browse the repository at this point in the history
  • Loading branch information
Miquel Martín committed Oct 8, 2014
1 parent ec5a2c6 commit 63198fb
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 0 deletions.
216 changes: 216 additions & 0 deletions AdMobAdsTest.xdk
@@ -0,0 +1,216 @@
{
"project": {
"projectSettingsVersion": "1.1",
"creationData": {
"type": "Blank Project",
"projectTypeName": "com.intel.xdk.projecttype.jsapp",
"src": "blankproject",
"projectGuid": "0bd8e16d-85bf-4f81-b0cb-cace6649d6ef",
"lastModifiedDate": 1412793614835,
"creationDate": 1411884247500
},
"sourceDirectory": "www",
"startFile": "index.html",
"projectFiles": {},
"projectDirectories": {},
"libraries": [
{
"name": "Cordova",
"version": "2.9.0",
"data": {
"default": true
}
},
{
"name": "intelXDK",
"version": "4.0.0",
"data": {
"default": true
}
}
],
"serviceMethods": [],
"cordovaPluginsDirectory": "plugins",
"cordovaPlugins": [
{
"id": "org.apache.cordova.device",
"version": "0.2.5",
"selectedState": "Auto",
"data": {},
"paramvals": {}
},
{
"id": "org.apache.cordova.splashscreen",
"version": "0.2.5",
"selectedState": "Auto",
"data": {},
"paramvals": {}
},
{
"id": "com.jamiestarke.webviewdebug",
"version": "",
"selectedState": "Included",
"data": {},
"paramvals": {},
"custom": "true",
"name": "WebViewDebug",
"origin": "com.jamiestarke.webviewdebug",
"originType": "cordova.io"
},
{
"id": "com.admob.google",
"version": "",
"selectedState": "Included",
"data": {},
"paramvals": {},
"custom": "true",
"name": "admob",
"origin": "com.admob.google",
"originType": "cordova.io"
}
],
"buildConfigurations": {
"Android": {
"platform_": "android",
"runtime_": "Cordova 3.x",
"name_": "Android",
"preferences_": {
"android-minSdkVersion": "10",
"android-targetSdkVersion": "19"
},
"isActive_": true,
"appName_": "AdMobAdsTest",
"appID_": "com.appfeel.admobadstest",
"appAccess_": "*",
"icons_": [
{
"relPath": "img/appFeel-36.png",
"density": "ldpi",
"height": 36,
"width": 36
},
{
"relPath": "img/appFeel-48.png",
"density": "mdpi",
"height": 48,
"width": 48
},
{
"relPath": "img/appFeel-72.png",
"density": "hdpi",
"height": 72,
"width": 72
},
{
"relPath": "img/appFeel-96.png",
"density": "xhdpi",
"height": 96,
"width": 96
}
],
"splashes_": [],
"iosProvs_": [],
"addlPermissions_": "",
"excludedLibraries_": "",
"cordovaCLIVersion_": "3.3",
"crosswalkVersion_": "stable",
"appVersion_": "0.0.1",
"appDescription_": "AdMob Ads Test application for Intel XDK.",
"appAuthor_": "https://github.com/appfeel/admob-google-cordova",
"appVersionCode_": "1"
},
"Android-Crosswalk": {
"platform_": "android",
"runtime_": "Crosswalk with Cordova 3.x",
"name_": "Android-Crosswalk",
"preferences_": {
"android-minSdkVersion": "14",
"android-targetSdkVersion": "19"
},
"isActive_": true,
"appName_": "AdMobAdsTest",
"appID_": "xdk.intel.blank.project",
"appAccess_": "*",
"icons_": [
{
"relPath": "img/appFeel-36.png",
"density": "ldpi",
"height": 36,
"width": 36
},
{
"relPath": "img/appFeel-48.png",
"density": "mdpi",
"height": 48,
"width": 48
},
{
"relPath": "img/appFeel-72.png",
"density": "hdpi",
"height": 72,
"width": 72
},
{
"relPath": "img/appFeel-96.png",
"density": "xhdpi",
"height": 96,
"width": 96
}
],
"splashes_": [],
"iosProvs_": [],
"addlPermissions_": "",
"excludedLibraries_": "",
"cordovaCLIVersion_": "3.3",
"crosswalkVersion_": "stable",
"appVersion_": "0.0.1",
"appDescription_": "AdMob Ads Test application for Intel XDK.",
"appAuthor_": "https://github.com/appfeel/admob-google-cordova",
"appVersionCode_": "1"
},
"iOS": {
"platform_": "ios",
"runtime_": "Cordova 3.x",
"name_": "iOS",
"preferences_": {
"ios-target": "5",
"ios-configuration": "adhoc"
},
"isActive_": true,
"appName_": "AdMobAdsTest",
"appID_": "xdk.intel.blank.project",
"appAccess_": "*",
"icons_": [
{
"relPath": "img/appFeel-120.png",
"height": 120,
"width": 120
},
{
"relPath": "img/appFeel-60.png",
"height": 60,
"width": 60
},
{
"relPath": "img/appFeel-152.png",
"height": 152,
"width": 152
},
{
"relPath": "img/appFeel-76.png",
"height": 76,
"width": 76
}
],
"splashes_": [],
"iosProvs_": [],
"addlPermissions_": "",
"excludedLibraries_": "",
"cordovaCLIVersion_": "3.3",
"crosswalkVersion_": "stable",
"appVersion_": "0.0.1",
"appDescription_": "AdMob Ads Test application for Intel XDK."
}
}
}
}
Binary file added demo/img1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/img2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/img3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions www/css/app.css
@@ -0,0 +1,27 @@
/*
* Please see the included README.md file for license terms and conditions.
*/

body {
/* Disable certain interactions on touch devices */
/* derived from https://github.com/ftlabs/fastclick/blob/master/examples/input.html */
-webkit-touch-callout: none ;
-webkit-text-size-adjust: none ; -ms-text-size-adjust: none ;
-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;
-webkit-highlight: none ;
-webkit-tap-highlight-color: rgba(0,0,0,0) ;
-webkit-tap-highlight-color: transparent ; /* For some Androids */

/* margin: 0.5rem ; */
background: white ;
color: black ;
}

input, textarea {
/* allow copy-paste */
-webkit-user-select: text ; -moz-user-select: text ; -ms-user-select: text ; user-select: text ;
}

.align-center {
text-align: center ;
}
Binary file added www/img/appFeel-120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-152.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-36.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-60.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-72.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-76.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/img/appFeel-96.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions www/index.html
@@ -0,0 +1,45 @@
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
<title>AdMob Ads Test for Intel XDK</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<style type="text/css">
/* Prevent copy paste for all elements except text fields */
* { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
input, textarea { -webkit-user-select:text; }
body { background-color:white; color:black }
</style>

</head>
<body>
<p>XDK Demo for AdMob Plugin</p>

<h1>Banner</h1>

Standard:
<select id="adSize">
<option value='SMART_BANNER'>SMART_BANNER</option>
<option value='BANNER'>BANNER</option>
<option value='IAB_MRECT'>IAB_MEDIUM_RECTANGLE</option>
<option value='IAB_BANNER'>IAB_BANNER</option>
<option value='IAB_LEADERBOARD'>IAB_LEADERBOARD</option>
</select><br/>

<input type='checkbox' id='bannerAtTop'/>at top<br/>
<input type='checkbox' id='overlap'/>overlap<br/>

<button onclick="createSelectedBanner();">create</button><br/>
<button onclick="admob.showBannerAd(false);">remove banner</button><br/>

<hr/>

<h1>Interstitial</h1>
<input type='checkbox' id='autoshow' checked/>auto show when ready<br/>
<button onclick="prepareInterstitial();">Prepare</button>
<button onclick="admob.showInterstitialAd();">Show</button>

<script src='cordova.js'></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
94 changes: 94 additions & 0 deletions www/js/app.js
@@ -0,0 +1,94 @@
/*jslint browser:true, devel:true, white:true, vars:true */
/*global $:false, intel:false, dev:false, admob:false */

var onXDKReady = function () {
intel.xdk.device.hideSplashScreen();
};
document.addEventListener("intel.xdk.device.ready", onXDKReady, false);

var onDeviceReady = function() {
testAdMob_main();
};
document.addEventListener("deviceready", onDeviceReady, false);

var admobid = {
banner: 'ca-app-pub-8440343014846849/3119840614',
interstitial: 'ca-app-pub-8440343014846849/4596573817'
};

function testAdMob_main() {
if (!window.admob) {
alert('admob plugin not ready');
return;
}

initAds();
admob.createBannerView(function () {
}, function (data) {
alert(JSON.stringify(data));
});
}

function initAds() {
var defaultOptions = admob.options;

defaultOptions.publisherId = admobid.banner;
defaultOptions.interstitialId = admobid.interstitial;
defaultOptions.isTesting = true;
defaultOptions.bannerAtTop = true;
defaultOptions.overlap = false;

admob.setOptions(defaultOptions);
registerAdEvents();
}

// optional, in case respond to events or handle error
function registerAdEvents() {
document.addEventListener(admob.events.onAdFailedToLoad, function (data) {
alert(data.adType + ' failed. Error: ' + data.error + ', reason: ' + data.reason);
});
document.addEventListener(admob.events.onAdLoaded, function (e) {
if (e.adType = admob.AD_TYPE.INTERSTITIAL) {
var autoshow = document.getElementById('autoshow').checked;
if (!autoshow) {
alert("Interstital available, click show to view it");
}
}
});
document.addEventListener(admob.events.onAdOpened, function (e) {});
document.addEventListener(admob.events.onAdLeftApplication, function (e) {});
document.addEventListener(admob.events.onAdClosed, function (e) {});
document.addEventListener(admob.events.onInAppPurchaseRequested, function (e) {});
}

// click button to call following functions
function getSelectedAdSize() {
var i = document.getElementById("adSize").selectedIndex;
var items = document.getElementById("adSize").options;
return items[i].value;
}

function createSelectedBanner() {
var overlap = document.getElementById('overlap').checked;
var bannerAtTop = document.getElementById("bannerAtTop").checked;
admob.createBannerView({
adId:admobid.banner,
bannerAtTop: bannerAtTop,
overlap:overlap,
adSize: getSelectedAdSize()
}, function () {
}, function (e) {
alert(JSON.stringify(e));
});
}

function prepareInterstitial() {
var autoshow = document.getElementById('autoshow').checked;
admob.requestInterstitialAd({
adId:admobid.interstitial,
autoShow:autoshow
}, function () {
}, function (e) {
alert(JSON.stringify(e));
});
}

0 comments on commit 63198fb

Please sign in to comment.