Skip to content
Browse files

Add network selector to send_raw's web page.

  • Loading branch information...
1 parent 80acaa7 commit 165c9ed082715ecc155918de90154001ed35ecea @DarthGandalf DarthGandalf committed Jul 20, 2012
Showing with 29 additions and 6 deletions.
  1. +11 −0 modules/data/send_raw/files/select.js
  2. +16 −4 modules/data/send_raw/tmpl/index.tmpl
  3. +2 −2 modules/send_raw.cpp
View
11 modules/data/send_raw/files/select.js
@@ -0,0 +1,11 @@
+function updateUser() {
+ var select = document.getElementById('selectnetwork');
+ var opt = select.options[select.selectedIndex];
+ document.getElementById('user').value = opt.parentNode.getAttribute('label');
+}
+
+function init() {
+ updateUser();
+ document.getElementById('networklabel').firstChild.nodeValue = 'Network:';
+ document.getElementById('userblock').removeAttribute('style');
+}
View
20 modules/data/send_raw/tmpl/index.tmpl
@@ -1,3 +1,4 @@
+<? ADDROW JSLoop HREF=/modfiles/user/send_raw/select.js ?>
<? INC Header.tmpl ?>
<form method="post" action="<? VAR ModPath ?>">
@@ -8,11 +9,20 @@
<div class="sectionbg">
<div class="sectionbody">
- <div class="subsection third">
+ <div class="subsection third" id="userblock" style="display:none">
<div class="inputlabel">User:</div>
- <select name="user">
- <? LOOP UserLoop?>
- <option value="<? VAR Username ESC=HTML ?>"><? VAR Username ESC=HTML ?></option>
+ <input id="user" type="text" disabled="disabled" title="To change user, click to Network selector"/>
+ </div>
+
+ <div class="subsection third">
+ <div class="inputlabel" id="networklabel">User/Network:</div>
+ <select name="network" id="selectnetwork" onchange="javascript:updateUser()">
+ <? LOOP UserLoop ?>
+ <optgroup label="<? VAR Username ?>">
+ <? LOOP NetworkLoop ?>
+ <option value="<? VAR Username ?>/<? VAR Network ?>"><? VAR Network ?></option>
+ <? ENDLOOP ?>
+ </optgroup>
<? ENDLOOP ?>
</select>
</div>
@@ -38,4 +48,6 @@
</div>
</form>
+<script type="text/javascript">init();</script>
+
<? INC Footer.tmpl ?>
View
4 modules/send_raw.cpp
@@ -68,13 +68,13 @@ class CSendRaw_Mod: public CModule {
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
if (sPageName == "index") {
if (WebSock.IsPost()) {
- CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("user").Token(0, false, "/"));
+ CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("network").Token(0, false, "/"));
if (!pUser) {
WebSock.GetSession()->AddError("User not found");
return true;
}
- CIRCNetwork *pNetwork = pUser->FindNetwork(WebSock.GetParam("user").Token(1, false, "/"));
+ CIRCNetwork *pNetwork = pUser->FindNetwork(WebSock.GetParam("network").Token(1, false, "/"));
if (!pNetwork) {
WebSock.GetSession()->AddError("Network not found");
return true;

0 comments on commit 165c9ed

Please sign in to comment.
Something went wrong with that request. Please try again.