prepare for service shutdown

This commit is contained in:
codepoet80 committed 2026-04-04 12:43:55 -04:00
1 parent 28cb116c98
commit 94ae488549
12 files changed
+421 -269

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ DownloadAssistant.prototype.setup = function() {
DownloadAssistant.prototype.activate = function(event) {
Mojo.Log.info("Dashboard activating!");
//Set options for service model
serviceModel.ForceHTTP = appModel.AppSettingsCurrent["ForceHTTP"];
serviceModel.ForceHTTPS = appModel.AppSettingsCurrent["ForceHTTPS"];
serviceModel.UseCustomEndpoint = appModel.AppSettingsCurrent["UseCustomEndpoint"];
serviceModel.CustomEndpointURL = appModel.AppSettingsCurrent["EndpointURL"];
serviceModel.CustomShortURL = appModel.AppSettingsCurrent["ShortURL"];
+46 -8
View File
@@ -108,7 +108,7 @@ MainAssistant.prototype.setup = function() {
MainAssistant.prototype.activate = function(data) {
//Set options for service model
serviceModel.ForceHTTP = appModel.AppSettingsCurrent["ForceHTTP"];
serviceModel.ForceHTTPS = appModel.AppSettingsCurrent["ForceHTTPS"];
serviceModel.UseCustomEndpoint = appModel.AppSettingsCurrent["UseCustomEndpoint"];
serviceModel.CustomEndpointURL = appModel.AppSettingsCurrent["EndpointURL"];
serviceModel.CustomShortURL = appModel.AppSettingsCurrent["ShortURL"];
@@ -116,6 +116,19 @@ MainAssistant.prototype.activate = function(data) {
serviceModel.UseCustomClientId = appModel.AppSettingsCurrent["UseCustomClientId"];
serviceModel.CustomClientId = appModel.AppSettingsCurrent["CustomClientId"];
// Deprecation banner: show when using the default endpoint and not yet dismissed
var usingDefault = (!appModel.AppSettingsCurrent["UseCustomEndpoint"]
|| !appModel.AppSettingsCurrent["EndpointURL"]
|| appModel.AppSettingsCurrent["EndpointURL"] == "");
var dismissed = appModel.DeprecationDismissed;
if (usingDefault && !dismissed) {
this.controller.get("divDeprecationBanner").style.display = "block";
this.bannerClickHandler = this.handleBannerClick.bind(this);
this.controller.get("divDeprecationBanner").addEventListener("click", this.bannerClickHandler);
} else {
this.controller.get("divDeprecationBanner").style.display = "none";
}
//Set correct menu label
var loggedInLabel = "Log In";
if (appModel.AppSettingsCurrent["Username"] != "" && appModel.AppSettingsCurrent["Credential"] != "") {
@@ -507,23 +520,44 @@ MainAssistant.prototype.showNewShareScene = function() {
}
/* Login Stuff */
MainAssistant.prototype.handleBannerClick = function(event) {
var targetId = event.target ? event.target.id : "";
if (targetId == "lnkDismissBanner") {
appModel.DeprecationDismissed = true;
this.controller.get("divDeprecationBanner").style.display = "none";
this.controller.get("divDeprecationBanner").removeEventListener("click", this.bannerClickHandler);
} else {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.pushScene({ name: "preferences", disableSceneScroller: false });
}
}
MainAssistant.prototype.showWelcomePrompt = function() {
var hasEndpoint = (appModel.AppSettingsCurrent["UseCustomEndpoint"]
&& appModel.AppSettingsCurrent["EndpointURL"] != "");
var choices = [
{ label: 'Log In', value: "login", type: 'affirmative' },
{ label: 'Create New', value: "new", type: 'neutral' },
{ label: 'Preferences', value: "prefs", type: 'neutral' }
];
var message = hasEndpoint
? "Do you want to Log In to an existing share space, or create a new one on your server?"
: "The community server is shutting down later this year. Log In to retrieve your content before it closes, or set up your own server in Preferences.";
this.controller.showAlertDialog({
onChoose: function(value) {
if (value == "login") {
this.showLogin();
} else if (value == "new") {
Mojo.Log.info("new selected!");
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.swapScene({ transition: Mojo.Transition.crossFade, name: "newuser" });
} else if (value == "prefs") {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.pushScene({ name: "preferences", disableSceneScroller: false });
}
},
}.bind(this),
title: "Welcome to Share Space!",
message: "Your shared clipboard for webOS! This client app can be used with a web service and web app that lets you share content between devices, or with other users! Do you want to Log In to an existing share space, or create a new one?",
choices: [
{ label: 'Log In', value: "login", type: 'affirmative' },
{ label: 'Create New', value: "new", type: 'neutral' },
]
message: message,
choices: choices
});
}
@@ -574,6 +608,10 @@ MainAssistant.prototype.deactivate = function(event) {
/* remove any event handlers you added in activate and do any other cleanup that should happen before
this scene is popped or another scene is pushed on top */
this.controller.window.clearInterval(refreshInt);
if (this.bannerClickHandler) {
this.controller.get("divDeprecationBanner").removeEventListener("click", this.bannerClickHandler);
this.bannerClickHandler = null;
}
Mojo.Event.stopListening(this.controller.get("shareList"), Mojo.Event.listDelete, this.handleListDelete);
Mojo.Event.stopListening(this.controller.get("shareList"), Mojo.Event.listTap, this.handleListClick);
Mojo.Event.stopListening(this.controller.get("shareList"), Mojo.Event.listAdd, this.handleListAdd);
+10 -3
View File
@@ -149,10 +149,17 @@ NewuserAssistant.prototype.cancelClick = function(event) {
NewuserAssistant.prototype.errorHandler = function (errorText, callback) {
Mojo.Log.error(errorText);
Mojo.Controller.getAppController().showBanner({ messageText: errorText, icon: "assets/notify.png" }, "", "");
errorText = errorText.charAt(0).toUpperCase() + errorText.slice(1);
Mojo.Additions.ShowDialogBox("Share Sevice Error", errorText);
this.controller.get('btnOK').mojo.deactivate();
if (errorText.indexOf("disabled on this server") != -1) {
Mojo.Additions.ShowDialogBox("Account Creation Disabled",
"This server is not accepting new accounts. " +
"Contact the server operator for access, or set up " +
"your own server in Preferences.");
} else {
Mojo.Controller.getAppController().showBanner({ messageText: errorText, icon: "assets/notify.png" }, "", "");
errorText = errorText.charAt(0).toUpperCase() + errorText.slice(1);
Mojo.Additions.ShowDialogBox("Share Service Error", errorText);
}
}
NewuserAssistant.prototype.deactivate = function(event) {
+181 -188
View File
@@ -1,24 +1,100 @@
function PreferencesAssistant() {
/* this is the creator function for your scene assistant object. It will be passed all the
additional parameters (after the scene name) that were passed to pushScene. The reference
to the scene controller (this.controller) has not be established yet, so any initialization
that needs the scene controller should be done in the setup function below. */
}
function PreferencesAssistant() {}
PreferencesAssistant.prototype.setup = function() {
/* setup widgets here */
//Theme picker
// --- Server Settings ---
this.controller.setupWidget("toggleCustomEndPoint",
this.attributes = { trueValue: true, falseValue: false },
this.model = { value: appModel.AppSettingsCurrent["UseCustomEndpoint"], disabled: false }
);
this.controller.setupWidget("txtEndpointURL",
this.attributes = {
hintText: $L("http://raspberrypi.local:8080/"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["EndpointURL"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("txtShortURL",
this.attributes = {
hintText: $L("http://short.link/ (optional)"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["ShortURL"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("txtCustomCreateKey",
this.attributes = {
hintText: $L("Your Server Create Key"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["CustomCreateKey"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("toggleForceHTTPS",
this.attributes = { trueValue: true, falseValue: false },
this.model = {
value: appModel.AppSettingsCurrent["ForceHTTPS"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("btnTestConnection",
{ type: Mojo.Widget.defaultButton },
{ label: "Test Connection", disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"] }
);
this.controller.setupWidget("drawerSelfHost",
this.attributes = { modelProperty: 'open', unstyled: false },
this.model = { open: appModel.AppSettingsCurrent["UseCustomEndpoint"] }
);
this.controller.setupWidget("toggleCustomClientId",
this.attributes = { trueValue: true, falseValue: false },
this.model = { value: appModel.AppSettingsCurrent["UseCustomClientId"], disabled: false }
);
this.controller.setupWidget("txtCustomClientId",
this.attributes = {
hintText: $L("Your Server Client ID"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["CustomClientId"],
disabled: !appModel.AppSettingsCurrent["UseCustomClientId"]
}
);
// Endpoint status description
this.updateEndpointStatus();
// --- Basic Settings ---
this.controller.setupWidget("listThemePreference",
{label: $L({value:"Theme", key:"theme"}),
labelPlacement: Mojo.Widget.labelPlacementLeft,
choices: [
{label: $L({value:"Light", key:"themeLight"}), value: "palm-default"},
{label: $L({value:"Dark", key:"themeDark"}), value: "palm-dark"},
{label: $L({value:"System Pref", key:"themeSystem"}), value: "system-theme"}
]},
{ value: appModel.AppSettingsCurrent["ThemePreference"] });
//Refresh timeout picker
{ label: $L({value:"Theme", key:"theme"}),
labelPlacement: Mojo.Widget.labelPlacementLeft,
choices: [
{label: $L({value:"Light", key:"themeLight"}), value: "palm-default"},
{label: $L({value:"Dark", key:"themeDark"}), value: "palm-dark"},
{label: $L({value:"System Pref", key:"themeSystem"}), value: "system-theme"}
]},
{ value: appModel.AppSettingsCurrent["ThemePreference"] }
);
this.controller.setupWidget("listRefresh",
this.attributes = {
label: $L("Refresh"),
@@ -30,26 +106,13 @@ PreferencesAssistant.prototype.setup = function() {
{ label: "5 minutes", value: 300000 }
]
},
this.model = {
value: appModel.AppSettingsCurrent["RefreshTimeout"],
disabled: false
}
this.model = { value: appModel.AppSettingsCurrent["RefreshTimeout"], disabled: false }
);
//Toggles
var disableDL = true;
if (appModel.FileMgrPresent)
disableDL = false;
var disableDL = !appModel.FileMgrPresent;
this.controller.setupWidget("toggleAutoDownload",
this.attributes = {
trueValue: true,
falseValue: false
},
this.model = {
value: appModel.AppSettingsCurrent["UseAutoDownload"],
disabled: disableDL
}
this.attributes = { trueValue: true, falseValue: false },
this.model = { value: appModel.AppSettingsCurrent["UseAutoDownload"], disabled: disableDL }
);
//List boxes
this.controller.setupWidget("listAutoDownloadTime",
this.attributes = {
label: $L("Download Interval"),
@@ -64,121 +127,19 @@ PreferencesAssistant.prototype.setup = function() {
{ label: "24 Hours", value: "23:59:59" }
]
},
this.model = {
value: appModel.AppSettingsCurrent["AutoDownloadTime"],
disabled: disableDL
}
this.model = { value: appModel.AppSettingsCurrent["AutoDownloadTime"], disabled: disableDL }
);
if (appModel.FileMgrPresent)
this.controller.get("divDownloadExplain").innerHTML = "Frequent automatic downloads can have significant impact on battery life.";
//More toggles
this.controller.setupWidget("toggleCopyLinkOnShare",
this.attributes = {
trueValue: true,
falseValue: false
},
this.model = {
value: appModel.AppSettingsCurrent["CopyLinkOnShare"],
disabled: false
}
this.attributes = { trueValue: true, falseValue: false },
this.model = { value: appModel.AppSettingsCurrent["CopyLinkOnShare"], disabled: false }
);
this.controller.setupWidget("toggleForceHTTP",
this.attributes = {
trueValue: true,
falseValue: false
},
this.model = {
value: appModel.AppSettingsCurrent["ForceHTTP"],
disabled: false
}
);
this.controller.setupWidget("toggleCustomClientId",
this.attributes = {
trueValue: true,
falseValue: false
},
this.model = {
value: appModel.AppSettingsCurrent["UseCustomClientId"],
disabled: false
}
);
this.controller.setupWidget("toggleCustomEndPoint",
this.attributes = {
trueValue: true,
falseValue: false
},
this.model = {
value: appModel.AppSettingsCurrent["UseCustomEndpoint"],
disabled: false
}
);
//Text fields
this.controller.setupWidget("txtCustomClientId",
this.attributes = {
hintText: $L("Your Service Client Id"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["CustomClientId"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("txtEndpointURL",
this.attributes = {
hintText: $L("http://your-server.com/"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["EndpointURL"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("txtShortURL",
this.attributes = {
hintText: $L("http://short.link/"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["ShortURL"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
this.controller.setupWidget("txtCustomCreateKey",
this.attributes = {
hintText: $L("Your Service Create Key"),
multiline: false,
enterSubmits: false,
autoReplace: false,
textCase: Mojo.Widget.steModeLowerCase
},
this.model = {
value: appModel.AppSettingsCurrent["CustomCreateKey"],
disabled: !appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
//Drawer
this.controller.setupWidget("drawerSelfHost",
this.attributes = {
modelProperty: 'open',
unstyled: false
},
this.model = {
open: appModel.AppSettingsCurrent["UseCustomEndpoint"]
}
);
//OK Button
// --- Done Button ---
this.controller.setupWidget("btnOK", { type: Mojo.Widget.activityButton }, { label: "Done", disabled: false });
//Menu
// --- App Menu ---
this.appMenuAttributes = { omitDefaultItems: true };
this.appMenuModel = {
label: "Settings",
@@ -188,36 +149,39 @@ PreferencesAssistant.prototype.setup = function() {
]
};
this.controller.setupWidget(Mojo.Menu.appMenu, this.appMenuAttributes, this.appMenuModel);
};
PreferencesAssistant.prototype.updateEndpointStatus = function() {
var statusEl = this.controller.get("divEndpointStatus");
if (!statusEl) return;
if (appModel.AppSettingsCurrent["UseCustomEndpoint"]
&& appModel.AppSettingsCurrent["EndpointURL"] != "") {
statusEl.innerHTML = "Using: " + appModel.AppSettingsCurrent["EndpointURL"];
} else {
statusEl.innerHTML = "Using: default service (shutting down)";
}
};
PreferencesAssistant.prototype.activate = function(event) {
/* put in event handlers here that should only be in effect when this scene is active. For
example, key handlers that are observing the document */
/* add event handlers to listen to events from widgets */
Mojo.Event.listen(this.controller.get("listThemePreference"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("listRefresh"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleAutoDownload"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("listAutoDownloadTime"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleCopyLinkOnShare"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleForceHTTP"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleCustomClientId"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("txtCustomClientId"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleCustomEndPoint"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("txtEndpointURL"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("txtShortURL"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("txtCustomCreateKey"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("toggleForceHTTPS"), Mojo.Event.propertyChange, this.handleValueChange.bind(this));
Mojo.Event.listen(this.controller.get("btnTestConnection"), Mojo.Event.tap, this.testConnection.bind(this));
Mojo.Event.listen(this.controller.get("btnOK"), Mojo.Event.tap, this.okClick.bind(this));
};
PreferencesAssistant.prototype.showBetaFeatures = function() {
//No beta features right now
}
PreferencesAssistant.prototype.handleValueChange = function(event) {
Mojo.Log.info(event.srcElement.id + " value changed to " + event.value);
switch (event.srcElement.id) {
case "listThemePreference":
appModel.AppSettingsCurrent["ThemePreference"] = event.value;
@@ -225,59 +189,92 @@ PreferencesAssistant.prototype.handleValueChange = function(event) {
break;
case "toggleCustomClientId":
{
var thisWidgetSetup = this.controller.getWidgetSetup("txtCustomClientId");
thisWidgetSetup.model.disabled = !event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var clientIdSetup = this.controller.getWidgetSetup("txtCustomClientId");
clientIdSetup.model.disabled = !event.value;
this.controller.modelChanged(clientIdSetup.model);
if (event.value)
this.controller.get('txtCustomClientId').mojo.focus();
break;
}
case "toggleAutoDownload":
{
var thisWidgetSetup = this.controller.getWidgetSetup("listAutoDownloadTime");
thisWidgetSetup.model.disabled = !event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var dlTimeSetup = this.controller.getWidgetSetup("listAutoDownloadTime");
dlTimeSetup.model.disabled = !event.value;
this.controller.modelChanged(dlTimeSetup.model);
break;
}
case "toggleCustomEndPoint":
{
//Toggle enabled on related text boxes
var thisWidgetSetup = this.controller.getWidgetSetup("drawerSelfHost");
thisWidgetSetup.model.open = event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var thisWidgetSetup = this.controller.getWidgetSetup("txtEndpointURL");
thisWidgetSetup.model.disabled = !event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var thisWidgetSetup = this.controller.getWidgetSetup("txtShortURL");
thisWidgetSetup.model.disabled = !event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var thisWidgetSetup = this.controller.getWidgetSetup("txtCustomCreateKey");
thisWidgetSetup.model.disabled = !event.value;
this.controller.modelChanged(thisWidgetSetup.model);
var drawerSetup = this.controller.getWidgetSetup("drawerSelfHost");
drawerSetup.model.open = event.value;
this.controller.modelChanged(drawerSetup.model);
var urlSetup = this.controller.getWidgetSetup("txtEndpointURL");
urlSetup.model.disabled = !event.value;
this.controller.modelChanged(urlSetup.model);
var shortSetup = this.controller.getWidgetSetup("txtShortURL");
shortSetup.model.disabled = !event.value;
this.controller.modelChanged(shortSetup.model);
var keySetup = this.controller.getWidgetSetup("txtCustomCreateKey");
keySetup.model.disabled = !event.value;
this.controller.modelChanged(keySetup.model);
var httpsSetup = this.controller.getWidgetSetup("toggleForceHTTPS");
httpsSetup.model.disabled = !event.value;
this.controller.modelChanged(httpsSetup.model);
var testSetup = this.controller.getWidgetSetup("btnTestConnection");
testSetup.model.disabled = !event.value;
this.controller.modelChanged(testSetup.model);
if (event.value)
this.controller.get('txtEndpointURL').mojo.focus();
this.updateEndpointStatus();
break;
}
case "txtEndpointURL":
var lastChar = event.value[event.value.length - 1]
if (lastChar != "/") {
event.value = event.value + "/";
Mojo.Log.warn("Custom end point URL was missing trailing slash, it has been added. Value is now: " + event.value);
// Ensure trailing slash
if (event.value && event.value.length > 0) {
var lastChar = event.value[event.value.length - 1];
if (lastChar != "/") {
event.value = event.value + "/";
}
}
if(!appModel.AppSettingsCurrent["ShortURL"] || appModel.AppSettingsCurrent["ShortURL"] == "") {
// Auto-fill short URL if not yet set
if (!appModel.AppSettingsCurrent["ShortURL"] || appModel.AppSettingsCurrent["ShortURL"] == "") {
this.controller.get('txtShortURL').mojo.setValue(event.value);
appModel.AppSettingsCurrent["ShortURL"] = event.value;
}
this.updateEndpointStatus();
break;
}
//We stashed the preference name in the title of the HTML element, so we don't have to use a case statement
Mojo.Log.info(event.srcElement.title + " now: " + event.value);
appModel.AppSettingsCurrent[event.srcElement.title] = event.value;
appModel.SaveSettings();
};
//Handle menu and button bar commands
PreferencesAssistant.prototype.testConnection = function() {
var endpointURL = this.controller.get('txtEndpointURL').mojo.getValue();
if (!endpointURL || endpointURL == "") {
endpointURL = Mojo.Controller.appInfo.serviceURL;
}
if (endpointURL[endpointURL.length - 1] == "/") {
endpointURL = endpointURL.substring(0, endpointURL.length - 1);
}
var pingURL = endpointURL + "/ping.php";
Mojo.Log.info("Testing connection to: " + pingURL);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", pingURL);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
if (xmlhttp.status == 200) {
Mojo.Additions.ShowDialogBox("Connection OK", "Successfully reached server at " + endpointURL + ".");
} else {
Mojo.Additions.ShowDialogBox("Connection Failed", "Could not reach server at " + endpointURL + ". Check the address and try again.");
}
}
};
};
PreferencesAssistant.prototype.handleCommand = function(event) {
if (event.type == Mojo.Event.command) {
switch (event.command) {
@@ -294,7 +291,7 @@ PreferencesAssistant.prototype.handleCommand = function(event) {
PreferencesAssistant.prototype.okClick = function(event) {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.popScene();
}
};
PreferencesAssistant.prototype.deactivate = function(event) {
if (this.controller.get('txtEndpointURL').mojo.getValue() == "") {
@@ -303,24 +300,20 @@ PreferencesAssistant.prototype.deactivate = function(event) {
appModel.SaveSettings();
appModel.EstablishAlarms();
/* remove any event handlers you added in activate and do any other cleanup that should happen before
this scene is popped or another scene is pushed on top */
Mojo.Event.stopListening(this.controller.get("listThemePreference"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("listRefresh"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleAutoDownload"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("listAutoDownloadTime"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleForceHTTP"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleCopyLinkOnShare"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleCustomClientId"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("txtCustomClientId"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleCustomEndPoint"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("txtEndpointURL"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("txtShortURL"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("txtCustomCreateKey"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("toggleForceHTTPS"), Mojo.Event.propertyChange, this.handleValueChange);
Mojo.Event.stopListening(this.controller.get("btnTestConnection"), Mojo.Event.tap, this.testConnection);
Mojo.Event.stopListening(this.controller.get("btnOK"), Mojo.Event.tap, this.okClick);
};
PreferencesAssistant.prototype.cleanup = function(event) {
/* this function should do any cleanup needed before the scene is destroyed as
a result of being popped off the scene stack */
};
PreferencesAssistant.prototype.cleanup = function(event) {};
+53
View File
@@ -0,0 +1,53 @@
function SetupAssistant() {}
SetupAssistant.prototype.setup = function() {
this.controller.setupWidget("btnSetupPreferences",
{ type: Mojo.Widget.defaultButton },
{ label: "Configure Server", buttonClass: "affirmative", disabled: false }
);
this.controller.setupWidget("btnSetupSkip",
{ type: Mojo.Widget.defaultButton },
{ label: "Skip for Now", buttonClass: "negative", disabled: false }
);
this.controller.setupWidget(Mojo.Menu.appMenu, { omitDefaultItems: true }, { visible: false });
};
SetupAssistant.prototype.activate = function(event) {
Mojo.Event.listen(this.controller.get("btnSetupPreferences"), Mojo.Event.tap, this.openPreferences.bind(this));
Mojo.Event.listen(this.controller.get("btnSetupSkip"), Mojo.Event.tap, this.skipSetup.bind(this));
// When returning from Preferences, auto-advance to main if an endpoint is now configured
if (appModel.AppSettingsCurrent["UseCustomEndpoint"]
&& appModel.AppSettingsCurrent["EndpointURL"] != "") {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.swapScene({ transition: Mojo.Transition.crossFade, name: "main" });
}
};
SetupAssistant.prototype.openPreferences = function() {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.pushScene({ name: "preferences", disableSceneScroller: false });
};
SetupAssistant.prototype.skipSetup = function() {
this.controller.showAlertDialog({
onChoose: function(value) {
if (value == "continue") {
var stageController = Mojo.Controller.getAppController().getActiveStageController();
stageController.swapScene({ transition: Mojo.Transition.crossFade, name: "main" });
}
},
title: "No Server Configured",
message: "Without a server address, Share Space cannot connect to anything. You can configure one later in Preferences.",
choices: [
{ label: "Continue Anyway", value: "continue", type: "negative" },
{ label: "Go Back", value: "back", type: "affirmative" }
]
});
};
SetupAssistant.prototype.deactivate = function(event) {
Mojo.Event.stopListening(this.controller.get("btnSetupPreferences"), Mojo.Event.tap, this.openPreferences);
Mojo.Event.stopListening(this.controller.get("btnSetupSkip"), Mojo.Event.tap, this.skipSetup);
};
SetupAssistant.prototype.cleanup = function(event) {};
+13 -1
View File
@@ -15,6 +15,7 @@ var AppModel = function() {
this.LastShareSelected = null;
this.CurrentShareURL = null;
this.FileMgrPresent = true;
this.DeprecationDismissed = false;
//Define your app preferences (to be saved by OS)
this.AppSettingsCurrent = null;
@@ -27,7 +28,7 @@ var AppModel = function() {
UseAutoDownload: false,
AutoDownloadTime: "01:00:00",
CopyLinkOnShare: true,
ForceHTTP: false,
ForceHTTPS: false,
UseCustomEndpoint: false,
EndpointURL: "",
ShortURL: "",
@@ -160,6 +161,17 @@ AppModel.prototype.LoadSettings = function(safe) {
}
AppModel.prototype.loadCookieIntoCurrent = function(cookieSettings) {
// Migrate settings from v1.x: remove the old ForceHTTP key (inverted logic,
// replaced by ForceHTTPS). HTTP is now the default so no value needs porting.
if (typeof cookieSettings["ForceHTTP"] !== "undefined") {
delete cookieSettings["ForceHTTP"];
}
// Backfill any keys added in this version that are absent from older cookies
for (var key in this.AppSettingsDefaults) {
if (typeof cookieSettings[key] === "undefined") {
cookieSettings[key] = this.AppSettingsDefaults[key];
}
}
this.AppSettingsCurrent = cookieSettings;
}
+3 -3
View File
@@ -12,7 +12,7 @@ var ShareServiceModel = function() {
};
//Properties
ShareServiceModel.prototype.ForceHTTP = false;
ShareServiceModel.prototype.ForceHTTPS = false;
ShareServiceModel.prototype.UseCustomShare = false;
ShareServiceModel.prototype.UseCustomEndpoint = false;
ShareServiceModel.prototype.CustomEndpointURL = "";
@@ -35,8 +35,8 @@ ShareServiceModel.prototype.buildURL = function(username, actionType) {
var path = urlBase + "/" + actionType + ".php";
if (username)
path += "?username=" + username;
if (this.ForceHTTP)
path = path.replace ("https:", "http:");
if (this.ForceHTTPS)
path = path.replace("http:", "https:");
return path;
}
+5
View File
@@ -5,6 +5,11 @@
</div>
</div>
<div id="divDeprecationBanner" style="display:none; background-color:#cc6600; color:white; padding:8px; text-align:center; font-size:small;">
<span id="spnDeprecationMessage">The default service is shutting down. Tap here to set up your own server.</span>
&nbsp;&nbsp;<span id="lnkDismissBanner" style="font-weight:bold;">[Dismiss]</span>
</div>
<div id="showShareList" name="showShareList" style="display:none">
<div class="palm-group">
<div class="palm-group-title"><span x-mojo-loc='' id="spnUsername">Task List</span></div>
+77 -63
View File
@@ -4,6 +4,81 @@
</div>
</div>
<div class="palm-group">
<div class="palm-group-title">
<span x-mojo-loc=''>Server Settings</span>
</div>
<div class="palm-list">
<div class="palm-row first">
<div class="palm-row-wrapper">
<div class="explanation-text" id="divEndpointStatus"></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleCustomEndPoint" title="UseCustomEndpoint"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Use Custom Server</span></div>
</div>
</div>
<div x-mojo-element="Drawer" id="drawerSelfHost" class="drawerClass" name="drawerSelfHost">
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtEndpointURL" name="txtEndpointURL" x-mojo-element="TextField" title="EndpointURL"></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtShortURL" name="txtShortURL" x-mojo-element="TextField" title="ShortURL"></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtCustomCreateKey" name="txtCustomCreateKey" x-mojo-element="TextField" title="CustomCreateKey"></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper">
<div class="explanation-text">Find your Client ID and Create Key in your server's setup output (<span style="font-style:normal;">docker logs</span>).</div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleForceHTTPS" title="ForceHTTPS"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Always use HTTPS</span></div>
</div>
</div>
<div class="palm-row last">
<div class="palm-row-wrapper" style="padding: 8px 12px;">
<div x-mojo-element="Button" id="btnTestConnection" name="btnTestConnection"></div>
</div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleCustomClientId" title="UseCustomClientId"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Custom Client API Key</span></div>
</div>
</div>
<div class="palm-row last">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtCustomClientId" name="txtCustomClientId" x-mojo-element="TextField" title="CustomClientId"></div>
</div>
</div>
</div>
</div>
<div class="palm-group">
<div class="palm-group-title">
<span x-mojo-loc=''>Basic</span>
@@ -40,74 +115,13 @@
</div>
</div>
<div class="palm-row">
<div class="palm-row last">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleCopyLinkOnShare" title="CopyLinkOnShare"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Copy Link on Share</span></div>
</div>
</div>
<div class="palm-row last">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleForceHTTP" title="ForceHTTP"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Always use HTTP</span></div>
</div>
</div>
</div>
</div>
<div class="palm-group">
<div class="palm-group-title">
<span x-mojo-loc=''>Self Hosting</span>
</div>
<div class="palm-list">
<div class="palm-row first">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleCustomClientId" title="UseCustomClientId"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Custom Client API Key</span></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtCustomClientId" name="txtCustomClientId" x-mojo-element="TextField" title="CustomClientId"></div>
</div>
</div>
<div class="palm-row last">
<div class="palm-row-wrapper">
<div x-mojo-element="ToggleButton" id="toggleCustomEndPoint" title="UseCustomEndpoint"></div>
<div class="title" style="margin-left: -4px; float:left;"><span class="label">Custom Endpoint</span></div>
</div>
</div>
<div x-mojo-element="Drawer" id="drawerSelfHost" class="drawerClass" name="drawerSelfHost">
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtEndpointURL" name="txtEndpointURL" x-mojo-element="TextField" title="EndpointURL"></div>
</div>
</div>
<div class="palm-row">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtShortURL" name="txtShortURL" x-mojo-element="TextField" title="ShortURL"></div>
</div>
</div>
<div class="palm-row last">
<div class="palm-row-wrapper" style="margin:14px 22px 4px 12px">
<div id="txtCustomCreateKey" name="txtCustomCreateKey" x-mojo-element="TextField" title="CustomCreateKey"></div>
</div>
</div>
</div>
<div class="explanation-text">For more information on self-hosting, please visit <a href="https://github.com/webosarchive/webos-sharespace">https://github.com/webosarchivewebos-sharespace</a></div>
</div>
</div>
<div x-mojo-element="Button" id="btnOK" name="btnOK"></div>
<div x-mojo-element="Button" id="btnOK" name="btnOK"></div>
+26
View File
@@ -0,0 +1,26 @@
<div class="palm-page-header multi-line">
<div class="header-icon sharespace"></div>
<div class="header-text">
<span x-mojo-loc=''>Share Space - Setup</span>
</div>
</div>
<div class="welcome">
<div class="my-scene-fade-top" x-mojo-scroll-fade="top"></div>
<h3>Server Required</h3>
<div class="welcome-text">
<p>Share Space requires a server to store and retrieve your shared content.</p>
<p>The community-hosted server is shutting down. To use Share Space, you will need to
connect to a server — either one you run yourself, or one hosted by someone you trust.</p>
<p>Running your own server on a Raspberry Pi is easier than it sounds.
Visit <b>github.com/webosarchive/sharing-service</b> for step-by-step instructions.</p>
<p>Once your server is running, tap <b>Configure Server</b> below and enter the
server address under <b>Server Settings</b>.</p>
</div>
<div class="my-scene-fade-bottom" x-mojo-scroll-fade="bottom"></div>
</div>
<div x-mojo-element="Button" id="btnSetupPreferences" name="btnSetupPreferences"></div>
<div x-mojo-element="Button" id="btnSetupSkip" name="btnSetupSkip"></div>
+2 -2
View File
@@ -1,6 +1,6 @@
{
"id": "com.palm.webos.sharespace",
"version": "1.0.5",
"version": "2.0.0",
"vendor": "webOS Archive",
"type": "web",
"main": "index.html",
@@ -22,5 +22,5 @@
}
}
},
"startupMessage": "<img src='icon.png' style='float:right; margin-left: 6px'>Welcome to ShareSpace -- a powerful app for getting content on and off your webOS device! You can interact with this app from anywhere at <a href='http://share.webosarchive.org'>share.webosarchive.org</a>!<br>Here are some things you should know..."
"startupMessage": "<img src='icon.png' style='float:right; margin-left: 6px'>Share Space now requires a self-hosted server. Open Preferences and configure your server address under the Server section. Visit <a href='https://github.com/webosarchive/sharing-service'>github.com/webosarchive/sharing-service</a> to learn how to run your own server on a Raspberry Pi.<br>Here are some things you should know..."
}
+4
View File
@@ -13,6 +13,10 @@
"scene": "newuser",
"source": "app/assistants/newuser-assistant.js"
},
{
"scene": "setup",
"source": "app/assistants/setup-assistant.js"
},
{
"scene": "welcome",
"source": "app/assistants/welcome-assistant.js"