|
@@ -17,8 +17,6 @@
|
17
|
17
|
* along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
|
18
|
18
|
*/
|
19
|
19
|
|
20
|
|
-// @flow
|
21
|
|
-
|
22
|
20
|
import * as React from 'react';
|
23
|
21
|
import {StackNavigationProp} from '@react-navigation/stack';
|
24
|
22
|
import WebViewScreen from '../../components/Screens/WebViewScreen';
|
|
@@ -26,21 +24,24 @@ import AvailableWebsites from '../../constants/AvailableWebsites';
|
26
|
24
|
import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
|
27
|
25
|
|
28
|
26
|
type PropsType = {
|
29
|
|
- navigation: StackNavigationProp,
|
30
|
|
- route: {params: {host: string, path: string | null, title: string}},
|
|
27
|
+ navigation: StackNavigationProp<any>;
|
|
28
|
+ route: {params: {host: string; path: string | null; title: string}};
|
31
|
29
|
};
|
32
|
30
|
|
33
|
|
-const ENABLE_MOBILE_STRING = `<meta name="viewport" content="width=device-width, initial-scale=1.0">`;
|
|
31
|
+const ENABLE_MOBILE_STRING =
|
|
32
|
+ '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
|
34
|
33
|
|
35
|
|
-const AVAILABLE_ROOMS_STYLE = `<style>body,body>.container2{padding-top:0;width:100%}b,body>.container2>h1,body>.container2>h3,br,header{display:none}.table-bordered td,.table-bordered th{border:none;border-right:1px solid #dee2e6;border-bottom:1px solid #dee2e6}.table{padding:0;margin:0;width:200%;max-width:200%;display:block}tbody{display:block;width:100%}thead{display:block;width:100%}.table tbody tr,tbody tr[bgcolor],thead tr{width:100%;display:inline-flex}.table tbody td,.table thead td[colspan]{padding:0;flex:1;height:50px;margin:0}.table tbody td[bgcolor=white],.table thead td,.table>tbody>tr>td:nth-child(1){flex:0 0 150px;height:50px}</style>`;
|
36
|
|
-const BIB_STYLE = `<style>.hero-unit,.navbar,footer{display:none}.hero-unit-form,.hero-unit2,.hero-unit3{background-color:#fff;box-shadow:none;padding:0;margin:0}.hero-unit-form h4{font-size:2rem;line-height:2rem}.btn{font-size:1.5rem;line-height:1.5rem;padding:20px}.btn-danger{background-image:none;background-color:#be1522}.table{font-size:.8rem}.table td{padding:0;height:18.2333px;border:none;border-bottom:1px solid #c1c1c1}.table td[style="max-width:55px;"]{max-width:110px!important}.table-bordered{min-width:50px}th{height:50px}.table-bordered{border-collapse:collapse}</style>`;
|
|
34
|
+const AVAILABLE_ROOMS_STYLE =
|
|
35
|
+ '<style>body,body>.container2{padding-top:0;width:100%}b,body>.container2>h1,body>.container2>h3,br,header{display:none}.table-bordered td,.table-bordered th{border:none;border-right:1px solid #dee2e6;border-bottom:1px solid #dee2e6}.table{padding:0;margin:0;width:200%;max-width:200%;display:block}tbody{display:block;width:100%}thead{display:block;width:100%}.table tbody tr,tbody tr[bgcolor],thead tr{width:100%;display:inline-flex}.table tbody td,.table thead td[colspan]{padding:0;flex:1;height:50px;margin:0}.table tbody td[bgcolor=white],.table thead td,.table>tbody>tr>td:nth-child(1){flex:0 0 150px;height:50px}</style>';
|
|
36
|
+const BIB_STYLE =
|
|
37
|
+ '<style>.hero-unit,.navbar,footer{display:none}.hero-unit-form,.hero-unit2,.hero-unit3{background-color:#fff;box-shadow:none;padding:0;margin:0}.hero-unit-form h4{font-size:2rem;line-height:2rem}.btn{font-size:1.5rem;line-height:1.5rem;padding:20px}.btn-danger{background-image:none;background-color:#be1522}.table{font-size:.8rem}.table td{padding:0;height:18.2333px;border:none;border-bottom:1px solid #c1c1c1}.table td[style="max-width:55px;"]{max-width:110px!important}.table-bordered{min-width:50px}th{height:50px}.table-bordered{border-collapse:collapse}</style>';
|
37
|
38
|
|
38
|
39
|
const BIB_BACK_BUTTON =
|
39
|
|
- `<div style='width: 100%; display: flex'>` +
|
|
40
|
+ "<div style='width: 100%; display: flex'>" +
|
40
|
41
|
`<a style='margin: auto' href='${AvailableWebsites.websites.BIB}'>` +
|
41
|
|
- `<button id='customBackButton' class='btn btn-primary'>Retour</button>` +
|
42
|
|
- `</a>` +
|
43
|
|
- `</div>`;
|
|
42
|
+ "<button id='customBackButton' class='btn btn-primary'>Retour</button>" +
|
|
43
|
+ '</a>' +
|
|
44
|
+ '</div>';
|
44
|
45
|
|
45
|
46
|
class WebsiteScreen extends React.Component<PropsType> {
|
46
|
47
|
fullUrl: string;
|
|
@@ -53,6 +54,8 @@ class WebsiteScreen extends React.Component<PropsType> {
|
53
|
54
|
|
54
|
55
|
constructor(props: PropsType) {
|
55
|
56
|
super(props);
|
|
57
|
+ this.fullUrl = '';
|
|
58
|
+ this.host = '';
|
56
|
59
|
props.navigation.addListener('focus', this.onScreenFocus);
|
57
|
60
|
this.injectedJS = {};
|
58
|
61
|
this.customPaddingFunctions = {};
|
|
@@ -63,7 +66,7 @@ class WebsiteScreen extends React.Component<PropsType> {
|
63
|
66
|
this.injectedJS[AvailableWebsites.websites.BIB] =
|
64
|
67
|
`document.querySelector('head').innerHTML += '${ENABLE_MOBILE_STRING}';` +
|
65
|
68
|
`document.querySelector('head').innerHTML += '${BIB_STYLE}';` +
|
66
|
|
- `if ($(".hero-unit-form").length > 0 && $("#customBackButton").length === 0)` +
|
|
69
|
+ 'if ($(".hero-unit-form").length > 0 && $("#customBackButton").length === 0)' +
|
67
|
70
|
`$(".hero-unit-form").append("${BIB_BACK_BUTTON}");true;`;
|
68
|
71
|
|
69
|
72
|
this.customPaddingFunctions[AvailableWebsites.websites.BLUEMIND] = (
|
|
@@ -72,7 +75,7 @@ class WebsiteScreen extends React.Component<PropsType> {
|
72
|
75
|
return (
|
73
|
76
|
`$('head').append('${ENABLE_MOBILE_STRING}');` +
|
74
|
77
|
`$('.minwidth').css('top', ${padding}` +
|
75
|
|
- `$('#mailview-bottom').css('min-height', 500);`
|
|
78
|
+ "$('#mailview-bottom').css('min-height', 500);"
|
76
|
79
|
);
|
77
|
80
|
};
|
78
|
81
|
this.customPaddingFunctions[AvailableWebsites.websites.WIKETUD] = (
|
|
@@ -103,20 +106,26 @@ class WebsiteScreen extends React.Component<PropsType> {
|
103
|
106
|
if (this.host != null && path != null) {
|
104
|
107
|
path = path.replace(this.host, '');
|
105
|
108
|
this.fullUrl = this.host + path;
|
106
|
|
- } else this.fullUrl = this.host;
|
|
109
|
+ } else {
|
|
110
|
+ this.fullUrl = this.host;
|
|
111
|
+ }
|
107
|
112
|
|
108
|
|
- if (title != null) navigation.setOptions({title});
|
|
113
|
+ if (title != null) {
|
|
114
|
+ navigation.setOptions({title});
|
|
115
|
+ }
|
109
|
116
|
}
|
110
|
117
|
}
|
111
|
118
|
|
112
|
|
- render(): React.Node {
|
|
119
|
+ render() {
|
113
|
120
|
const {navigation} = this.props;
|
114
|
121
|
let injectedJavascript = '';
|
115
|
122
|
let customPadding = null;
|
116
|
|
- if (this.host != null && this.injectedJS[this.host] != null)
|
|
123
|
+ if (this.host != null && this.injectedJS[this.host] != null) {
|
117
|
124
|
injectedJavascript = this.injectedJS[this.host];
|
118
|
|
- if (this.host != null && this.customPaddingFunctions[this.host] != null)
|
|
125
|
+ }
|
|
126
|
+ if (this.host != null && this.customPaddingFunctions[this.host] != null) {
|
119
|
127
|
customPadding = this.customPaddingFunctions[this.host];
|
|
128
|
+ }
|
120
|
129
|
|
121
|
130
|
if (this.fullUrl != null) {
|
122
|
131
|
return (
|