Answer To: CRICOS Provider No. 00103D Page 1 of 5 ITECH3108 Dynamic Web Programming Assignment 2 - Tattoo Share...
Mohd answered on Jun 05 2021
Tattoo Share/api.php
include "php/ajax/config.php";
include_once "php/ajax/Common.php";
if (isset($_GET['name'])){
$apiName = $_GET['name'];
switch ($apiName){
case "events":
$response = array();
$common = new Common();
$allEvents = $common->getAllEvents($connection);
while ($row = $allEvents->fetch_object()){
$response[] = $row;
}
echo json_encode($response);
break;
}
}
Tattoo Share/assets/img/line.png
Tattoo Share/assets/img/line2.png
Tattoo Share/assets/img/plus.png
Tattoo Share/assets/img/tattoo_logo.png
Tattoo Share/assets/js/ajaxjs.js
$(document).ready(function () {
// alert('hi');
getAllEvents();
//getAllVoters();
});
window.setInterval(function(){
/// call your function here
getAllEvents();
// getAllVoters();
}, 5000);
$("form#addEditCoAdminForm").on("submit",function (e) {
e.preventDefault();
var eventName = $("#eventName").val();
var eventTime = $("#eventTime").val();
var posterName = $("#posterName").val();
// var eventDescription = $("#eventDescription").val();
if (eventName == ""){
alert("Please enter event name");
eventName.focus();
}else if (eventTime == ""){
eventTime.focus();
}/*else if (eventDescription == ""){
eventDescription.focus();
}*/else{
$.post("php/ajax/ajax.php",{
addEvent:"addEvent",
eventName:eventName,
eventTime:eventTime,
posterName:posterName,
//eventDescription:eventDescription
},function (response) {
$("#addNewEventModal").modal('hide');
$('#addEditCoAdminForm').trigger("reset");
var data = response.split('^');
if (data[1] == "saved"){
// alert("saved");
getAllEvents();
}
});
}
});
function getAllEvents() {
$.post("php/ajax/ajax.php",{getAllEvents:"getAllEvents"},function (response) {
var data = response.split('^');
$("#eventTimeLineData").html(data[1]);
});
}
function voteTheEvent(eventId) {
$("#vottingModal").modal('show');
$("#eventId").val(eventId);
}
$("form#vottingForm").on("submit",function (e) {
e.preventDefault();
var voterName = $("#voterName").val();
var eventId = $("#eventId").val();
if (voterName == ""){
alert("Please enter your name");
$("#voterName").focus();
}else{
$.post("php/ajax/ajax.php",{voteTheEvent:"voteTheEvent",voterName:voterName,eventId:eventId},function (response) {
var data = response.split('^');
if (data[1] == "voted"){
alert("Your vote has been saved for this event");
$("#vottingModal").modal('hide');
$('#vottingForm').trigger("reset");
getAllEvents();
}
});
}
});
$("form#addVoterForm").on("submit",function (e) {
e.preventDefault();
var voterName = $("#voterName").val();
var eventId = $("#eventId").val();
if (voterName == ""){
alert("Please enter voter name");
$("#voterName").focus();
}else{
$.post("php/ajax/ajax.php",{addVoter:"addVoter",voterName:voterName,eventId:eventId},function (response) {
var data = response.split('^');
if (data[1] == "added"){
alert("Voter added");
$("#addVoterModal").modal('hide');
$('#addVoterForm').trigger("reset");
getAllVoters(eventId);
}
});
}
});
function getAllVoters(eventId) {
$.post("php/ajax/ajax.php",{getAllVoters:"getAllVoters",eventId:eventId},function (response) {
var data = response.split('^');
$("#votersData").html(data[1]);
});
}
function suggestEventTime(eventId) {
$("#suggesstionModal").modal('show');
$("#eventId").val(eventId);
}
$("form#suggesstionForm").on("submit",function (e) {
e.preventDefault();
var posterName = $("#suggestorName").val();
var suggestedTime = $("#suggestedTimes").val();
var eventId = $("#eventId").val();
/* if (posterName ==""){
alert("Please enter your name");
$("#suggestorName").focus();
}*/ if (suggestedTime==""){
alert("Please enter your suggested time");
$("#suggestedTimes").focus();
}else{
$.post("php/ajax/ajax.php",{suggestTiming:"suggestTiming",posterName:posterName,suggestedTime:suggestedTime,eventId:eventId},function (response) {
var data = response.split('^');
if (data[1] == "saved"){
alert("Your suggestion has been saved");
$("#suggesstionModal").modal('hide');
$('#suggesstionForm').trigger("reset");
}
});
}
});
function getAllSuggestions(eventId) {
$.post("php/ajax/ajax.php",{getAllSuggestions:"getAllSuggestions",eventId:eventId},function (response) {
var data = response.split('^');
$("#suggestionsData").html(data[1]);
});
}
Tattoo Share/assets/style.css
ul.timeline {
list-style-type: none;
position: relative;
}
ul.timeline:before {
content: ' ';
background: #d4d9df;
display: inline-block;
position: absolute;
left: 29px;
width: 2px;
height: 100%;
z-index: 400;
}
ul.timeline > li {
margin: 20px 0;
padding-left: 20px;
}
ul.timeline > li:before {
content: ' ';
background: white;
display: inline-block;
position: absolute;
border-radius: 50%;
border: 3px solid #22c0e8;
left: 20px;
width: 20px;
height: 20px;
z-index: 400;
}
Tattoo Share/data.json
[{"id":"8","eventName":"Tattoo Share 7","eventTime":"12:10AM","postedDate":"2019-09-24 15:37:55","posterName":"Raja","eventDescription":""},{"id":"7","eventName":"Tattoo Share 6","eventTime":"ddd","postedDate":"2020-09-24 13:38:38","posterName":"Parth ","eventDescription":""},{"id":"6","eventName":"Tattoo Share 5","eventTime":"fghjk","postedDate":"2020-09-24 13:38:30","posterName":"Abhishek","eventDescription":""},{"id":"5","eventName":"Tattoo Share 4","eventTime":"ddfghj","postedDate":"2019-09-24 13:30:32","posterName":"Ram Singh","eventDescription":"fghjio"},{"id":"4","eventName":"Synergy","eventTime":"5:30","postedDate":"2019-09-24 13:28:30","posterName":"","eventDescription":"hjkasdfgthyujkisdfghjkl hjkasdfgthyujkisdfghjkl hjkasdfgthyujkisdfghjkl "},{"id":"3","eventName":"Tattoo Share 3","eventTime":"10:00PM","postedDate":"2019-09-24 13:23:10","posterName":"","eventDescription":"For a complete reference of all modal options, methods aFor a complete reference of all modal options, methods a"},{"id":"2","eventName":"Tattoo Share 2","eventTime":"10:00PM","postedDate":"2019-09-24 13:23:04","posterName":"","eventDescription":"For a complete reference of all modal options, methods aFor a complete reference of all modal options, methods a"},{"id":"1","eventName":"Tattoo Share 1","eventTime":"12:10AM","postedDate":"2020-09-24 13:07:50","posterName":"Mohd Lucky","eventDescription":""}]
Tattoo Share/footer.php