1
0
Fork 0
mirror of https://github.com/koniu/recoll-webui.git synced 2025-10-05 02:29:29 +02:00

whitespace/linebreak cleanup

This commit is contained in:
koniu 2012-12-18 10:45:55 +00:00
parent 43500e5e61
commit 813304bed2
7 changed files with 308 additions and 310 deletions

View file

@ -309,13 +309,13 @@ class Router(object):
def path_filter(self, conf): def path_filter(self, conf):
return r'.*?', None, None return r'.*?', None, None
def add_filter(self, name, func): def add_filter(self, name, func):
''' Add a filter. The provided function is called with the configuration ''' Add a filter. The provided function is called with the configuration
string as parameter and must return a (regexp, to_python, to_url) tuple. string as parameter and must return a (regexp, to_python, to_url) tuple.
The first element is a string, the last two are callables or None. ''' The first element is a string, the last two are callables or None. '''
self.filters[name] = func self.filters[name] = func
def parse_rule(self, rule): def parse_rule(self, rule):
''' Parses a rule into a (name, filter, conf) token stream. If mode is ''' Parses a rule into a (name, filter, conf) token stream. If mode is
None, name contains a static rule part. ''' None, name contains a static rule part. '''
@ -2465,10 +2465,10 @@ class FileCheckerThread(threading.Thread):
thread.interrupt_main() thread.interrupt_main()
break break
time.sleep(self.interval) time.sleep(self.interval)
def __enter__(self): def __enter__(self):
self.start() self.start()
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
if not self.status: self.status = 'exit' # silent exit if not self.status: self.status = 'exit' # silent exit
self.join() self.join()

View file

@ -1,5 +1,5 @@
// To allow access to files via recoll-webui include the following in your: // To allow access to files via recoll-webui include the following in your:
// ~/.mozilla/firefox/<profile>/user.js // ~/.mozilla/firefox/<profile>/user.js
user_pref("capability.policy.policynames", "localfilelinks"); user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://localhost:8080"); user_pref("capability.policy.localfilelinks.sites", "http://localhost:8080");

View file

@ -1,8 +1,8 @@
$(document).ready(function(){ $(document).ready(function(){
$("form").submit(function() { $("form").submit(function() {
$("input").blur() $("input").blur()
$("#fade").height($("#searchbox").height()+1) $("#fade").height($("#searchbox").height()+1)
$("#fade").fadeIn("slow") $("#fade").fadeIn("slow")
}) })
if ($("#results").length) { $("input").blur() } if ($("#results").length) { $("input").blur() }
$('input[name="after"]').jdPicker({}); $('input[name="after"]').jdPicker({});

View file

@ -1,180 +1,180 @@
.jdpicker_w { .jdpicker_w {
display: inline; display: inline;
} }
.jdpicker_w .date_selector * { .jdpicker_w .date_selector * {
width: auto; width: auto;
height: auto; height: auto;
border: none; border: none;
background: none; background: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
text-align: left; text-align: left;
text-decoration: none; text-decoration: none;
font-size:12px; font-size:12px;
} }
.jdpicker_w .date_selector { .jdpicker_w .date_selector {
background: #FFF; background: #FFF;
border: 1px solid black; border: 1px solid black;
padding: 5px; padding: 5px;
margin: -1px 0 0 0; margin: -1px 0 0 0;
position: absolute; position: absolute;
z-index: 100000; z-index: 100000;
display: none; display: none;
width:210px width:210px
} }
.jdpicker_w .date_selector table{ .jdpicker_w .date_selector table{
width:210px; width:210px;
margin-left:3px; margin-left:3px;
border-collapse: collapse; border-collapse: collapse;
} }
.jdpicker_w .date_clearer{ .jdpicker_w .date_clearer{
color: #a00; color: #a00;
padding-left:3px; padding-left:3px;
cursor:pointer; cursor:pointer;
font-weight:bold; font-weight:bold;
font-family:sans-serif font-family:sans-serif
} }
.jdpicker_w .date_selector_ieframe { .jdpicker_w .date_selector_ieframe {
position: absolute; position: absolute;
z-index: 99999; z-index: 99999;
display: none; display: none;
} }
.jdpicker_w .error_msg{ .jdpicker_w .error_msg{
display:none; display:none;
text-align:center; text-align:center;
font-size:0.8em; font-size:0.8em;
color:#666 color:#666
} }
.jdpicker_w .date_selector .nav { .jdpicker_w .date_selector .nav {
width: 17.5em; /* 7 * 2.5em */ width: 17.5em; /* 7 * 2.5em */
} }
.jdpicker_w .date_selector .month_nav, .jdpicker_w .date_selector .year_nav { .jdpicker_w .date_selector .month_nav, .jdpicker_w .date_selector .year_nav {
margin: 0 0 3px 0; margin: 0 0 3px 0;
padding: 0; padding: 0;
display: block; display: block;
position: relative; position: relative;
text-align: center; text-align: center;
} }
.jdpicker_w .date_selector .month_nav { .jdpicker_w .date_selector .month_nav {
float: left; float: left;
width: 56%; width: 56%;
} }
.jdpicker_w .date_selector .year_nav { .jdpicker_w .date_selector .year_nav {
float: right; float: right;
width: 37%; width: 37%;
position:relative; position:relative;
} }
.jdpicker_w .date_selector .month_nav select { .jdpicker_w .date_selector .month_nav select {
width:75px; width:75px;
margin: 0 auto; margin: 0 auto;
border:1px solid #ccc; border:1px solid #ccc;
position:relative; position:relative;
top:1px top:1px
} }
.jdpicker_w .date_selector .year_nav .year_input { .jdpicker_w .date_selector .year_nav .year_input {
text-align:center; text-align:center;
width:36px; width:36px;
border:1px solid #ccc; border:1px solid #ccc;
position:relative; position:relative;
top:2px top:2px
} }
.jdpicker_w .date_selector .month_name, .jdpicker_w .date_selector .year_name { .jdpicker_w .date_selector .month_name, .jdpicker_w .date_selector .year_name {
font-weight: bold; font-weight: bold;
line-height: 20px; line-height: 20px;
} }
.jdpicker_w .date_selector .button { .jdpicker_w .date_selector .button {
display: block; display: block;
position: absolute; position: absolute;
top: 0; top: 0;
width: 18px; width: 18px;
height: 18px; height: 18px;
line-height: 17px; line-height: 17px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
text-align: center; text-align: center;
font-size: 120%; font-size: 120%;
overflow: hidden; overflow: hidden;
cursor:pointer; cursor:pointer;
} }
.jdpicker_w .date_selector .button:hover, .jdpicker_w .date_selector .button.hover { .jdpicker_w .date_selector .button:hover, .jdpicker_w .date_selector .button.hover {
background: none; background: none;
color: white; color: white;
cursor: pointer; cursor: pointer;
background: #ccc; background: #ccc;
} }
.jdpicker_w .date_selector .prev { .jdpicker_w .date_selector .prev {
left: 0; left: 0;
} }
.jdpicker_w .date_selector .next { .jdpicker_w .date_selector .next {
right: 0; right: 0;
} }
.jdpicker_w .date_selector table { .jdpicker_w .date_selector table {
margin:0 auto; margin:0 auto;
clear: both; clear: both;
} }
.jdpicker_w .date_selector th{ .jdpicker_w .date_selector th{
padding-top:5px; padding-top:5px;
padding-bottom:5px; padding-bottom:5px;
} }
.jdpicker_w .date_selector th, .jdpicker_w .date_selector td { .jdpicker_w .date_selector th, .jdpicker_w .date_selector td {
text-align: center; text-align: center;
color: black; color: black;
} }
.jdpicker_w .date_selector th.week_label{ .jdpicker_w .date_selector th.week_label{
font-weight:normal; font-weight:normal;
font-style:italic; font-style:italic;
font-size:80%; font-size:80%;
width:25px width:25px
} }
.jdpicker_w .date_selector .week_num, .jdpicker_w .date_selector .hover .week_num, .jdpicker_w .date_selector .selected .week_num{ .jdpicker_w .date_selector .week_num, .jdpicker_w .date_selector .hover .week_num, .jdpicker_w .date_selector .selected .week_num{
font-style:italic; font-style:italic;
color:#333 !important; color:#333 !important;
vertical-align:bottom !important; vertical-align:bottom !important;
text-align:right; text-align:right;
border:none !important; border:none !important;
font-size:70%; font-size:70%;
background:#FCFCFC !important; background:#FCFCFC !important;
padding-right:4px; padding-right:4px;
} }
.jdpicker_w .date_selector td { .jdpicker_w .date_selector td {
line-height: 2em; line-height: 2em;
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
color: #003C78; color: #003C78;
background: white; background: white;
} }
.jdpicker_w .date_selector td.today { .jdpicker_w .date_selector td.today {
color: darkorange !important; color: darkorange !important;
} }
.jdpicker_w .date_selector td.unselected_month { .jdpicker_w .date_selector td.unselected_month {
color: #ccc; color: #ccc;
} }
.jdpicker_w .date_selector td.selectable_day, .jdpicker_w .date_selector tr.selectable_week td { .jdpicker_w .date_selector td.selectable_day, .jdpicker_w .date_selector tr.selectable_week td {
cursor: pointer; cursor: pointer;
color:#333 color:#333
} }
.jdpicker_w .date_selector td.selected, .jdpicker_w .date_selector tr.selected td{ .jdpicker_w .date_selector td.selected, .jdpicker_w .date_selector tr.selected td{
background: lightgreen; background: lightgreen;
font-weight: bold; font-weight: bold;
} }
.jdpicker_w .date_selector tr.selectable_week.hover td, .jdpicker_w .date_selector td.selectable_day.hover { .jdpicker_w .date_selector tr.selectable_week.hover td, .jdpicker_w .date_selector td.selectable_day.hover {
color: white; color: white;
background: #ccc; background: #ccc;
} }

View file

@ -28,18 +28,18 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.
*/ */
jdPicker = (function($) { jdPicker = (function($) {
function jdPicker(el, opts) { function jdPicker(el, opts) {
if (typeof(opts) != "object") opts = {}; if (typeof(opts) != "object") opts = {};
$.extend(this, jdPicker.DEFAULT_OPTS, opts); $.extend(this, jdPicker.DEFAULT_OPTS, opts);
this.input = $(el); this.input = $(el);
this.bindMethodsToObj("show", "hide", "hideIfClickOutside", "keydownHandler", "selectDate"); this.bindMethodsToObj("show", "hide", "hideIfClickOutside", "keydownHandler", "selectDate");
this.build(); this.build();
this.selectDate(); this.selectDate();
this.hide(); this.hide();
}; };
jdPicker.DEFAULT_OPTS = { jdPicker.DEFAULT_OPTS = {
@ -60,169 +60,169 @@ jdPicker.DEFAULT_OPTS = {
}; };
jdPicker.prototype = { jdPicker.prototype = {
build: function() { build: function() {
this.wrapp = this.input.wrap('<div class="jdpicker_w">'); this.wrapp = this.input.wrap('<div class="jdpicker_w">');
switch (this.date_format){ switch (this.date_format){
case "dd/mm/YYYY": case "dd/mm/YYYY":
this.reg = new RegExp(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); this.reg = new RegExp(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
this.date_decode = "new Date(matches[3], parseInt(matches[2]-1), matches[1]);"; this.date_decode = "new Date(matches[3], parseInt(matches[2]-1), matches[1]);";
this.date_encode = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1) + "/" + date.getFullYear();'; this.date_encode = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1) + "/" + date.getFullYear();';
this.date_encode_s = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1)'; this.date_encode_s = 'this.strpad(date.getDate()) + "/" + this.strpad(date.getMonth()+1)';
break; break;
case "FF dd YYYY": case "FF dd YYYY":
this.reg = new RegExp(/^([a-zA-Z]+) (\d{1,2}) (\d{4})$/); this.reg = new RegExp(/^([a-zA-Z]+) (\d{1,2}) (\d{4})$/);
this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[1]), matches[2]);"; this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[1]), matches[2]);";
this.date_encode = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();'; this.date_encode = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();';
this.date_encode_s = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate());'; this.date_encode_s = 'this.month_names[date.getMonth()] + " " + this.strpad(date.getDate());';
break; break;
case "dd MM YYYY": case "dd MM YYYY":
this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]{3}) (\d{4})$/); this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]{3}) (\d{4})$/);
this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[2]), matches[1]);"; this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[2]), matches[1]);";
this.date_encode = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()] + " " + date.getFullYear();'; this.date_encode = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()] + " " + date.getFullYear();';
this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()];'; this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.short_month_names[date.getMonth()];';
break; break;
case "MM dd YYYY": case "MM dd YYYY":
this.reg = new RegExp(/^([a-zA-Z]{3}) (\d{1,2}) (\d{4})$/); this.reg = new RegExp(/^([a-zA-Z]{3}) (\d{1,2}) (\d{4})$/);
this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[1]), matches[2]);"; this.date_decode = "new Date(matches[3], this.indexFor(this.short_month_names, matches[1]), matches[2]);";
this.date_encode = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();'; this.date_encode = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate()) + " " + date.getFullYear();';
this.date_encode_s = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate());'; this.date_encode_s = 'this.short_month_names[date.getMonth()] + " " + this.strpad(date.getDate());';
break; break;
case "dd FF YYYY": case "dd FF YYYY":
this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]+) (\d{4})$/); this.reg = new RegExp(/^(\d{1,2}) ([a-zA-Z]+) (\d{4})$/);
this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[2]), matches[1]);"; this.date_decode = "new Date(matches[3], this.indexFor(this.month_names, matches[2]), matches[1]);";
this.date_encode = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()] + " " + date.getFullYear();'; this.date_encode = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()] + " " + date.getFullYear();';
this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()];'; this.date_encode_s = 'this.strpad(date.getDate()) + " " + this.month_names[date.getMonth()];';
break; break;
case "YYYY-mm-dd": case "YYYY-mm-dd":
default: default:
this.reg = new RegExp(/^(\d{4})\-(\d{1,2})\-(\d{1,2})$/); this.reg = new RegExp(/^(\d{4})\-(\d{1,2})\-(\d{1,2})$/);
this.date_decode = "new Date(matches[1], parseInt(matches[2]-1), matches[3]);"; this.date_decode = "new Date(matches[1], parseInt(matches[2]-1), matches[3]);";
this.date_encode = 'date.getFullYear() + "-" + this.strpad(date.getMonth()+1) + "-" + this.strpad(date.getDate());'; this.date_encode = 'date.getFullYear() + "-" + this.strpad(date.getMonth()+1) + "-" + this.strpad(date.getDate());';
this.date_encode_s = 'this.strpad(date.getMonth()+1) + "-" + this.strpad(date.getDate());'; this.date_encode_s = 'this.strpad(date.getMonth()+1) + "-" + this.strpad(date.getDate());';
break; break;
} }
if(this.date_max != "" && this.date_max.match(this.reg)){ if(this.date_max != "" && this.date_max.match(this.reg)){
var matches = this.date_max.match(this.reg); var matches = this.date_max.match(this.reg);
this.date_max = eval(this.date_decode); this.date_max = eval(this.date_decode);
}else }else
this.date_max = ""; this.date_max = "";
if(this.date_min != "" && this.date_min.match(this.reg)){ if(this.date_min != "" && this.date_min.match(this.reg)){
var matches = this.date_min.match(this.reg); var matches = this.date_min.match(this.reg);
this.date_min = eval(this.date_decode); this.date_min = eval(this.date_decode);
}else }else
this.date_min = ""; this.date_min = "";
var monthNav = $('<p class="month_nav">' + var monthNav = $('<p class="month_nav">' +
'<span class="button prev" title="[PageUp]">&#171;</span>' + '<span class="button prev" title="[PageUp]">&#171;</span>' +
' <span class="month_name"></span> ' + ' <span class="month_name"></span> ' +
'<span class="button next" title="[PageDown]">&#187;</span>' + '<span class="button next" title="[PageDown]">&#187;</span>' +
'</p>'); '</p>');
this.monthNameSpan = $(".month_name", monthNav); this.monthNameSpan = $(".month_name", monthNav);
$(".prev", monthNav).click(this.bindToObj(function() { this.moveMonthBy(-1); })); $(".prev", monthNav).click(this.bindToObj(function() { this.moveMonthBy(-1); }));
$(".next", monthNav).click(this.bindToObj(function() { this.moveMonthBy(1); })); $(".next", monthNav).click(this.bindToObj(function() { this.moveMonthBy(1); }));
this.monthNameSpan.dblclick(this.bindToObj(function(){ this.monthNameSpan.dblclick(this.bindToObj(function(){
this.monthNameSpan.empty().append(this.getMonthSelect()); this.monthNameSpan.empty().append(this.getMonthSelect());
$('select', this.monthNameSpan).change(this.bindToObj(function(){ $('select', this.monthNameSpan).change(this.bindToObj(function(){
this.moveMonthBy(parseInt($('select :selected', this.monthNameSpan).val()) - this.currentMonth.getMonth()); this.moveMonthBy(parseInt($('select :selected', this.monthNameSpan).val()) - this.currentMonth.getMonth());
})); }));
})); }));
var yearNav = $('<p class="year_nav">' + var yearNav = $('<p class="year_nav">' +
'<span class="button prev" title="[Shift+PageUp]">&#171;</span>' + '<span class="button prev" title="[Shift+PageUp]">&#171;</span>' +
' <span class="year_name" id="year_name"></span> ' + ' <span class="year_name" id="year_name"></span> ' +
'<span class="button next" title="[Shift+PageDown]">&#187;</span>' + '<span class="button next" title="[Shift+PageDown]">&#187;</span>' +
'</p>'); '</p>');
this.yearNameSpan = $(".year_name", yearNav); this.yearNameSpan = $(".year_name", yearNav);
$(".prev", yearNav).click(this.bindToObj(function() { this.moveMonthBy(-12); })); $(".prev", yearNav).click(this.bindToObj(function() { this.moveMonthBy(-12); }));
$(".next", yearNav).click(this.bindToObj(function() { this.moveMonthBy(12); })); $(".next", yearNav).click(this.bindToObj(function() { this.moveMonthBy(12); }));
this.yearNameSpan.dblclick(this.bindToObj(function(){ this.yearNameSpan.dblclick(this.bindToObj(function(){
if($('.year_name input', this.rootLayers).length==0){ if($('.year_name input', this.rootLayers).length==0){
var initialDate = this.yearNameSpan.html(); var initialDate = this.yearNameSpan.html();
var yearNameInput = $('<input type="text" class="text year_input" value="'+initialDate+'" />'); var yearNameInput = $('<input type="text" class="text year_input" value="'+initialDate+'" />');
this.yearNameSpan.empty().append(yearNameInput); this.yearNameSpan.empty().append(yearNameInput);
$(".year_input", yearNav).keyup(this.bindToObj(function(){ $(".year_input", yearNav).keyup(this.bindToObj(function(){
if($('input',this.yearNameSpan).val().length == 4 && $('input',this.yearNameSpan).val() != initialDate && parseInt($('input',this.yearNameSpan).val()) == $('input',this.yearNameSpan).val()){ if($('input',this.yearNameSpan).val().length == 4 && $('input',this.yearNameSpan).val() != initialDate && parseInt($('input',this.yearNameSpan).val()) == $('input',this.yearNameSpan).val()){
this.moveMonthBy(parseInt(parseInt(parseInt($('input',this.yearNameSpan).val()) - initialDate)*12)); this.moveMonthBy(parseInt(parseInt(parseInt($('input',this.yearNameSpan).val()) - initialDate)*12));
}else if($('input',this.yearNameSpan).val().length>4) }else if($('input',this.yearNameSpan).val().length>4)
$('input',this.yearNameSpan).val($('input',this.yearNameSpan).val().substr(0, 4)); $('input',this.yearNameSpan).val($('input',this.yearNameSpan).val().substr(0, 4));
})); }));
$('input',this.yearNameSpan).focus(); $('input',this.yearNameSpan).focus();
$('input',this.yearNameSpan).select(); $('input',this.yearNameSpan).select();
} }
})); }));
var error_msg = $('<div class="error_msg"></div>'); var error_msg = $('<div class="error_msg"></div>');
var nav = $('<div class="nav"></div>').append(error_msg, monthNav, yearNav); var nav = $('<div class="nav"></div>').append(error_msg, monthNav, yearNav);
var tableShell = "<table><thead><tr>"; var tableShell = "<table><thead><tr>";
if(this.show_week == 1) tableShell +='<th class="week_label">'+(this.week_label)+'</th>'; if(this.show_week == 1) tableShell +='<th class="week_label">'+(this.week_label)+'</th>';
$(this.adjustDays(this.short_day_names)).each(function() { $(this.adjustDays(this.short_day_names)).each(function() {
tableShell += "<th>" + this + "</th>"; tableShell += "<th>" + this + "</th>";
}); });
tableShell += "</tr></thead><tbody></tbody></table>"; tableShell += "</tr></thead><tbody></tbody></table>";
var style = (this.input.context.type=="hidden")?' style="display:block; position:static; margin:0 auto"':''; var style = (this.input.context.type=="hidden")?' style="display:block; position:static; margin:0 auto"':'';
this.dateSelector = this.rootLayers = $('<div class="date_selector" '+style+'></div>').append(nav, tableShell).insertAfter(this.input); this.dateSelector = this.rootLayers = $('<div class="date_selector" '+style+'></div>').append(nav, tableShell).insertAfter(this.input);
if ($.browser.msie && $.browser.version < 7) { if ($.browser.msie && $.browser.version < 7) {
this.ieframe = $('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector); this.ieframe = $('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector);
this.rootLayers = this.rootLayers.add(this.ieframe); this.rootLayers = this.rootLayers.add(this.ieframe);
$(".button", nav).mouseover(function() { $(this).addClass("hover"); }); $(".button", nav).mouseover(function() { $(this).addClass("hover"); });
$(".button", nav).mouseout(function() { $(this).removeClass("hover"); }); $(".button", nav).mouseout(function() { $(this).removeClass("hover"); });
}; };
this.tbody = $("tbody", this.dateSelector); this.tbody = $("tbody", this.dateSelector);
this.input.change(this.bindToObj(function() { this.selectDate(); })); this.input.change(this.bindToObj(function() { this.selectDate(); }));
this.selectDate(); this.selectDate();
}, },
selectMonth: function(date) { selectMonth: function(date) {
var newMonth = new Date(date.getFullYear(), date.getMonth(), date.getDate()); var newMonth = new Date(date.getFullYear(), date.getMonth(), date.getDate());
if(this.isNewDateAllowed(newMonth)){ if(this.isNewDateAllowed(newMonth)){
if (!this.currentMonth || !(this.currentMonth.getFullYear() == newMonth.getFullYear() && if (!this.currentMonth || !(this.currentMonth.getFullYear() == newMonth.getFullYear() &&
this.currentMonth.getMonth() == newMonth.getMonth())) { this.currentMonth.getMonth() == newMonth.getMonth())) {
this.currentMonth = newMonth; this.currentMonth = newMonth;
var rangeStart = this.rangeStart(date), rangeEnd = this.rangeEnd(date); var rangeStart = this.rangeStart(date), rangeEnd = this.rangeEnd(date);
var numDays = this.daysBetween(rangeStart, rangeEnd); var numDays = this.daysBetween(rangeStart, rangeEnd);
var dayCells = ""; var dayCells = "";
for (var i = 0; i <= numDays; i++) { for (var i = 0; i <= numDays; i++) {
var currentDay = new Date(rangeStart.getFullYear(), rangeStart.getMonth(), rangeStart.getDate() + i, 12, 00); var currentDay = new Date(rangeStart.getFullYear(), rangeStart.getMonth(), rangeStart.getDate() + i, 12, 00);
if (this.isFirstDayOfWeek(currentDay)){ if (this.isFirstDayOfWeek(currentDay)){
var firstDayOfWeek = currentDay; var firstDayOfWeek = currentDay;
var lastDayOfWeek = new Date(currentDay.getFullYear(), currentDay.getMonth(), currentDay.getDate()+6, 12, 00); var lastDayOfWeek = new Date(currentDay.getFullYear(), currentDay.getMonth(), currentDay.getDate()+6, 12, 00);
if(this.select_week && this.isNewDateAllowed(firstDayOfWeek)) if(this.select_week && this.isNewDateAllowed(firstDayOfWeek))
dayCells += "<tr date='" + this.dateToString(currentDay) + "' class='selectable_week'>"; dayCells += "<tr date='" + this.dateToString(currentDay) + "' class='selectable_week'>";
else else
dayCells += "<tr>"; dayCells += "<tr>";
if(this.show_week==1) if(this.show_week==1)
dayCells += '<td class="week_num">'+this.getWeekNum(currentDay)+'</td>'; dayCells += '<td class="week_num">'+this.getWeekNum(currentDay)+'</td>';
} }
@ -231,14 +231,14 @@ jdPicker.prototype = {
} else { } else {
dayCells += '<td class="unselected_month" date="' + this.dateToString(currentDay) + '">' + currentDay.getDate() + '</td>'; dayCells += '<td class="unselected_month" date="' + this.dateToString(currentDay) + '">' + currentDay.getDate() + '</td>';
}; };
if (this.isLastDayOfWeek(currentDay)) dayCells += "</tr>"; if (this.isLastDayOfWeek(currentDay)) dayCells += "</tr>";
}; };
this.tbody.empty().append(dayCells); this.tbody.empty().append(dayCells);
this.monthNameSpan.empty().append(this.monthName(date)); this.monthNameSpan.empty().append(this.monthName(date));
this.yearNameSpan.empty().append(this.currentMonth.getFullYear()); this.yearNameSpan.empty().append(this.currentMonth.getFullYear());
if(this.select_week == 0){ if(this.select_week == 0){
$(".selectable_day", this.tbody).click(this.bindToObj(function(event) { $(".selectable_day", this.tbody).click(this.bindToObj(function(event) {
this.changeInput($(event.target).attr("date"));if(this.input.context.type!="hidden") this.hide(); this.changeInput($(event.target).attr("date"));if(this.input.context.type!="hidden") this.hide();
@ -248,7 +248,7 @@ jdPicker.prototype = {
this.changeInput($(event.target.parentNode).attr("date"));if(this.input.context.type!="hidden") this.hide(); this.changeInput($(event.target.parentNode).attr("date"));if(this.input.context.type!="hidden") this.hide();
})); }));
} }
$("td[date='" + this.dateToString(new Date()) + "']", this.tbody).addClass("today"); $("td[date='" + this.dateToString(new Date()) + "']", this.tbody).addClass("today");
if(this.select_week == 1){ if(this.select_week == 1){
$("tr", this.tbody).mouseover(function() { $(this).addClass("hover"); }); $("tr", this.tbody).mouseover(function() { $(this).addClass("hover"); });
@ -258,22 +258,22 @@ jdPicker.prototype = {
$("td.selectable_day", this.tbody).mouseout(function() { $(this).removeClass("hover"); }); $("td.selectable_day", this.tbody).mouseout(function() { $(this).removeClass("hover"); });
} }
}; };
$('.selected', this.tbody).removeClass("selected"); $('.selected', this.tbody).removeClass("selected");
$('td[date="' + this.selectedDateString + '"], tr[date="' + this.selectedDateString + '"]', this.tbody).addClass("selected"); $('td[date="' + this.selectedDateString + '"], tr[date="' + this.selectedDateString + '"]', this.tbody).addClass("selected");
}else }else
this.show_error(this.error_out_of_range); this.show_error(this.error_out_of_range);
}, },
selectDate: function(date) { selectDate: function(date) {
if (typeof(date) == "undefined") { if (typeof(date) == "undefined") {
date = this.stringToDate(this.input.val()); date = this.stringToDate(this.input.val());
}; };
if (!date) date = new Date(); if (!date) date = new Date();
if(this.select_week == 1 && !this.isFirstDayOfWeek(date)) if(this.select_week == 1 && !this.isFirstDayOfWeek(date))
date = new Date(date.getFullYear(), date.getMonth(), (date.getDate() - date.getDay() + this.start_of_week), 12, 00); date = new Date(date.getFullYear(), date.getMonth(), (date.getDate() - date.getDay() + this.start_of_week), 12, 00);
if(this.isNewDateAllowed(date)){ if(this.isNewDateAllowed(date)){
this.selectedDate = date; this.selectedDate = date;
this.selectedDateString = this.dateToString(this.selectedDate); this.selectedDateString = this.dateToString(this.selectedDate);
@ -287,7 +287,7 @@ jdPicker.prototype = {
this.input.val(" "); this.input.val(" ");
} }
}, },
isNewDateAllowed: function(date){ isNewDateAllowed: function(date){
return ((!this.date_min) || this.daysBetween(this.date_min, date)>=0) && ((!this.date_max) || this.daysBetween(date, this.date_max)>=0); return ((!this.date_min) || this.daysBetween(this.date_min, date)>=0) && ((!this.date_max) || this.daysBetween(date, this.date_max)>=0);
}, },
@ -295,11 +295,11 @@ jdPicker.prototype = {
isHoliday: function(date){ isHoliday: function(date){
return ((this.indexFor(this.selectable_days, date.getDay())===false || this.indexFor(this.non_selectable, this.dateToString(date))!==false) || this.indexFor(this.rec_non_selectable, this.dateToShortString(date))!==false); return ((this.indexFor(this.selectable_days, date.getDay())===false || this.indexFor(this.non_selectable, this.dateToString(date))!==false) || this.indexFor(this.rec_non_selectable, this.dateToShortString(date))!==false);
}, },
changeInput: function(dateString) { changeInput: function(dateString) {
this.input.val(dateString).change(); this.input.val(dateString).change();
}, },
show: function() { show: function() {
$('.error_msg', this.rootLayers).css('display', 'none'); $('.error_msg', this.rootLayers).css('display', 'none');
this.rootLayers.slideDown("fast"); this.rootLayers.slideDown("fast");
@ -308,9 +308,9 @@ jdPicker.prototype = {
$(document.body).keydown(this.keydownHandler); $(document.body).keydown(this.keydownHandler);
this.setPosition(); this.setPosition();
this.orig_date = this.input.val() this.orig_date = this.input.val()
}, },
hide: function() { hide: function() {
if(this.input.context.type!="hidden"){ if(this.input.context.type!="hidden"){
this.rootLayers.slideUp("fast"); this.rootLayers.slideUp("fast");
@ -319,28 +319,28 @@ jdPicker.prototype = {
$(document.body).unbind("keydown", this.keydownHandler); $(document.body).unbind("keydown", this.keydownHandler);
} }
}, },
hideIfClickOutside: function(event) { hideIfClickOutside: function(event) {
if (event.target != this.input[0] && !this.insideSelector(event)) { if (event.target != this.input[0] && !this.insideSelector(event)) {
this.hide(); this.hide();
}; };
}, },
insideSelector: function(event) { insideSelector: function(event) {
var offset = this.dateSelector.position(); var offset = this.dateSelector.position();
offset.right = offset.left + this.dateSelector.outerWidth(); offset.right = offset.left + this.dateSelector.outerWidth();
offset.bottom = offset.top + this.dateSelector.outerHeight(); offset.bottom = offset.top + this.dateSelector.outerHeight();
return event.pageY < offset.bottom && return event.pageY < offset.bottom &&
event.pageY > offset.top && event.pageY > offset.top &&
event.pageX < offset.right && event.pageX < offset.right &&
event.pageX > offset.left; event.pageX > offset.left;
}, },
keydownHandler: function(event) { keydownHandler: function(event) {
switch (event.keyCode) switch (event.keyCode)
{ {
case 9: case 9:
this.hide() this.hide()
return; return;
break; break;
@ -388,10 +388,10 @@ jdPicker.prototype = {
} }
event.preventDefault(); event.preventDefault();
}, },
stringToDate: function(string) { stringToDate: function(string) {
var matches; var matches;
if (matches = string.match(this.reg)) { if (matches = string.match(this.reg)) {
if(matches[3]==0 && matches[2]==0 && matches[1]==0) if(matches[3]==0 && matches[2]==0 && matches[1]==0)
return null; return null;
@ -401,7 +401,7 @@ jdPicker.prototype = {
return null; return null;
}; };
}, },
dateToString: function(date) { dateToString: function(date) {
return eval(this.date_encode); return eval(this.date_encode);
}, },
@ -409,14 +409,14 @@ jdPicker.prototype = {
dateToShortString: function(date){ dateToShortString: function(date){
return eval(this.date_encode_s); return eval(this.date_encode_s);
}, },
setPosition: function() { setPosition: function() {
var offset = this.input.offset(); var offset = this.input.offset();
this.rootLayers.css({ this.rootLayers.css({
top: offset.top + this.input.outerHeight(), top: offset.top + this.input.outerHeight(),
left: offset.left left: offset.left
}); });
if (this.ieframe) { if (this.ieframe) {
this.ieframe.css({ this.ieframe.css({
width: this.dateSelector.outerWidth(), width: this.dateSelector.outerWidth(),
@ -424,12 +424,12 @@ jdPicker.prototype = {
}); });
}; };
}, },
moveDateBy: function(amount) { moveDateBy: function(amount) {
var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate() + amount); var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate() + amount);
this.selectDate(newDate); this.selectDate(newDate);
}, },
moveDateMonthBy: function(amount) { moveDateMonthBy: function(amount) {
var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth() + amount, this.selectedDate.getDate()); var newDate = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth() + amount, this.selectedDate.getDate());
if (newDate.getMonth() == this.selectedDate.getMonth() + amount + 1) { if (newDate.getMonth() == this.selectedDate.getMonth() + amount + 1) {
@ -437,7 +437,7 @@ jdPicker.prototype = {
}; };
this.selectDate(newDate); this.selectDate(newDate);
}, },
moveMonthBy: function(amount) { moveMonthBy: function(amount) {
if(amount<0) if(amount<0)
var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount+1, -1); var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount+1, -1);
@ -445,11 +445,11 @@ jdPicker.prototype = {
var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount, 1); var newMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + amount, 1);
this.selectMonth(newMonth); this.selectMonth(newMonth);
}, },
monthName: function(date) { monthName: function(date) {
return this.month_names[date.getMonth()]; return this.month_names[date.getMonth()];
}, },
getMonthSelect:function(){ getMonthSelect:function(){
var month_select = '<select>'; var month_select = '<select>';
for(var i = 0; i<this.month_names.length; i++){ for(var i = 0; i<this.month_names.length; i++){
@ -459,81 +459,81 @@ jdPicker.prototype = {
month_select += '<option value="'+(i)+'">'+this.month_names[i]+'</option>'; month_select += '<option value="'+(i)+'">'+this.month_names[i]+'</option>';
} }
month_select += '</select>'; month_select += '</select>';
return month_select; return month_select;
}, },
bindToObj: function(fn) { bindToObj: function(fn) {
var self = this; var self = this;
return function() { return fn.apply(self, arguments) }; return function() { return fn.apply(self, arguments) };
}, },
bindMethodsToObj: function() { bindMethodsToObj: function() {
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i++) {
this[arguments[i]] = this.bindToObj(this[arguments[i]]); this[arguments[i]] = this.bindToObj(this[arguments[i]]);
}; };
}, },
indexFor: function(array, value) { indexFor: function(array, value) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
if (value == array[i]) return i; if (value == array[i]) return i;
}; };
return false; return false;
}, },
monthNum: function(month_name) { monthNum: function(month_name) {
return this.indexFor(this.month_names, month_name); return this.indexFor(this.month_names, month_name);
}, },
shortMonthNum: function(month_name) { shortMonthNum: function(month_name) {
return this.indexFor(this.short_month_names, month_name); return this.indexFor(this.short_month_names, month_name);
}, },
shortDayNum: function(day_name) { shortDayNum: function(day_name) {
return this.indexFor(this.short_day_names, day_name); return this.indexFor(this.short_day_names, day_name);
}, },
daysBetween: function(start, end) { daysBetween: function(start, end) {
start = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate()); start = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());
end = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate()); end = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());
return (end - start) / 86400000; return (end - start) / 86400000;
}, },
changeDayTo: function(dayOfWeek, date, direction) { changeDayTo: function(dayOfWeek, date, direction) {
var difference = direction * (Math.abs(date.getDay() - dayOfWeek - (direction * 7)) % 7); var difference = direction * (Math.abs(date.getDay() - dayOfWeek - (direction * 7)) % 7);
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + difference); return new Date(date.getFullYear(), date.getMonth(), date.getDate() + difference);
}, },
rangeStart: function(date) { rangeStart: function(date) {
return this.changeDayTo(this.start_of_week, new Date(date.getFullYear(), date.getMonth()), -1); return this.changeDayTo(this.start_of_week, new Date(date.getFullYear(), date.getMonth()), -1);
}, },
rangeEnd: function(date) { rangeEnd: function(date) {
return this.changeDayTo((this.start_of_week - 1) % 7, new Date(date.getFullYear(), date.getMonth() + 1, 0), 1); return this.changeDayTo((this.start_of_week - 1) % 7, new Date(date.getFullYear(), date.getMonth() + 1, 0), 1);
}, },
isFirstDayOfWeek: function(date) { isFirstDayOfWeek: function(date) {
return date.getDay() == this.start_of_week; return date.getDay() == this.start_of_week;
}, },
getWeekNum:function(date){ getWeekNum:function(date){
date_week= new Date(date.getFullYear(), date.getMonth(), date.getDate()+6); date_week= new Date(date.getFullYear(), date.getMonth(), date.getDate()+6);
var firstDayOfYear = new Date(date_week.getFullYear(), 0, 1, 12, 00); var firstDayOfYear = new Date(date_week.getFullYear(), 0, 1, 12, 00);
var n = parseInt(this.daysBetween(firstDayOfYear, date_week)) + 1; var n = parseInt(this.daysBetween(firstDayOfYear, date_week)) + 1;
return Math.floor((date_week.getDay() + n + 5)/7) - Math.floor(date_week.getDay() / 5); return Math.floor((date_week.getDay() + n + 5)/7) - Math.floor(date_week.getDay() / 5);
}, },
isLastDayOfWeek: function(date) { isLastDayOfWeek: function(date) {
return date.getDay() == (this.start_of_week - 1) % 7; return date.getDay() == (this.start_of_week - 1) % 7;
}, },
show_error: function(error){ show_error: function(error){
$('.error_msg', this.rootLayers).html(error); $('.error_msg', this.rootLayers).html(error);
$('.error_msg', this.rootLayers).slideDown(400, function(){ $('.error_msg', this.rootLayers).slideDown(400, function(){
setTimeout("$('.error_msg', this.rootLayers).slideUp(200);", 2000); setTimeout("$('.error_msg', this.rootLayers).slideUp(200);", 2000);
}); });
}, },
adjustDays: function(days) { adjustDays: function(days) {
var newDays = []; var newDays = [];
for (var i = 0; i < days.length; i++) { for (var i = 0; i < days.length; i++) {
@ -541,12 +541,12 @@ jdPicker.prototype = {
}; };
return newDays; return newDays;
}, },
strpad: function(num){ strpad: function(num){
if(parseInt(num)<10) return "0"+parseInt(num); if(parseInt(num)<10) return "0"+parseInt(num);
else return parseInt(num); else return parseInt(num);
} }
}; };
$.fn.jdPicker = function(opts) { $.fn.jdPicker = function(opts) {
@ -557,6 +557,6 @@ $.jdPicker = { initialize: function(opts) {
} }; } };
return jdPicker; return jdPicker;
})(jQuery); })(jQuery);
$($.jdPicker.initialize); $($.jdPicker.initialize);

View file

@ -1,5 +1,5 @@
body { body {
margin: 0; margin: 0;
font-family: sans; font-family: sans;
} }
#searchbox { #searchbox {
@ -10,7 +10,7 @@ body {
#status { padding: 1.5em; } #status { padding: 1.5em; }
#found { float: left; } #found { float: left; }
#downloads { position: fixed; bottom: 2px; right: 7px; margin-left: 1em; } #downloads { position: fixed; bottom: 2px; right: 7px; margin-left: 1em; }
#downloads a { #downloads a {
border: 1px solid #aaa; border: 1px solid #aaa;
padding: 5px; padding: 5px;
background: #f8f8f8; background: #f8f8f8;
@ -27,7 +27,7 @@ body {
padding-bottom: 0.5em; padding-bottom: 0.5em;
padding-top: 1em; padding-top: 1em;
} }
.search-result-title, .search-result-ipath { .search-result-title, .search-result-ipath {
margin-bottom: 6px; margin-bottom: 6px;
font-weight: bold; font-weight: bold;
font-size: 12pt; font-size: 12pt;
@ -49,7 +49,7 @@ body {
} }
.search-result-number a { font-size: 10pt; font-weight: normal; color:#bbb; background: #f8f8f8; padding: 4px; } .search-result-number a { font-size: 10pt; font-weight: normal; color:#bbb; background: #f8f8f8; padding: 4px; }
.search-result-number a:hover { color:white; background: #ccc; } .search-result-number a:hover { color:white; background: #ccc; }
.search-result-snippet { .search-result-snippet {
margin-left: 1px; margin-left: 1px;
margin-top: 2px; margin-top: 2px;
font-size: 10pt; font-size: 10pt;
@ -79,8 +79,8 @@ form { margin: 0 }
input, select { input, select {
margin-top: 2px; margin-top: 2px;
margin-bottom: 2px; margin-bottom: 2px;
background: white; background: white;
border: 1px solid #999; border: 1px solid #999;
padding: 3px; padding: 3px;
width: 100%; width: 100%;
color: #555; color: #555;

View file

@ -17,10 +17,8 @@
<div id="results"> <div id="results">
%for i in range(0, len(res)): %for i in range(0, len(res)):
%d = res[i] %d = res[i]
<div class="search-result"> <div class="search-result">
<div class="search-result-number"><a href="#r{{d['sha']}}">#{{i+1}}</a> <div class="search-result-number"><a href="#r{{d['sha']}}">#{{i+1}}</a></div>
</div>
<div class="search-result-title" id="r{{d['sha']}}" title="{{d['abstract']}}"><a href="{{d['url']}}">{{d['label']}}</a></div> <div class="search-result-title" id="r{{d['sha']}}" title="{{d['abstract']}}"><a href="{{d['url']}}">{{d['label']}}</a></div>
%if len(d['ipath']) > 0: %if len(d['ipath']) > 0:
<div class="search-result-ipath">[{{d['ipath']}}]</div> <div class="search-result-ipath">[{{d['ipath']}}]</div>