diff --git a/.gitignore b/.gitignore index 27eb534..c249fa8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ !**/src/test/**/target/ +Databases/ +logs/ +Results/ ### STS ### .apt_generated diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java index a24e857..98f55b0 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/controller/VotingController.java @@ -6,7 +6,6 @@ import com.github.cato447.AbizeitungVotingSystem.helper.RandomNumber; import com.github.cato447.AbizeitungVotingSystem.repositories.*; import com.github.cato447.AbizeitungVotingSystem.table.TableAction; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Controller; @@ -19,22 +18,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import javax.annotation.PostConstruct; +import java.time.LocalDate; +import java.time.Month; import java.util.*; @Controller public class VotingController { - - @Value("motto") - String motto; - @Value("adding") - String adding; - @Value("voting") - String voting; - - private boolean votingPhase = false; - private boolean mottoPhase = false; - private boolean addingPhase = false; + private boolean votingPhase; + private boolean addingPhase; private static final Logger LOGGER = LogManager.getLogger(VotingController.class); private TableAction tableAction = new TableAction(); @@ -48,9 +40,6 @@ public class VotingController { @Autowired CategoryRepository categoryRepository; - @Autowired - MottoRepository mottoRepository; - @Autowired PossibleCandidateRepository possibleCandidateRepository; @@ -63,21 +52,10 @@ public class VotingController { @PostConstruct public void init() { - if (motto != null){ - mottoPhase = true; - } else if (adding != null){ - addingPhase = true; - } else if (voting != null){ - votingPhase = true; - } + votingPhase = true; + addingPhase = false; - -// //TODO: TESTING REMOVE ON SHIPPING -// votingPhase = false; -// mottoPhase = true; -// addingPhase = false; - - LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " mottoPhase=" + mottoPhase + " addingPhase=" + addingPhase); + LOGGER.info("Program started with arguments: votingPhase="+ votingPhase + " addingPhase=" + addingPhase); if (voterRepository.findAll().size() == 0) { tableAction.setUpVoters(voterRepository); @@ -86,14 +64,10 @@ public class VotingController { if (categoryRepository.findAll().size() == 0) { tableAction.setUpCategories(categoryRepository); + possibleCandidateRepository.deleteAll(); LOGGER.info("Categories successfully set up"); } - if (mottoRepository.findAll().size() == 0){ - tableAction.setUpMottos(mottoRepository); - LOGGER.info("Mottos successfully set up"); - } - if (candidateRepository.findAll().size() == 0 && votingPhase == true && possibleCandidateRepository.findAll().size() != 0) { tableAction.setUpCandidates(possibleCandidateRepository, candidateRepository); LOGGER.info("Candidates successfully set up"); @@ -102,7 +76,16 @@ public class VotingController { @RequestMapping("/") public String WelcomeSite() { - return "start.html"; + LocalDate finishDate = LocalDate.of(2021, Month.JANUARY,24); + LocalDate now = LocalDate.now(); + + if(now.isAfter(finishDate)){ + LOGGER.warn("passed"); + return "errors/votingClosed.html"; + } else { + LOGGER.warn("in Bounds"); + return "start.html"; + } } public void sendSimpleMessage(String to, String subject, String text) { @@ -119,18 +102,18 @@ public class VotingController { try { LOGGER.warn(name); Voter voter = voterRepository.findByEmail(name.toLowerCase().strip()); + if (voter == null){ + LOGGER.error(name + " is not allowed to vote"); + return "errors/notRegistered.html"; + } if (voter.getVote_status() && votingPhase) { LOGGER.warn(name + " has already voted"); return "errors/alreadyVoted.html"; } else if (voter.getCandidatesubmit_status() && addingPhase) { LOGGER.warn(name + " has already submitted its candidates"); - return "errors/alreadysubmittedcandidates.html"; - } else if (voter.getMotto_status() && mottoPhase) { - LOGGER.warn(name + " has already chose their motto"); - return "errors/alreadyVotedForMotto.html"; + return "errors/alreadyVoted.html"; } else { if (authCodesRepository.findByName(name) == null) { - LOGGER.warn("no code"); AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository); sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); } else if (authCodesRepository.findByName(name) != null && authCodesRepository.findByName(name).isExpired()) { @@ -138,32 +121,38 @@ public class VotingController { sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); } model.addAttribute("name", name); + model.addAttribute("codeTime", authCodesRepository.findByName(name).getExpirationTime()); model.addAttribute("codeExpired", false); model.addAttribute("codeFalse", false); return "authenticate.html"; } } catch (Exception e) { e.printStackTrace(); - LOGGER.error(name + " is not allowed to vote"); - return "errors/notRegistered.html"; + tableAction.deleteToken(name, authCodesRepository); + return "error.html"; } } else { return "errors/falseInput.html"; } } + @RequestMapping("/newCode") + public String provideNewCode(@RequestParam String name, Model model){ + AuthCode authCode = tableAction.generateToken(name, RandomNumber.getRandomNumberString(), authCodesRepository); + sendSimpleMessage(name, "Code zur Authentifizierung", "Dein Code lautet: " + authCode.getCode()); + model.addAttribute("name", name); + model.addAttribute("codeTime", authCodesRepository.findByName(name).getExpirationTime()); + model.addAttribute("codeExpired", false); + model.addAttribute("codeFalse", false); + return "authenticate.html"; + } + @RequestMapping("/vote") public String voting_adding(@RequestParam String code, @RequestParam String name, Model model) { String tokenStatus = tableAction.checkToken(name, code, authCodesRepository); - if (tokenStatus.equals("matched")) { LOGGER.warn("matched"); - if (mottoPhase) { - List mottos = mottoRepository.findAll(); - model.addAttribute("mottos", mottos); - model.addAttribute("name", name); - return "mottoVoting.html"; - } else if (addingPhase) { + if (addingPhase) { PossibleCandidateWrapper possibleCandidates = new PossibleCandidateWrapper(); List categories = categoryRepository.findAll(); for (int i = 0; i < categories.size(); i++) { @@ -197,7 +186,7 @@ public class VotingController { @RequestMapping("/saveCandidates") public String candidateSaving(@ModelAttribute PossibleCandidateWrapper possibleCandidates, @RequestParam String name) { - if (voterRepository.findByEmail(name).getVote_status()) { + if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { return "errors/alreadyVoted.html"; } else { LinkedList posCandidates = possibleCandidates.getPossibleCandidates(); @@ -208,42 +197,55 @@ public class VotingController { PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName(), categoryRepository.findById(index).get()); p.setVotes(p.getVotes() + 1); possibleCandidateRepository.save(p); + } else if (possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()) != null){ + PossibleCandidate p = possibleCandidateRepository.findByNameAndCategory(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1], categoryRepository.findById(index).get()); + p.setVotes(p.getVotes() + 1); + possibleCandidateRepository.save(p); } else { - PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); - possibleCandidateRepository.save(possibleCandidate); + if (index > 31 && posCandidate.getName().indexOf(" ") != -1) { + if (posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Neumann") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("neumann") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("Mecklenburg") || + posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length-1].equals("mecklenburg")){ + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); + } else { + posCandidate.setName(posCandidate.getName().split(" ")[posCandidate.getName().split(" ").length - 1]); + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); + } + } else { + PossibleCandidate possibleCandidate = new PossibleCandidate(posCandidate.getName(), categoryRepository.findById(index).get()); + possibleCandidateRepository.save(possibleCandidate); + } } } index++; } - tableAction.updateCandidatesubmit_status(name, voterRepository); - return "candidateAddingSuccessful.html"; - } - } - @RequestMapping("/saveMotto") - public String mottoSaving(@RequestParam String name, @RequestParam String voteValue) { - LOGGER.info(name); - if (voterRepository.findByEmail(name).getMotto_status()) { - return "errors/alreadySubmitted.html"; - } else { - tableAction.voteForMotto(voteValue, mottoRepository); - tableAction.updateMottoStatus(name, voterRepository); - LOGGER.info(name + " has choose his motto"); + tableAction.updateCandidatesubmit_status(name, voterRepository); + return "voteSuccessful.html"; } - return "voteSuccessful.html"; } @RequestMapping("/processVote") public String ProcessVote(@RequestParam String name, @RequestParam String voteValues) { - if (voterRepository.findByEmail(name).getCandidatesubmit_status()) { - return "errors/alreadySubmitted.html"; + if (voterRepository.findByEmail(name).getVote_status()) { + return "errors/alreadyVoted.html"; } else { - String[] partVoteValues = voteValues.split(","); - for (String s : partVoteValues) { + LinkedList voteFor = new LinkedList<>(); + if(!voteValues.equals("")) { + String[] partVoteValues = voteValues.split(","); + for (String s : partVoteValues) { + voteFor.add(s); + } + LOGGER.info(name + " has voted!"); + } + for (String s: voteFor) { tableAction.voteForCandidate(s, candidateRepository); } + tableAction.updateVotingStatus(name, voterRepository); - LOGGER.info(name + " has voted!"); return "voteSuccessful.html"; } } diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java index 84ab6ce..846d666 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/AuthCode.java @@ -37,8 +37,12 @@ public class AuthCode { return time; } + public long getExpirationTime(){ + return time + 1800*1000; + } + public boolean isExpired(){ - return System.currentTimeMillis() >= (time + 600*1000); + return System.currentTimeMillis() >= (time + 1800*1000); } public void setTime(long time) { diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java deleted file mode 100644 index e3d6334..0000000 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Motto.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.github.cato447.AbizeitungVotingSystem.entities; - -import javax.persistence.*; - -@Entity -@Table(name = "mottos") -public class Motto implements Comparable{ - - public Motto() { - super(); - } - - public Motto(String name) { - super(); - this.name = name; - this.votes = 0; - } - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - private String name; - - private Integer votes; - - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public Integer getVotes() { - return votes; - } - - public void setName(String name) { - this.name = name; - } - - public void setVotes(Integer votes) { - this.votes = votes; - } - - public void voteFor() { - this.votes += 1; - } - - @Override - public int compareTo(Motto m) { - if (getVotes() == null || m.getVotes() == null) { - return 0; - } - return m.getVotes().compareTo(getVotes()); - } -} diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java index 3bbe10a..97a2c51 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/entities/Voter.java @@ -14,7 +14,6 @@ public class Voter { this.email = email; this.vote_status = false; this.candidatesubmit_status = false; - this.motto_status = false; } @Id @@ -22,7 +21,6 @@ public class Voter { private Long id; private String email; private Boolean vote_status; - private Boolean motto_status; private Boolean candidatesubmit_status; public Long getId() { @@ -41,10 +39,6 @@ public class Voter { return candidatesubmit_status; } - public Boolean getMotto_status() { - return motto_status; - } - public void vote(){ vote_status = true; } @@ -52,6 +46,4 @@ public class Voter { public void submitCandidates() { candidatesubmit_status = true; } - - public void voteMotto() { motto_status = true;} } diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java deleted file mode 100644 index 0d3ecb0..0000000 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/repositories/MottoRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.github.cato447.AbizeitungVotingSystem.repositories; - -import com.github.cato447.AbizeitungVotingSystem.entities.Motto; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -public interface MottoRepository extends JpaRepository { - - public Motto findByName(String name); - - Optional findById(Long id); - -} diff --git a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java index c2ce93a..a12a89b 100644 --- a/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java +++ b/src/main/java/com/github/cato447/AbizeitungVotingSystem/table/TableAction.java @@ -1,16 +1,9 @@ package com.github.cato447.AbizeitungVotingSystem.table; -import com.github.cato447.AbizeitungVotingSystem.controller.VotingController; import com.github.cato447.AbizeitungVotingSystem.entities.*; import com.github.cato447.AbizeitungVotingSystem.repositories.*; -import org.aspectj.weaver.loadtime.definition.LightXMLParser; import java.io.*; -import java.lang.reflect.Array; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.nio.Buffer; import java.util.*; public class TableAction { @@ -31,12 +24,6 @@ public class TableAction { voterRepository.save(voter); } - public void updateMottoStatus(String email, VoterRepository voterRepository){ - Voter voter = voterRepository.findByEmail(email); - voter.voteMotto(); - voterRepository.save(voter); - } - public AuthCode generateToken(String name, String code, AuthCodesRepository authCodesRepository) { AuthCode authCode = new AuthCode(name, code); try{ @@ -67,12 +54,12 @@ public class TableAction { return "wrong"; } - private boolean fiveMinutesPassed(Long time){ - return System.currentTimeMillis() >= (time + 300*1000); + public void deleteToken(String name, AuthCodesRepository authCodesRepository){ + authCodesRepository.delete(authCodesRepository.findByName(name)); } private int getLimit(List possibleCandidates){ - return possibleCandidates.size() <= 5 ? possibleCandidates.size() : 5; + return possibleCandidates.size() <= 15 ? possibleCandidates.size() : 15; } public void voteForCandidate(String id, CandidateRepository candidateRepository){ @@ -82,15 +69,8 @@ public class TableAction { candidateRepository.save(candidate); } - public void voteForMotto(String id, MottoRepository mottoRepository){ - long mottoID = Long.valueOf(id); - Motto motto = mottoRepository.findById(mottoID).get(); - motto.voteFor(); - mottoRepository.save(motto); - } - public void setUpVoters(VoterRepository voterRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Q2_emails.txt"); + try (InputStream inputStream = getClass().getResourceAsStream("/Email_Whitelist.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String line = ""; ArrayList voters = new ArrayList(); @@ -119,8 +99,17 @@ public class TableAction { Collections.sort(possibleCandidatesPerCategory, Comparator.comparing(PossibleCandidate::getVotes)); Collections.reverse(possibleCandidatesPerCategory); for (int j = 0; j < getLimit(possibleCandidatesPerCategory); j++){ - Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); - candidateRepository.save(candidate); + if (j >= 10 && possibleCandidatesPerCategory.get(j).getVotes() == possibleCandidatesPerCategory.get(9).getVotes()){ + Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); + candidateRepository.save(candidate); + } + if (j < 10){ + Candidate candidate = new Candidate(possibleCandidatesPerCategory.get(j).getName(), possibleCandidatesPerCategory.get(j).getCategory()); + candidateRepository.save(candidate); + } + if (j == 14){ + break; + } } i += -1; possibleCandidatesPerCategory.clear(); @@ -147,20 +136,4 @@ public class TableAction { e.printStackTrace(); } } - - public void setUpMottos(MottoRepository mottoRepository){ - try (InputStream inputStream = getClass().getResourceAsStream("/Mottos.txt"); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { - String line = ""; - ArrayList mottos = new ArrayList<>(); - while ((line = reader.readLine())!= null){ - String name = line; - Motto motto = new Motto(name); - mottos.add(motto); - } - mottoRepository.saveAll(mottos); - } catch (IOException e) { - e.printStackTrace(); - } - } } diff --git a/src/main/resources/Categories.txt b/src/main/resources/Categories.txt index 143e51d..e69de29 100644 --- a/src/main/resources/Categories.txt +++ b/src/main/resources/Categories.txt @@ -1,36 +0,0 @@ -Wer wird nie von zuhause ausziehen? -Wer ist der/die kreativste Zuspätkommer/in? -Mit wem wird man am ehesten in der Zukunft angeben zur Schule gegangen zu sein? -Wer wohnt im Fittnessstudio? (Schüler) -Wer ist der coolste Leherer? -Wer ist die coolste Lehrerin? -Wer macht den besten Matheunterricht? -Welcher Lehrer hat den Beruf verfehlt? -Welcher Lehrer ist nie da? -Wer hat das Internet erfunden? -Wer sponsort Schollin? (Schüler) -Wer ist am engagiertesten? (Schüler) -Wer wird Bundeskanzler? (Schüler) -Wer hat das Kimpeltum gegründet? (Schüler) -Wer saß am längsten im Klassenschrank? (Schüler) -Wer hat die gößte Sauklaue? (Leherer) -Wer gründet das nächste Google? (Schüler) -Wer kommt am schnellsten in den Knast? (Schüler) -Top 3-Pärchen? (Schüler) -Top 3 Lehrergespanne? (Schüler) -Wer ist der motiviertester Lehrer? -Wer ist Google auf zwei Beinen(Schüler)? -Wer hat den besten Style (Schüler)? -Wer hat den besten Style (Lehrer)? -Wer währe ein gutes Pärchen (Lehrer)? -Wer trinkt am meisten Kaffe (Schüler)? -Wer trinkt am meisten Kaffe (Lehrer)? -Tischflip? -Wer wird Harzer? -Wer hat Wiedererkennungswert (Schüler)? -Wen erkennt man an der Lache (Schüler)? -Wer bringt die dümmsten Witze? (Lehrer) -Wer hat den meisten Schwachsinn erzählt? (Lehrer) -Welche Lehrer machen nie das, was die Schüler wollten? (Lehrer) -Wer isst immer? (Lehrer) -Wer hat die meisten peinlichen Momente gebracht? \ No newline at end of file diff --git a/src/main/resources/Mottos.txt b/src/main/resources/Mottos.txt deleted file mode 100644 index 645759b..0000000 --- a/src/main/resources/Mottos.txt +++ /dev/null @@ -1,11 +0,0 @@ -CannABIs - wir haben es durchgezogen! -ABI 2,010 ‰ - Meist dichter als Denker -KABItän Blaubär - Immer blau und trotzdem schlau -HABI Potter - Wir verlassen die Kammer des Schreckens -A BItch - Für einen Punkt tue ich alles! -ABIthur - Wenn das Elite von die Gymnahsium gehen tut -LABIrinth - Planlos zum Ziel -ABIcrombie & Fitch - Models gehen, Elche bleiben (Abercrombie & Fitch) -SemipermeABIlität - Nur die Besten kommen durch -KohlrABI - Wir machen uns vom Acker -ABIgasmus - Aber das war nur das Vorspiel \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 58e3e6a..987925f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ -spring.datasource.url=jdbc:mysql://localhost/VotingSystem -spring.datasource.username=***REMOVED*** -spring.datasource.password=***REMOVED*** +spring.datasource.url=jdbc:mysql://hostadress/database +spring.datasource.username=mysql_username +spring.datasource.password=mysql_password spring.jpa.hibernate.ddl-auto=update @@ -8,11 +8,11 @@ spring.jpa.hibernate.ddl-auto=update server.port = 8000 ######Email Properties ###### -spring.mail.host=smtp.gmail.com -spring.mail.port=587 +spring.mail.host= +spring.mail.port= spring.mail.properties.mail.smtp.starttls.enable=true -spring.mail.username=***REMOVED*** -spring.mail.password=***REMOVED*** +spring.mail.username= +spring.mail.password= spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.connectiontimeout=5000 diff --git a/src/main/resources/static/styles/addingCandidates.css b/src/main/resources/static/styles/addingCandidates.css index 10be17b..6d68b66 100644 --- a/src/main/resources/static/styles/addingCandidates.css +++ b/src/main/resources/static/styles/addingCandidates.css @@ -20,15 +20,19 @@ body { } h1 { - margin-top: 5%; color: #FFF; - margin-bottom: 5%; } -h2.categoryHeader { +h2 { color: #FFF; } +h2.categoryCategory { + color: #bb1515; + margin-top: 5%; + margin-bottom: 1%; +} + input { background: #bb1515b2; border: none; @@ -41,7 +45,6 @@ input { .submitButton { margin-top: 5%; - margin-bottom: 5%; border: 0; outline: 0; background: #bb1515; diff --git a/src/main/resources/static/styles/allreadyVoted.css b/src/main/resources/static/styles/allreadyVoted.css new file mode 100644 index 0000000..4d4f997 --- /dev/null +++ b/src/main/resources/static/styles/allreadyVoted.css @@ -0,0 +1,51 @@ +body { + background-color: rgb(44, 49, 54); + font-family: Arial, Helvetica, sans-serif; +} + +.center-screen { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.centered { + background: transparent; + margin: 0 auto; + padding: 20px; + width: 100%; + overflow: auto; +} + +h1 { + color: #FFF; + font-size: 75px; +} + +h2 { + color: #6d6d78; +} + +.submitButton { + padding: .25em 0; + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + +html, +body { + width: 100%; + height: 100%; + background-image: linear-gradient(to bottom right, #111E25 0%, #111 100%); + font-family: 'Lato', sans-serif; +} \ No newline at end of file diff --git a/src/main/resources/static/styles/authenticate.css b/src/main/resources/static/styles/authenticate.css index d2178b4..16f0640 100644 --- a/src/main/resources/static/styles/authenticate.css +++ b/src/main/resources/static/styles/authenticate.css @@ -21,9 +21,12 @@ body { } h1 { - margin-top: 5%; color: #FFF; - margin-bottom: 5%; +} + +h1.end { + color: #6d6d78; + margin-bottom: 2%; } h2 { @@ -41,7 +44,7 @@ input { .submitButton { margin-top: 5%; - margin-bottom: 5%; + margin-bottom: 1%; border: 0; outline: 0; background: #bb1515; @@ -54,6 +57,19 @@ input { text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); } +.newCode { + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 1rem; + width: 250px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + .errorCode { margin-top: 10%; color: #bb1515; diff --git a/src/main/resources/static/styles/start.css b/src/main/resources/static/styles/start.css index 7831a91..76a47b8 100644 --- a/src/main/resources/static/styles/start.css +++ b/src/main/resources/static/styles/start.css @@ -14,28 +14,6 @@ div.userLogin { transform: translate(-50%, -50%); } -input.email_input { - background-color: transparent; - border: transparent; - border-bottom: 2px solid red; - color: #FFF; - font-size: xx-large; - width: fit-content; -} - -input.password_input { - background-color: transparent; - border: transparent; - color: #FFF; - font-size: medium; - width: fit-content; -} - -label { - color: #FFF; - display: block; -} - #signup_button { display: block; margin: auto; @@ -52,8 +30,24 @@ label { text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); } -@media only screen and (max-device-width: 1024px) { - input.email_input { - font-size: large; - } +input.email_input { + background-color: transparent; + border: transparent; + border-bottom: 2px solid #bb1515; + color: #FFF; + font-size: xx-large; + width: 500px; +} + +input.password_input { + background-color: transparent; + border: transparent; + color: #FFF; + font-size: medium; + width: fit-content; +} + +label { + color: #FFF; + display: block; } \ No newline at end of file diff --git a/src/main/resources/static/styles/voteSuccessful.css b/src/main/resources/static/styles/voteSuccessful.css new file mode 100644 index 0000000..faaa063 --- /dev/null +++ b/src/main/resources/static/styles/voteSuccessful.css @@ -0,0 +1,54 @@ +body { + background-color: rgb(44, 49, 54); + font-family: Arial, Helvetica, sans-serif; +} + +.center-screen { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.centered { + background: transparent; + margin: 0 auto; + padding: 20px; + width: 100%; + overflow: auto; +} + +h1 { + color: #FFF; +} + +h2 { + color: #FFF; +} + +h2.time_remain { + color: #6d6d78; +} + +.submitButton { + padding: .25em 0; + border: 0; + outline: 0; + background: #bb1515; + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); +} + +html, +body { + width: 100%; + height: 100%; + background-image: linear-gradient(to bottom right, #111E25 0%, #111 100%); + font-family: 'Lato', sans-serif; +} \ No newline at end of file diff --git a/src/main/resources/static/styles/voting.css b/src/main/resources/static/styles/voting.css index e0ff00c..5c99db7 100644 --- a/src/main/resources/static/styles/voting.css +++ b/src/main/resources/static/styles/voting.css @@ -42,7 +42,8 @@ button { } .submitButton { - margin-top: 5%; + margin-top: 2%; + margin-bottom: 5%; padding: .25em 0; border: 0; outline: 0; @@ -56,6 +57,23 @@ button { text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); } +@media only screen and (max-device-width: 480px) { + .submitButton { + margin-top: 2%; + padding: .25em 0; + border: 0; + outline: 0; + background: rgb(6, 216, 136); + color: rgba(255, 255, 255, 0.85); + font-size: 2rem; + width: 500px; + letter-spacing: .0625rem; + border-radius: 12px; + box-shadow: 0 3px 5px 1px rgba(0, 0, 0, 0.25); + text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.2); + } +} + html, body { width: 100%; diff --git a/src/main/resources/templates/addingCandidates.html b/src/main/resources/templates/addingCandidates.html index 4db657a..908566b 100644 --- a/src/main/resources/templates/addingCandidates.html +++ b/src/main/resources/templates/addingCandidates.html @@ -28,7 +28,7 @@ $('#inputForm div.group:nth-child(' + q + ')').hide(); $('#inputForm div.group:nth-child(' + (q + 1) + ')').show(); if (q == (qMax - 1)) { - $('#btnNext').html('Submit Answers'); + $('#btnNext').html('Eingabe bestätigen'); } q++; } else { @@ -42,11 +42,17 @@
+
+

Lehrer

+
+
+

Schüler

+

- +
- +
diff --git a/src/main/resources/templates/authenticate.html b/src/main/resources/templates/authenticate.html index d20b486..f57a703 100644 --- a/src/main/resources/templates/authenticate.html +++ b/src/main/resources/templates/authenticate.html @@ -10,14 +10,9 @@ - -

+

Nicht wundern das kann ein wenig dauern!

+

Bitte gebe den Authentifizierungscode ein

@@ -28,11 +23,18 @@ -
+ + +
+ + +
+ +
-

Der Code ist nicht mehr gültig!
Fordere einen neuen an

+

Der Code ist nicht mehr gültig!

@@ -76,6 +78,33 @@ output.value = code; document.getElementById("passForm").submit(); } + + function updateCounter(time) { + const zeroPad = (num, places) => String(num).padStart(places, '0') + + // Show time remaining now. + showTimeRemaining(); + + var dateFuture = time; + console.log(dateFuture); + + // Set a timer to update the displayed clock every 1000 milliseconds. + var updateTimeLoop = setInterval(showTimeRemaining, 1000); + + function showTimeRemaining() { + var dateNow = Date.now(); + var days = zeroPad(Math.floor((dateFuture - dateNow) / (1000 * 60 * 60 * 24)), 2); + var hours = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24) / (1000 * 60 * 60)), 2); + var mins = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60) / (1000 * 60)), 2); + var secs = zeroPad(Math.floor(((dateFuture - dateNow) - days * 1000 * 60 * 60 * 24 - hours * 1000 * 60 * 60 - mins * 1000 * 60) / 1000), 2); + document.getElementById("time_remain").innerHTML = "Der Code gilt noch für " + mins + ":" + secs; + if (hours + mins + secs == 0) { + document.getElementById("time_remain").innerHTML = "Der Code ist abgelaufen"; + } + } + } + + updateCounter(document.getElementById("time_remain").innerHTML); diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 4e05b4b..dcf2207 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -1,10 +1,24 @@ - + - -

Something went wrong!

-

Our Engineers are on it

- Go Home + + + Title + + + + +
+

Oops irgendwas ist kaputt gegangen

+

Keine Sorge!
Probiers nochmal :D

+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadyVoted.html b/src/main/resources/templates/errors/alreadyVoted.html index e6cb039..2fafb30 100644 --- a/src/main/resources/templates/errors/alreadyVoted.html +++ b/src/main/resources/templates/errors/alreadyVoted.html @@ -3,12 +3,21 @@ - Abizeitung 2020/2021 Voting + Title + - -

Jeder darf nur einmal abstimmen!

- Return to Login-Site + +
+

Du hast schon abgestimmt!

+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadyVotedForMotto.html b/src/main/resources/templates/errors/alreadyVotedForMotto.html deleted file mode 100644 index 572e139..0000000 --- a/src/main/resources/templates/errors/alreadyVotedForMotto.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Title - - - -

Du hast deine Motto schon gewählt!

- Return to Login-Site - - - \ No newline at end of file diff --git a/src/main/resources/templates/errors/alreadysubmittedcandidates.html b/src/main/resources/templates/errors/alreadysubmittedcandidates.html deleted file mode 100644 index e976e5b..0000000 --- a/src/main/resources/templates/errors/alreadysubmittedcandidates.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Title - - - -

Du hast deine Kandidaten schon vorgeschlagen!

- Return to Login-Site - - - \ No newline at end of file diff --git a/src/main/resources/templates/errors/notRegistered.html b/src/main/resources/templates/errors/notRegistered.html index 6ef3123..b8ce0b4 100644 --- a/src/main/resources/templates/errors/notRegistered.html +++ b/src/main/resources/templates/errors/notRegistered.html @@ -1,14 +1,24 @@ - + - Abizeitung 2020/2021 Voting + Title + - -

Überprüfe noch einmal die eingegebene E-Mail Adresse Sollte der Fall eintreten, dass du deine E-Mail Adresse richtig eingegeben hast und du Schüler der Q2 bist, schreibe eine Mail an simon.bussmann@adolfinum.de mit dem Betreff LoginFehler

- Return to Login-Site + +
+

Du bist nicht zur Wahl zugelassen!

+

Falls du abstimmen können solltest
schreibe eine Mail an ***REMOVED***

+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/errors/votingClosed.html b/src/main/resources/templates/errors/votingClosed.html new file mode 100644 index 0000000..b41d13c --- /dev/null +++ b/src/main/resources/templates/errors/votingClosed.html @@ -0,0 +1,24 @@ + + + + + + Title + + + + +
+

Du bist leider zu spät

+

Momentan ist hier auf der Seite nichts los

+ +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/test.html b/src/main/resources/templates/test.html deleted file mode 100644 index 77b50c0..0000000 --- a/src/main/resources/templates/test.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - Abizeitung 2020/2021 Voting - - - - -

Paragraphes

-

This is a paragraph.

-

This is another paragraph.

- -

Links

- This is a link - -

HTML Images

-

HTML images are defined with the img tag:

- Binary example picture - -

Line breaks

-

This is a
paragraph with a line break.

- -

Styling

-

This is a red paragraph.

- -

Title attribute

-

This is a paragraph.

- -

Quotes in attributes

-

Example 1

-

Example 2

- -

Bigger headings

-

Heading 1

- -

HTML Display

-

- This paragraph contains a lot of lines in the source code, but the browser ignores it. -

-

- This paragraph contains a lot of spaces in the source code, but the browser ignores it. -

- -

Poem Problem

-

- My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me. -

- -
Solution:
-
-            My Bonnie lies over the ocean.
-          
-            My Bonnie lies over the sea.
-          
-            My Bonnie lies over the ocean.
-          
-            Oh, bring back my Bonnie to me.
-    
- - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/voteSuccessful.html b/src/main/resources/templates/voteSuccessful.html index 566549b..3d74f7d 100644 --- a/src/main/resources/templates/voteSuccessful.html +++ b/src/main/resources/templates/voteSuccessful.html @@ -1,10 +1,24 @@ - + + Title + - + +
+

Deine Auswahl fließt nun in die Wahl ein!

+

Danke fürs abstimmen!

+ +
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/voting.html b/src/main/resources/templates/voting.html index 9f90626..ab60204 100644 --- a/src/main/resources/templates/voting.html +++ b/src/main/resources/templates/voting.html @@ -62,7 +62,7 @@ $('#votingButtons div.voteDiv:nth-child(' + q + ')').hide(); $('#votingButtons div.voteDiv:nth-child(' + (q + 1) + ')').show(); if (q == (qMax - 1)) { - $('#btnNext').html('Submit Answers'); + $('#btnNext').html('Auswahl bestätigen'); } q++; } else { @@ -81,7 +81,7 @@
- +