forked from yupferris/fuse-example-using-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainView.ux
75 lines (60 loc) · 1.97 KB
/
MainView.ux
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
<App Theme="Basic" ClearColor="#eeeeeeff">
<DockPanel>
<JavaScript File="parse-1.6.7.js" ux:Global="Parse" />
<JavaScript File="api-keys.js" ux:Global="ApiKeys" />
<JavaScript>
var Observable = require("FuseJS/Observable");
var Parse = require("Parse").Parse;
var ApiKeys = require("ApiKeys");
Parse.initialize(ApiKeys.appId, ApiKeys.jsKey);
Parse.serverURL="https://parseapi.back4app.com/"
var Tag = Parse.Object.extend("Tag");
var tags = Observable();
var updateInterval = 500;
function updateTags() {
new Parse.Query("Tag").find().then(function(serverTags) {
//debug_log("Query successful: " + JSON.stringify(serverTags));
// Let's only add the ones that are newer than what we have
for (var i = tags.length; i < serverTags.length; i++) {
tags.add(serverTags[i].get("text"));
}
}, function(error) {
debug_log("Could not update tags: " + error);
});
setTimeout(updateTags, updateInterval);
}
updateTags();
var currentText = Observable("");
function submit() {
new Tag().save({
text: currentText.value
}).then(function(tag) {
debug_log("Tag saved successfully!");
}, function(error) {
debug_log("Could not save tag: " + error);
})
//tags.add(currentText.value);
currentText.value = "";
}
module.exports = {
currentText: currentText,
submit: submit,
tags: tags
};
</JavaScript>
<StatusBarBackground Dock="Top" />
<BottomBarBackground Dock="Bottom" />
<Text Dock="Top" Alignment="Center" FontSize="80" Margin="0,50,0,50" TextColor="#1e88e5">tag</Text>
<StackPanel Dock="Bottom" Margin="0,50,0,0">
<Button Text="tag" Clicked="{submit}" />
<TextInput Value="{currentText}" TextAlignment="Center" />
</StackPanel>
<ScrollView ClipToBounds="true">
<StackPanel>
<Each Items="{tags}">
<Text Value="{}" TextWrapping="Wrap" Margin="9" TextAlignment="Center" />
</Each>
</StackPanel>
</ScrollView>
</DockPanel>
</App>