Merge branch 'develop' of 86.50.143.68:vtmk/web2.0 into develop
This commit is contained in:
@@ -44,10 +44,8 @@ app.service("InstanceList", ["$http", function($http){
|
||||
});
|
||||
}
|
||||
this.createRotation = function(name) {
|
||||
data = {'name': name}
|
||||
console.log(name)
|
||||
$http.post("/infoscreen/create_rotation", data).then(function(response) {
|
||||
});
|
||||
var data = {'name': name}
|
||||
$http.post("/infoscreen/create_rotation", data);
|
||||
}
|
||||
this.deleteRotation = function(id) {
|
||||
$http.delete("/infoscreen/delete_rotation/" + id).then(function(response) {
|
||||
@@ -145,7 +143,6 @@ app.controller('infoadmin_hslitem_create', function($scope, $http,ItemList){
|
||||
|
||||
app.controller('infoadmin_image_create', ['$scope', 'Upload', '$timeout',"ItemList", function ($scope, Upload, $timeout,ItemList) {
|
||||
$scope.send = function(file) {
|
||||
console.log("name: "+$scope.imagename);
|
||||
file.upload = Upload.upload({
|
||||
url: '/infoscreen/create_image',
|
||||
data: {name: $scope.imagename, image: file},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
var activescope;
|
||||
var app = angular.module('infoApp', ['ngAnimate', 'ngRoute', 'monospaced.qrcode']);
|
||||
app.controller('infoscreen_main', function($scope,$http,$timeout){
|
||||
var templates = [];
|
||||
@@ -30,7 +29,7 @@ app.controller('infoscreen_main', function($scope,$http,$timeout){
|
||||
$scope.active = {
|
||||
template: temp.item.template_url,
|
||||
onload: function(){
|
||||
for (key in temp.item.options){
|
||||
for (var key in temp.item.options){
|
||||
$scope[key] = temp.item.options[key]
|
||||
}
|
||||
}
|
||||
@@ -92,67 +91,76 @@ app.controller('timetableCtrl',
|
||||
objects=data['data'];
|
||||
for(var objectIndex in objects){
|
||||
var stop = objects[objectIndex];
|
||||
for(var lineIndex in stop['lines']){
|
||||
|
||||
var lineIndex;
|
||||
for (lineIndex in stop['lines']){
|
||||
var elem=stop['lines'][lineIndex].split(":");
|
||||
dict[elem[0]]=elem[1];
|
||||
}
|
||||
for(var lineIndex in stop['departures']){
|
||||
for (lineIndex in stop['departures']){
|
||||
var line = stop['departures'][lineIndex];
|
||||
var time=line['time'];
|
||||
date=line['date'];
|
||||
var hours= Math.floor(line['time']/100);
|
||||
if(hours>=24){
|
||||
hours-=24;
|
||||
var time = line['time'];
|
||||
var date = line['date'];
|
||||
var hours = Math.floor(line['time'] / 100);
|
||||
var minutes = line['time'] % 100;
|
||||
if (hours >= 24) {
|
||||
hours -= 24;
|
||||
date++;
|
||||
}
|
||||
var minutes= line['time']%100;
|
||||
var code= line['code'].substring(1,5);
|
||||
if(code.charAt(0)=='0')
|
||||
code=code.substring(1,4);
|
||||
temp={"stop":stop['name'].split(",")[0],
|
||||
"dist":stop['dist'],
|
||||
"bus":code,
|
||||
"date":date,
|
||||
"time":pad(hours,2)+":"+pad(minutes,2),
|
||||
"laststop":dict[line['code']].split(",")[0].split(" l.")[0], //
|
||||
"hurry":false
|
||||
};
|
||||
//We don't want busses to Otaniemi
|
||||
if(temp['laststop']=='Otaniemi')
|
||||
break;
|
||||
if(temp['stop']=='Alvar Aallon puisto')
|
||||
temp['stop']="A. A. puisto"
|
||||
var trigger=true;
|
||||
for(var objIndex= $scope.arr.length-1;objIndex>=0;objIndex--){
|
||||
var temp2 = $scope.arr[objIndex];
|
||||
if( temp2['bus']==temp['bus'] && temp2['laststop']==temp['laststop']){
|
||||
if( temp2['dist']==temp['dist']){
|
||||
break;
|
||||
}
|
||||
else if( temp2['dist'] > temp['dist']){
|
||||
$scope.arr.splice(objIndex,1);
|
||||
}
|
||||
else
|
||||
trigger=false;
|
||||
}
|
||||
}
|
||||
if(trigger){
|
||||
$scope.arr.push(temp);
|
||||
var code = line['code'].substring(1, 5);
|
||||
if (code.charAt(0) == '0') {
|
||||
code = code.substring(1,4);
|
||||
}
|
||||
|
||||
var departure = {
|
||||
"stop": stop['name'].split(",")[0],
|
||||
"dist": stop['dist'],
|
||||
"bus": code,
|
||||
"date": date,
|
||||
"time": pad(hours, 2) + ":" + pad(minutes, 2),
|
||||
"laststop": dict[line['code']].split(",")[0].split(" l.")[0],
|
||||
"hurry": false
|
||||
};
|
||||
if(departure['laststop']=='Otaniemi')
|
||||
break;
|
||||
if(departure['stop']=='Alvar Aallon puisto')
|
||||
departure['stop']="A. A. puisto"
|
||||
var trigger = true;
|
||||
for (var arrIndex = $scope.arr.length - 1; arrIndex >= 0; arrIndex--) {
|
||||
if ($scope.arr[arrIndex]['bus'] == departure['bus'] &&
|
||||
$scope.arr[arrIndex]['laststop'] == departure['laststop']) {
|
||||
|
||||
if ($scope.arr[arrIndex]['dist'] == departure['dist']){
|
||||
break;
|
||||
}
|
||||
else if ($scope.arr[arrIndex]['dist'] > departure['dist']){
|
||||
$scope.arr.splice(arrIndex, 1);
|
||||
}
|
||||
else {
|
||||
trigger = false;
|
||||
}
|
||||
}
|
||||
if (trigger) {
|
||||
$scope.arr.push(departure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pad(num, size) {
|
||||
var s = num+"";
|
||||
while (s.length < size) s = "0" + s;
|
||||
var s = num + "";
|
||||
while (s.length < size) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
delOld();
|
||||
}
|
||||
function delOld(){
|
||||
tooSoon = typeof($scope.departureThreshold) != 'undefined' ? $scope.departureThreshold: 0;
|
||||
hurry = typeof($scope.hurryThreshold) != 'undefined' ? $scope.hurryThreshold : 0;
|
||||
f= new Date();
|
||||
var tooSoon = typeof($scope.departureThreshold) != 'undefined' ? $scope.departureThreshold: 0;
|
||||
var hurry = typeof($scope.hurryThreshold) != 'undefined' ? $scope.hurryThreshold : 0;
|
||||
f = new Date();
|
||||
for(var a=$scope.arr.length-1; a>=0; a--){
|
||||
var time=$scope.arr[a]['time'].split(":");
|
||||
date=$scope.arr[a]['date'].toString();
|
||||
@@ -161,11 +169,12 @@ app.controller('timetableCtrl',
|
||||
d.setHours(time[0]);
|
||||
d.setMinutes(time[1]);
|
||||
var diff=(d.getTime()-f.getTime());
|
||||
if(diff < tooSoon*60000)
|
||||
if(diff < tooSoon*60000) {
|
||||
$scope.arr.splice(a,1);
|
||||
else if(diff < hurry*60000)
|
||||
}
|
||||
else if (diff < hurry*60000) {
|
||||
$scope.arr[a]['hurry']=true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user