Merge pull request #396 from fanthos/master
[project/luci.git] / applications / luci-app-freifunk-widgets / luasrc / view / freifunk / widgets / search / main.htm
1 <%
2 --[[
3 LuCI - Lua Configuration Interface
4
5 Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 ]]--
14 local utl = require "luci.util"
15 local title = luci.i18n.translate(data.title or "Search")
16 local name = data['.name']
17 local width = data.width or "100%"
18
19 if type(width) == "number" then
20         width = width .. "px"
21 end
22
23 local engines = {}
24 if type(data.engine) == "table" then
25                 engines = data.engine
26 else
27         for k, v in ipairs(string.split(data.engine, " ")) do
28                 table.insert(engines, v)
29         end
30 end
31 %>
32
33 <div id="<%=name%>" style="width:<%=width%>;float:left">
34         <h2><%=title%></h2>
35         <div id="form_<%=name%>">
36                 <form name="searchform" id="search_<%=name%>" action="<%=url('freifunk/search_redirect')%>">
37                         <input type="text" name="searchterms" style="margin-bottom:15px; width: 90%"><br />
38                         <%
39                         local checked = " checked"
40                         for k, v in ipairs(engines) do
41                                 local e = utl.split(v, "|")
42                                 local name = e[1]
43                                 local url = e[2]
44                                 if name and url then
45                         %>
46                         <input name="engine" type="radio" value="<%=url%>"<%=checked%>> <%=name%><br />
47         <%      end
48                 checked = ""
49         end
50 %>
51                         <input type="submit" name="SearchSubmit" value="Search" style="margin-top: 15px">
52                 </form>
53         </div>
54 </div>