summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2011-09-07 21:19:03 +0000
committerTed Trask <ttrask01@yahoo.com>2011-09-07 21:19:03 +0000
commit7fe8cea615b518c71817bc06b1bc3880ad319e4b (patch)
tree5f524c15b628f10fee2e13a38a7040900fdefefe
parent13b0dd0cb952d316b27f911f06d0a9c60a60ffd8 (diff)
downloadacf-weblog-7fe8cea615b518c71817bc06b1bc3880ad319e4b.tar.bz2
acf-weblog-7fe8cea615b518c71817bc06b1bc3880ad319e4b.tar.xz
Cleaned up javascript and used ajax for select action
-rw-r--r--template-silent.lsp9
-rw-r--r--weblog-controller.lua4
-rw-r--r--weblog-model.lua26
-rw-r--r--weblog-viewweblog-html.lsp163
4 files changed, 74 insertions, 128 deletions
diff --git a/template-silent.lsp b/template-silent.lsp
deleted file mode 100644
index 45a8ad4..0000000
--- a/template-silent.lsp
+++ /dev/null
@@ -1,9 +0,0 @@
-<% local viewtable, viewlibrary, pageinfo, session = ... %>
-Status: 204 No content
-Content-Type: <% print(viewtable.option or "application/octet-stream") %>
-<% if viewtable.length then %>
-Content-Length: <%= viewtable.length %>
-<% end %>
-<% if viewtable.label ~= "" then %>
-Content-Disposition: attachment; filename="<%= viewtable.label %>"
-<% end %>
diff --git a/weblog-controller.lua b/weblog-controller.lua
index cf7a99b..fcf2a06 100644
--- a/weblog-controller.lua
+++ b/weblog-controller.lua
@@ -95,10 +95,7 @@ function downloadselected(self)
end
function checkselected(self)
- --calls template-silent.lsp which allows us to execute something without refreshing or leaving the page
- self.conf.viewtype = "silent"
return self.model.editselected(self.clientdata.chkdata)
- --return file
end
function clearselected(self)
@@ -106,7 +103,6 @@ function clearselected(self)
end
function viewselected(self)
- --return self.model.getselected(self.clientdata.csvdata, self.clientdata.starttime, self.clientdata.endtime)
return self.model.getweblog(self.clientdata.activelog, self.clientdata.clientuserid, self.clientdata.starttime, self.clientdata.endtime, self.clientdata.clientip, self.clientdata.badyesno, self.clientdata.deniedyesno, self.clientdata.bypassyesno, self.clientdata.score, self.clientdata.urisearch, self.clientdata.sortby, self.clientdata.getselected, clientdata.focus)
end
diff --git a/weblog-model.lua b/weblog-model.lua
index 6f440d3..87c070d 100644
--- a/weblog-model.lua
+++ b/weblog-model.lua
@@ -1193,32 +1193,6 @@ local handleparameters = function(activelog, clientuserid, starttime, endtime, c
return result
end
-function getselected(csvdata)
- local result = {}
- result.id = cfe({ value=csvdata or "", label="Record ID", descr="Id of Record"})
- result.log = cfe({ type="list", value={}, label="Weblog Access Log" })
- local res, err = pcall(function()
- databaseconnect(DatabaseUser)
- local entries = {}
- -- retrieve a cursor
- local sql = "SELECT * FROM pubweblog where selected = true and logdatetime >= '" .. starttime .. "' and logdatetime <= '" .. endtime .. "'"
- local idcnt = 0
- sql = sql .. " ORDER BY logdatetime;"
- cur = assert (con:execute(sql))
- row = cur:fetch ({}, "a")
- while row do
- entries[#entries+1] = {sourcename=row.sourcename, clientip=row.clientip, clientuserid=row.clientuserid, logdatetime=row.logdatetime, uri=row.uri, shorturi=shorturi, bytes=row.bytes, reason=row.reason, core=row.score, shortreason=row.shortreason, badyesno=row.badyesno, deniedyesno=row.deniedyesno, bypassyesno=row.bypassyesno, wordloc=row.wordloc, selected=row.selected }
- row = cur:fetch (row, "a")
- end
- -- close everything
- cur:close()
- result.log.value = entries or {}
- --result.log.value = sql
- databasedisconnect()
- end)
- return cfe({ type="group", value=result, errtxt=err, label="Weblog Selected" })
-end
-
function editselected(chkdata)
keycnt = 0
sql = "UPDATE pubweblog SET selected = "
diff --git a/weblog-viewweblog-html.lsp b/weblog-viewweblog-html.lsp
index 758d3bc..7e85480 100644
--- a/weblog-viewweblog-html.lsp
+++ b/weblog-viewweblog-html.lsp
@@ -26,8 +26,18 @@ function string_highlight(txtvalue, searchval, fcolour, bcolour)
end
%>
-<% if data.value.focus.value ~= "" then %>
<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"></script>
+<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"></script>
+<script type="text/javascript">
+ $(document).ready(function() {
+ $("#loglist").tablesorter({headers: {0:{sorter: false},1:{sorter: false}, 2:{sorter: 'text'}, 6:{sorter: false}, 7:{sorter: false}, 8:{sorter: false}}});
+ });
+ function hideColumn(myCol) {
+ myCol.style.display = "none";
+ };
+</script>
+
+<% if data.value.focus.value ~= "" then %>
<script type="text/javascript">
$(function(){
if ($("#focus").length) {
@@ -38,17 +48,6 @@ end
</script>
<% end %>
-<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.min.js"></script>
-<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix)%>/js/jquery.tablesorter.js"></script>
-<script type="text/javascript">
- $(document).ready(function() {
- $("#loglist").tablesorter({headers: {0:{sorter: false},1:{sorter: false}, 2:{sorter: 'text'}, 6:{sorter: false}, 7:{sorter: false}, 8:{sorter: false}}});
- });
- function hideColumn(myCol) {
- myCol.style.display = "none";
- };
-</script>
-
<% local subdata, pagedata = paginate(data.value.log.value, page_info.clientdata, 200) %>
<style type="text/css">
@@ -174,8 +173,6 @@ end
</TR>
</THEAD>
<TBODY>
-<FORM action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/checkselected") %>" name="markselected" onsubmit="return false" method="POST">
-<input type="hidden" id="chkdata" name="chkdata" value="chkdata"></FORM>
<% for i,watch in ipairs(subdata) do
local a,b = math.modf((i/2))
local mark = ''
@@ -246,80 +243,68 @@ end
<% end %>
<script type="text/javascript">
- $('#chkHead').click(function () {
- if (this.checked == false) {
- $('.chktbl:checked').attr('checked', false);
- }
- else {
- $('.chktbl:not(:checked)').attr('checked', true);
- }
- if ($(this).attr("checked")==true)
- {
- $("#loglist").find('tr:not(#chktbl)').css("background-color","#FC9A01");
- }
- else
- {
- $("#loglist").find('tr:not(#chktbl)').css("background-color","#FFF");
- }
- });
- $('#chkHead').click(function(){
- });
-
- $('.chktbl').click(function () {
- if($("chkHead").attr('checked') == true && this.checked == false)
- {
- var csv_data = "";
- var csv_cnt = 0;
- $(".chktbl").attr('checked',false);
- $(this).closest('tr').css("background-color","#ffffff");
- $(this).closest('tr').each(function () {
- $(this).find('td').each(function () {
- if(csv_cnt == 1)
- { document.viewweblog.chktbl.value = "false|" + $(this).text();
- return false;
- }
- csv_cnt +=1;
- });
- });
- }
- if(this.checked == true)
- {
- $(this).closest('tr').css("background-color","#FC9A01");
- var csv_list = "";
- var csv_cnt = 0;
- $(this).closest('tr').each(function () {
- $(this).find('td').each(function () {
- if(csv_cnt == 1)
- { document.markselected.chkdata.value = "true|" + $(this).text();
- //alert("this is: " + document.markselected.chkdata.value );
- return false;
- }
- csv_cnt +=1;
- });
- });
- document.forms["markselected"].submit();
- //document.getElementById("subbutton").click();
-
- }
- if(this.checked == false)
- {
- $(this).closest('tr').css("background-color","#ffffff");
- var csv_list = "";
- var csv_cnt = 0;
- $(this).closest('tr').each(function () {
- $(this).find('td').each(function () {
- if(csv_cnt == 1)
- { document.markselected.chkdata.value = "false|" + $(this).text();
- return false;
- }
- csv_cnt +=1;
- });
- });
- document.forms["markselected"].submit();
- }
- });
-
-</script>
-
+ $('#chkHead').click(function () {
+ if (this.checked == false) {
+ $('.chktbl:checked').attr('checked', false);
+ } else {
+ $('.chktbl:not(:checked)').attr('checked', true);
+ }
+ if ($(this).attr("checked")==true) {
+ $("#loglist").find('tr:not(#chktbl)').css("background-color","#FC9A01");
+ } else {
+ $("#loglist").find('tr:not(#chktbl)').css("background-color","#FFF");
+ }
+ });
+ $('.chktbl').click(function () {
+ if ($("chkHead").attr('checked') == true && this.checked == false) {
+ var csv_data = "";
+ var csv_cnt = 0;
+ $(".chktbl").attr('checked',false);
+ $(this).closest('tr').css("background-color","#ffffff");
+ $(this).closest('tr').each(function () {
+ $(this).find('td').each(function () {
+ if (csv_cnt == 1) {
+ document.viewweblog.chktbl.value = "false|" + $(this).text();
+ return false;
+ }
+ csv_cnt +=1;
+ });
+ });
+ }
+ var chkdata = "";
+ if (this.checked == true) {
+ $(this).closest('tr').css("background-color","#FC9A01");
+ var csv_list = "";
+ var csv_cnt = 0;
+ $(this).closest('tr').each(function () {
+ $(this).find('td').each(function () {
+ if (csv_cnt == 1) {
+ chkdata = "true|" + $(this).text();
+ //alert("this is: " + chkdata);
+ return false;
+ }
+ csv_cnt +=1;
+ });
+ });
+ } else {
+ $(this).closest('tr').css("background-color","#ffffff");
+ var csv_list = "";
+ var csv_cnt = 0;
+ $(this).closest('tr').each(function () {
+ $(this).find('td').each(function () {
+ if (csv_cnt == 1) {
+ chkdata = "false|" + $(this).text();
+ return false;
+ }
+ csv_cnt +=1;
+ });
+ });
+ }
+ $.getJSON(
+ '<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/checkselected") %>?viewtype=ajax&chkdata='+chkdata,
+ function(data) {}
+ );
+ });
+</script>
</DL>