forked from Antiarchitect/taurus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
390 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<% | ||
building_c = <<eos | ||
'<div class=\"building\"> | ||
<h2>'+building.name+' корпус</h2>' | ||
eos | ||
building_c.gsub!(/\n\s*/, "") | ||
content = <<eos | ||
'<div class=\"classroom\"> | ||
<h3>'+classroom.name+(classroom.title ? '<small>: '+classroom.title+'</small>' : '')+'</h3> | ||
<a href=\"/timetable/classrooms/'+classroom.id+location.search+'\" class=\"button link_to_timetable\">Расписание</a> | ||
</div>' | ||
eos | ||
content.gsub!(/\n\s*/, "") | ||
%> | ||
|
||
jQuery(document).ready(function($) { | ||
|
||
$('#classroom_name_input').on('input', function () { | ||
$.ajax({ | ||
url: "/timetable/classrooms.json", | ||
data: {classroom: $(this).val()}, | ||
dataType: 'json', | ||
timeout: 15000, | ||
beforeSend: function (jqXHR, settings) { | ||
$(".ajax_message").hide(); | ||
$(".ajax_spinner").show(); | ||
$(".ajax_loading").show(); | ||
}, | ||
error: function (jqXHR, textStatus, errorThrown) { | ||
$(".ajax_error").show(); | ||
}, | ||
success: function (data, textStatus, jqXHR) { | ||
if (data.length) { | ||
$(".list_box").empty(); | ||
$.each(data, function (i, elem) { | ||
var building = elem.building; | ||
var html = <%= building_c %>; | ||
$.each(building.classrooms, function (j, classroom) { | ||
html += <%= content %>; | ||
}); | ||
$(html+'</div>').appendTo(".list_box"); | ||
}); | ||
} else { | ||
$(".ajax_not_found").show(); | ||
} | ||
}, | ||
complete: function (jqXHR, textStatus) { | ||
$(".ajax_spinner").hide(); | ||
$(".ajax_loading").hide(); | ||
} | ||
}); | ||
}); | ||
|
||
if ($('#lecturer_name_input').val()) $('#lecturer_name_input').trigger('input'); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* Keyboard preferences */ | ||
$key_width: 2em; | ||
$key_margin: 0.25em; | ||
$keyboard_width: 12*($key_width+2*$key_margin); | ||
|
||
div.classroom_timetable_search { | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 1em; | ||
} | ||
|
||
.search_box { | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
font-size: 1.2em; | ||
padding: 0.5em; | ||
position: static; | ||
overflow: hidden; | ||
top: 49px; | ||
width: 100%; | ||
z-index: 0; | ||
border-bottom: 1px solid silver; | ||
background: #F0F0F9; | ||
-moz-box-shadow: 1px 1px 10px 0 rgba(0,0,0,0.25); | ||
-webkit-box-shadow: 1px 1px 10px 0 rgba(0,0,0,0.25); | ||
box-shadow: 1px 1px 10px 0 rgba(0,0,0,0.25); | ||
background-image: -o-linear-gradient(top, #dfdfe6 0%, #F0F0F9 50%, #dfdfe6 100%); | ||
background-image: -moz-linear-gradient(top, #dfdfe6 0%, #F0F0F9 50%, #dfdfe6 100%); | ||
background-image: -webkit-linear-gradient(top, #dfdfe6 0%, #F0F0F9 50%, #dfdfe6 100%); | ||
background-image: -ms-linear-gradient(top, #dfdfe6 0%, #F0F0F9 50%, #dfdfe6 100%); | ||
background-image: linear-gradient(top, #dfdfe6 0%, #F0F0F9 50%, #dfdfe6 100%); | ||
|
||
form { | ||
margin-left: $keyboard_width; | ||
} | ||
|
||
} | ||
|
||
.keyboard { | ||
margin: 0; | ||
text-align: center; | ||
float: left; | ||
width: $keyboard_width; | ||
|
||
.kbd_row { | ||
overflow: hidden; | ||
margin: 0 auto; | ||
text-align: center; | ||
|
||
&.large { | ||
font-size: 120%; | ||
} | ||
|
||
} | ||
|
||
@for $i from 9 through 12 { | ||
.kbd_row.k#{$i} { | ||
width: $i*($key_width+2*$key_margin); | ||
} | ||
} | ||
|
||
.key { | ||
float: left; | ||
margin: $key_margin - 0.05em; // Strange Opera behaviour fix here | ||
width: $key_width; | ||
text-align: center; | ||
font-size: 1em; | ||
font-weight: bold; | ||
} | ||
|
||
.key.backspace, .key.clear { | ||
color: maroon !important; | ||
} | ||
|
||
.key.whitespace { | ||
width: 6*($key_width+2*$key_margin); | ||
} | ||
|
||
.key.backspace { | ||
width: 1.5*$key_width; | ||
} | ||
|
||
} | ||
|
||
.list_box { | ||
margin: 0; | ||
|
||
h2 { | ||
font-size: 200%; | ||
margin-bottom: 0.5em; | ||
margin-top: 1.5em; | ||
} | ||
|
||
.classroom { | ||
padding: 0.5em 1em; | ||
border: 1px dotted silver; | ||
margin: -1px; | ||
clear: both; | ||
overflow: hidden; | ||
|
||
h3 { | ||
margin: 0; | ||
padding: 0.1em 1em 0.1em 0; | ||
font-size: 2em; | ||
float: left; | ||
clear: left; | ||
} | ||
|
||
a.button { | ||
display: block; | ||
width: 200px; | ||
float: right; | ||
font-size: 1.5em; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Timetable::ClassroomsController < Timetable::BaseController | ||
|
||
def index | ||
@buildings = Building.includes(:classrooms).reorder("buildings.id,(substring(classrooms.name, '^[0-9]+'))::int,substring(classrooms.name, '[^0-9_].*$')") | ||
@buildings = @buildings.where("classrooms.name ILIKE ? OR classrooms.title ILIKE ? OR buildings.name ILIKE ?", *(["%#{params[:classroom]}%"]*3)) if params[:classroom] | ||
respond_to do |format| | ||
format.html do | ||
if @buildings.count == 1 and @buildings.first.classrooms.count == 1 | ||
redirect_to timetable_classroom_path(@buildings.first.classrooms.first) | ||
end | ||
end | ||
format.json do | ||
render :json => @buildings.to_json(only: [:id, :name], include: {classrooms: {only: [:id, :title, :name]}}) | ||
end | ||
end | ||
end | ||
|
||
def show | ||
@id = params[:id].to_i | ||
unless @classroom = Classroom.find_by_id(@id) | ||
suffix = @terminal ? '?terminal=true' : '' | ||
redirect_to :controller => 'timetable/classrooms' + suffix | ||
else | ||
pairs = @classroom.pairs.includes(:subgroups).in_semester(current_semester).flatten | ||
@days = Timetable.days | ||
@times = Timetable.times | ||
@weeks = Timetable.weeks | ||
@pairs = Array.new(@days.size).map!{Array.new(@times.size).map!{Array.new(@weeks.size + 1).map!{Array.new}}} | ||
pairs.each do |pair| | ||
@pairs[pair.day_of_the_week - 1][pair.pair_number - 1][pair.week] << pair | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Timetable::ClassroomsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- both_week_pairs = @pairs[day_counter][time][0] | ||
- first_week_pairs = @pairs[day_counter][time][1] | ||
- second_week_pairs = @pairs[day_counter][time][2] | ||
%td | ||
-# Uncomment for debug purpose only! | ||
=# both_week_pairs.size | ||
=# first_week_pairs.size | ||
=# second_week_pairs.size | ||
- if both_week_pairs.empty? and first_week_pairs.empty? and second_week_pairs.empty? | ||
.nopair | ||
- else | ||
.daycellcontainer{:title => day} | ||
%table{:class => 'daycell'} | ||
- if both_week_pairs.any? and !first_week_pairs.any? and !second_week_pairs.any? | ||
%tr | ||
= render 'week_in_day', :pairs => both_week_pairs, :skipcell => [], :singlerow => true | ||
- else | ||
- skipcell = [] | ||
%tr | ||
- if first_week_pairs.any? or both_week_pairs.any? | ||
= render 'week_in_day', :pairs => first_week_pairs+both_week_pairs, :skipcell => skipcell, :singlerow => false | ||
%tr | ||
- if second_week_pairs.any? | ||
= render 'week_in_day', :pairs => second_week_pairs, :skipcell => skipcell, :singlerow => false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%th | ||
= day_header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- flow = p.charge_card.groups.map{|g| g.name }.join ", " | ||
.pair | ||
= "#{flow}" | ||
%br | ||
- if p.assistant && p.assistant_id | ||
.lecturer #{p.lecturer}, #{p.assistant} | ||
- else | ||
.lecturer #{p.lecturer} | ||
= "#{p.discipline}" | ||
- if ![1,2,9].include?(p.active_at.month) or ![5,6,7,12].include?(p.expired_at.month) | ||
%br | ||
с #{p.active_at} по #{p.expired_at} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%tr.timetablerow | ||
%th | ||
= time | ||
= render :partial => 'day', :collection => @days, :locals => {:time => time_counter} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- subgroups = [] | ||
- to_display = [] | ||
- pairs.sort_by { |p| p.expired_at }.each do |b| | ||
- b.subgroups.each do |s| | ||
- if !subgroups.include?(s.number) | ||
- subgroups << s.number | ||
- subgroups << 0 # Если есть пара с подгруппами, то пара без подгрупп уже не влезет | ||
- to_display << [b, s.number] | ||
|
||
- if to_display.size > 0 | ||
-# Если без подгрупп или есть только одна пара 3-ей или ещё какой подгруппы | ||
- if subgroups.max == 0 or (subgroups.max > 2 and to_display.size == 1) | ||
%td{:colspan => 2} | ||
- pair = to_display.first[0] | ||
= render 'pair', :p => pair, :s => to_display.first[1] | ||
- else | ||
-# Если есть пара третьей или большей подгруппы и есть место куда её воткнуть | ||
- to_display.find_all{ |elem| elem[1] > 2 }.each do |elem| | ||
- if subgroups.max > 2 and to_display.size == 2 and to_display.size - skipcell.size > 0 | ||
- elem[2] = elem[1] # elem[1] - подгруппа-позиция, elem[2] - реальная подгруппа пары | ||
- elem[1] = to_display.find_all{ |elem| elem[1] == 1 }.size > 1 ? 2 : 1 | ||
- 1.upto(2) do |sub| | ||
- if skipcell.include?(sub) | ||
- skipcell - [sub] | ||
- next | ||
- sp = to_display.find_all{ |elem| elem[1] == sub } | ||
- if sp.size > 0 | ||
- pair = sp.first[0] | ||
- a = {} | ||
- if pair.week == 0 and !singlerow | ||
- skipcell << sub | ||
- a = {:rowspan=>2} | ||
%td{a} | ||
= render 'pair', :p => pair, :s => sp.first[2] | ||
- else | ||
%td.empty | ||
|
Oops, something went wrong.