Example #1
0
PresetsPage.prototype.getContainer = function () {
    if (this.container) { return this.container; }
    var page = this;

    var titleBar = new TitleBar({name:"Presets", back: false, home: true, borders: true, page: page});
    
    var AddPresetButton = BUTTONS.Button.template(function ($) { return {
        left: 5, width: Preset.PREVIEW_WIDTH, top: 20, height: Preset.PREVIEW_HEIGHT,
        skin: new Skin({fill:"white",}),
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
            onTap: { value: function (button) {
                trace("add preset does nothing\n");
            }}
        }),
        contents: [
            new Label({
                    left: 0, right: 0, top:0, bottom:0,
                    style: new Style({color: "black", font:" bold 30px"}),
                    skin: presetSkin,
                    string: "+", 
                }),
        ]
    };});

    var valPreset = new PresetPreview({
        preset: page.presets[0],
        presetName: page.presets[0].name,
        url:valentineURL,
    });
    
    var calPreset = new PresetPreview({
        preset: page.presets[1],
        presetName: page.presets[1].name,
        url:calURL,
    });
    
    page.displayLine.add(valPreset);
    page.displayLine.add(calPreset);

    var rootColumn = new Column({
        top: 0, left: 0, bottom: 0, right: 0,
        skin: rootSkin,
        contents: [
            titleBar,
            new Container({
                name:"presets", top: 0, left: 0, bottom: 0, right: 0, 
                skin: rootSkin,
                contents:[page.displayLine],

        }),
        page.navBar,
        ],
    });
    this.container = rootColumn;
    return this.container; 
};
Example #2
0
	} else if (json.count < 6) {
		messageLabel.string = "Seems just right for " + dogName + "'s appetite!";;
	} else {
		messageLabel.string = "Don't let " + dogName + " starve you fool!";
	}
	nextEatenLabel.string = new Date().addHours(json.count).toLocaleString();
}

// buttons
var foodDecreaseButton = BUTTONS.Button.template(function($){ return{
	left: 80, right: 80, height:20, top:15,
	contents: [
		new Label({left:0, right:0, height:20, string:"Decrease", style: labelStyle})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
		onTap: { value: function(content){
			content.invoke(new Message(deviceURL + "foodDecrease"), Message.JSON);
		}},
		onComplete: { value: function(content, message, json){
			setMessage(json);
		}}
	})
}});

var foodIncreaseButton = BUTTONS.Button.template(function($){ return{
	left: 80, right: 80, height:20, top:3,
	contents: [
		new Label({left:0, right:0, height:20, string:"Increase", style: labelStyle})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
		onTap: { value: function(content){
			content.invoke(new Message(deviceURL + "foodIncrease"), Message.JSON);
Example #3
0
var preview = null;
var presetCoordinates = {1:(20, 20), 2: (20, 0)}; // {presetCount: (top, left)} top, left of the displayed presetPreview on the page
var number = 1;


var PresetPreview = BUTTONS.Button.template(function ($) { return {
    left: 5, width: Preset.PREVIEW_WIDTH, top: 20, height: Preset.PREVIEW_HEIGHT,
    skin: presetSkin,
    behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
        onTap: { value: function (button) {
            presetsPage.selectedPreset = $.preset;// :/
            trace("viewPresetPage in the works\n");
            
            var viewPreset = new ViewPresetPage($.preset, presetsPage, presetsPage.switchPages);
            presetsPage.switchPages(viewPreset);
        }}
    }),
    contents: [
        new Picture({left:0, right:0, top:0, bottom: 0, url: $.url,}), 
        new Label({
                left: 0, right: 0, bottom:0, height:15,
                style: new Style({color: "black", font:"10px"}),
                string: $.presetName, 
                skin: new Skin({color:"red"}),
            }),
    ]
};});

/**
 * Return the kinoma Container which will be added to the application when this
 * page becomes active.
 */
Example #4
0
var menuURL = mergeURI(application.url, "images/blueMenu.png");

var MenuBarButtonTemplate = BUTTONS.Button.template(function($){ return {
    left: 15, bottom:0, width:20, height:navBarHeight, skin: backSkin,
    contents: [
        new Picture({ width:30, height:30, url: menuURL })
    ],
    behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
        onTap: { value: function(content) {
            window1Button = new WindowButtonTemplate({page: $.page, string: "Window 1", index: 0});
            window2Button = new WindowButtonTemplate({page: $.page, string: "Window 2", index: 1});
            window3Button = new WindowButtonTemplate({page: $.page, string: "Window 3", index: 2});
            if (menuVisible) {
                $.page.container.remove(menu);
                menuVisible = false;
            } else {
                menu = new Container({ top: navBarHeight, left: 0, right: 0, bottom:0,
                    contents:[
                        new ViewMenuContainer({page: $.page, status: false, presets: true, edit: false}),
                    ],
                });
                $.page.container.add(menu);
                menuVisible = true;
            }
        }}
    })
};});

var ViewMenuContainer = Container.template(function($) { return {
    left: 0, right: 0, top: 0, bottom: 0,
Example #5
0
		},
		onFinished: function(container, data){
			application.remove(container);
		},
	})
}});


var LevelButton = BUTTONS.Button.template(function($){ return{
	skin: lightGreenSkin, top:0, height:40, left:3, right:3,
	contents:[
		new Label({top:0,left: 0, right: 0, height: 40, string: $.string, style: normalText})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
		onTap: { value:  function(button){
			LevelButtons[0].skin = lightGreenSkin;
			LevelButtons[1].skin = lightGreenSkin;
			LevelButtons[2].skin = lightGreenSkin;
			button.skin = selectedSkin;
 			level = $.string;
		}}
	})
}});

var LevelButtons = [new LevelButton({string: "easy"}), new LevelButton({string: "medium"}), new LevelButton({string: "hard"})];
LevelButtons[1].behavior.onTap(LevelButtons[1]);


var StartButton = BUTTONS.Button.template(function($){ return{
	skin:blueSkin, top:5, left:50, right:50, 
	contents:[
Example #6
0
	onTap: { value:  function(nextButton){
		comicNumber += 1;
		xUrl = "http://xkcd.com/" + comicNumber + "/info.0.json";
		application.invoke(new Message("/getTitle"));		
		application.invoke(new Message("/getImage"));
		mainColumn.remove(myPic);	
		mainColumn.add(below);
		
		
	}}
});

var myButtonTemplate = BUTTONS.Button.template(function($){ return{
	bottom:20, left:200, right:30,
	contents:[
		new Label({left:0, right:0, height:30, string:$.textForLabel, style:bigText})
	],
	behavior: new buttonBehavior
}});

var nextButton = new myButtonTemplate({textForLabel:"Next"});


///////////
var buttonBehavior = function(content, data){
	BUTTONS.ButtonBehavior.call(this, content, data);
}
buttonBehavior.prototype = Object.create(BUTTONS.ButtonBehavior.prototype, {
	onTap: { value:  function(prevButton){
		if(comicNumber > 1) {
		comicNumber -= 1;
Example #7
0
MainPage.prototype.getContainer = function () {
    if (this.container) { return this.container; }
    var page = this;
	
    var HorizontalWindowButton1 = BUTTONS.Button.template(function($) { return {
        left: 75, right: 75, top: 52, height: 30,
        skin: buttonSkin, 
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
            onTap: { value: function (button) {
                if ($.number == 1){
                	page.switchPages(statusPage1);
                } else {
                    page.switchPages(statusPage3);
                }
            }},
        }),
        contents: [
            new Label({
                top: 0, left: 0, bottom: 0, right: 0,
                style: labelStyle,
                string: $.string
            })
        ]
    };});
    
 	
    var HorizontalWindowButton3 = BUTTONS.Button.template(function($) { return {
        left: 73, right: 73, top: 295, height:30 ,
        skin: buttonSkin, 
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
            onTap: { value: function (button) {
                if ($.number == 1){
                	page.switchPages(statusPage1);
                } else {
                    page.switchPages(statusPage3);
                }
            }},
        }),
        contents: [
            new Label({
                top: 0, left: 0, bottom: 0, right: 0,
                style: labelStyle,
                string: $.string
            })
        ]
    };});   
    
    var VerticalWindowButton = BUTTONS.Button.template(function($) { return {
        left: 285, right: 1, height: 140, top: 110,
        skin: buttonSkin,
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
            onTap: { value: function (button) {
                page.switchPages(statusPage2);                
            }},
            
            onDisplaying: {value: function(button) {
                var string = $.string;
                var size = labelStyle.measure(string);
                var label = new Label( { left: 0, right: 0, top: 0, bottom: 0}, undefined, labelStyle, string );
                var layer = new Layer( { width:button.height, height:size.height, opacity:0.9 });
                layer.add( label );
                layer.origin = { x:70, y:15 };
                layer.rotation = 90;
                button.add(layer);
            }},
        }),
        contents: []
    };});

    var titleBar = new TitleBar({name:"Fresh Glass", back: false, home: true, borders: true, page: page});

    var navBar = new NavBar({ page: page });
	
	var innerContainer = new Container({
		top: 0, left:0, right:0, bottom:0,
		skin: rootSkin,
		contents: [
            new Picture({width:300, height:500, top:0, bottom: 0, left:0, right:0, url: floorplanURL}),
			new HorizontalWindowButton1({ window: this.windows[0], string: this.windows[0].name, number: 1}),
			new VerticalWindowButton({window: this.windows[1], string: this.windows[1].name, number: 2}),
            new HorizontalWindowButton3({ window: this.windows[2], string: this.windows[2].name, number: 3}),
		]
	});

    var rootContainer = new Column({
        top: 0, left: 0, right: 0, bottom: 0,
        skin: rootSkin,
        contents: [
            titleBar,
			innerContainer,
        ]
    });

    rootContainer.add(navBar);

    this.container = rootContainer;
    return this.container;
};
Example #8
0
StatusPage.prototype.getContainer = function () {
    if (this.container) { return this.container; }
    var page = this;

    var navBar = new NavBar({ page: page });
    var windowSelector = new WindowSelector({status:true, presets: false, edit: false, page: page, name: page.window.name});

    this.sunIcon = new Picture({width: 50, height: 55, left: 190, url: sunURL});
    this.thermometer = new Picture({width: 50, height: 55, right: 190, url: thermURL});

    this.temperatureLabel = new Label({
        left: 40, right: 0, top: 0, bottom: 0,
        style: new Style({color: "black", font: "25px Helvetica Neue"}),
        string: page.window.temperature + "°F"
    });

    this.brightnessLabel = new Label({
        left: 0, right: 40, top: 0, bottom: 0,
        style: new Style({color: "black", font: "25px Helvetica Neue"}),
        string: page.window.brightness + "%"
    });

    var statusLine = new Line({
        left: 0, right: 0, height: 55,
        contents: [page.temperatureLabel, page.brightnessLabel]

    });

    var SavePresetButton = BUTTONS.Button.template(function ($) { return {
        left: 200, right: 10, bottom: 10, top:10,
        skin: new Skin({fill: blue, stroke:"black"}),
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
            onTap: { value: function (button) {
                presetsPage.addToPresetsPage(page.window);
            }}
        }),
        contents: [
            new Label({
                left: 0, right: 0, bottom: 0, top: 0,
                style: new Style({color: "white", size: 16, font: "Helvetica Neue"}),
                string: "Save as Preset"
            })
        ]
    };});

    page.windowPreviewContainer = new Container({
        left: 0, right: 0, top: 15, bottom: 0,
        contents: [
            page.window.renderPreview(),
        ]
    });

    var statusContainer = new Container({
        top: 0, left: 0, right: 0, height: 80,
        contents: [
           this.sunIcon,
           this.thermometer,
           statusLine,
        ]
    });

    var rootColumn = new Column({
        top: 0, left: 0, bottom: 0, right: 0,
        skin: new Skin({fill: "white"}),
        contents: [
            windowSelector,
            statusContainer,
            page.windowPreviewContainer,
            new Line({
                left: 0, right: 0, height: 45,
                contents: [
                    new SavePresetButton()
                ]
            }),
           navBar,
        ]
    });

   rootContainter = new Container({
        top:0, bottom: 0, left: 0, right: 0, 
        skin: rootContainterSkin,
        contents: [ 
            rootColumn
        ]
    });

    this.container = rootContainter;
    return this.container;
};
var addButtonTemplate = BUTTONS.Button.template(function($){ return{
        skin:greenS, width:74, height: 27, contents: [
                new Label({string:"Add", name:"addLabel", style: whiteLabelStyle})
        ],
        behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
                onTouchBegan: { value:  function(button){
					addButtonBG.url = "buttons/schedule_addbutton2.png";
					button.skin = buttonPressedS;
				}},
				onTouchEnded: { value:  function(button){
					addButtonBG.url = "buttons/schedule_addbutton.png";
					button.skin = greenS;
					if (checkError()) {
						if (hasError) {
							mainFieldContainer.remove(errorMessage);
						}
						updateInfo();
                    	info1 = "Step " + step + ": " + info.action + " at " + info.temperature + "°F";
                    	info1Label = new Label({top:5, left:0, bottom:0, height:20, string:info1, style: fieldStyle});
                    	var info2 = "for " + info.hour + " hours and " + info.minutes + " minutes";
                    	info2Label = new Label({top:0, left:0, bottom:5, height:20, string:info2, style: fieldStyle});
                    	var data = {
      						label1: info1Label,
      						label2: info2Label,
      						step: step
   						};
                     	schedSteps.steps[schedSteps.size] = info1;
                    	schedSteps.temps[schedSteps.normSize] = info.temperature
                    	schedSteps.hrs[schedSteps.normSize] = info.hour
                    	schedSteps.mins[schedSteps.normSize] = info.minutes
                    	schedSteps.normSize += 1
                    	schedSteps.size += 1;
                    	schedSteps.steps[schedSteps.size] = info2;
                    	schedSteps.size += 1;
                    	instructionContainer.col.add(new stepBox(data));
                    	mainFieldContainer.remove(fieldContainer);
                    	step++;
                    	reinitialize();
    					mainFieldContainer.add(fieldContainer);
    				} else {
    					if (!hasError) {
    						mainFieldContainer.add(errorMessage);
    						hasError = true;
    					}
    				}
				}}
        })
}});
Example #10
0
var feedingButton = BUTTONS.Button.template(function($){ return{
	left: 50, right: 50, height:50, bottom:10, skin:feedBtnSkin,
	contents: [
		new Label({left:0, right:0, height:50, string:$.btnName, style: btnStyle})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
		onTouchBegan: { value: function(content){
			content.skin = feedBtnClicked;
			if ($.btnName == "Dispense Hay") {
				if (hungerBar.height - 20 > 0) {
				    hungerBar.height -= 20;
				} else {
				    hungerBar.height = 1;
				}
				if (feedingSchedule.food.first.width + 60 <= 300) {
					feedingSchedule.food.first.width += 60;
				}
			}
			else if ($.btnName == "Dispense Water") {
				if (thirstBar.height - 20 > 0) {
					thirstBar.height -= 20;
				} else {
				    thirstBar.height = 1;
				}
				if (feedingSchedule.water.first.width + 60 <= 300) {
					feedingSchedule.water.first.width += 60;
				}
			} else {
			}
		}},
		onTouchEnded: { value: function(content, message, json){
			if ($.btnName == "Clean Cage") {
				cleaningAlert.visible = true;
				content.invoke(new Message("/clean"));
			}
			content.skin = feedBtnSkin;
		}}
	})
}});
Example #11
0
				 $.leftItem,
			  ],
			}),
			new Label({left:0, right:0, height:60, string:$.title, style:headerLabelStyle}),
			new Container({right: 0, width: 100, height: 60, skin: blueSkin, active: true,
			  contents: [
				 $.rightItem,
			  ],
			}),
	], 
}});

ButtonTemplate = BUTTONS.Button.template(function($){ return{
  bottom:0, left:0, right:0, name:$.textForLabel, skin:$.skin,
  contents:[
    new Label({left:$.left, right:$.right, height:$.height, width:$.width, string:$.textForLabel, style:$.style, horizontal: 'center'}),
  ],
  behavior:$.behavior
}});


// Radio group template

HorizontalRadioGroup = Line.template(function($) { return {
    left:10,
    active: true,
    behavior: $.behavior,
}});

// Credit to https://github.com/wdimmit/k4/blob/master/ScrollerDemo/src/main.js
ScrollContainer = Container.template(function($) { return {
Example #12
0
var comicPic = new Picture ({left: 0, right: 0, height: 700});
var currNum = 0;
var mostCurrentNum = 0;
var currUrl = "http://xkcd.com/info.0.json";
var isFlickr = 0;


//nextButton

var nextButton = BUTTONS.Button.template(function(){ return{
	top:0, bottom:0, left:0, right:0,
	contents:[
		new Label({left:0, right:0, height:10, string:"Next", style:bigText})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {
		onTap: { value:  function(button){
			currNum -= 1;
			updateImage();
		}}
	})
}});


//prevButtom

var prevButton = BUTTONS.Button.template(function(){ return{
	top:0, bottom:0, left:0, right:0,
	contents:[
		new Label({left:0, right:0, height:10, string:"Previous", style:bigText})
	],
	behavior: Object.create(BUTTONS.ButtonBehavior.prototype, {