Opening HDevelop examples from internal function description - halcon

We have an extensive internal Halcon library, which is used by more and more people. Now we have arrived at the point, where it would be very useful if we could directly access HDevelop examples written specifically for this function as it is already available for MVTec's functions.
This is not possible at the moment, and MVTec will not provide this in the future (their words).
I have made some progress but I'm not able to find a solution.
If a text is filled in one of the boxes in Procedures/Edit Interface/General Documentation/Suggestions it generates an HTML link. Is is possible to start HDevelop using Internet Explorer:
<html>
<head>
<script type="text/javascript">
function foo() {
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("hdevelop.exe");
var input = "";
while (!oExec.StdOut.AtEndOfStream) {
input += oExec.StdOut.ReadLine() + "<br />";
}
if (input)
document.getElementById("dummy").innerHTML = input;
}
</script>
</head>
<body onload="foo();">
<code id="dummy"></code>
</body>
</html>
Unfortunately if the reference to an HTML document is local, it is opened inside the HDevelop's browser, which does not support ActiveX objects. If the reference starts with http, it is opened in your default browser.
Does anyone else have another solution which wouldn't require local server to access local files and setting your default browser to IE?

It is possible to do it by generating a simple HTML file:
<html>
<body>
<TT>Example</TT>
</body>
</html>
and referencing it in any of the Suggestions fields without the .html extension:
There is going to be one step more when accessing the example, where you have to click on the hyperlink "Example" because automatic redirecting is not working.

Related

Microsoft WebHelpers with NETCore.App (2.1)

I'm trying to get the below code to work, but I keep getting compatibility problems with Microsoft.Web.Helpers v 3.2.6 and my current SDK package of NETCore 2.1. Also, for the life of me, I can't get the simplest calls of IsPost and Request to be recognized. I'm sure it's an obvious fix, but I can't find it!
Thanks in Advance for any direction...
#using Microsoft.Web.Helpers;
#{
var fileName = "";
if (IsPost) {
var fileSavePath = "";
var uploadedFile = Request.Files[0];
fileName = Path.GetFileName(uploadedFile.FileName);
fileSavePath = Server.MapPath("~/App_Data/UploadedFiles/" +
fileName);
uploadedFile.SaveAs(fileSavePath);
}
}
<!DOCTYPE html>
<html>
<head>
<title>FileUpload - Single-File Example</title>
</head>
<body>
<h1>FileUpload - Single-File Example</h1>
#FileUpload.GetHtml(
initialNumberOfFiles:1,
allowMoreFilesToBeAdded:false,
includeFormTag:true,
uploadText:"Upload")
#if (IsPost) {
<span>File uploaded!</span><br/>
}
</body>
</html>
The WebHelpers library is not compatible with ASP.NET Core. It relies on System.Web, which .NET Core has been designed to move away from.
The replacement for the IsPost block is a handler method. By convention, a handler method named OnPost will be executed if the method used to request the page is POST (which is what the IsPost property used to check).
Personally, I never understood the point of the FileUpload helper unless you wanted to allow the user to add additional file uploads to the page (which you clearly don't in this case). An input type="file" is easier to add to a page.
File uploading in ASP.NET Core is completely different to Web Pages. Here's some guidance on it: https://www.learnrazorpages.com/razor-pages/forms/file-upload

Test a Google Sheet add-on

I have created an add-on in Script Editor with Code.gs and Index.html. I choose Publish ==> Test as add-on... and then selected another google sheet in the dialog box. Clicking on Test opens that google sheet, but I don't see any taskpane that should be made by index.html, =myFunction() does not work either in cells.
Does anyone know how to test this add-on?
Edit 1: Code.gs:
function myFunction() {
return 100
}
Index.html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
super add-on
</body>
</html>
You can definitely test the sidebar add-on, in other sheet. You need to use the below script. Also, make sure you select INSTALLATION CONFIG as Installed & Enabled.
function onOpen() {
var html = HtmlService.createHtmlOutputFromFile('index') //your html page name
.setTitle('My custom sidebar')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
Currently, custom functions are not working in test add-on mode. There is already an issue reported for this and Google as accepted it. Check this.

Downloading PDFs opened in new tab with CasperJS

I'm trying to write a casperJS program that can navigate and download PDFs. If I can grab an actual URL corresponding to the PDF it's pretty straight-forward, but that isn't always the case. To test this, I've been working with this simple example locally:
<html>
<head>
</head>
<body>
<h1 class="page-title">Hello</h1>
<a id='1' href="test.pdf" target="_blank">one</a>
</body>
</html>
Basic casper:
casper.start('file:///opt/templates/templates/src/main/resources/casperjs/example.html').then(function() {
this.echo('started')
});
casper.then(function() {
this.waitForSelector('a', function() {
this.click('a');
});
});
casper.wait(1000, function() {
this.echo(JSON.stringify(this.popups[0]));
});
casper.run();
When I run this, the (only) popup that's present is a blank HTML page that never loads. It's also worth noting that if you test this without the 'target="_blank"' (i.e. the PDF opens in the same tab), the 'resource.received' event will be emitted (with null content type), but loading the resource will fail:
[warning] [phantom] Loading resource failed with status=fail: file:///opt/templates/templates/src/main/resources/casperjs/test.pdf
Is there any good way to handle links that will open/download PDFs in some generic way? You can hook into 'navigation.requested' perhaps and download there, but I don't think there's a wonderful way to figure out that the nav is for a PDF (the URL may not always have file extension).

Google+ share button with preview text + image

I try to add a Google+ button to my page. The button itself works, but the text and the image are always empty. I annotated my body and some elements with the schema.org tags, but it is not working. What am I doing wrong here?
<body itemscope itemtype="http://schema.org/Article">
<div itemprop="name">This is the article name</div>
<img itemprop="image" src="thumbnail.jpg" />
<p itemprop="description">This is the description of the article.</p>
<g:plus action="share" href="testUrl"></g:plus>
<script type="text/javascript">
window.___gcfg = {
lang: 'en-US'
};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
You can debug what microdata is getting parsed by using the Google Structured Data Testing Tool. This can help you to understand what Google is seeing on your microdata annotations.
Try removing the URL from your share / +1. The target Url will fallback to the current page, which I'm assuming is you want people to share.
If that's not the problem, there are a few other things that might help:
Your snippet:
Did you use the Google+ Snippet generator? It tends to work pretty well. Also, if you have a complex page, it can help to use meta tags in the <header> section to begin with for debugging.
Proxies:
Which brings me to the next point, if there is a proxy blocking your page or security that prevents people from accessing it, that will block the share preview renderer. Make sure your page (share target) is publicly accessible.
Another possibility: if your page is cached in your server's proxy, this will prevent the page from being updated by the share preview renderer.
If you add an anchor link or query string to the end of the url, e.g. foo.com/index.html vs foo.com/index.html#test vs foo.com/index.html?test=yes it should ensure that a cached version without microdata will be included.
It might be the href attribute on your g:plus tag. Instead, change it to data-href.

WinJS: How can I access page functions and variables from HTML?

I'm defining page with some vars and methods. Then I wanna use it in html markup (for example data-win-bind="textContent: myPage.variable). How can I access page variables in html markup?
In the JavaScript code behind your page, say default.js, you'd include your ViewModel for the data binding, something like:
(function(){
WinJS.Namespace.define("MyModel.myPage", {
variable : null
};
MyModel.myPage.variable = 'foo';
})();
Then in when the page is activated (in default.js), you'll need to initialize the bindings with a call like
WinJS.Binding.processAll(document.body, MyModel);
There's quite a bit more functionality available though, so this is just a simplistic one-way binding case that should get you started. For more info, check out the Quickstart: binding data and styles.
You have to use javascript here's the skeleton:
<html>
<head>
<script type="text/javascript">
//Code goes here
</script>
</head>
<body>
</body>
<html>