Commit 780d8a26 by sopham

all buttons worked

parent 7f53639a
<?php
include_once "dbconnection_data.php";
$server = "anysql.itcollege.ee";
$user = "team4";
$password = "rw_353MIl_e";
$database = "WT_4";
$link = new mysqli($server, $user, $password, $database);
if ($link -> connect_error) die("Connection to DB failed: ". $link ->connect_error);
if($link -> connect_error) die("Connecion to DB failed: ". $link -> connect_error);
$query = "INSERT INTO toDoList(task) VALUES ('".$_POST["add-task"]."')";
if (mysqli_query($link, $query)) {
echo "Successfully added. ";
}
else {
echo "Error: " . $query . "<br>" . mysqli_error($link);
}
$link -> close();
?>
<?php
$server = "anysql.itcollege.ee";
$user = "team4";
$password = "rw_353MIl_e";
$database = "WT_4";
?>
<?php
include_once "dbconnection.php";
/*
$link = new mysqli($server, $user, $password, $database);
if($link -> connect_error) die("Connecion to DB failed: ". $link -> connect_error);
$query = "SELECT task FROM toDoList;";
$result = $link -> query($query);
if (!$result) die ("Database access failed");
*/
$query = "TRUNCATE TABLE toDoList;";
if(!$link->query($query)) {
echo "(".$link->errno.")".$link->error;
}
?>
<?php
include_once "dbconnection.php";
$query ="DELETE FROM toDoList WHERE task=?";
$query = $link->prepare($query);
$query->bind_param('s', $_GET['task']);
$query->execute();
$query->close();
$link->close();
?>
<?php
header('Content-type: application/json');
include_once "dbconnection.php";
$query = "SELECT task FROM toDoList;";
$result = $link -> query($query);
if (!$result) die ("Database access failed");
$data = array();
for ($i = 0; $i < $result->num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_NUM);
array_push($data, $row[0]);
}
header('Content-Type: application/json');
echo json_encode($data);
$link->close();
?>
var i = 0;
//add new row to list after submitting
function addRow(){
if (document.getElementById('addTask').value!=''){
if (document.getElementById('add-task').value!=''){
i++;
var title = document.getElementById('addTask').value;
var title = document.getElementById('add-task').value;
var node = document.createElement('div');
node.innerHTML = '<input id="option' + i + '" type="checkbox" class="hidden" name="checkbox"><label for="option' + i + '" class="check--label"><span class="check--label-box"></span><span class="check--label-text">'+ title +'</span>';
document.getElementById('doList').appendChild(node);
}
}
//clear input after submitting
function onFormSubmit(){
document.getElementById('addTask').value='';
}
//delete all tasks
function deleteAll() {
var e = document.getElementById("doList");
......@@ -23,20 +18,6 @@ function deleteAll() {
}
}
//delete completed tasks
function deleteComplete() {
var boxes = document.getElementsByClassName('hidden');
var texts = document.getElementsByClassName('check--label');
for(let i = 0; i<boxes.length; i++){
box = boxes[i];
txt = texts[i];
if(box.checked){
box.parentNode.removeChild(box);
txt.parentNode.removeChild(txt);
}
}
}
//scrolling
window.onscroll = function() {myFunction()};
function myFunction() {
......@@ -61,3 +42,40 @@ function readURL(input) {
$("#imageUpload").change(function() {
readURL(this);
});
//display input from database
$(document).ready(function() {
$.ajax({
dataType: 'JSON',
url: 'display.php',
success: function(data) {
var items = [];
$.each( data, function(key, val) {
i++;
var title = val;
var node = document.createElement('div');
node.innerHTML = '<input id="option' + i + '" type="checkbox" class="hidden" name="checkbox"><label for="option' + i + '" class="check--label"><span class="check--label-box"></span><span class="check--label-text">' + title + '</span>';
document.getElementById('doList').appendChild(node);
})
}
});
});
//delete completed tasks
$(document).ready(function() {
$('#delete-complete').click(function() {
$("input.hidden:checkbox:checked").each(function() {
//$(this).parent().remove();
$.ajax({
type: "GET",
url: "delete-complete.php",
data: {task: $(this).next().children(".check--label-text").text()}
});
$(this).parent().remove();
});
});
});
//add user input to database
$("#addAction").submit(function(event) {
event.preventDefault();
var task = $("#add-task").val();
$.ajax({
url: "insert.php",
type:"POST",
data:{
"task": task },
success: function() {
$("#add-task").val("");
}
});
});
//enter to add to list
var input = document.getElementById("add-task");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("add").click();
}
});
//delete all from database
$("#delete-button").click(function() {
$.ajax({
url: "delete-all.php",
type: "POST"
});
});
......@@ -8,6 +8,7 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="function.js" type="text/javascript"></script>
<script async src="function1.js" type="text/javascript"></script>
</head>
<body>
<div id="wrapper">
......@@ -28,10 +29,10 @@
<div class="task-card">
<div class="extra-content" id="extraContent">
<a href="javascript:window.print()"><i class="glyphicon glyphicon-print"></i> Print List</a>
<a onclick="deleteComplete();"><i class="fa fa-trash w3-large"></i> Completed Tasks</a>
<a onclick="deleteAll();"><i class="fa fa-trash w3-large"></i> Delete All</a>
<a id="delete-complete"><i class="fa fa-trash w3-large"></i> Completed Tasks</a>
<a onclick="deleteAll();" id="delete-button"><i class="fa fa-trash w3-large"></i> Delete All</a>
</div><br>
<form action="" method="POST" id="action">
<form action="login_check.php" method="POST" id="action">
<input type="submit" class="logout-button" name="logout"value="Logout">
</form>
</div>
......@@ -41,11 +42,10 @@
<div class="card">
<form action="dbconnection.php" method="POST" id="addAction">
<input type="text" id="addTask" onkeypress="return event.keyCode != 13" id="add-task" name="add-task" placeholder="Add tasks..." autocomplete="off">
<input type="submit" class="add-button" id="add" name="add-button" value="Add">
<!--<input type="button" class="add-button" id="add" onclick="addRow(); onFormSubmit();" onkeypress="return searchKeyPress(event);" name="add-button" value="Add">-->
<input type="text" id="add-task" onkeypress="return event.keyCode != 13" name="add-task" placeholder="Add tasks..." autocomplete="off">
<!--<input type="submit" class="add-button" id="add" onclick="insert(); addRow(); onFormSubmit();" name="add-button" value="Add">-->
<input type="submit" class="add-button" id="add" onclick="addRow();" onkeypress="return searchKeyPress(event);" name="add-button" value="Add">
</form>
<form class="task-board card" class="list" id="form">
<div class="list-item" id="doList">
<div class="progress-container">
......@@ -57,16 +57,5 @@
</div>
</div>
</div>
<script>
//enter to add to list
var input = document.getElementById("addTask");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("add").click();
}
});
</script>
</body>
</html>
<?php
include_once "dbconnection.php";
$query = "INSERT INTO toDoList (task) VALUES (?) ";
$query = $link->prepare($query);
$query->bind_param('s', $_POST['task']);
$query ->execute();
$query -> close();
$link -> close();
?>
<?php
?>
......@@ -37,28 +37,34 @@
}
@media screen and (max-width: 600px) {
body {float: none;}
body {
float: none;
}
}
.row {
margin: 0 -5px;
display: flex;
width: 100%;
min-width: 1050px;
}
.main {
width: 100%;
float:none;
}
.card {
width: 100%;
height: 100%;
min-height: 940px;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 30px;
padding: 20px;
text-align: center;
background-color: #f1f1f1;
margin: 10px 10px 10px 10px;
}
.list-card {
width: 90%;
height: 20%;
height: 35%;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 12px;
text-align: center;
......@@ -70,8 +76,8 @@
.task-card {
cursor: pointer;
width: 90%;
height: 80%;
width: 220px;
height: 64%;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 30px;
margin: 10px 10px 10px 10px;
......@@ -80,7 +86,6 @@
}
.side {
width: 205;
padding: 0px 5px 0px 30px;
}
......@@ -152,15 +157,14 @@ input[type=text] {
.task-board {
border: 6px;
margin-top: 160px;
margin-top: 150px;
margin-left: 90px;
height: 80%;
width: 80%;
background-color: white;
border-radius: 15px;
overflow-y: scroll;
min-width: 200px;
height: 200px;
height: 460px;
}
.checkmark {
......@@ -178,14 +182,6 @@ input[type=text] {
appearance: none;
}
.main {
width: 80%;
}
.side {
width: 20%;
}
.list {
display: flex;
}
......@@ -325,17 +321,3 @@ input[type=text] {
background-repeat: no-repeat;
background-position: center;
}
\ No newline at end of file
.progress-container {
position: relative;
width: 100%;
height: 8px;
background: #ccc;
}
#myBar {
position: absolute;
height: 8px;
background: red;
width: 0%;
}
var i = 0;
//add new row to list after submitting
function addRow(){
if (document.getElementById('addTask').value!=''){
i++;
var title = document.getElementById('addTask').value;
var node = document.createElement('div');
node.setAttribute("id", "n" + i);
node.innerHTML = '<input id="option' + i + '" type="checkbox" class="hidden" name="checkbox"><label for="option' + i + '" class="check--label"><span class="check--label-box"></span><span class="check--label-text">'+ title +'</span>';
document.getElementById('doList').appendChild(node);
}
}
//clear input after submitting
function onFormSubmit(){
document.getElementById('addTask').value='';
}
//delete all tasks
function deleteAll() {
let x;
for (x = 1; x <= i; x++) {
let e = document.getElementById("n" + x);
e.parentNode.removeChild(e);
}
}
//delete completed tasks
function deleteComplete() {
var boxes = document.getElementsByClassName('hidden');
var texts = document.getElementsByClassName('check--label');
for(let i = 0; i<boxes.length; i++){
box = boxes[i];
txt = texts[i];
if(box.checked){
box.parentNode.removeChild(box);
txt.parentNode.removeChild(txt);
}
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="function.js" type="text/javascript"></script>
</head>
<body>
<div id="wrapper">
<div class="row">
<div class="side" id="side">
<div class="list-card">
<div class="avatar-upload">
<div class="avatar-edit">
<input type="file" accept="image/gif, image/jpeg, image/png" id="imageUpload" onchange="readURL(this);">
<label for="imageUpload"></label>
</div>
<div class="avatar-preview">
<div id="imagePreview" style="background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/20625/avatar-bg.png);"></div>
</div>
</div>
</div>
<div class="task-card">
<div class="extra-content" id="extraContent">
<a href="javascript:window.print()"><i class="glyphicon glyphicon-print"></i> Print List</a>
<a onclick="deleteComplete();"><i class="fa fa-trash w3-large"></i> Completed Tasks</a>
<a onclick="deleteAll();"><i class="fa fa-trash w3-large"></i> Delete All</a>
</div><br>
<form action="index_php.php" method="POST" id="action">
<input type="submit" class="logout-button" name="logout"value="Logout">
</form>
</div>
</div>
<div class="main">
<div class="card">
<form action="" method="POST" id="addAction">
<input type="text" id="addTask" onkeypress="return event.keyCode != 13" name="add-task" placeholder="Add tasks..." autocomplete="off">
<input type="button" class="add-button" id="add" onclick="addRow(); onFormSubmit();" onkeypress="return searchKeyPress(event);" name="add-button" value="Add">
</form>
<form class="task-board card" class="list" id="form">
<div class="list-item" id="doList">
<div class="progress-container">
<div class="progress-bar" id="myBar"></div>
</div>
<input id="option" type="checkbox" name="checkbox" class="hidden">
<label for="option" class="check--label">
<span class="check--label-box"></span>
<span class="check--label-text">One</span>
</label>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
//enter to add to list
var input = document.getElementById("addTask");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("add").click();
}
});
//scrolling
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}
</script>
</body>
</html>
<?php
if(isset($_POST['logout'])) {
session_destroy();
header('Location: login_page.php');
exit;
}
if(isset($_POST['add-button'])){
$addTask = $_POST['add-task'];
$file = fopen("taskList.txt","a+") or die("Unable to open file");
$s = $addTask."\r\n";
fputs($file,$s) or die("Unable to open save");
fclose($file);
header('Location: index.php');
}
?>
\ No newline at end of file
<?php
session_start();
error_reporting(0);
$user = $_POST['username'];
$pass = $_POST['password'];
if(isset($_POST['submit'])){
if($user=="admin" && $pass==admin){
header('Location:index.php');
}
else{
echo "Wrong Username or/and Password";
}
}
?>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="login_style.css">
</head>
<body>
<div id="wrapper">
<div class="row">
<div class="column">
<div class="card">
<form name="input" action="login_check.php" method="POST">
<label for="username">Username</label>
<input type="text" id="username" name="username" pattern="[a-zA-Z][a-zA-Z0-9-_\.]{1,20}" required><br>
<label for="password">Password</label>
<input type="password" id="password" name="password" autocomplete="off" required><br>
<input type="submit" name="submit" value="Login">
</form>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
@charset "UTF-8";
#wrapper{
max-width: 1350px;
min-width: 1350px;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
padding: 50px 50px 70px 50px;
text-align: center;
background-color: #9370DB;
border-radius: 6px;
width: 350px;
margin: auto;
margin-top: 15%;
color: white;
font-size: 25px;
font-family: 'Roboto Slab', serif;
}
input[type=text], [type=password] {
position: inherit;
padding: 10px 0px 10px 10px;
margin: 8px;
display: inline-block;
border: 1px solid #ccc;
border-radius: 6px;
box-sizing: border-box;
color: black;
font-size: 20px;
font-family: 'Roboto Slab', serif;
vertical-align: middle;
width: 50%;
}
input[type=submit] {
font-family: 'Roboto Slab', serif;
font-size: 15px;
font-weight: bold;
background-color: white;
color: black;
padding: 10px 20px;
margin: 7px 35px 0px 0px;
border-radius: 6px;
border: 1px solid #ccc;
cursor: pointer;
float: right;
letter-spacing: 1px;
}
input[type=submit]:hover {
background-color: rgb(182, 171, 189);
color: white;
border-radius: 6px;
}
\ No newline at end of file
@charset "UTF-8";
* {
box-sizing: border-box;
font-family: 'Roboto Slab', serif;
font-size: 20px;
}
@media print{
#form {
overflow-y:hidden;
}
#side {
display: none; }
#action{
display: none;
}
#addAction{
display: none;
}
#buttonExtra{
display: none;
}
#extraContent{
display: none;
}
#dropContent{
display: none;
}
#doList {
display: block;
position: absolute;
top: 10px;
left: 20px;
}
}
@media screen and (max-width: 600px) {
body {float: none;}
}
.row {
margin: 0 -5px;
display: flex;
}
.card {
width: 1005px;
height: 100%;
min-height: 940px;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 30px;
text-align: center;
background-color: #f1f1f1;
margin: 10px 10px 10px 10px;
}
.list-card {
height: 20%;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 12px;
text-align: center;
font-family: 'Roboto Slab', serif;
background-color: #f1f1f1;
text-align: center;
margin: 10px 10px 10px 10px;
}
.task-card {
cursor: pointer;
height: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
padding: 30px;
margin: 10px 10px 10px 10px;
text-align: center;
background-color: #f1f1f1;
}
.side {
padding: 0px 5px 0px 30px;
}
.extra-content {
font-family: 'Roboto Slab', serif;
width: 100%;
border-radius: 6px;
}
.extra-content a {
color: black;
padding: 15px 16px;
display: block;
border-radius: 6px;
}
.extra-content a:hover {
color: white;
background-color:#b198e6b9;
}
.logout-button {
background-color: #9370DB;
font-family: 'Roboto Slab', serif;
width: 100%;
padding: 10px;
border-radius: 6px;
border: none;
transition: all 0.5s;
cursor: pointer;
display: inline-block;
color: white;
}
.logout-button:hover{
background: red;
}
input[type=text] {
width: 70%;
box-sizing: border-box;
border: 2px solid #9370DB;
border-radius: 6px;
background-color: white;
padding: 12px 0 12px 40px;
float:left;
margin-left: 90px;
margin-top: 60px;
}
.add-button {
background-color:rgb(83, 68, 170);
font-family: 'Roboto Slab', serif;
width: 10%;
color: white;
padding: 14px;
border-radius: 6px;
border: none;
transition: all 0.5s;
cursor: pointer;
float: left;
margin-top: 60px;
margin-left: 5px;
}
.add-button:hover{
background-color: #9370DB;
color: white;
}
.task-board {
border: 6px;
margin-top: 160px;
margin-left: 90px;
height: 80%;
width: 80%;
background-color: white;
border-radius: 15px;
overflow-y: scroll;
min-width: 200px;
height: 200px;
}
.checkmark {
position: absolute;
top: 9px;
left: 15px;
height: 25px;
width: 25px;
border-radius: 50%;
background-color: #eee;
}
.hidden {
position: absolute;
appearance: none;
}
.list {
display: flex;
}
.check--label {
display: flex;
justify-content: flex-start;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
margin-top: 15px;
height: 40px;
}
.check--label-box {
display: flex;
align-self: center;
position: relative;
height: 25px;
width: 25px;
margin: 0 20px;
border: 2px solid rgb(83, 68, 170);
cursor: pointer;
border-radius: 50%;
}
.check--label-text {
position: relative;
display: flex;
cursor: pointer;
align-self: center;
padding: 20px;
font-size: 22px;
border-left: 1px solid #ecf0f1;
}
.check--label-text:after {
content: '';
display: block;
width: 0%;
height: 2px;
background-color: #000;
position: absolute;
top: 50%;
left: 7.5%;
transform: translateY(-50%);
transition: width 100ms ease-in-out;
}
.hidden:checked + .check--label {
background-color: #fff;
}
.hidden:checked + .check--label .check--label-box {
background-color: rgb(83, 68, 170);
}
.hidden:checked + .check--label .check--label-box:after {
content: '';
display: block;
position: absolute;
top: 3px;
left: 7px;
width: 7px;
height: 12px;
border: solid white;
border-width: 0 3px 3px 0;
transform: rotate(45deg);
}
.hidden:checked + .check--label .check--label-text:after {
width: 85%;
}
.avatar-upload {
position: relative;
max-width: 205px;
margin: 50px auto;
}
.avatar-edit {
position: absolute;
right: 12px;
z-index: 1;
top: -20px;
}
.avatar-upload .avatar-edit input {
display: none;
}
.avatar-upload input + label {
display: inline-block;
width: 34px;
height: 34px;
margin-bottom: 0;
border-radius: 100%;
background: #FFFFFF;
border: 1px solid transparent;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.12);
cursor: pointer;
font-weight: normal;
transition: all .2s ease-in-out;
}
.avatar-upload input + label:hover {
background: #f1f1f1;
border-color: #d6d6d6;
}
.avatar-upload input + label:after {
content: "\f040";
font-family: 'FontAwesome';
color: #757575;
position: absolute;
top: 2px;
left: 0px;
right: 0px;
text-align: center;
margin: auto;
}
.avatar-preview {
width: 190px;
height: 190px;
position: relative;
top: -35px;
border-radius: 100%;
border: 6px solid #F8F8F8;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
}
.avatar-preview > div {
width: 100%;
height: 100%;
border-radius: 50%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.progress-container {
position: relative;
width: 100%;
height: 8px;
background: #ccc;
}
#myBar {
position: absolute;
height: 8px;
background: red;
width: 0%;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment