WebOSDev - Programming has just evolved

The online blog for the webOS developer community you can find everything you need here to get a strong start developing applications for the webOS platform

AdMob.com integration

Posted by codesos Sunday, February 21, 2010 0 comments

Want to add professional advertisements to your palm pre applicatio?
It's as simple as 1,2,3



1 . go to  http://code.google.com/p/admob-webos/

download admob.js and place it in your application

2. HTML File:

<div id="admob_ad"></div>
3.
Initialize:


      AdMob.ad.initialize({
                      pub_id: '*********', // your publisher id get it from admob.com
                      bg_color: '#ccc', // optional background color, defaults to #fff
                      text_color: '#333' 
                      });


and for each time you want to display ad:

 AdMob.ad.request({
                        onSuccess: (function (ad)
                        {
                        Mojo.Log.info("**************** AdMob OK ");
                           // successful ad call, parameter 'ad' is the html markup for the ad                       
                            this.controller.get('admob_ad').insert(ad); // place mark up in the the previously declared div 
                               }).bind(this),    
                      onFailure: (function ()
                      { // no ad was returned or call was unsuccessful                       
                          Mojo.Log.info("**************** AdMob ERROr ");  
                       }).bind(this),
             });


That is all , Now start earning Money!!

Integrate with Flot Graph system using Webos

Posted by codesos Tuesday, January 12, 2010 0 comments

Want to be able to produce HI END graphs like this?:



It's very simple:

1. go to http://code.google.com/p/flot/ and download the package.
2. Extract it and add it to your project(just add the entire folder)
3. Add to the sources.json the relevant source you are going to use
(I.E {"source": "javascript/flot/jquery.js"},{"source": "javascript/flot/jquery.flot.js"}
4. Add new Scene or use exsiting one
5. In the HTML add the tag:
<div id="placeholder" style="top:20px;left:10px;width:300px;height:300px;"></div>
6. In the source file you can use this div:

var d1 = [];


for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
// a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
$.plot($("#placeholder"), [ d1, d2, d3 ],{ grid: { color: "#100" } });

Thats all!!

Howto interact between a wordpress site and webos

Posted by codesos Saturday, January 9, 2010 0 comments


Evere wanted to login to a wordpress type of site? here it is







1. load a PHP file to your site called myLogin.php

This file will act as your server side and it's job is to get the request wfom you app , do the login operation and returnt status



write the folowings inside the php file:



<?php

require( dirname(__FILE__) . '/wp-load.php' );

function login() {

$result = wp_signon();

if(!$result->data)

return "<br />Incorrect username or password.";

else

return TRUE;

}

echo login();

?>




2. in your webos application create a scene:

The idea is to send the PHP file the request with parameters

create username and password widget , emit a buttun press for login and write this:



ComunityAssistant.prototype.AjaxLogin = function(user,pwd)

{

var url = '[your site]/SERVICE-login.php';

try {

var request = new Ajax.Request(url, {

method: 'post',

parameters: {log: user, pwd: pwd},

onSuccess: this.AjaxLoginOK.bind(this),

onFailure: this.AjaxLoginError.bind(this)

});

}

catch(e)

{

Mojo.Log.info('Failed to get Ajax response');

Mojo.Log.info(e);

}

}





ComunityAssistant.prototype.AjaxLoginOK = function(response)

{

try

{

if (response.responseText.search("Incorrect username or password") != -1)

{

// error

}

else

{

if (response.responseText.search("1") != -1)

{

// OK

}

}

}

catch(e)

{

Mojo.log.error(e);

}

}







ComunityAssistant.prototype.AjaxLoginError =function(transport)

{

var t = new Template($L("Error: Status #{status} returned from AJAX Google search."));

var m = t.evaluate(transport);

this.controller.showAlertDialog

(

{

onChoose: function(value) {},

title: $L("Error"),

message: m,

choices:[

{label: $L('OK'), value:'ok', type:'color'}

]

}

);

}





there you go!!


User agents must consider statements that use the BEGIN, COMMIT, and ROLLBACK SQL features as being unsupported (and thus will mark them as bogus), so as to not let these statements interfere with the explicit transactions managed by the database API itself.