all: change most translate statements to new format, some need manual cleanup
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_join.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9         http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <%-
16
17         local sys = require "luci.sys"
18         local utl = require "luci.util"
19
20         function guess_wifi_signal(info)
21                 local scale = (100 / (info.quality_max or 100) * (info.quality or 0))
22                 local icon
23
24                 if not info.bssid or info.bssid == "00:00:00:00:00:00" then
25                         icon = resource .. "/icons/signal-none.png"
26                 elseif scale < 15 then
27                         icon = resource .. "/icons/signal-0.png"
28                 elseif scale < 35 then
29                         icon = resource .. "/icons/signal-0-25.png"
30                 elseif scale < 55 then
31                         icon = resource .. "/icons/signal-25-50.png"
32                 elseif scale < 75 then
33                         icon = resource .. "/icons/signal-50-75.png"
34                 else
35                         icon = resource .. "/icons/signal-75-100.png"
36                 end
37
38                 return icon
39         end
40
41         function percent_wifi_signal(info)
42                 local qc = info.quality or 0
43                 local qm = info.quality_max or 0
44
45                 if info.bssid and qc > 0 and qm > 0 then
46                         return math.floor((100 / qm) * qc)
47                 else
48                         return 0
49                 end
50         end
51
52         function format_wifi_encryption(info)
53                 if info.wep == true and not info.wpa_version then
54                         return "WEP"
55                 elseif info.wpa then
56                         return "<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>" % {
57                                 table.concat(info.pair_ciphers, ", "),
58                                 table.concat(info.group_ciphers, ", "),
59                                 (info.wpa == 3) and "mixed WPA/WPA2"
60                                         or (info.wpa == 2 and "WPA2" or "WPA"),
61                                 table.concat(info.auth_suites, ", ")
62                         }
63                 else
64                         return "<em>None</em>"
65                 end
66         end
67
68         local dev = luci.http.formvalue("device")
69         local iw = luci.sys.wifi.getiwinfo(dev)
70 -%>
71
72 <%+header%>
73
74 <h2><a id="content" name="content"><%:Wireless Scan%></a></h2>
75
76 <div class="cbi-map">
77         <fieldset class="cbi-section">
78                 <table class="cbi-section-table" style="empty-cells:hide">
79                         <!-- scan list -->
80                         <% for i, net in ipairs(iw.scanlist) do %>
81                         <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
82                                 <td class="cbi-value-field" style="width:16px; padding:3px">
83                                         <abbr title="Signal: <%=net.signal%> dB / Quality: <%=net.quality%>/<%=net.quality_max%>">
84                                                 <img src="<%=guess_wifi_signal(net)%>" /><br />
85                                                 <small><%=percent_wifi_signal(net)%>%</small>
86                                         </abbr>
87                                 </td>
88                                 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
89                                         <big><strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>hidden</em>"%></strong></big><br />
90                                         <strong>Channel:</strong> <%=net.channel%> |
91                                         <strong>Mode:</strong> <%=net.mode%> |
92                                         <strong>BSSID:</strong> <%=net.bssid%> |
93                                         <strong>Encryption:</strong> <%=format_wifi_encryption(net)%>
94                                 </td>
95                                 <td class="cbi-value-field" style="width:40px">
96                                         <form action="<%=REQUEST_URI%>" method="post">
97                                                 <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
98                                                 <input type="hidden" name="join" value="<%=utl.pcdata(net.ssid)%>" />
99                                                 <input type="hidden" name="mode" value="<%=net.mode%>" />
100                                                 <input type="hidden" name="bssid" value="<%=net.bssid%>" />
101                                                 <input type="hidden" name="channel" value="<%=net.channel%>" />
102                                                 <input type="hidden" name="wep" value="<%=net.wep and 1 or 0%>" />
103                                                 <% if net.wpa then %>
104                                                 <input type="hidden" name="wpa_version" value="<%=net.wpa%>" />
105                                                 <% for _, v in ipairs(net.auth_suites) do %><input type="hidden" name="wpa_suites" value="<%=v%>" />
106                                                 <% end; for _, v in ipairs(net.group_ciphers) do %><input type="hidden" name="wpa_group" value="<%=v%>" />
107                                                 <% end; for _, v in ipairs(net.pair_ciphers) do %><input type="hidden" name="wpa_pairwise" value="<%=v%>" />
108                                                 <% end; end %>
109
110                                                 <input class="cbi-button-apply" type="submit" value="Join Network" />
111                                         </form>
112                                 </td>
113                         </tr>
114                         <% end %>
115                         <!-- /scan list -->
116                 </table>
117         </fieldset>
118 </div>
119 <div class="cbi-page-actions right">
120         <form class="inline" action="<%=luci.dispatcher.build_url("admin/network/wireless")%>" method="get">
121                 <input class="cbi-button-reset" type="submit" value="<%:Back to overview%>" />
122         </form>
123         <form class="inline" action="<%=REQUEST_URI%>" method="get">
124                 <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
125                 <input class="cbi-input-find" type="submit" value="<%:Repeat scan%>" />
126         </form>
127 </div>
128
129 <%+footer%>