-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppController.j
90 lines (69 loc) · 2.32 KB
/
AppController.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* AppController.j
* dbstore
*
* Created by Randall Luecke on February 2, 2010.
* Copyright 2010, Randall Luecke All rights reserved.
*/
@import <Foundation/CPObject.j>
@import "RLOfflineDatabaseStore.j"
@import "RLOfflineLocalStorage.j"
@implementation AppController : CPObject
{
id dataStorage;
CPButton aButton;
CPTextField label;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[label setStringValue:@""];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
[label sizeToFit];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:[contentView center]];
[contentView addSubview:label];
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
dataStorage = [[RLOfflineLocalStorage alloc] initWithName:@"HelloWorld" delegate:self];
//[dataStorage setValue:@"World" forKey:@"word1"];
//if(dataStorage)
var value = [dataStorage getValueForKey:@"HelloWorldTestApp"];
[label setStringValue:value];
[label sizeToFit];
//[dataStorage removeValueForKey:@"word1"];
aButton = [[CPSlider alloc] initWithFrame:CGRectMake(100,100,100,24)];
[aButton setTarget:self];
[aButton setIntValue:value];
[aButton setAction:@selector(setNewValue:)];
[contentView addSubview:aButton];
}
- (void)didReciveData:(CPString)aString
{
[aButton setIntValue:aString];
[label setStringValue:aString];
[label sizeToFit];
}
- (void)setNewValue:(id)sender
{
//if(dataStorage)
[dataStorage setValue:[sender intValue] forKey:@"HelloWorldTestApp"];
[label setStringValue:[sender intValue]];
[label sizeToFit];
}
- (void)dataStoreIsNotSupported
{
alert("Your browser doesn\'t support offline localStorage.");
}
- (void)dataStoreIsNotSupported
{
alert("Your browser doesn\'t support offline database storage and stuff");
}
- (void)userDidRejectDatabase
{
alert("Dude. If you want offline storage you have to click the \"accept\" button!!!");
}
@end