Added CSS. Code refactoring.
This commit is contained in:
parent
006e24915e
commit
44909ac087
112
www/css/layout.css
Normal file
112
www/css/layout.css
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
*{
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font:14px/1.3 Arial,sans-serif;
|
||||||
|
background-color:#212121;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
background-color:#212121;
|
||||||
|
box-shadow: 0 -1px 2px #111111;
|
||||||
|
color:#fff;
|
||||||
|
display:block;
|
||||||
|
height:50px;
|
||||||
|
position:relative;
|
||||||
|
width:100%;
|
||||||
|
z-index:100;
|
||||||
|
}
|
||||||
|
h2{
|
||||||
|
font-size:22px;
|
||||||
|
font-weight:normal;
|
||||||
|
/*left:50%;*/
|
||||||
|
margin-left:20px;
|
||||||
|
padding:10px 0;
|
||||||
|
position:absolute;
|
||||||
|
/*width:540px;*/
|
||||||
|
color:#fff;
|
||||||
|
}
|
||||||
|
h3{
|
||||||
|
font-size:18px;
|
||||||
|
font-weight:normal;
|
||||||
|
left:50%;
|
||||||
|
/*margin-left:-400px;*/
|
||||||
|
padding:10px 0;
|
||||||
|
/*position:absolute;*/
|
||||||
|
width:540px;
|
||||||
|
color:#fff;
|
||||||
|
}
|
||||||
|
h4{
|
||||||
|
font-size:16px;
|
||||||
|
font-weight:normal;
|
||||||
|
/*margin-left:20px;*/
|
||||||
|
padding:10px 0;
|
||||||
|
color:#fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
header a.stuts,a.stuts:visited{
|
||||||
|
border:none;
|
||||||
|
text-decoration:none;
|
||||||
|
color:#fcfcfc;
|
||||||
|
font-size:14px;
|
||||||
|
left:50%;
|
||||||
|
line-height:31px;
|
||||||
|
margin:23px 0 0 110px;
|
||||||
|
position:absolute;
|
||||||
|
top:0;
|
||||||
|
}
|
||||||
|
header .stuts span {
|
||||||
|
font-size:22px;
|
||||||
|
font-weight:bold;
|
||||||
|
margin-left:5px;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
height: 40px;
|
||||||
|
margin: 30px auto;
|
||||||
|
/*width: 957px;*/
|
||||||
|
}
|
||||||
|
.table_dark {
|
||||||
|
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
|
||||||
|
font-size: 12px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
.table_dark th {
|
||||||
|
color: #CAD4D6;
|
||||||
|
border-top: 1px solid #CAD4D6;
|
||||||
|
border-bottom: 1px solid #CAD4D6;
|
||||||
|
padding: 12px 17px;
|
||||||
|
background: #212121;
|
||||||
|
}
|
||||||
|
.table_dark td {
|
||||||
|
color: #CAD4D6;
|
||||||
|
border-bottom: 1px solid #CAD4D6;
|
||||||
|
border-right:1px solid #CAD4D6;
|
||||||
|
padding: 7px 17px;
|
||||||
|
}
|
||||||
|
.table_dark tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.table_dark td:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
A:link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #CAD4D6;
|
||||||
|
}
|
||||||
|
A:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #CAD4D6;
|
||||||
|
}
|
||||||
|
A:active {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #CAD4D6;
|
||||||
|
}
|
||||||
|
A:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #00B4FF;
|
||||||
|
}
|
||||||
|
|
129
www/css/menu.css
Normal file
129
www/css/menu.css
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
#nav,#nav ul {
|
||||||
|
list-style: none outside none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
#nav {
|
||||||
|
background: url('menu_bg.png') no-repeat scroll 0 0 transparent;
|
||||||
|
clear: both;
|
||||||
|
font-size: 12px;
|
||||||
|
height: 58px;
|
||||||
|
padding: 0 0 0 9px;
|
||||||
|
position: relative;
|
||||||
|
width: 957px;
|
||||||
|
}
|
||||||
|
#nav ul {
|
||||||
|
background-color: #222;
|
||||||
|
border:1px solid #222;
|
||||||
|
border-radius: 0 5px 5px 5px;
|
||||||
|
border-width: 0 1px 1px;
|
||||||
|
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.5);
|
||||||
|
left: -9999px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
top: -9999px;
|
||||||
|
z-index: 2;
|
||||||
|
-moz-transform: scaleY(0);
|
||||||
|
-ms-transform: scaleY(0);
|
||||||
|
-o-transform: scaleY(0);
|
||||||
|
-webkit-transform: scaleY(0);
|
||||||
|
transform: scaleY(0);
|
||||||
|
-moz-transform-origin: 0 0;
|
||||||
|
-ms-transform-origin: 0 0;
|
||||||
|
-o-transform-origin: 0 0;
|
||||||
|
-webkit-transform-origin: 0 0;
|
||||||
|
transform-origin: 0 0;
|
||||||
|
-moz-transition: -moz-transform 0.1s linear;
|
||||||
|
-ms-transition: -ms-transform 0.1s linear;
|
||||||
|
-o-transition: -o-transform 0.1s linear;
|
||||||
|
-webkit-transition: -webkit-transform 0.1s linear;
|
||||||
|
transition: transform 0.1s linear;
|
||||||
|
}
|
||||||
|
#nav li {
|
||||||
|
background: url('menu_line.png') no-repeat scroll right 5px transparent;
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
#nav li a {
|
||||||
|
color: #FFFFFF;
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
font-weight: normal;
|
||||||
|
height: 30px;
|
||||||
|
padding: 23px 20px 0;
|
||||||
|
position: relative;
|
||||||
|
text-decoration: none;
|
||||||
|
text-shadow: 1px 1px 1px #000000;
|
||||||
|
}
|
||||||
|
#nav li:hover > a {
|
||||||
|
color: #00B4FF;
|
||||||
|
}
|
||||||
|
#nav li:hover, #nav a:focus, #nav a:hover, #nav a:active {
|
||||||
|
background: none repeat scroll 0 0 #121212;
|
||||||
|
outline: 0 none;
|
||||||
|
}
|
||||||
|
#nav li:hover ul.subs {
|
||||||
|
left: 0;
|
||||||
|
top: 53px;
|
||||||
|
width: 180px;
|
||||||
|
-moz-transform: scaleY(1);
|
||||||
|
-ms-transform: scaleY(1);
|
||||||
|
-o-transform: scaleY(1);
|
||||||
|
-webkit-transform: scaleY(1);
|
||||||
|
transform: scaleY(1);
|
||||||
|
}
|
||||||
|
#nav ul li {
|
||||||
|
background: none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
#nav ul li a {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
#nav ul li:hover > a {
|
||||||
|
background-color: #121212;
|
||||||
|
color: #00B4FF;
|
||||||
|
}
|
||||||
|
#lavalamp {
|
||||||
|
background: url('lavalamp.png') no-repeat scroll 0 0 transparent;
|
||||||
|
height: 16px;
|
||||||
|
left: 13px;
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
width: 64px;
|
||||||
|
-moz-transition: all 300ms ease;
|
||||||
|
-ms-transition: all 300ms ease;
|
||||||
|
-o-transition: all 300ms ease;
|
||||||
|
-webkit-transition: all 300ms ease;
|
||||||
|
transition: all 300ms ease;
|
||||||
|
}
|
||||||
|
#lavalamp:hover {
|
||||||
|
-moz-transition-duration: 3000s;
|
||||||
|
-ms-transition-duration: 3000s;
|
||||||
|
-o-transition-duration: 3000s;
|
||||||
|
-webkit-transition-duration: 3000s;
|
||||||
|
transition-duration: 3000s;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(1):hover ~ #lavalamp {
|
||||||
|
left: 13px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(2):hover ~ #lavalamp {
|
||||||
|
left: 90px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(3):hover ~ #lavalamp {
|
||||||
|
left: 170px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(4):hover ~ #lavalamp {
|
||||||
|
left: 250px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(5):hover ~ #lavalamp {
|
||||||
|
left: 330px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(6):hover ~ #lavalamp {
|
||||||
|
left: 410px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(7):hover ~ #lavalamp {
|
||||||
|
left: 490px;
|
||||||
|
}
|
||||||
|
#nav li:nth-of-type(8):hover ~ #lavalamp {
|
||||||
|
left: 565px;
|
||||||
|
}
|
141
www/index.py
141
www/index.py
|
@ -1,66 +1,93 @@
|
||||||
#!/usr/bin/python3
|
import os, sys, \
|
||||||
# -*- coding: utf-8 -*-
|
pymysql, urlparse3
|
||||||
# Turn on debug mode.
|
|
||||||
import sys
|
|
||||||
import cgi
|
|
||||||
import cgitb
|
|
||||||
cgitb.enable()
|
|
||||||
# Print necessary headers.
|
|
||||||
print("Content-Type: text/html; charset=UTF-8\n\n")
|
|
||||||
# Connect to the database.
|
|
||||||
import pymysql
|
|
||||||
conn = pymysql.connect(
|
|
||||||
db='ats',
|
|
||||||
user='user',
|
|
||||||
passwd='password',
|
|
||||||
host='localhost',
|
|
||||||
charset='utf8')
|
|
||||||
|
|
||||||
c = conn.cursor()
|
def application(environ, start_response):
|
||||||
# Insert some example data.
|
#sys.stdout._encoding = 'utf-8'
|
||||||
#c.execute("INSERT INTO numbers VALUES (1, 'One!')")
|
status = '200 OK'
|
||||||
#c.execute("INSERT INTO numbers VALUES (2, 'Two!')")
|
# проверяем наличие параметров в запросе и всяко-разно реагируем
|
||||||
#c.execute("INSERT INTO numbers VALUES (3, 'Three!')")
|
if environ['QUERY_STRING'] == '':
|
||||||
#conn.commit()
|
output = bytes((header() + body() + footer()).encode('utf8'))
|
||||||
# Print the contents of the database.
|
elif environ['QUERY_STRING'].split('&'):
|
||||||
#c.execute("SELECT * FROM int_number")
|
paramDict = {item.split('=')[0]: item.split('=')[1] for item in environ['QUERY_STRING'].split('&')}
|
||||||
print("<html><head><meta charset=\"utf-8\"><link rel=\"shortcut icon\" href=\"favicon.png\" ></link><link rel=\"icon\" type=\"image/png\" href=\"favicon.png\" ></link>")
|
if paramDict.get('query_type') == 'internal':
|
||||||
print("<title>Телефоны</title></head><body>")
|
output = bytes((header() + body() + getInternalNumbers() + footer()).encode('utf8'))
|
||||||
print("<table width=100%><tr valign=center><td><img src=img/logo-1.png></td><td width=100%><h2 align=center>ТЕЛЕФОНЫ</h2></td></table>")
|
elif paramDict.get('query_type') == 'external':
|
||||||
print("<p><hr>[Справочник] [<a href=report.py>Отчёты</a>]<br><hr></p><p>")
|
output = bytes((header() + body() + getCOline() + footer()).encode('utf8'))
|
||||||
print("<h3>Телефонный справочник</h3>")
|
else:
|
||||||
print("<table><tr valign=top><td bgcolor=#e3e3e3><a href=index.py?qwery_type=internal>Внутренние</a><br><a href=index.py?qwery_type=external>Городские</a></td><td>")
|
output = bytes((header() + body() + footer()).encode('utf8'))
|
||||||
|
|
||||||
param = cgi.FieldStorage()
|
|
||||||
#Передали заголовки ранее
|
|
||||||
param = cgi.FieldStorage() #Здесь пустых значений нет!
|
|
||||||
if "qwery_type" not in param:
|
|
||||||
qwery_type="internal"
|
|
||||||
else:
|
|
||||||
qwery_type = param["qwery_type"].value
|
|
||||||
|
|
||||||
if "order" not in param:
|
response_headers = [('Content-type', 'text/html;charset=utf-8'),
|
||||||
order="fio"
|
('Content-Length', str(len(output)))]
|
||||||
else:
|
start_response(status, response_headers)
|
||||||
order = param["order"].value
|
|
||||||
|
|
||||||
if qwery_type == "internal":
|
return [output]
|
||||||
print("<h4 align=center>Список внутренних телефонов</h4>")
|
|
||||||
|
def header():
|
||||||
|
txtHeader = '<html><head><meta charset="utf-8"><link rel="shortcut icon" href="favicon.png" >\n' \
|
||||||
|
'<link rel="icon" type="image/png" href="favicon.png" >\n' \
|
||||||
|
'<link href="css/layout.css" rel="stylesheet" type="text/css" />\n' \
|
||||||
|
'<title>Телефоны</title>\n' \
|
||||||
|
'<link href="css/menu.css" rel="stylesheet" type="text/css" /></head><body>\n'
|
||||||
|
return txtHeader
|
||||||
|
|
||||||
|
def footer():
|
||||||
|
txtFooter = '</td></tr></table></body></html>\n'
|
||||||
|
return txtFooter
|
||||||
|
|
||||||
|
def body():
|
||||||
|
txtBody = '<table><tr><td><h2 align=left>ТЕЛЕФОНЫ</h2></td></tr>\n' \
|
||||||
|
'<tr><td>{}</td></tr><tr><td>\n'.format(menu())
|
||||||
|
return txtBody
|
||||||
|
def menu():
|
||||||
|
#<div class="container">
|
||||||
|
txtMenu = '<div class="container"><ul id="nav"></li>\n' \
|
||||||
|
'<li><a class="hsubs" href="#">Справочник</a><ul class="subs">\n' \
|
||||||
|
'<li><a href="?query_type=external">Городские телефоны</a></li>\n' \
|
||||||
|
'<li><a href="?query_type=internal">Внутренние</a></li></ul></li>\n' \
|
||||||
|
'<li><a class="hsubs" href="">Отчёты</a><ul class="subs"><li><a href="#">Звонки по отделам</a></li>\n' \
|
||||||
|
'</ul></div>\n'
|
||||||
|
return txtMenu
|
||||||
|
|
||||||
|
def getInternalNumbers():
|
||||||
|
conn = connectDB()
|
||||||
|
c = conn.cursor()
|
||||||
|
order = 'int_number'
|
||||||
|
result = '<h4 align=center>Список внутренних телефонов</h4>'
|
||||||
qwr = "SELECT * FROM int_number ORDER by " + order
|
qwr = "SELECT * FROM int_number ORDER by " + order
|
||||||
c.execute(qwr)
|
c.execute(qwr)
|
||||||
print("<table><tr bgcolor=#ffb7b7 align=center><td><b>№ п/п</b></td><td><b><a href=index.py?qwery_type=internal&order=int_number>Телефон</a></b></td><td><b><a href=index.py?qwery_type=internal&order=fio>ФИО</a></b></td><td><b>Описание</b></td><td><b>Электро-почта</b></td><tr>")
|
listHeader = '<table class="table_dark"><tr><th>№ п/п</th>\n' \
|
||||||
|
'<th><a href=index.py?query_type=internal&order=int_number>Телефон</a></th>\n' \
|
||||||
|
'<th><a href=index.py?query_type=internal&order=fio>ФИО</a></th>\n' \
|
||||||
|
'<th>Описание<th>Электро-почта</th></tr>\n'
|
||||||
|
result = result + listHeader
|
||||||
for row in c.fetchall():
|
for row in c.fetchall():
|
||||||
print("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (row[0], row[1], row[2], row[4], row[3]))
|
rowData = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" % (row[0], row[1], row[2], row[4], row[3])
|
||||||
print("</table>")
|
result = result + rowData
|
||||||
|
return (result + "</table>\n")
|
||||||
|
|
||||||
if qwery_type == "external":
|
def getCOline():
|
||||||
print("<h4 align=center>Список городских телефонов</h4>")
|
conn = connectDB()
|
||||||
c.execute("SELECT * FROM ext_co_line")
|
c = conn.cursor()
|
||||||
print("<table><tr bgcolor=#ffb7b7 align=center><td><b>№ п/п</b></td><td><b>Линия</b></td><td><b>Телефон</b></td><td><b>Описание</b></td><tr>")
|
order = 'ext_co_line'
|
||||||
for r in c.fetchall():
|
result = '<h4 align=center>Список внешних линий</h4>'
|
||||||
print("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (r[0], r[1], r[2], r[3]))
|
qwr = "SELECT * FROM ext_co_line ORDER by " + order
|
||||||
print("</table>")
|
c.execute(qwr)
|
||||||
|
listHeader = '<table class="table_dark"><tr><th>№ п/п</th>\n' \
|
||||||
|
'<th>Линия</a></th>\n' \
|
||||||
|
'<th>Номер телефона</th>\n' \
|
||||||
|
'<th>Описание</th></tr>\n'
|
||||||
|
result = result + listHeader
|
||||||
|
for row in c.fetchall():
|
||||||
|
rowData = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (row[0], row[1], row[2], row[3])
|
||||||
|
result = result + rowData
|
||||||
|
return (result + "</table>\n")
|
||||||
|
|
||||||
print("</td></tr></table>")
|
def connectDB():
|
||||||
|
c = pymysql.connect(
|
||||||
print("</body></html>")
|
db='ats_test',
|
||||||
|
user='ats',
|
||||||
|
passwd='',
|
||||||
|
host='kis',
|
||||||
|
charset='utf8')
|
||||||
|
return c
|
Loading…
Reference in New Issue
Block a user