blob: 8df939f154e12bac9bcabf2dafe8f635d3b05e6c (
plain) (
blame)
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
|
import QtQuick 2.2
import Sailfish.Silica 1.0
import ".."
ApplicationWindow {
initialPage: pageComponent
Component {
id: pageComponent
Page {
id: page
allowedOrientations: Orientation.All
SilicaFlickable {
anchors.fill: parent
contentHeight: root.height
PullDownMenu {
MenuItem {
text: qsTr("Leaderboard")
onClicked: pageStack.push(Qt.resolvedUrl(
"LeaderBoard.qml"))
}
}
Column {
property int bits: 4
property var matrix: new Array(Math.pow(bits + 1, 2))
id: root
width: page.width
height: page.height
spacing: Theme.paddingLarge
PageHeader {
title: "Binary Fun"
}
function check(index) {
root.matrix[index] ^= 1;
console.log(root.matrix);
console.log(Number(root.matrix.slice(5, 9).join("")).toString());
console.log(parseInt((root.matrix[9] >>> 0).toString(2)));
if (Number(root.matrix.slice(5, 9).join("")).toString() === (root.matrix[9] >>> 0).toString(2)) {
console.log("YAY");
}
}
Grid {
id: grid
anchors.verticalCenter: parent.verticalCenter
columns: root.bits + 1
rows: root.bits + 1
Repeater {
id: repeater
model: Math.pow(root.bits + 1, 2)
delegate: Bit {
bits: root.bits
index: modelData
width: page.width / (root.bits + 1)
}
}
}
}
}
}
}
}
|