I used following function for the windows mobile app(phonegap) to handle the backbutton navigation function.
function onBackKeyDown() {
var currentPageId = $.mobile.activePage.attr('id');
if(currentPageId == 'contact-us' || currentPageId == 'about-us' || currentPageId == 'location-map' || currentPageId == 'services'){
$.mobile.changePage("index.html", {
transition : "slide",
reverse : true,
changeHash : false
});
}else{
navigator.app.exitApp();
}
}
I wanted to come to the index if the current page is not index. Otherwise exit the app.
It seems like navigator.app.exitApp() doesn't work in windows phone 7. Is there any solution for overcome this issue.
This plugin came in handy for me.
http://shinymetilda.github.io/Cordova_Exit_Plugin/
Add the .cs file to your plugin directory.
Add the following code to config.xml
<feature name="AppTerminate">
<param name="wp-package" value="AppTerminate" />
</feature>
write this code instead of navigator.app.exitApp()
cordova.exec(null, null, "AppTerminate", "execute", []);
Related
I created an Outlook add-in and posted it using Integrated Apps in the admin center. I created the add-in using Yeoman. The application status is OK and appears in the Outlook of relevant users, but I get the following error message when trying to execute it's function:
Apologies for the blur, I can't seem to fix that though my source image is fine
I have the following line in my manifest.xml file calling the function:
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
And I have the following code in that specific function:
function action(event) {
const message = {
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Web URL opened.",
icon: "Icon.80x80",
persistent: true,
};
// Show a notification message
window.open("https://myurl.com");
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
// Be sure to indicate when the add-in command function is complete
event.completed();
}
function getGlobal() {
return typeof self !== "undefined"
? self
: typeof window !== "undefined"
? window
: typeof global !== "undefined"
? global
: undefined;
}
const g = getGlobal();
// The add-in command functions need to be available in global scope
g.action = action;
Does anyone know how what could be going wrong here? And how I can fix this to execute the redirect when the button is clicked?
I am trying to figure out if I can Auto-Magically select no in a UI alert in google script..
var old = e.oldValue;
var ui = SpreadsheetApp.getUi() ;
if( old == null ){} else{
if( old == "NO"){} else {
if(e.range.getRow() == 3 ) {}
else{ var response = ui.alert('⚠️ Change order? ⚠️', 'Are you sure you want to change this order?',ui.ButtonSet.YES_NO)}}} ;
if(response == ui.Button.NO) {e.range.setValue(old)} ;
this is where I am at, everything works great.... as long as a button is pressed, I am hoping there is a way to Auto press "no" after ~20 seconds.
This is not exactly you want.
Because it doesn't ask for yes or no. It just shows a timeout message. But I think it can be modified as per your requirement.
function showTimeoutAlert(header, message, time){
SpreadsheetApp.getUi().showModelessDialog(
HtmlService.createHtmlOutput(
'<div>'+ message + '</div>' +
'<script> \
var a = document.querySelector("div"); \
a.addEventListener("click",()=>{setTimeout(google.script.host.close,'+ time +')}); \
a.click(); \
</script>'
).setHeight(50),
header
);
}
Use it like:
showTimeoutAlert("No serial number(s) found", "Sr. No(s) 2, 3 not found", 2000)
It will show this message for 2 seconds
One can adjust timeout time in milliseconds.
I believe your goal as follows.
You want to automatically run the script as clicking "NO" button after 20 seconds from opening the dialog.
Modification points:
Unfortunately, in the current stage, the count down cannot be achieved with SpreadsheetApp.getUi().alert(). So in your situation, in order to achieve your goal, I would like to propose to use the custom dialog. When the custom dialog is used, Javascript can be used. By this, the count down can be used.
When above points are reflected to a script, it becomes as follows.
Sample script:
Google Apps Script side:
Please copy and paste the following script to Code.gs of the script editor of Spreadsheet.
function processForNo(value) {
// do something
Browser.msgBox(`Clicked NO. Retrueved value is '${value || ""}'.`);
}
function processForYes(value) {
// do something
Browser.msgBox(`Clicked YES. Retrueved value is '${value || ""}'.`);
}
// Please run this function.
function main() {
var value = "ok";
var html = HtmlService.createTemplateFromFile("index");
html.value = value;
SpreadsheetApp.getUi().showModalDialog(html.evaluate().setHeight(100), '⚠️ Change order? ⚠️');
}
HTML & Javascript:
Please copy and paste the following script to index.html of the script editor of Spreadsheet.
Are you sure you want to change this order?
<input type="button" id="yes" value="YES" onclick="google.script.run.withSuccessHandler(google.script.host.close).processForYes()">
<input type="button" id="no" value="NO" onclick="processForNo('')">
<script>
const processForNo = _ => google.script.run.withSuccessHandler(google.script.host.close).processForNo(<?= value ?>);
setTimeout(processForNo, 20000);
</script>
When main() of above script is run, a dialog is opened. When you don't click the buttons, the dialog is closed after 20 seconds, and the process is run as clicking "NO" button. At that time, processForNo is run. Also, the value can be sent when the dialog is opened.
When "YES" button is clicked, processForYes is run.
Testing:
When above script is tested, the following situation is obtained.
Note:
Above script is a sample script for confirming the script. When above script is included in your script, it becomes as follows.
Google Apps Script side
function myFunction() {
// do something. I cannot understand about your whole script. So please add your actual script and function name.
var old = e.oldValue;
var ui = SpreadsheetApp.getUi();
if (old == null) {
} else {
if (old == "NO") {
} else {
if (e.range.getRow() == 3) {
} else {
var html = HtmlService.createTemplateFromFile("index");
html.value = old;
ui.showModalDialog(html.evaluate().setHeight(100), '⚠️ Change order? ⚠️');
}
}
}
}
function processForNo(old) {
// do something
}
function processForYes(value) {
// do something
}
HTML & Javascript side is the same with above sample script.
Although I cannot confirm your function name from your question, from var old = e.oldValue in your script, I thought that you might be using the OnEdit trigger of the simple trigger. If my understanding is correct, when you use above script, please use the installable OnEdit trigger. By this, when the cell is edited, showModalDialog works. Ref
References:
Custom dialogs
Installable Triggers
Is it possible to build the windows desktop app at fullscreen? 'Cause initially when I run my app, the size is at 1200x900.
In my config.xml I have this <preference name="Fullscreen" value="true" />
I also have this code based on my research from cordova-plugin-statusbar :
this.platform.ready().then(() => {
StatusBar.hide();
});
But I have no luck in running the app at fullscreen for Windows. I have found a solution but only for android:
if (this.platform.is("android")) {
this.androidFullScreen.isImmersiveModeSupported().then(
() => this.androidFullScreen.immersiveMode()
).catch((error: any) => console.log(error));
}
you can try below code , add in page.ts file
ionViewWillEnter() {
this.statusBar.overlaysWebView(true);
}// where you want full screen
ionViewWillEnter() {
this.statusBar.overlaysWebView(true);
}// where you want normal screen
Dynamically set hintText for textarea is not displaying in ios app created using appcelerator titanium.Please advise any alternative. However it works fine in android.
if (rowId == 1 ){
$.remarktextarea.hintText = "Input Remarks";
} else if (rowId == 2) {
$.remarktextarea.hintText = "Add Annotation";
}
The HintText property of a textarea is not supported on iOS, as you can see in the documentation
I'd recommend placing a label on top of the textarea with the styling you want your hinttext to have, and add touchEnabled: false to the property, so users can't click on it (but the click will go through to the textarea instead).
Then watch for changes on the textArea <TextArea id="remarktextarea" onChange="handleChange" /> and hide and show the hinttext based on length:
function handleChange(){
$.hinttextlabel.visible = $.remarktextarea.value.length == 0
}
I'm trying to develop a ff addon that allows a user to right-click on a form element and perform a task associated with it.
Unfortunately somebody decided that the context menu shouldn't appear for form inputs in ff and despite long discussions https://bugzilla.mozilla.org/show_bug.cgi?id=433168, they still don't appear for checkboxes, radios or selects.
I did find this: https://developer.mozilla.org/en-US/docs/Offering_a_context_menu_for_form_controls but I cannot think how to translate the code to work with the new add-on SDK.
I tried dumping the javascript shown into a content script and also via the observer-service but to no avail.
I also cannot find the source for the recommended extension https://addons.mozilla.org/en-US/firefox/addon/form-control-context-menu/ which considering it was 'created specifically to demonstrate how to do this' is pretty frustrating.
This seems like very basic addon functionality, any help or links to easier documentation would be greatly appreciated.
** UPDATE **
I have added the following code in a file, required from main, that seems to do the trick.
var {WindowTracker} = require("window-utils");
var tracker = WindowTracker({
onTrack: function(window){
if (window.location.href == "chrome://browser/content/browser.xul") {
// This is a browser window, replace
// window.nsContextMenu.prototype.setTarget function
window.setTargetOriginal = window.nsContextMenu.prototype.setTarget;
window.nsContextMenu.prototype.setTarget = function(aNode, aRangeParent, aRangeOffset) {
window.setTargetOriginal.apply(this, arguments);
this.shouldDisplay = true;
};
};
}
, onUntrack: function(window) {
if (window.location.href == "chrome://browser/content/browser.xul") {
// In case we were called because the extension is uninstalled - restore
// original window.nsContextMenu.prototype.setTarget function
window.nsContextMenu.prototype.setTarget = window.setTargetOriginal;
};
}
});
Unfortunately this still does not bring up a context menu for disabled inputs, but this is not a show-stopper for me.
Many Thanks
The important piece of code in this extension can be seen here. It is very simple - it replaces nsContextMenu.prototype.setTarget function in each browser window and makes sure that it sets shouldDisplay flag for form controls.
The only problem translating this to Add-on SDK is that the high-level modules don't give you direct access to browser windows. You have to use the deprecated window-utils module. Something like this should work:
var {WindowTracker} = require("sdk/deprecated/window-utils");
var tracker = WindowTracker({
onTrack: function(window)
{
if (window.location.href == "chrome://browser/content/browser.xul")
{
// This is a browser window, replace
// window.nsContextMenu.prototype.setTarget function
}
},
onUntrack: function(window)
{
if (window.location.href == "chrome://browser/content/browser.xul")
{
// In case we were called because the extension is uninstalled - restore
// original window.nsContextMenu.prototype.setTarget function
}
}
});
Note that WindowTracker is supposed to be replaced in some future SDK version. Also, for reference: nsContextMenu implementation