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

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.

Activating one app menu for all the scenes

Posted by codesos Tuesday, November 3, 2009 0 comments

Want to define one app menu , Handle it once but acrivate it from all scenes?

Here is the way

1. Define the  menue modal and att as globals in the stage scene

glob = {};


glob.MenuAttr = {omitDefaultItems: true};



glob.appMenuModel = {

               visible: true,

               items: [

                           Mojo.Menu.editItem, //must


                            {label: $L("Preferences..."), command: "do-Prefs"},

                            {label: $L("Help"), command: "do-about"}


                          ]

                    };

define the handle command in the same stage scene :

StageAssistant.prototype.handleCommand = function(event)
{
                      var currentScene = Mojo.Controller.stageController.activeScene();

                      if (event.type == Mojo.Event.commandEnable) {

                                  if ((event.command == "do-Update")) {

                                            event.preventDefault();
                                   }

                       }

else {

           if(event.type == Mojo.Event.command) {

               switch(event.command) {

                     case "do-about":

                         Mojo.Controller.stageController.pushScene('support');

                     break;

                     case "do-Prefs":

                          Mojo.Log.info("do-Prefs");

                         Mojo.Controller.stageController.pushScene("preferences");

                     break;

                  case "do-Update":

                  break;

           }

     }

}
}

now in every scene's setup function do this:

this.controller.setupWidget(Mojo.Menu.appMenu, glob.MenuAttr, glob.appMenuModel);


Done!!