How to determine OS type on device with Tabris - tabris

I've looked through the official documentation on the Tabris site, but I've not yet found an answer. So, within a Tabris app, how does one determine the current OS its running within?
Specifically, I'd like to be able to detect Android or iOS.
Edit
I found this example on their site after #Holger posted the answer, I'm pasting here to help others:
var page = tabris.create("Page", {
title: "Device Info",
topLevel: true
});
["platform", "version", "model", "language"].forEach(function(property) {
tabris.create("TextView", {
layoutData: {left: 10, right: 10, top: [page.children().last(), 10]},
text: property + ": " + device[property]
}).appendTo(page);
});
page.open();

There is a Client Service called "ClientDevice". You can ge tthe platform, os version and so on form it. See http://developer.eclipsesource.com/tabris/docs/1.4/working/client-services/client-device#the_clients_platform

Related

Creating Menu in SwiftUI - receive output message of [UILog] Called -[UIContextMenuInteraction updateVisibleMenuWithBlock:]

I'm attempting to create a pull down menu in SwiftUI , the menu seems to be fully visible on the device/simulator and I can interact with it but I get the following message:
[UILog] Called -[UIContextMenuInteraction updateVisibleMenuWithBlock:] while no context menu is visible. This won't do anything.
Can anyone suggest a solution or help me understand the problem ? XCode Version 12.2 beta 4
struct AardvarkQuantity: View {
var body: some View {
VStack{
Menu(content: {
ForEach((1...5), id: \.self) {
Text("\($0)")
.font(Font.fontSFProText(size: 9))
}
}, label: {
Text("Number of Aardvarks")
.font(Font.fontSFProText(size: 12))
.foregroundColor(ColorManager.itemRowLabelText)
})
}
}
}
As Andrew and pawello2222 both confirmed, the error message appears to be a log warning and code appears to be working
I ended up using the solution listed here.
Although I'm still not clear on how I should respond to the warning.

How to minimize a prime ng dialog?

I would like to know how can I minimize a prime ng dialog box. I read this but it is not working in Angular 7.
Also, as per their site here, the property minimizable is not present
Also I am using the dialogService of primeng. Is there any way that I can minimize the dialog and continue working.
Demo code for reference where I am using dialog service to open the angular component:
showPopup(header: string, groupName: string, controlName: string) {
const dialogRef = this.dialogService.open(StandardParagrahPopupComponent, {
header: header,
width: '60%',
closable: true,
data: {
groupName: groupName
}
});
dialogRef.onClose.subscribe(comments =>
this.onPopupClose(comments, controlName)
);
}
Minimize is not working in PrimeNG for Angular.
It is only working in Primefaces for JavaServletFaces.
The first link you provides leads to Primefaces Showcase, the second to PrimeNG showcase. So it is correct that on the second link you canĀ“t find the minimize feature.

How to use content that's stored in other elements?

I am trying to create multiple jBoxes using the data-attributes and I want to feed them with content from other elements.
I assumed this wouldn't be possible (out of the box), so I used a data-jbox-content-from attribute which is supposed to be point to the element with the content.
But I'm confused now: I know that I should be creating a single jBox only - but I do not see how that is doable when on the other hand I need distinct calls per element to provide the content?
And to confirm my uncertainty...the fiddle isn't working. So I hope someone will find a way to do this either my fixing bugs in my "ugly" approach (eaching over the controls) or a smarter use of JS/jBox.
$("[data-jbox-content-from]").each(function() {
new jBox("Tooltip", {
theme: "TooltipDark",
id: "jBoxTooltip_" + $(this).attr("id"),
getTitle: "data-jbox-title",
content: $($(this).attr("data-jbox-content-from")),
attach: "#" + $(this).attr("id")
}).attach();
});
Complete fiddle here
You approach is correct. But you need to put your code into domready:
$(document).ready(function () {
$("[data-jbox-content-from]").each(function() {
new jBox("Tooltip", {
theme: "TooltipDark",
id: "jBoxTooltip_" + $(this).attr("id"),
getTitle: "data-jbox-title",
content: $($(this).attr("data-jbox-content-from")),
attach: "#" + $(this).attr("id")
});
});
});
Also notice that I removed the .attach() method after new jBox. jBox does that when it initializes.
See updated fiddle: https://jsfiddle.net/StephanWagner/kqgxcda1/1/

Chrome DevTools Protocol: control new tabs

Need to be done: I need to simulate user interactions (journeys) across a chain of sites.
Question: Do you have any tips how to programatically controll a tab opened as a result of a simulated click?
My experience:
I'm using the chrome-remote-interface npm package.
I'm able to simulate a click with a custom ChromeController class which initializes the chrome-remote-interface and these methods:
async simulateClick(selector) {
return await this.evaluate(function (selector) {
document.querySelector(selector).click()
}, selector);
}
/**
* Shamelessly stolen from simple-headless-browser
*/
async evaluate (fn, ...args) {
const exp = args && args.length > 0 ? `(${String(fn)}).apply(null, ${JSON.stringify(args)})` : `(${String(fn)}).apply(null)`
const result = await this.client.Runtime.evaluate({
expression: exp,
returnByValue: true
})
return result
}
Now I would like to interact with the recently opened tab. I can get the targetId of the new tab with the experimenetal Target Domain (prototyping in node cli):
var targets;
chromeController.client.Target.getTargets().then(t => targets = t);
Which results in:
{ targetInfos:
[ { targetId: '97556479-cdb6-415c-97a1-6efa4e00b281',
type: 'page',
title: 'xxx/preview/239402/',
url: 'xxx/preview/239402/' },
{ targetId: 'bbfe11d5-8e4a-4879-9081-10bb7234209c',
type: 'page',
title: 'Document',
url: 'xxx/preview/239402/teaser/0/' } ] }
I am able to switch between the tabs with:
chromeController.client.Target.activateTarget({targetId:'xxx'})
However I'm not able to get any interaction with this, I can't find the connection, how to load it into the Page and Runtime objects.
I've searched in the docs and also tried googling: 'site:chromedevtools.github.io targetId' which only lead me to
> chromeController.client.Browser.getWindowForTarget({targetId: '97556479-cdb6-415c-97a1-6efa4e00b281'}).catch(e => console.log(e.message));
Promise { <pending> }
> 'Browser.getWindowForTarget' wasn't found
I've also tried to Target.setDiscoverTargets({discover: true}) and to close the original tab.
Thanks for any help!
Recently faced this same issue and in short I had to create a new dev tools protocol client for each new target I wanted control over.
My experience is with dev tools protocol using direct communication with websocket but the api is the same so it should be similar. So here is a summary of what I had to do.
Initially looking at the docs I would have assumed Target.attachToTarget should give us control of the new tab but I found that it didn't work.
My workaround was to create a listener that listened for the Target.targetCreated event which provides a targetInfos just like you found with Target.getTargets but for every new target created like a new tab, page, or iframe. Note: you need to enable Target.setDiscoverTargets in order to receive these events over the protocol.
[ { targetId: '97556479-cdb6-415c-97a1-6efa4e00b281',
type: 'page',
title: 'xxx/preview/239402/',
url: 'xxx/preview/239402/' },
{ targetId: 'bbfe11d5-8e4a-4879-9081-10bb7234209c',
type: 'page',
title: 'Document',
url: 'xxx/preview/239402/teaser/0/' } ] }
With that listener I looked for targets that were of type page, you could filter on a specific url if you know what the page will be. With the targetId in hand I requested available websocket targets following the HTTPEndpoints section near the bottom of the devtools home page.
GET /json or /json/list
A list of all available websocket targets.
[ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734",
"id": "DAB7FB6187B554E10B0BD18821265734",
"title": "Yahoo",
"type": "page",
"url": "https://www.yahoo.com/",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734"
} ]
I could then launch a new dev tools protocol client using the webSocketDebuggerUrl and have full control over the tab.
I know this is a pretty round about way but, its the only way I was able to make if work.
Although these days it's probably easier to use something like puppeteer to interface with multiple tabs in chrome if you can. Here is the source code to a puppeteer module that follows new tabs that could be good reference for trying to replicate it pageVideoStreamCollector.ts
This is a very late answer but just putting this here if anyone else has the same issue as help on chrome dev tools is very hard to come by. Hope it helps someone out.
I also am getting "Browser.getWindowForTarget wasn't found" on debian, google-chrome-unstable version 61

Dialog is not displaying in the word add-in

I am trying to show a dialog in the word add-in I am working on right now. This is how I implement it within my code
function loadServers() {
var dialogUrl = 'https://' + location.host + '/App/Signin/signin.html';
Office.context.ui.displayDialogAsync(dialogUrl, { width: 50, height: 50, requireHTTPS: true }, function (asyncResult) {
if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
}
});
}
But when I execute above code snippet It show me below Add-in error
ADD-IN ERROR Sorry, you seem to have lost your network and/or Internet connection. Click "Retry" once you're back online.
I already tried the solution mentioned here. But it didn't work for me. When I tried HTTP instead of the HTTPS, nothing happens. But when I try HTTPS, I got this error. Does anyone has an idea, how do I fix this?
The issue was fixed by adding the URL into the AppDomains entry in the Add-in manifest.

Resources