connect(ui->show_schedule_btn, &QPushButton::clicked, this, &MainWindow::show_schedule_clicked);
connect(ui->show_carousel_btn, &QPushButton::clicked, this, &MainWindow::show_carousel_clicked);
connect(ui->show_nothing_btn, &QPushButton::clicked, this, &MainWindow::show_nothing_clicked);
+ connect(ui->show_roster_1_btn, &QPushButton::clicked, this, [this]() { show_roster_clicked(ui->initials_1_edit->text().toStdString()); });
+ connect(ui->show_roster_2_btn, &QPushButton::clicked, this, [this]() { show_roster_clicked(ui->initials_2_edit->text().toStdString()); });
+ connect(ui->show_roster_carousel_btn, &QPushButton::clicked, this, &MainWindow::show_roster_carousel_clicked);
autocomment_update();
acmp->send_command("cg 1 invoke 1 showgroup_from_state");
}
+void MainWindow::show_roster_clicked(const std::string &team_code)
+{
+ map<string, string> param;
+ param["team_code"] = team_code;
+ acmp->send_command("cg 1 invoke 1 stopcarousel");
+ acmp->send_command("cg 1 update 1 \"" + escape_quotes(serialize_as_json(param)) + "\"");
+ acmp->send_command("cg 1 invoke 1 showroster_from_state");
+}
+
void MainWindow::show_schedule_clicked()
{
acmp->send_command("cg 1 invoke 1 stopcarousel");
acmp->send_command("cg 1 invoke 1 showcarousel");
}
+void MainWindow::show_roster_carousel_clicked()
+{
+ map<string, string> param;
+ param["team1"] = escape_html(ui->initials_1_edit->text().toStdString());
+ param["team2"] = escape_html(ui->initials_2_edit->text().toStdString());
+ acmp->send_command("cg 1 invoke 1 stopcarousel");
+ acmp->send_command("cg 1 update 1 \"" + escape_quotes(serialize_as_json(param)) + "\"");
+ acmp->send_command("cg 1 invoke 1 showrostercarousel_from_state");
+}
+
void MainWindow::show_nothing_clicked()
{
acmp->send_command("cg 1 invoke 1 hidescorebug");
void autocomment_update();
void show_scorebug_clicked();
void show_group_clicked(const std::string &group_name);
+ void show_roster_clicked(const std::string &team_code);
void show_schedule_clicked();
void show_carousel_clicked();
+ void show_roster_carousel_clicked();
void show_nothing_clicked();
Ui::MainWindow *ui;
<rect>
<x>0</x>
<y>0</y>
- <width>720</width>
- <height>552</height>
+ <width>803</width>
+ <height>597</height>
</rect>
</property>
<property name="windowTitle">
<item>
<widget class="QPushButton" name="show_scorebug_btn">
<property name="text">
- <string>Show scorebug</string>
+ <string>Show score</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="show_roster_1_btn">
+ <property name="text">
+ <string>Roster 1</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="show_roster_2_btn">
+ <property name="text">
+ <string>Roster 2</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="show_roster_carousel_btn">
+ <property name="text">
+ <string>Roster 1+2</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="show_group_a_btn">
<property name="text">
- <string>Show group A</string>
+ <string>Group A</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="show_group_b_btn">
<property name="text">
- <string>Show group B</string>
+ <string>Group B</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="show_schedule_btn">
<property name="text">
- <string>Show schedule</string>
+ <string>Schedule</string>
</property>
</widget>
</item>
--- /dev/null
+function load_roster(sheet, cb)
+{
+ var req = new XMLHttpRequest();
+ req.onload = function(e) {
+ var response = JSON.parse(req.responseText);
+
+ var team_name = '';
+ if (response.values[0].length >= 1 &&
+ response.values[0][0] !== undefined &&
+ response.values[0][0] !== null) {
+ team_name = response.values[0][0];
+ }
+
+ var roster = [];
+ var i;
+ for (i = 0; i < response.values.length; ++i) {
+ if (response.values[i][0] === 'Number') {
+ ++i;
+ break;
+ }
+ }
+
+ for ( ; response.values[i] !== undefined && response.values[i].length >= 3; ++i) {
+ var display_number = response.values[i][1];
+ var name = response.values[i][2];
+ roster.push({
+ "number": display_number,
+ "name": name
+ });
+ }
+ cb(team_name, roster);
+ };
+ req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1RciMlauWxqM9LYKdsY6lPjJbIAcHJpCXTqyZSEHxH3U/values/\'' + sheet + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU');
+ req.send();
+};
+
+function display_roster(team_name, roster)
+{
+ document.getElementById('entire-bug').style.display = 'none';
+
+ var carousel = document.getElementById('carousel');
+ clear_carousel(carousel);
+
+ if (team_name === '') {
+ addheading(carousel, 4, 'Team lineup');
+ } else {
+ addheading(carousel, 4, 'Team lineup<br />' + team_name);
+ }
+
+ for (var i = 0; i < roster.length; i += 2) {
+ var tr = document.createElement("tr");
+
+ addth(tr, "playernum", roster[i].number);
+ addtd(tr, "playername", roster[i].name);
+
+ if (i + 1 < roster.length) {
+ addth(tr, "playernum", roster[i + 1].number);
+ addtd(tr, "playername", roster[i + 1].name);
+ } else {
+ addth(tr, "playernum", "");
+ addtd(tr, "playername", "");
+ }
+ carousel.appendChild(tr);
+ }
+ fade_in_rows(carousel);
+
+ carousel.style.display = 'table';
+}
+
+function showroster(sheet)
+{
+ load_roster(sheet, display_roster);
+}
+
+function showroster_from_state()
+{
+ showroster(state['team_code']);
+}
+
+function showrostercarousel(sheet1, sheet2)
+{
+ var team_names = [null, null];
+ var rosters = [null, null];
+ var num_left = 2;
+
+ var cb = function(id, team_name, roster) {
+ team_names[id] = team_name;
+ rosters[id] = roster;
+ if (--num_left == 0) {
+ do_series([
+ [ 13000, function() { display_roster(team_names[0], rosters[0]); } ],
+ [ 2000, function() { hidetable(); } ],
+ [ 13000, function() { display_roster(team_names[1], rosters[1]); } ],
+ [ 2000, function() { hidetable(); } ]
+ ]);
+ }
+ };
+
+ load_roster(sheet1, function(team_name, roster) { cb(0, team_name, roster); });
+ load_roster(sheet2, function(team_name, roster) { cb(1, team_name, roster); });
+}
+
+function showrostercarousel_from_state()
+{
+ showrostercarousel(state['team1'], state['team2']);
+}
text-transform: none;
}
+/* roster */
+#carousel .playerpadding {
+ font-size: 25px;
+ background: rgba(0,0,0,0);
+}
+#carousel th.playernum, #carousel .playername {
+ font-size: 35px;
+}
+#carousel th.playernum {
+ text-align: center;
+ padding-right: 8px;
+ padding-left: 0px; margin-left: 0px;
+ width: 80px;
+}
+#carousel .playername {
+ text-transform: none;
+ width: auto;
+}
+
.nplayed, .gd, .pts {
text-align: center;
}
</p>
<p>
<a href="javascript:stopcarousel();hidetable();showscorebug()">show scorebug</a>
+ <a href="javascript:stopcarousel();showroster('TFK')">show roster 1</a>
+ <a href="javascript:stopcarousel();showroster('ESK')">show roster 2</a>
+ <a href="javascript:stopcarousel();showrostercarousel('TFK', 'ESK')">show roster 1+2</a>
<a href="javascript:stopcarousel();showgroup('Group A')">show group A</a>
<a href="javascript:stopcarousel();showgroup('Group B')">show group B</a>
<a href="javascript:stopcarousel();showschedule()">show schedule</a>
<script src="carousel.js" type="text/javascript"></script>
<script src="score.js" type="text/javascript"></script>
<script src="quickl3.js" type="text/javascript"></script>
+<script src="roster.js" type="text/javascript"></script>
</body>
</html>