diff options
author | Adam <adam@sigterm.info> | 2013-02-20 14:58:59 -0800 |
---|---|---|
committer | Adam <adam@sigterm.info> | 2013-02-20 14:58:59 -0800 |
commit | 59792173e7da0efb675123d96d155cfa934d6c0d (patch) | |
tree | 87567ddd0ae87ca019c7074f97b68d2d662505ae | |
parent | ed68482b4e76677b69381b44f99dc380905d7c9e (diff) | |
parent | 29fcdc5f404c58209ae42a2e016e70b61685df9f (diff) |
Merge pull request #12 from MatthewM/webcpanel
Web Panel Modifications
-rw-r--r-- | modules/extra/webcpanel/pages/hostserv/request.cpp | 2 | ||||
-rw-r--r-- | modules/extra/webcpanel/pages/memoserv/memos.cpp | 4 | ||||
-rw-r--r-- | modules/extra/webcpanel/templates/default/chanserv/main.html | 2 | ||||
-rw-r--r-- | modules/extra/webcpanel/templates/default/header.html | 89 | ||||
-rw-r--r-- | modules/extra/webcpanel/templates/default/memoserv/memos.html | 53 | ||||
-rw-r--r-- | modules/extra/webcpanel/templates/default/style.css | 90 | ||||
-rw-r--r-- | modules/extra/webcpanel/webcpanel.cpp | 11 | ||||
-rw-r--r-- | modules/extra/webcpanel/webcpanel.h | 5 |
8 files changed, 226 insertions, 30 deletions
diff --git a/modules/extra/webcpanel/pages/hostserv/request.cpp b/modules/extra/webcpanel/pages/hostserv/request.cpp index 2a44df221..6335b1a56 100644 --- a/modules/extra/webcpanel/pages/hostserv/request.cpp +++ b/modules/extra/webcpanel/pages/hostserv/request.cpp @@ -18,7 +18,7 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope:: std::vector<Anope::string> params; params.push_back(HTTPUtils::URLDecode(message.post_data["req"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements, "CMDR"); } if (na->HasVhost()) diff --git a/modules/extra/webcpanel/pages/memoserv/memos.cpp b/modules/extra/webcpanel/pages/memoserv/memos.cpp index 9fa36d3c4..db4fcfc1b 100644 --- a/modules/extra/webcpanel/pages/memoserv/memos.cpp +++ b/modules/extra/webcpanel/pages/memoserv/memos.cpp @@ -57,7 +57,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"])); params.push_back(HTTPUtils::URLDecode(message.post_data["message"])); - WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/send", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/send", params, replacements, "CMDR"); } if (message.get_data.count("del") > 0 && message.get_data.count("number") > 0) { @@ -66,7 +66,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st params.push_back(chname); params.push_back(message.get_data["number"]); - WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/del", params, replacements); + WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/del", params, replacements, "CMDR"); } if (message.get_data.count("read") > 0 && message.get_data.count("number") > 0) { diff --git a/modules/extra/webcpanel/templates/default/chanserv/main.html b/modules/extra/webcpanel/templates/default/chanserv/main.html index 99fec7d75..dd9288f00 100644 --- a/modules/extra/webcpanel/templates/default/chanserv/main.html +++ b/modules/extra/webcpanel/templates/default/chanserv/main.html @@ -1,6 +1,8 @@ {INCLUDE header.html} <b>Channels you have access in:</b><br/> + <div class="cinfo"> {FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES} <a href="/chanserv/set?channel={ECH}">{CH}</a></br> {END FOR} + </div> {INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/header.html b/modules/extra/webcpanel/templates/default/header.html index 38f367acc..3cb1cf372 100644 --- a/modules/extra/webcpanel/templates/default/header.html +++ b/modules/extra/webcpanel/templates/default/header.html @@ -2,9 +2,98 @@ <html> <head> <link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" /> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <title>{TITLE}</title> + {IF EXISTS CMDR} + <script type="text/javascript"> + var tSec=5; //Time in seconds to keep the overlay open + var t=(tSec*1000); //Convert the time to ms so we can use it + + $(document).ready(function() \{ + + /*Modal*/ + var id = "#dialog"; + + var mHeight; + var mWidth; + var oHeight = $(id).height(); + var oWidth = $(id).height(); + + var top; + var left; + + showModal(); + + $('.close').click(function (e) \{ + e.preventDefault(); + hideModal(); + \}); + + $('#mask').click(function () \{ + hideModal(); + \}); + + function hideModal() \{ + if ($('#mask').not(':hidden')) \{ + $('.master').fadeTo('slow',1.0); + $('#mask, .window').fadeOut(200); + \} + \} + + function showModal() \{ + mHeight = $(document).height(); + mWidth = $(window).width(); + + var alertMsg = '<br/>{CMDR}<br/>'; + + $('#mask').css(\{'width': mWidth, 'height': mHeight\}); + $('#mask').fadeIn(200); + $('#mask').fadeTo('fast',0.75); + + $('#dialogMsg').html(alertMsg); + + top = mHeight/2-oHeight/2; + left = mWidth/2-oHeight/2; + + $(id).css('top', top); + $(id).css('left', left); + $('.master').fadeTo('fast',0.3); + + $(id).fadeIn(500); + setTimeout(hideModal, t); + + \} + + $(window).resize(function() \{ + if ($('#mask').not(':hidden')) \{ + mHeight = $(document).height(); + mWidth = $(window).width(); + + /* Might as well only change the postion of box if the window is large enough */ + if ((mHeight > oHeight) && (mWidth > oWidth)) \{ + top = mHeight/2-oHeight/2; + left = mWidth/2-oHeight/2; + $('#mask').css(\{'width': mWidth, 'height': mHeight\}); + $(id).css('top', top); + $(id).css('left', left); + \} + + \} + \}) + + \}); + </script> + {END IF} </head> <body> + <div id="boxes"> + <div id="dialog" class="window"> + <h2>Status Message:</h2> + <div id="dialogMsg"></div> + <div id="dialogClose"><a href="#" class="close">Dismiss</a></div> + </div> + <div id="mask"></div> + </div> <div class="master"> <div class="header"> <ul id="button"> diff --git a/modules/extra/webcpanel/templates/default/memoserv/memos.html b/modules/extra/webcpanel/templates/default/memoserv/memos.html index 559efd35b..4239a926f 100644 --- a/modules/extra/webcpanel/templates/default/memoserv/memos.html +++ b/modules/extra/webcpanel/templates/default/memoserv/memos.html @@ -1,7 +1,7 @@ {INCLUDE header.html} <b>Channels you have access in:</b><br/> {FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES} - <a href="/memoserv/memos?channel={ECH}">{CH}</a> + <a href="/memoserv/memos?channel={ECH}" class="channel">{CH}</a> {END FOR} <br/><br/> {FOR M IN MESSAGES} @@ -9,29 +9,48 @@ {END FOR} <br/> {IF EXISTS NUMBER} + <script type="text/javascript"> + $("#memoTable").ready(function() \{ + $(".reply").click(function(e) \{ + e.preventDefault(); + var recv = $(this).attr('href'); + $("#receiver").val(recv); + \}); + \}); + </script> <b>Memos List:</b> - <table width="100%" height="100%"> + <table width="100%" height="100%" id="memoTable"> <tr> - <th>Number</th> - <th>Sender</th> - <th>Time/Message</th> + <th class="akillR1">Number</th> + <th class="akillR3">Sender</th> + <th class="akillR2">Time/Message</th> </tr> {FOR I,S,T,TXT,U IN NUMBER,SENDER,TIME,TEXT,UNREAD} - <tr> - <td>{I}</td> - <td>{S}</td> - <td>{T}</td> {IF EQ U YES} - <td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=1">Mark as Read</a></td> + <tr class="read"> {ELSE} - <td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=2">Mark as Unread</a></td> + <tr class="unread"> {END IF} - <td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td> - + <td class="akillR1">{I}</td> + <td class="akillR3">{S}</td> + <td class="akillR2"><abbr title="{T}">{TXT}</abbr></td> </tr> - <tr> - <td></td><td></td> - <td>{TXT}</td> + {IF EQ U YES} + <tr class="read"> + <td></td> + <td></td> + <td class="right"><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=1">Mark as Read</a> + <a href="{S}" class="reply" id="memo{I}">Reply</a> + <a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td> + {ELSE} + <tr class="unread"> + <td></td> + <td></td> + <td class="right"><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=2">Mark as Unread</a> + <a href="{S}" class="reply" id="memo{I}">Reply</a> + <a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td> + {END IF} + </tr> {END FOR} </table> @@ -43,7 +62,7 @@ <b>Send a new Memo</b> <form method="post" action="/memoserv/memos?channel={ESCAPED_CHANNEL}"> - Receiver: <input type="text" name="receiver"> + Receiver: <input type="text" name="receiver" id="receiver" value=""> Message: <input type="text" name="message"> <input type="submit" value="Send"> </form> diff --git a/modules/extra/webcpanel/templates/default/style.css b/modules/extra/webcpanel/templates/default/style.css index 7934e4850..13b4e4759 100644 --- a/modules/extra/webcpanel/templates/default/style.css +++ b/modules/extra/webcpanel/templates/default/style.css @@ -3,6 +3,7 @@ font-family: 'Cabin', Helvetica, Arial, sans-serif; }
body {
overflow:hidden;
+ z-index: 10;
}
.master {
margin-left:0px;
@@ -101,6 +102,15 @@ body { height: 125px;
}
+.cinfo {
+ overflow-x: scroll;
+ height: 450px;
+}
+
+.right {
+ text-align: right;
+}
+/* Table Stuff */
.akillR1 {
width: 80px;
text-align: left;
@@ -114,7 +124,81 @@ body { text-align: left;
}
-.danger {
- color: red;
- weight: bolder;
+td.right a:link, td.right a:visited {
+ color: #000;
+ background-color: #FFF;
+ border: 1px solid #000;
+ padding: 0px 4px;
+ -webkit-border-radius: 5x;
+ border-radius: 5px;
+ text-decoration: none;
+}
+
+td.right a:hover {
+ color: #00F;
+}
+
+table#memoTable {
+ border-spacing: 0px;
+ border-collapse: collapse;
+}
+
+table#memoTable tr {
+ padding: 1px;
+}
+
+tr.read {
+ background-color: #FFF;
+}
+
+tr.unread {
+ background-color: #EEE;
+}
+
+tr.read td, tr.unread td {
+ padding: 2px;
+}
+
+/* Modal Window */
+#mask {
+ position: absolute;
+ z-index: 9000;
+ background-color: #000;
+ height: 100%;
+ width: 100%;
+ display: none;
+}
+
+#boxes .window {
+ position:fixed;
+ width:440px;
+ height:200px;
+ display:none;
+ z-index:9999;
+ padding:20px;
+}
+
+#boxes #dialog {
+ text-align: center;
+ background-color: #FFF;
+ width:375px;
+ height:203px;
+ padding: 20px;
+ -webkit-border-radius: 15px;
+ border-radius: 15px;
+ display: none;
+}
+
+#dialogClose {
+ padding-top: 20px;
+}
+
+#dialogClose a:link, #dialogClose a:visited {
+ color: #000;
+ text-decoration: none;
+}
+
+#dialogClose a:hover {
+ color: #000;
+ text-decoration: underline;
}
diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index 9855e6771..77e99dd4e 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -217,12 +217,12 @@ class ModuleWebCPanel : public Module namespace WebPanel { - void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r) + void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) { ServiceReference<Command> cmd("Command", c); if (!cmd) { - r["MESSAGES"] = "Unable to find command " + c; + r[key] = "Unable to find command " + c; return; } @@ -237,15 +237,16 @@ namespace WebPanel struct MyComandReply : CommandReply { TemplateFileServer::Replacements &re; + const Anope::string &k; - MyComandReply(TemplateFileServer::Replacements &_r) : re(_r) { } + MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { } void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override { - re["MESSAGES"] = msg; + re[k] = msg; } } - my_reply(r); + my_reply(r, key); CommandSource source(user, NULL, nc, &my_reply, bi); cmd->Execute(source, params); diff --git a/modules/extra/webcpanel/webcpanel.h b/modules/extra/webcpanel/webcpanel.h index d7c8b99db..74a8805d4 100644 --- a/modules/extra/webcpanel/webcpanel.h +++ b/modules/extra/webcpanel/webcpanel.h @@ -145,9 +145,10 @@ namespace WebPanel * @param service Service for source.owner and source.service * @param c Command to run (as a service name) * @param params Command parameters - * @param r Replacements, reply from command goes back into r["MESSAGES"] + * @param r Replacements, reply from command goes back here into key + * @param key The key to put the replies into r */ - extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r); + extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); } #include "pages/index.h" |