Fix admin TodoList
This commit is contained in:
parent
531ce61936
commit
4409a3a338
4 changed files with 84 additions and 61 deletions
|
@ -49,7 +49,7 @@ switch($mode)
|
|||
die();
|
||||
}
|
||||
break;
|
||||
case 'update_todo':
|
||||
case 'update_todo': /* Never used yet */
|
||||
{
|
||||
|
||||
$id = $_POST["pk"];
|
||||
|
@ -61,7 +61,7 @@ switch($mode)
|
|||
die();
|
||||
}
|
||||
break;
|
||||
case 'update_pharse':
|
||||
case 'update_pharse': /* Never used yet */
|
||||
{
|
||||
|
||||
$id = $_POST["pk"];
|
||||
|
|
|
@ -307,13 +307,11 @@
|
|||
<div class="widgetBox">
|
||||
<div class="addTodo paddingRightSmall paddingLeftLarge marginBottomLarge">
|
||||
<div class="row">
|
||||
<div class="from-group col-md-10">
|
||||
<input type="text" name="addTodo" class="form-control">
|
||||
</div>
|
||||
<div class="from-group relative">
|
||||
<div class="addTodoButton">
|
||||
<button id="addTodo" class="btn btn-primary btn-sm">Add</button>
|
||||
</div>
|
||||
<div class="from-group relative">
|
||||
<div class="from-group">
|
||||
<input type="text" name="addTodo" class="form-control addTodoText">
|
||||
<button id="addTodo" class="btn btn-primary btn-sm">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -789,53 +787,54 @@ $.ajax({
|
|||
e.preventDefault();
|
||||
var self = this;
|
||||
var newVal = $(this).parents(".addTodo").find("input").val();
|
||||
if(newVal.length){
|
||||
$(this).parents(".addTodo").find("input").val("");
|
||||
var ajaxCall = $.ajax({
|
||||
url: page,
|
||||
type: "post",
|
||||
data: {
|
||||
val: newVal,
|
||||
mode: "add_todo",
|
||||
},
|
||||
});
|
||||
ajaxCall.success(function(data){
|
||||
data = $.parseJSON(data);
|
||||
var li = document.createElement("li");
|
||||
li.className = "col-md-12";
|
||||
var p = document.createElement("p");
|
||||
p.className = "oneTodo paddingLeftSmall col-md-10";
|
||||
p.id = data.id;
|
||||
p.innerHTML = data.todo;
|
||||
var a = document.createElement("a");
|
||||
a.href = "#";
|
||||
a.className = "col-md-2 btn btn-danger btn-xs delete";
|
||||
a.innerHTML = "Delete";
|
||||
$(a).on("click", function(e){
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
var id = $(this).prev().attr("id");
|
||||
var ajaxCall = $.ajax({
|
||||
url: page,
|
||||
type: "post",
|
||||
data: {
|
||||
id: id,
|
||||
mode: "delete_todo",
|
||||
},
|
||||
});
|
||||
ajaxCall.success(function(data){
|
||||
$(self).parents("li").remove();
|
||||
});
|
||||
if(newVal.length)
|
||||
{
|
||||
$(this).parents(".addTodo").find("input").val("");
|
||||
var ajaxCall = $.ajax({
|
||||
url: page,
|
||||
type: "post",
|
||||
data: {
|
||||
val: newVal,
|
||||
mode: "add_todo",
|
||||
},
|
||||
});
|
||||
ajaxCall.success(function(data){
|
||||
data = $.parseJSON(data);
|
||||
var li = document.createElement("li");
|
||||
li.className = "col-md-12";
|
||||
var p = document.createElement("p");
|
||||
p.className = "oneTodo paddingLeftSmall col-md-10";
|
||||
p.id = data.id;
|
||||
p.innerHTML = data.todo;
|
||||
var a = document.createElement("a");
|
||||
a.href = "#";
|
||||
a.className = "col-md-2 btn btn-danger btn-xs delete";
|
||||
a.innerHTML = "Delete";
|
||||
$(a).on("click", function(e){
|
||||
e.preventDefault();
|
||||
var self = this;
|
||||
var id = $(this).prev().attr("id");
|
||||
var ajaxCall = $.ajax({
|
||||
url: page,
|
||||
type: "post",
|
||||
data: {
|
||||
id: id,
|
||||
mode: "delete_todo",
|
||||
},
|
||||
});
|
||||
ajaxCall.success(function(data){
|
||||
$(self).parents("li").remove();
|
||||
});
|
||||
|
||||
});
|
||||
var div = document.createElement("div");
|
||||
div.className = "col-md-12";
|
||||
});
|
||||
var div = document.createElement("div");
|
||||
div.className = "col-md-12";
|
||||
|
||||
$(li).append(div).find("div").append(p).append(a);
|
||||
$(self).parents(".widgetBox").find("ul").prepend(li);
|
||||
});
|
||||
$(li).append(div).find("div").append(p).append(a);
|
||||
$(self).parents(".widgetBox").find("ul").prepend(li);
|
||||
});
|
||||
}else{
|
||||
alert("Please enter a valid value");
|
||||
alert("Please enter a valid value");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -639,4 +639,9 @@ ul.mainTabs{
|
|||
top: 40px;
|
||||
width: 100%;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.addTodoText {
|
||||
width: 80%;
|
||||
display: inline;
|
||||
}
|
|
@ -932,20 +932,39 @@ class myquery {
|
|||
//$db->update(tbl("comments"),array("comment"),array($text)," comment_id = $cid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to update comment vote
|
||||
*/
|
||||
function update_comment_vote($cid,$text)
|
||||
{
|
||||
global $db;
|
||||
$db->Execute("UPDATE ".tbl("comments")." SET vote='$text' WHERE comment_id='$cid'");
|
||||
}
|
||||
/**
|
||||
* Function used to update comment vote
|
||||
*/
|
||||
function update_comment_vote($cid,$text)
|
||||
{
|
||||
global $db;
|
||||
$db->Execute("UPDATE ".tbl("comments")." SET vote='$text' WHERE comment_id='$cid'");
|
||||
}
|
||||
|
||||
function get_todos()
|
||||
{
|
||||
global $db;
|
||||
return $db->select(tbl('admin_todo'),'*'," userid='".userid()."'",NULL," date_added DESC ");
|
||||
}
|
||||
|
||||
function insert_todo($text)
|
||||
{
|
||||
global $db;
|
||||
$db->insert(tbl("admin_todo"),array('todo,date_added,userid'), array(mysql_clean($text),NOW(),userid()));
|
||||
}
|
||||
|
||||
function update_todo($id,$text)
|
||||
{
|
||||
global $db;
|
||||
$db->Execute("UPDATE ".tbl("admin_todo")." SET todo='".mysql_clean($text)."' WHERE comment_id='$id'");
|
||||
}
|
||||
|
||||
function delete_todo($id)
|
||||
{
|
||||
global $db;
|
||||
$db->delete(tbl("admin_todo"),array("todo_id"),array($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to validate comments
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue