Add network selector to send_raw's web page.

This commit is contained in:
Alexey Sokolov committed 2012-07-20 22:36:13 +07:00
1 parent 80acaa7c16
commit 165c9ed082
3 files changed
+29 -6

No files matched your search

+11
View File
@@ -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');
}
+16 -4
View File
@@ -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 ?>
+2 -2
View File
@@ -68,13 +68,13 @@ public:
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;