Skip to content

Commit c4c26bc

Browse files
committed
added isTiny URL parameter; fixed some bugs
tiny mode does not do anything yet but prevent browser pop-ups
1 parent 5ec422c commit c4c26bc

File tree

10 files changed

+84
-32
lines changed

10 files changed

+84
-32
lines changed

www/scripts/sepiaFW.account.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,11 @@ function sepiaFW_build_account(){
570570
$("#sepiaFW-main-window").removeClass("sepiaFW-translucent-10");
571571
}
572572
}
573+
Account.isLoginBoxOpen = function(){
574+
var box = document.getElementById("sepiaFW-login-box");
575+
if (box && box.style.display != 'none') return true;
576+
else return false;
577+
}
573578

574579
//Logout action e.g. for button
575580
Account.logoutAction = function(logoutAll){

www/scripts/sepiaFW.assistant.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,30 @@ function sepiaFW_build_assistant(){
214214
Assistant.isWaitingForDialog = false;
215215
broadcastDialogFinished(true);
216216
}
217+
218+
//------------------ SOME METHODS TO ENGAGE USER ------------------
219+
220+
/**
221+
* Wait for the right opportunity (e.g. idle time) and let the assistant say a text
222+
* loaded from server.
223+
*/
224+
Assistant.waitForOpportunityAndSay = function(dialogTagOrText, fallbackAction, minWait, maxWait){
225+
if (!minWait) minWait = 2000;
226+
if (!maxWait) maxWait = 30000;
227+
if (!dialogTagOrText) dialogTagOrText = "<error_client_control_0a>";
228+
SepiaFW.client.queueIdleTimeEvent(function(){
229+
var options = {}; //things like skipTTS etc. (see sendCommand function)
230+
var dataset = {
231+
info: "direct_cmd",
232+
cmd: "chat;;reply=" + dialogTagOrText + ";;",
233+
newReceiver: SepiaFW.assistant.id
234+
};
235+
SepiaFW.client.sendCommand(dataset, options);
236+
}, minWait, maxWait, function(){
237+
//Fallback, e.g.: SepiaFW.ui.showInfo(SepiaFW.local.g('no_client_support'));
238+
if (fallbackAction) fallbackAction();
239+
});
240+
}
217241

218242
//------------------- SOME BASIC COMMUNICATION METHODS ---------------------
219243

www/scripts/sepiaFW.client.controls.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,12 @@ function sepiaFW_build_client_controls(){
121121
}
122122

123123
//Feedback (to server and user ... server just loads a chat message in this case, but one could send real data back)
124-
SepiaFW.client.queueIdleTimeEvent(function(){
125-
var options = {}; //things like skipTTS etc. (see sendCommand function)
126-
var dataset = {
127-
info: "direct_cmd",
128-
cmd: "chat;;reply=<error_client_control_0a>;;",
129-
newReceiver: SepiaFW.assistant.id
130-
};
131-
SepiaFW.client.sendCommand(dataset, options);
132-
}, 2000, 30000, function(){
133-
//Fallback:
134-
SepiaFW.ui.showInfo(SepiaFW.local.g('mesh_node_fail'));
135-
});
124+
if (SepiaFW.assistant){
125+
SepiaFW.assistant.waitForOpportunityAndSay("<error_client_control_0a>", function(){
126+
//Fallback after max-wait:
127+
SepiaFW.ui.showInfo(SepiaFW.local.g('mesh_node_fail'));
128+
}, 2000, 30000); //min-wait, max-wait
129+
}
136130
});
137131
return true;
138132
}

www/scripts/sepiaFW.local.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function sepiaFW_build_strings(){
9393
StringsDE.way_home = 'Weg nach Hause';
9494
//More errors
9595
StringsDE.mesh_node_fail = 'Sorry, die Mesh-Node Funktion zeigte einen Fehler.';
96+
StringsDE.no_client_support = 'Sorry, aber diese Version der App unterstütz die aufgerufene Aktion nicht.';
9697
//Offline demo texts
9798
StringsDE.demoMode = 'Du befindest dich im Demo-Modus! In diesem Modus kannst du die Einstellungen ändern (z.B. hostname), das Tutorial anschauen und mit manchen(!) Teilen des Interfaces spielen. Um auf deinen Assistenten zuzugreifen melde dich bitte zuerst an.';
9899
StringsDE.notPossibleInDemoMode = 'Sorry aber das geht noch nicht im Demo-Modus.';
@@ -188,6 +189,7 @@ function sepiaFW_build_strings(){
188189
StringsEN.way_home = 'Way home';
189190
//More errors
190191
StringsEN.mesh_node_fail = 'Sorry, the Mesh-Node function showed an error.';
192+
StringsEN.no_client_support = 'Sorry, but this version of the app does not support the requested action.';
191193
//Offline demo texts
192194
StringsEN.demoMode = 'You are in demo-mode! This mode only allows you to change settings (e.g. hostname), check out the tutorial and play with some(!) parts of the UI. To get access to your assistant please log-in first.';
193195
StringsEN.notPossibleInDemoMode = 'Sorry this is not yet possible in demo-mode.';

www/scripts/sepiaFW.ui.actions.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,16 @@ function sepiaFW_build_ui_actions(){
150150
}
151151
var inAppBrowserOptions = 'location=yes,toolbar=yes,mediaPlaybackRequiresUserAction=yes,allowInlineMediaPlayback=yes,hardwareback=yes,disableswipenavigation=no,clearsessioncache=no,clearcache=no';
152152
Actions.openUrlAutoTarget = function(url, forceExternal){
153-
if (SepiaFW.ui.isCordova){
153+
if (SepiaFW.ui.isTinyApp){
154+
//Tiny app usually has no ability to open in-app browser
155+
if (SepiaFW.assistant){
156+
SepiaFW.assistant.waitForOpportunityAndSay("<error_client_support_0a>", function(){
157+
//Fallback after max-wait:
158+
SepiaFW.ui.showInfo(SepiaFW.local.g('no_client_support'));
159+
}, 2000, 30000); //min-wait, max-wait
160+
}
161+
162+
}else if (SepiaFW.ui.isCordova){
154163
if (forceExternal
155164
|| url.indexOf('https://maps.') === 0 || url.indexOf('http://maps.') === 0
156165
|| url.indexOf('https://www.google.com/maps/') === 0 || url.indexOf('https://www.google.de/maps/') === 0

www/scripts/sepiaFW.ui.build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function sepiaFW_build_ui_build(){
178178
});
179179
}
180180
//label button - note: for label content see ui.setLable/getLabel functions
181-
var sepiaLabel = document.getElementById("sepiaFW-nav-label");
181+
var sepiaLabel = document.getElementById("sepiaFW-nav-label-box");
182182
if (sepiaLabel){
183183
$(sepiaLabel).off();
184184
SepiaFW.ui.longPressShortPressDoubleTap(sepiaLabel, function(){

www/scripts/sepiaFW.ui.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ function sepiaFW_build_ui(){
373373
}
374374

375375
//is standalone app?
376-
UI.isStandaloneWebApp = isStandaloneWebApp();
377376
function isStandaloneWebApp(){
378377
if (UI.isCordova){
379378
isStandalone = true;
@@ -391,6 +390,20 @@ function sepiaFW_build_ui(){
391390
}
392391
return isStandalone;
393392
}
393+
UI.isStandaloneWebApp = isStandaloneWebApp();
394+
395+
//is tiny app?
396+
function isTinyApp(){
397+
var urlParam = SepiaFW.tools.getURLParameter("isTiny");
398+
if (urlParam && urlParam == "true"){
399+
urlParam = true;
400+
}
401+
if (urlParam){
402+
document.documentElement.className += " sepiaFW-tiny-app";
403+
}
404+
return urlParam;
405+
}
406+
UI.isTinyApp = isTinyApp();
394407

395408
//client
396409
SepiaFW.config.setClientInfo(((UI.isIOS)? 'iOS_' : '')
@@ -780,13 +793,13 @@ function sepiaFW_build_ui(){
780793
SepiaFW.debug.info('UI.listenToVisibilityChange: ' + document[visibility]);
781794

782795
//became visible
783-
//if (SepiaFW.client.isActive()){
796+
if (!SepiaFW.account || !SepiaFW.account.isLoginBoxOpen()){ //SepiaFW.client.isActive()
784797
if (!isFirstVisibilityChange && (UI.isVisible() || forceTriggerVisible)){
785798
//update myView (is automatically skipped if called too early)
786799
UI.updateMyView(false, true, 'visibilityChange');
787800
}
788801
isFirstVisibilityChange = false;
789-
//}
802+
}
790803
}
791804
//broadcaster for myView show
792805
var isFirstMyViewShow = true;

www/scripts/sepiaFW.wakeTriggers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function sepiaFW_build_wake_triggers() {
4343
}
4444

4545
//start setup?
46-
if (WakeTriggers.autoLoadWakeWord){
46+
if (WakeTriggers.autoLoadWakeWord){ //TODO: move to Client.onActive ?
4747
WakeTriggers.setupWakeWords();
4848
}
4949
}

www/scripts/sepiaFW.webSocket.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,15 @@ function sepiaFW_build_webSocket_client(){
843843
if (SepiaFW.ui.isCordova){
844844
$(inAppBrowserBtn).off();
845845
$(inAppBrowserBtn).on("click", function () {
846-
var inAppBrowserOptions = 'location=yes,toolbar=yes,mediaPlaybackRequiresUserAction=yes,allowInlineMediaPlayback=yes,hardwareback=yes,disableswipenavigation=no,clearsessioncache=no,clearcache=no';
847-
cordova.InAppBrowser.open("<inappbrowser-last>", '_blank', inAppBrowserOptions); //also valid: <inappbrowser-home>
846+
SepiaFW.ui.actions.openUrlAutoTarget("<inappbrowser-last>"); //also valid: <inappbrowser-home>
848847
closeControlsMenueWithDelay();
849848
});
850849
}else{
851850
$(inAppBrowserBtn).hide();
852-
/*
853851
$(inAppBrowserBtn).on("click", function () {
854-
window.open("search.html", '_blank');
852+
SepiaFW.ui.actions.openUrlAutoTarget("search.html");
855853
closeControlsMenueWithDelay();
856854
});
857-
*/
858855
}
859856
}
860857
}

www/search.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>SepiaFW Search</title>
88
<meta name="application-name" content="SepiaFW Search"/>
99
<meta name="description" content="SepiaFW plain search page">
10-
<meta name="theme-color" content="#007AFF">
10+
<meta name="theme-color" content="#beff1a">
1111
<!--<link rel="icon" sizes="192x192" href="img/icon.png">
1212
<link rel="apple-touch-icon" href="img/icon.png">
1313
<meta property="og:image" content="img/icon.png"/>-->
@@ -58,17 +58,24 @@
5858
margin: auto;
5959
}
6060
.labelBlock {
61+
height: 100%;
62+
width: 100%;
63+
display: flex;
64+
align-content: center;
65+
align-items: flex-end;
66+
justify-content: center;
67+
overflow: hidden;
6168
}
6269
.labelBlock label {
6370
font-size: 32px;
6471
font-weight: 300;
65-
/*color: #ceff1a;*/
72+
color: #beff1a;
6673
/*color: #15abc3;*/
67-
color: #007AFF;
74+
/*color: #007AFF;*/
6875
}
6976
.inputBlock {
7077
background: #fff;
71-
border: 1px solid #007AFF;
78+
border: 1px solid #beff1a;
7279
border-radius: 3px;
7380
overflow: hidden
7481
}
@@ -88,11 +95,11 @@
8895
.buttonBlock button {
8996
border: 0;
9097
border-radius: 3px;
91-
/*background: #ceff1a;*/
98+
background: #beff1a;
9299
/*background: #15abc3;*/
93-
background: #007AFF;
94-
color: #fff;
95-
/*color: #000;*/
100+
/*background: #007AFF;*/
101+
/*color: #fff;*/
102+
color: #222;
96103
font-size: 16px;
97104
padding: 5px 12px;
98105
margin: 4px 2px;
@@ -106,7 +113,8 @@
106113
<!-- Main -->
107114
<section style="display:flex;justify-content:center;align-items:flex-end;width:100%;height:33%;">
108115
<div class='labelBlock'>
109-
<label class='font-effect-wallpaper'>Search</label>
116+
<img src="img/icon.png" style="height: 128px; max-width: 100%; max-height: 100%;">
117+
<!--<label class='font-effect-wallpaper'>Search</label>-->
110118
</div>
111119
</section>
112120
<section>

0 commit comments

Comments
 (0)