Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function VilloAssistant() {
- /* this is the creator function for your scene assistant object. It will be passed all the
- additional parameters (after the scene name) that were passed to pushScene. The reference
- to the scene controller (this.controller) has not be established yet, so any initialization
- that needs the scene controller should be done in the setup function below. */
- }
- VilloAssistant.prototype.setup = function() {
- /* this function is for setup tasks that have to happen when the scene is first created */
- /* use Mojo.View.render to render view templates and add them to the scene, if needed */
- villo.init({"api": "d1ba1edefac481a14758a3937897de50","type": "mobile","pubnub": true})
- /* setup widgets here */
- this.controller.setupWidget("theUsername",
- this.attributes = {
- hintText: $L(""),
- multiline: false,
- enterSubmits: false,
- autoFocus: true
- },
- this.theusername = {
- value: "",
- disabled: false
- }
- );
- this.controller.setupWidget("thePassword",
- this.attributes = {
- hintText: $L(""),
- multiline: false,
- enterSubmits: true,
- autoFocus: false
- },
- this.thepassword = {
- value: "",
- disabled: false
- }
- );
- this.controller.setupWidget("login",
- this.attributes = {
- },
- this.model = {
- label : "Login",
- disabled: false
- }
- );
- this.controller.setupWidget("register",
- this.attributes = {
- },
- this.model = {
- label : "Register For Villo",
- disabled: false
- }
- );
- this.controller.setupWidget("logout",
- this.attributes = {
- },
- this.model = {
- label : "Log out of Villo",
- disabled: false
- }
- );
- /* add event handlers to listen to events from widgets */
- Mojo.Event.listen(this.controller.get("login"), Mojo.Event.tap, this.login.bind(this));
- Mojo.Event.listen(this.controller.get("register"),Mojo.Event.tap, this.villoRegistration.bindAsEventListener(this));
- Mojo.Event.listen(this.controller.get("logout"),Mojo.Event.tap, this.villoLogout);
- };
- VilloAssistant.prototype.login = function(event){
- villo.user.login({
- username: this.theusername.value,
- password: this.thepassword.value
- }, this.loginCallback.bind(this));
- };
- VilloAssistant.prototype.loginCallback = function(sof){
- if(sof === 0){
- this.controller.stageController.swapScene("prefs");
- }else{
- Mojo.Controller.errorDialog("Error Logging In!");
- }
- };
- VilloAssistant.prototype.activate = function(event) {
- /* put in event handlers here that should only be in effect when this scene is active. For
- example, key handlers that are observing the document */
- };
- VilloAssistant.prototype.deactivate = function(event) {
- /* remove any event handlers you added in activate and do any other cleanup that should happen before
- this scene is popped or another scene is pushed on top */
- };
- VilloAssistant.prototype.cleanup = function(event) {
- /* this function should do any cleanup needed before the scene is destroyed as
- a result of being popped off the scene stack */
- };
- VilloAssistant.prototype.villoRegistration = function() {
- this.controller.stageController.pushScene("villoRegister");
- };
- VilloAssistant.prototype.logout = function() {
- villo.user.logout();
- Mojo.Controller.errorDialog("Successfully Logged Out.");
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement