mirror of
https://github.com/Threnklyn/myBahn.git
synced 2026-05-18 12:13:30 +02:00
Version 1.1
- Status-Bar - Detaildarstellung für PTR angepasst
This commit is contained in:
+1
-1
@@ -109,5 +109,5 @@
|
||||
"watchface": false
|
||||
}
|
||||
},
|
||||
"version": "1.0.0"
|
||||
"version": "1.1.0"
|
||||
}
|
||||
|
||||
+15
-15
@@ -157,44 +157,44 @@ bool BahnInterface_handle_app_message(DictionaryIterator *iter, void *context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int prv_combine_product_code(AllowedProducts* p1, AllowedProducts* p2) {
|
||||
static int prv_get_product_code(AllowedProducts* p) {
|
||||
if (p->allow_all) {
|
||||
return 1023;
|
||||
}
|
||||
int result = 0;
|
||||
if (p1->ice || p2->ice || p1->allow_all || p2->allow_all) {
|
||||
if (p->ice) {
|
||||
result +=1;
|
||||
}
|
||||
if (p1->ic || p2->ic || p1->allow_all || p2->allow_all) {
|
||||
if (p->ic) {
|
||||
result +=2;
|
||||
}
|
||||
if (p1->ir || p2->ir || p1->allow_all || p2->allow_all) {
|
||||
if (p->ir) {
|
||||
result +=4;
|
||||
}
|
||||
if (p1->zug || p2->zug || p1->allow_all || p2->allow_all) {
|
||||
if (p->zug) {
|
||||
result +=8;
|
||||
}
|
||||
if (p1->sbahn || p2->sbahn || p1->allow_all || p2->allow_all) {
|
||||
if (p->sbahn) {
|
||||
result +=16;
|
||||
}
|
||||
if (p1->bus || p2->bus || p1->allow_all || p2->allow_all) {
|
||||
if (p->bus) {
|
||||
result +=32;
|
||||
}
|
||||
if (p1->schiff || p2->schiff || p1->allow_all || p2->allow_all) {
|
||||
if (p->schiff) {
|
||||
result +=64;
|
||||
}
|
||||
if (p1->ubahn || p2->ubahn || p1->allow_all || p2->allow_all) {
|
||||
if (p->ubahn) {
|
||||
result +=128;
|
||||
}
|
||||
if (p1->tram || p2->tram || p1->allow_all || p2->allow_all) {
|
||||
if (p->tram) {
|
||||
result +=256;
|
||||
}
|
||||
if (p1->ast || p2->ast || p1->allow_all || p2->allow_all) {
|
||||
if (p->ast) {
|
||||
result +=512;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int prv_get_product_code(AllowedProducts* products) {
|
||||
return prv_combine_product_code(products, products);
|
||||
}
|
||||
|
||||
int get_products_for_connection(int valid_connection_index) {
|
||||
return prv_get_product_code(MyBahnSettings_get_allowed_products_for_connection(valid_connection_index));
|
||||
@@ -205,7 +205,7 @@ int get_products_for_station_to_station(int from_station_index, int to_station_i
|
||||
StationConfig* s2 = MyBahnSettings_get_valid_station(to_station_index);
|
||||
AllowedProducts* p1 = s1->use_default_products ? MyBahnSettings_get_default_products() : &s1->allowed_products;
|
||||
AllowedProducts* p2 = s2->use_default_products ? MyBahnSettings_get_default_products() : &s2->allowed_products;
|
||||
return prv_combine_product_code(p1, p2);
|
||||
return prv_get_product_code(p1) | prv_get_product_code(p2);
|
||||
}
|
||||
|
||||
void BahnInterface_init() {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#define CONNECTION_RESULT_TITLE_LENGTH 20
|
||||
#define CONNECTION_RESULT_SUBTITLE_LENGTH 25
|
||||
#define CONNECTION_RESULT_DETAIL_LINK_LENGTH 172
|
||||
#define CONNECTION_DETAILS_LENGTH 1024
|
||||
#define CONNECTION_RESULT_DETAIL_LINK_LENGTH 128
|
||||
#define CONNECTION_DETAILS_LENGTH 768
|
||||
#define MAX_CONNECTION_RESULTS 20
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "resources.h"
|
||||
#include "mybahn_settings.h"
|
||||
|
||||
// #define CREATE_DUMMY_SETTINGS
|
||||
//#define CREATE_DUMMY_SETTINGS
|
||||
static MyBahnSettings settings;
|
||||
|
||||
static void prv_validate_station(StationConfig* station) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ GRect computeEffectiveWindowBounds(Window* window, StatusBarLayer* status_bar_la
|
||||
}
|
||||
|
||||
StatusBarLayer* addStatusBar(Window* window) {
|
||||
return NULL;
|
||||
//return NULL;
|
||||
StatusBarLayer* status_bar = status_bar_layer_create();
|
||||
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var baseUrl = 'http://mobil.bahn.de/bin/query.exe/dox?start=1&rt=1';
|
||||
var detailsUrlBase = 'http://reiseauskunft.bahn.de/bin/query2.exe/dox?';
|
||||
|
||||
function xhrRequest(url, type, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
@@ -62,7 +63,7 @@ function extractConnectionResultInfos(text) {
|
||||
|
||||
var frueherLink = text.match(frueherExp);
|
||||
if (frueherLink) {
|
||||
frueherLink = frueherLink[1].replace(ampExp, "&");
|
||||
frueherLink = frueherLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
|
||||
results.push({moreLink: frueherLink, earlier: true});
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ function extractConnectionResultInfos(text) {
|
||||
|
||||
var detailLink = connectionInfo.match(detailLinkExp);
|
||||
if (detailLink) {
|
||||
result.detailLink = detailLink[1].replace(ampExp, "&");
|
||||
result.detailLink = detailLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
|
||||
}
|
||||
|
||||
zeitExp.lastIndex = 0;
|
||||
@@ -124,7 +125,7 @@ function extractConnectionResultInfos(text) {
|
||||
|
||||
var spaeterLink = text.match(spaeterExp);
|
||||
if (spaeterLink) {
|
||||
spaeterLink = spaeterLink[1].replace(ampExp, "&");
|
||||
spaeterLink = spaeterLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
|
||||
results.push({moreLink: spaeterLink, later: true});
|
||||
}
|
||||
return results;
|
||||
@@ -244,6 +245,9 @@ function extractHimDetails(himDetailsUrl) {
|
||||
}
|
||||
|
||||
function getConnectionsFromUrl(url, resultCallback) {
|
||||
if (url.substring(0, 4) != 'http') {
|
||||
url = detailsUrlBase + url;
|
||||
}
|
||||
xhrRequest(url, 'GET', function(responseText) {
|
||||
var results = extractConnectionResultInfos(responseText);
|
||||
resultCallback(results);
|
||||
@@ -260,7 +264,7 @@ function getConnections(startKey, zielKey, journeyProducts, resultCallback) {
|
||||
}
|
||||
|
||||
function getConnectionDetailInfos(detailLink, resultCallback) {
|
||||
xhrRequest(detailLink, 'GET', function(responseText){
|
||||
xhrRequest(detailsUrlBase + detailLink, 'GET', function(responseText){
|
||||
var result = extractConnectionDetailInfos(responseText);
|
||||
resultCallback(result);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user