-
Notifications
You must be signed in to change notification settings - Fork 4
/
MainView.ux
76 lines (61 loc) · 2.58 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
75
76
<App ClearColor="#eeeeeeff">
<DockPanel>
<JavaScript>
var Observable = require("FuseJS/Observable");
var Timer = require('FuseJS/Timer');
var tag = Observable();
var dbData = Observable();
var timer = Timer.create(function(){
load();}, 1000, true);
function load(){
fetch('https://fusetags.firebaseio.com/tags.json', {
method: 'GET',
cache: 'default',
headers: { "Content-type": "application/json"}
})
.then(function(result) {
if (result.status !== 200) {
console.log("Something went wrong :(");
return;}
return result.json();
})
.then(function(data) {
var keys = Object.keys(data);
keys.forEach(function(key, index) {
if (index >= dbData.length) {
var value = data[key];
dbData.add(value);
}
})
});
};
function submit() {
fetch('https://fusetags.firebaseio.com/tags.json', {
method: 'POST',
headers: { "Content-type": "application/json"},
body: JSON.stringify({"tag": tag.value})
});
tag.value = "";
}
module.exports = {
tag: tag,
dbData: dbData,
submit: submit
};
</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,20">
<Basic.TextInput Value="{tag}" TextAlignment="Center" PlaceholderText="Insert Tag Here..." Margin="0,0,0,-8"/>
<Basic.Button Text="tag" Clicked="{submit}" />
</StackPanel>
<ScrollView ClipToBounds="true">
<StackPanel>
<Each Items="{dbData}">
<Text Value="{tag}" TextWrapping="Wrap" Margin="9" TextAlignment="Center" />
</Each>
</StackPanel>
</ScrollView>
</DockPanel>
</App>