Skip to content

Commit

Permalink
Preview: Finally fixed bug with short names on narrow devices
Browse files Browse the repository at this point in the history
Previously, a dumb CSS replacement was done to number the stations. Now
a short name is passed based on station ID which should be a lot more
understandable.
  • Loading branch information
salbahra committed Feb 16, 2014
1 parent 53dbed4 commit 14941d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 2 additions & 7 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,8 @@ a {
overflow: hidden;
text-overflow: clip;
}
div.timeline-groups-text:not(.skip-numbering):before {
content: "S" counter(station) " ";
white-space:pre;
counter-increment: station;
}
div.skip-numbering:before {
content: "M ";
div.timeline-groups-text:before {
content: attr(data-shortname) " ";
white-space:pre;
}
.ui-mini {
Expand Down
12 changes: 9 additions & 3 deletions js/main.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,14 @@ function get_preview() {
if ($.trim(items) == "") {
$("#timeline").html("<p align='center'><?php echo _('No stations set to run on this day.'); ?></p>")
} else {
empty = false
empty = false;
var data = eval("["+items.substring(0, items.length - 1)+"]");
var shortnames = [];
$.each(data, function(){
this.start = new Date(date[0],date[1]-1,date[2],0,0,this.start);
this.end = new Date(date[0],date[1]-1,date[2],0,0,this.end);
})
shortnames[this.group] = this.shortname;
});
var options = {
'width': '100%',
'editable': false,
Expand Down Expand Up @@ -907,7 +909,11 @@ function get_preview() {
var currRange = timeline.getVisibleChartRange();
if ((currRange.end.getTime() - currRange.start.getTime()) > 6000000) timeline.setVisibleChartRange(currRange.start,new Date(currRange.start.getTime()+6000000))
}
$("#timeline .timeline-groups-text:contains('<?php echo _('Master'); ?>')").addClass("skip-numbering")
$("#timeline .timeline-groups-text").each(function(a,b){
var stn = $(b);
var name = shortnames[stn.text()];
stn.attr("data-shortname",name);
})
$("#timeline-navigation").show()
}
$.mobile.loading("hide");
Expand Down
6 changes: 3 additions & 3 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ function run_sched($simseconds,$st_array,$pid_array,$et_array,$data,$simt) {
if($data["seq"]==1) {
time_to_text($sid,$st_array[$sid],$pid_array[$sid],$et_array[$sid],$data,$simt);
if(($data["mas"]>0)&&($data["mas"]!=$sid+1)&&($data["masop"][$sid>>3]&(1<<($sid%8))))
echo "{'start': ".($st_array[$sid]+$data["mton"]).",'end': ".($et_array[$sid]+$data["mtoff"]).",'content':'','className':'master','group':'"._("Master")."'},";
echo "{'start': ".($st_array[$sid]+$data["mton"]).",'end': ".($et_array[$sid]+$data["mtoff"]).",'content':'','className':'master','shortname':'M','group':'"._("Master")."'},";
$endtime=$et_array[$sid];
} else {
time_to_text($sid,$simseconds,$pid_array[$sid],$et_array[$sid],$data,$simt);
Expand All @@ -557,14 +557,14 @@ function run_sched($simseconds,$st_array,$pid_array,$et_array,$data,$simt) {
}
}
}
if($data["seq"]==0&&$data["mas"]>0) echo "{'start': ".$simseconds.",'end': ".$endtime.",'content':'','className':'master','group':'"._("Master")."'},";
if($data["seq"]==0&&$data["mas"]>0) echo "{'start': ".$simseconds.",'end': ".$endtime.",'content':'','className':'master','shortname':'M','group':'"._("Master")."'},";
return $endtime;
}

function time_to_text($sid,$start,$pid,$end,$data,$simt) {
$class = "program-".(($pid+3)%4);
if (($data["settings"]["rd"]!=0)&&($simt+$start+($data["settings"]["tz"]-48)*900<=$data["settings"]["rdst"])) $class="delayed";
echo "{'start': ".$start.",'end': ".$end.",'className':'".$class."','content':'P".$pid."','group':'".$data["stations"][$sid]."'},";
echo "{'start': ".$start.",'end': ".$end.",'className':'".$class."','content':'P".$pid."','shortname':'S".($sid+1)."','group':'".$data["stations"][$sid]."'},";
}

#Get OpenSprinkler options
Expand Down

0 comments on commit 14941d2

Please sign in to comment.