Skip to content

Commit

Permalink
added AJAX
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Sep 5, 2015
1 parent 0279a92 commit 7d7b363
Show file tree
Hide file tree
Showing 29 changed files with 43 additions and 7 deletions.
Binary file not shown.
Binary file added AJAX/src/main/webapp/wikimediaimages/s_feld.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/s_s_dame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/s_s_turm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/s_w_dame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/s_w_turm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/w_feld.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/w_s_dame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/w_s_turm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/w_w_dame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AJAX/src/main/webapp/wikimediaimages/w_w_turm.png
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ public class Board implements Serializable {

private Chessboard chessboard = new Chessboard();

private boolean isPieceSelected=false;

private int selectedPieceRow;

private int selectedPieceColumn;

private List<Row> rows;

public Board() {

redraw();
}

private void redraw() {
int[][] pieces = chessboard.board;
setRows(new ArrayList<Row>());
for (int i = 0; i < 8; i++) {
Expand All @@ -34,5 +44,24 @@ public List<Row> getRows() {
public void setRows(List<Row> rows) {
this.rows = rows;
}

public String getOpacity(int row, int column) {
if (!isPieceSelected) return "1.0";
if (selectedPieceColumn==column && selectedPieceRow==row) return "1.0";
return "0.7";
}

public void onclick(int row, int column) {
if (isPieceSelected) {
isPieceSelected=false;
}
else
{
isPieceSelected=true;
selectedPieceRow=row;
selectedPieceColumn=column;
}
redraw();
}

}
21 changes: 14 additions & 7 deletions BootsFacesChess/src/main/webapp/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</h:head>
<h:body style="padding-top:75px">
<b:container id="menu">
<b:navBar brand="BootsFaces plays chess!" inverse="true" brandHref="#"
fixed="top">
<b:navBar brand="BootsFaces plays chess!" inverse="true"
brandHref="#" fixed="top">
<b:navbarLinks>
<b:navLink value="New game (white)" iconAwesome="home" href="#"></b:navLink>
<b:navLink value="New game (black)" icon="cross" href="#"></b:navLink>
Expand All @@ -26,13 +26,20 @@
</b:container>

<b:container id="content">
<ui:repeat id="rows" var="row" value="#{board.rows}">
<ui:repeat id="fields" var="image" value="#{row.images}">
<h:form>
<ui:repeat id="rows" var="row" value="#{board.rows}"
varStatus="rowStatus">
<ui:repeat id="fields" var="image" value="#{row.images}"
varStatus="columnStatus">

<b:image value="#{image}" style="width:70px;height:70px" />
<b:image value="#{image}"
style="width:70px;height:70px;opacity:#{board.getOpacity(rowStatus.index,columnStatus.index)}"
onclick="ajax:board.onclick(rowStatus.index,columnStatus.index)"
update="@form" />
</ui:repeat>
<br />
</ui:repeat>
<br />
</ui:repeat>
</h:form>
</b:container>
</h:body>
</html>

0 comments on commit 7d7b363

Please sign in to comment.