summaryrefslogtreecommitdiff
path: root/scripts/gen_css_tables.py
blob: 4bc5ea80d3b67b4b41328f9bad2b355bff861432 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!python3

# This script generates the css tables needed for halfnarp to work
# properly with different start and end dates, rooms and numers of
# days. Adapt the to your conference's needs and place the result
# in the css document, e.g. style_38c3_tables.css

start_y   = 400
starttime = 10
endtime   = 28
rooms     = 3
days      = 4
columns   = days * rooms          # how many columns does 
event_gap = { 'large': 5, 'medium': 3, 'small': 2 }  # how much is an event shorter than what the grid would allow in px
block_length = 210

time_grid = 5                     # what is the granularity of Fahrplan raster in minutes
elem_per_hour = 60 / time_grid    # how many sections does one hour get

# how many pixels are in one hour vertically in LARGE, MEDIUM, SMALL
hour_height={ 'large': 300, 'medium': 160, 'small': 120 }

# What is the height of one grid element
grid_height={ 'large': hour_height['large']  / elem_per_hour, 'medium': hour_height['medium'] / elem_per_hour, 'small': hour_height['small']  / elem_per_hour }

for size in ['large', 'medium', 'small']:
    y = start_y
    for hour in range(starttime, endtime):
        for minute in range(0,60,time_grid):
            print ( '.size-' + size + ' .time_' + str(hour % 24).zfill(2) + str(minute).zfill(2) + ' { top: ' + str(y) + 'px; }' )
            y += grid_height[size]

for size in ['large', 'medium', 'small']:
    for duration in range(300,12000,100):
        height = hour_height[size] * duration / 3600 - event_gap[size]
        print ( '.size-' + size + ' .duration_' + str(duration) + ' { min-height: ' + str(height) + 'px; max-height:  ' + str(height) + 'px; }')
    print ( '.size-' + size + ' .wholeblock     { height: ' + str(hour_height[size] * block_length / 60) + 'px; }' )

print ( '.size-large .grid           { height: ' + str(grid_height['large']) + 'px; font-size: 1em; }' )
print ( '.size-medium .grid          { height: ' + str(grid_height['medium'])+ 'px; font-size: 0.5em; }' )
print ( '.size-small .grid           { height: ' + str(grid_height['small']) + 'px; font-size: 0.3em; }' )

gap = 4
width = ( 100 - gap * ( 1 + rooms ) ) / rooms
for room in range(rooms):
    print ( '.in-calendar .room' + str(room+1) +' { left:  ' + str(gap * (room + 1) + width * room ) + '%; }' )

print ('.in-calendar .event, .in-calendar .room-label, .in-calendar .grid { position: absolute; width: ' + str(width)+ '%; }' )
print ('.in-calendar .r, .in-calendar .l { width: ' + str(width) + '%; }')
print ('.in-calendar .rr, .in-calendar .ll { width: ' + str(2*width+gap) + '%; }')
print ('.in-calendar .rrr, .in-calendar .lll { width: ' + str(3*width+2*gap) + '%; }')
print ('.in-calendar .rrrr, .in-calendar .llll { width: ' + str(4*width+3*gap) + '%; }')
print ('.in-calendar .r, .in-calendar .rr, .in-calendar .rrr, .in-calendar .rrrr { margin-left: ' + str(width / 2) + '% ; }')
print ('.in-calendar .l { margin-left: -' + str(width / 2) + '% ; }')
print ('.in-calendar .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }')
print ('.in-calendar .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }')
print ('.in-calendar .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }')

gap = 0.5
width = ( 100 - gap * ( 1 + columns ) ) / columns
for day in range(days):
    for room in range(rooms):
        print ( '.in-calendar.alldays .day_' + str(day+1) + '.room' + str(room+1) +' { left:  ' + str(gap * (day*rooms + room + 1) + width * (day * rooms + room ) ) + '%; }' )

print ('.wholeday, .wholeblock { width: ' + str(100 / days)+ '% }')
print ('.in-calendar.alldays .event, .in-calendar.alldays .room-label, .in-calendar.alldays .grid { width: ' + str(width)+ '%; }' )

print ('.in-calendar.alldays .r, .in-calendar.alldays .l { width: ' + str(width) + '%; }')
print ('.in-calendar.alldays .rr, .in-calendar.alldays .ll { width: ' + str(2*width+gap) + '%; }')
print ('.in-calendar.alldays .rrr, .in-calendar.alldays .lll { width: ' + str(3*width+2*gap) + '%; }')
print ('.in-calendar.alldays .rrrr, .in-calendar.alldays .llll { width: ' + str(4*width+3*gap) + '%; }')

print ('.in-calendar.alldays .r, .in-calendar.alldays .rr, .in-calendar.alldays .rrr, .in-calendar.alldays .rrrr { margin-left: ' + str(width / 2) + '% ; }')
print ('.in-calendar.alldays .l { margin-left: -' + str(width / 2) + '% ; }')
print ('.in-calendar.alldays .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }')
print ('.in-calendar.alldays .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }')
print ('.in-calendar.alldays .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }')

print ('.r, .rr, .rrr, .rrrr, .l, .ll, .lll, .llll { height: 4px; }')

for size in ['large', 'medium', 'small']:
    print ('.size-' + size +' .wholeday       { height: ' + str( ( endtime - starttime ) * hour_height[size] ) + 'px; }' )
    print ('.size-' + size +' .duration_inf   { height: ' + str( 7 * hour_height[size] ) + 'px; }' )