How can I change the GWT *.nocache.js file - javascript

i'm investigating how to change the generated javscript code in *.nocache.js.
I'm trying to add a custom gwt linker to do that, but i don't know how to find such nocache.js files.
I tried it like this:
SortedSet<EmittedArtifact> emittedArtifacts = toReturn.find(EmittedArtifact.class);
for (EmittedArtifact emittedArtifact : emittedArtifacts) {
logger.log(TreeLogger.WARN,
"++++++++++++++++++++++" + emittedArtifact.toString()
);
}
but there is no nocache.js in the output.
So is there anybody has idea about how to locate the nocache.js with GWT linker or how to change this js at all?
thanks!
Ok, I found the solution by myself. The problem is I need follow the Linker guideline of new GWT version. I should use #Shareable and override another version of link function:
public ArtifactSet link(
TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
boolean onePermutation) throws UnableToCompleteException

Ok, I found the solution by myself. The problem is I need follow the Linker guideline of new GWT version. I should use #Shareable and override another version of link function:
public ArtifactSet link(
TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
boolean onePermutation) throws UnableToCompleteException

Related

Karate UI Framework : have to run a javascript to store chrome session to launch website [duplicate]

Firstly, Karate UI automation is really awesome tool. I am kind of enjoying it while writing the UI tests using Karate. I ran into a situation where in, i was trying to fetch the shadowRoot elements. I read few similar posts related to javascript executor with karate and learnt that it is already answered. it is recommended to use driver.eval. But in Karate 0.9.5 there is no eval, it has script() or scriptAll(). I have gone through documentation couple of times to figure out how i can fetch element inside an element but no luck.
Using traditional selenium+java, we can fetch shadowRoot like this way:
something like shadowRoot which sits inside a parent element like div or body.
//downloads-manager is the tagname and under that downloads-manager, a shadowRoot element exists
The HTML looks like this. it is from chrome://downloads.
<downloads-manager>
#shadow-root(open)
</download-manager>
WebElement downloadManager =driver.findElement(By.tagName("downloads-manager");
WebElement shadowRoot= (WebElement)((JavaScriptExecutor)driver)
.executeScript("return arguments[0].shadowRoot",downloadManager);
So i tried the following in Karate UI
script("downloads-manager","return _.shadowRoot"); //js injection error
script('downloads-manager', "function(e){ return e.shadowRoot;}"); // same injection error as mentioned above.
def shadowRoot = locate("downloads-manager").script("function(e){return e.shadowRoot};"); //returns an empty string.
I bet there is a way to get this shadowRoot element using Karate UI but i am kind of running out of options and not able to figure out this.
Can someone please look into this & help me?
-San
Can you switch to XPath and see if that helps:
* def temp = script('//downloads-manager', '_.innerHTML')
Else please submit a sample in this format so we can debug: https://github.com/intuit/karate/tree/develop/examples/ui-test
EDIT: after you posted the link to that hangouts example in the comments, I figured out the JS that would work:
* driver 'http://html5-demos.appspot.com/hangouts'
* waitFor('#hangouts')
* def heading = script('hangout-module', "_.shadowRoot.querySelector('h1').textContent")
* match heading == 'Paul Irish'
It took some trial and error and fiddling with the DevTools console to figure this out. So the good news is that it is possible, you can use any JS you need, and you do need to know which HTML element to call .shadowRoot on.
EDIT: for other examples of JS in Karate: https://stackoverflow.com/a/60800181/143475

Class 'ConsoleTVs\Charts\Charts' not found

I tried to use Laravel charts - consoletvs/charts:6.*,
i using
serveice providers
ConsoleTVs\Charts\ChartsServiceProvider::class,
Alias is
'Charts' => ConsoleTVs\Charts\Charts::class,
In my controller i using use Charts
$chart = Charts::new('line', 'highcharts')
->setTitle('My nice chart')
->setLabels(['First', 'Second', 'Third'])
->setValues([5,10,20])
->setDimensions(1000,500)
->setResponsive(false);
Here I facing issue is:
Class 'ConsoleTVs\Charts\Charts' not found
I can't understand what's going on please help to find out this issues.
PHP version is 7.3.2
Laravel version is 5.5.45
Chart version is 6.3
I Found the issue and i fixed this the version only working
this GitHub version is working
When you use their generators (php artisan make:chart), it says the Library is optional. However, when I omit the library I ran into this error. I corrected it by removing the generated class, and regenerating it specifying the library I wanted (php artisan make:chart Fubar Echarts).
Change your code to the Following and see if it will work for your case:
$chart = Charts::create('line', 'highcharts')
->setTitle('My nice chart')
->setLabels(['First', 'Second', 'Third'])
->setValues([5,10,20])
->setDimensions(1000,500)
->setResponsive(false);
You also need to change the setTitle() attribute to title(),setLabels() to labels(),setValues() to values(),setdimensions() to dimensions() and setResponsive() to responsive().

Visual Studio Code Custom Extension Line Based Note

I am trying to create an extension for visual studio code, which requires the ability to annotate lines in a file similar to the references shown in the image, linked below.
I want to be able to add an annotation, such as the one shown in the red rectangle, without modifying the source code file. I would like to be able to do so for every line of the source file. I also want to be able to make dynamic modifications to the annotations' contents.
I have searched VSC's documentation as well as elsewhere. I have not found it. Can anyone guide me in the right direction please?
I know the following is incorrect, but I don't know where else to check for how it should be accomplished.
class TestCodeLensProvider implements vscode.CodeLensProvider {
public provideCodeLenses(document: TextDocument, token: CancellationToken):
CodeLens[] | Thenable<CodeLens[]> {
return new Array<CodeLens>();
}
public resolveCodeLens?(codeLens: CodeLens, token: CancellationToken):
CodeLens | Thenable<CodeLens> {
return new CodeLens(new vscode.Range(new vscode.Position(1, 1), new vscode.Position(1, 2)),/*I also don't know how to specify my command here*/ );
}
}
export function activate(ctx: vscode.ExtensionContext): void {
ctx.subscriptions.push(
vscode.languages.registerCodeLensProvider(
'json', new TestCodeLensProvider()));
The feature in your screenshot is called "Code Lens". More specifcally, you're looking for the registerCodeLensProvider() function of the languages namespace. Or if you're writing a Language Server instead of using the VSCode API directly, the textDocument/codeLens request method.

How to put external js API in cocos creator?

I am just wondering how to put another js API library( in my case, i want to put the smartfoxserver javascript API library) in cocos creator? because what i did in cocos2d-js, i just need to add it in project.json, and I am wondering if i can do same way in cocos creator or another way?
thank you in advance
reference question from:
http://discuss.cocos2d-x.org/t/how-to-put-another-js-api-library-in-cocos-creator/32598
good day
you can use module exports
var x = {
/*
your stuff
*/
};
module.exports = x;
then access it from other scripts using
var externalScript=require("name of the script with module.exports");
cheers
i just scan the smartfoxserver. it use the websocket that is fine just drag an drop the SFS2X_API_JS.js to the project and require it and init it maybe you would use window.xxx to set the connection handler as global value

Call a JavaScript function from C++

I have a CDHTMLDialog, with which I have 2 HTML pages and a .js file with a few fairly simple functions.
I would like to be able to call one of the JS functions from my program with a simple data type passed with it. e.g. MyFunc(int). Nothing needs to be returned.
I would appreciate any guidance on how I go about this,
thanks.
Edit: Thanks to CR for his answer, and everyone else who submitted there ideas too.
Something a little like this worked in the end (stripped a little error handling from it for clarity):
void callJavaScriptFunc(int Fruit)
{
HRESULT hRes;
CString FuncStr;
CString LangStr = "javascript";
VARIANT vEmpty = {0};
CComPtr<IHTMLDocument2> HTML2Doc;
CComPtr<IHTMLWindow2> HTML2Wind;
hRes = GetDHtmlDocument(&HTML2Doc);
hRes = HTML2Doc->get_parentWindow(&HTML2Wind);
if( Fruit > 0 )
{
FuncStr = "myFunc(808)"; // Javascript parameters can be used
hRes = HTML2Wind->execScript(FuncStr.AllocSysString(), LangStr.AllocSysString(), &vEmpty);
}
}
Easiest approach would be to use the execScript() method in the IHTMLWindow2 interface.
So you could get the IHTMLDocument2 interface from your CDHTMLDialog by calling GetDHtmlDocument, then get the parentWindow from IHTMLDocument2. The parent window will have the IHTMLWindow2 interface that supports execScript().
There might be an easier way to get the IHTMLWindow2 interface from your CDHTMLDialog but I'm used to working at a lower level.
the SpiderMonkey library can "Call a JavaScript function from C++", please refer to
http://egachine.berlios.de/embedding-sm-best-practice/ar01s02.html#id2464522
but in your case, maybe this is not the answer.
To give you a hint - javascript injection in server-side-technologies is usually performed through bulk-load at startup (GWT) or injected when the HTML is generated and served each post-back (ASP.NET).
The important point of both approaches is that they inject the javascript calls somewhere in the page (or in a separated .js file linked in the HTML in case of GWT) when generating the HTML page.
Even if you're on win development (looks like it since you're on MFCs) it might be the case that you have to insert your js method call in the HTML and then load (or reload if you wish to interact with the html from your MFC app) the HTML file in your CHTMLDialog.
I don't see any other way of achieving this (maybe I am just not aware of some suitable out-of-the-box functionality) other than editing your HTML and (re)loading it - which is pretty convenient and workable if you have to call your js method once off or just inject some kind of event-handling logic.
Might be a bit of a pain if you have to interact with the page from your MFC app. In this case you have to re-generate your HTML and reload it in your CHTMLDialog.
Either way you can simply have some kind of placeholder in your HTML file, look for that and replace with your javascript code, then load the page in your CHTMLDialog:
onclick="__my_Javascript_Call_HERE__"

Categories

Resources