I'm trying to integrate TradingView library with my web app. The chart is loading fine, but when loading both, resolveSymbol method is called twice.
Datafeed.Container.prototype.resolveSymbol = function (
symbolName,
onSymbolResolvedCallback,
onResolveErrorCallback
) {
this._send(
datafeedUrl + this._symbolResolveURL,
{
symbol: symbolName ,
},
function (dataObj) {
onSymbolResolvedCallback(dataObj);
}
);
};
Actually the data returned on both times are the same. The Chrome dev tools network tab shows the calls as below
What is that going wrong? Somehow the library assumes the symbol is not resolved. How to rectify that?
Related
I'm working on a project that includes a module that helps with electricity recharge, so what happens is that the user's data is already saved in the app and when they choose to recharge, the app opens up this webpage in a web view.
Currently, I'm using WebBridgeView for opening the webpage as:-
render() {
return (
<WebViewBridge
ref="webviewbridge"
onBridgeMessage={this.onBridgeMessage.bind(this)}
source={{uri: "https://currencypin.com/PrepaidMeterPaymentsV2.0/cartwiz?c=IN&p=5&pm=tm"}}/>
);
}
}
Now, what I want is that when the webpage opens, the form fields come prefilled with the custom data that I have. So that the only field that the user needs to fill on the page is the CAPTCHA.
I was following this article for achieving the same, but it actually assumes that the website is customizable. Which is not possible in my case because it belongs to a 3rd party vendor.
What are the ways to achieve this?
You have to use the injectedJavaScript prop from WebView.
First declare a jsCode variable:
const amount = 2
const jscode = `
if (document.getElementById('txtAmount') == null) {
// field not existing, deal with the error
} else {
document.getElementById('txtAmount').value = '${amount}';
}
`
Please notice the " ` " character. Used to put variables in strings.
Then use it like so:
<WebViewBridge
ref="webviewbridge"
onBridgeMessage={this.onBridgeMessage.bind(this)}
injectedJavaScript={jsCode}
I am trying to implement the drag and drop funcationality with the Dynatree plugin. It works completely as expected in IE 9. In Chrome, however, the functionality is intermittent. I have downloaded the latest .js files from the Dynatree web site, and also played around with the versions of jquery.js that I am referencing.
At first, I thought that in Chrome the onDragOver and onDrop functions that I had declared were simply not getting called. However, when I inserted console log statements, then launched the MVC project in which the Dynatree object was being rendered, I could see in the Chrome developer tools console monitor that the onDragStart function was always called without fail, but when I would drag the mouse around with the "attached" node, I could only get the onDragOver function to fire in what seemed like random spots. When I got the onDragOver to fire and actually "reference" or highlight one of the other nodes in the tree, the onDrop function would also work.
Ironically, this code below works perfectly in IE9. I can get it to work in Chrome, but only if I use it in a WebForms ASP.NET project. Now, I'm sure you're thinking, "Why not just use it in a WebForms project?". That remains a possibility (last resort), but with what we need to accomplish with saving changes to our database, the MVC will work much better for the other aspects of the site. The code below fairly closely follows one of the examples provided on the Dynatree home website.
Thanks for any help you can provide.
Update: I have discovered that it isn't that the onDragOver and onDrop functions are not being called. When viewed in Chrome using MVC, the dynatree is just very picky and sensitve to exactly where you click. This could entirely be a product of my json string, or some settings on Chrome. I just don't know yet. If I click to the left of the node, I can select it every time, and move it to where I want. I have to be very specific with where I drag it and drop it. In Chrome, in the web forms model, it seems as though the "areas" within which you can operate are simply much larger. ?
$(document).ready(function () {
$("#OrgTree").dynatree({
initAjax: {
url: $('#Path').val()
},
dnd: {
onDragStart: function (node) {
/** This function MUST be defined to enable dragging for the tree.
* Return false to cancel dragging of node.
*/
//alert(node);
logMsg("tree.onDragStart(%o)", node);
return true;
},
onDragOver: function (node, sourceNode, hitMode) {
/** Return false to disallow dropping this node. * */
logMsg("tree.onDragOver(%o, %o, %o)", node, sourceNode, hitMode);
// Prevent dropping a parent below it's own child
if (node.isDescendantOf(sourceNode)) {
return false;
}
// Prohibit creating children in non-folders (only sorting allowed)
//if (!node.data.isFolder && hitMode === "over") { return "after"; }
},
onDrop: function (node, sourceNode, hitMode, ui, draggable) {
/** This function MUST be defined to enable dropping of items on
* the tree.
*/
logMsg("tree.onDrop(%o, %o, %o)", node, sourceNode, hitMode);
if (node.isDescendantOf(sourceNode)) {
return false;
}
//alert(node, sourceNode, hitMode);
//sourceNode.expand();
sourceNode.move(node, hitMode);
},
onDragEnter: function (node, sourceNode) {
/** sourceNode may be null for non-dynatree droppables.
* Return false to disallow dropping on node. In this case
* onDragOver and onDragLeave are not called.
* Return 'over', 'before, or 'after' to force a hitMode.
* Return ['before', 'after'] to restrict available hitModes.
* Any other return value will calc the hitMode from the cursor position.
*/
// Prevent dropping a parent below another parent (only sort
// nodes under the same parent)
// Allowing dropping *over* a node will create a child of that node
if (node.isDescendantOf(sourceNode)) {
return false;
}
return ["before", "after", "over"];
}
}
});
})
I have found that the issue lies with the references to icon files and an older version of the jquery library being used. I'm still not sure why it wasn't an issue for IE, but was for chrome.
My theory on why the incorrect reference to the icon file was causing a problem was that when no icons were rendered on the Dynatree object, Chrome did not insert any "pixel address" on which to click. I realize that is not the correct term, but it is my theory. In IE, it did not seem to be a problem.
When I rendered the page after correcting the reference to the icon file, all worked as expected.
"EXPORTED_SYMBOLS is not an array" Exception flagged when tried to use Components.utils.import("chrome://app/content/app1.js");.
I have a XUL application created and from one of the JS File(say app.js) I tried to include the other JS File as shown above.
Both app.js and app1.js are placed in content folder and also in chrome.manifest file following line is added
"content app content/"
In other JS File (app1.js), I have exported symbols like
var EXPORTED_SYMBOLS = ["Fooinstance"];
var Fooinstance = {
foo: function() {
...
}
}
In app.js,
Components.utils.import("chrome://app/content/app1.js");
// Error: chrome://app/content/app1.js - EXPORTED_SYMBOLS is not an array
...
Fooinstance.foo();
I am running this XUL app on XULRunner 17.0.1 win32 libraries.
I looked through the code in this link https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Using
It did not help and if I include it as resource it works however I do not want to include it as part of resource.
Could you someone point out what mistake would be ?
I had this same problem, and I solved it:
1) changing the file extension (.js) by .jsm
2) Adding a first line on your module exporting classes to share. EG:
var EXPORTED_SYMBOLS = ["Xobject"];
function Xobject(){
}
Xobject.prototype.stop = function() {
return 'stop';
}
Xobject.prototype.run = function() {
return 'running';
}
3) Calling this way
Components.utils.import('resource://gre/modules/Services.jsm' );
Components.utils.import("chrome://myFirstAddOn/content/Xobject.jsm");
var myXobject = new Xobject();
alert(myXobject.run());
Hope it help u
For anyone else getting this, another possible reason is a circular dependency. My case was a little different, but I had two JSM files each using Components.utils.import to import each other. Then I got this error in one of them.
I'm trying to work on the "different permissions based on workflow state" issue but I'm struggling with the fact that it seems impossible to get the id of the current object 'at any time' that is necessary in order to get the permission of that object. What I mean is that I manage to get it from the client state following jquery bbq docs like:
$.bbq.getState().id
BUT it looks like this is doable only AFTER a complete page load. I investigated this by placing some alert in the main view events, like:
openerp.web.PageView = openerp.web.PageView.extend({
on_loaded: function(data) {
this._super(data);
alert('page load ' + $.bbq.getState().id);
},
do_show: function() {
this._super();
alert('page show ' + $.bbq.getState().id);
},
reload: function() {
this._super();
alert('page reload ' + $.bbq.getState().id);
},
on_record_loaded: function(record) {
this._super(record);
alert('record loaded ' + $.bbq.getState().id);
}
});
and I found that when you open the page view (by clicking on an item in a search view, for instance) you get always "undefined".
Then, you get it into "reload" and "on_record_loaded" when passing from an object to another using paged navigation. And then, you miss it again when you click on the "edit" button.
In the form view I successfully got it only on the 1st load because it seems that some caching is in-place. So that, if I place a pdb into web client's fields_view_get and I do this into the form "init_view":
var ids = [];
if ($.bbq.getState().id){
ids = [parseInt($.bbq.getState().id)];
}
console.log(ids);
return this.rpc("/web/view/load", {
"model": this.model,
"view_id": this.view_id,
"view_type": "form",
toolbar: this.options.sidebar,
context: context,
ids: ids,
}, this.on_loaded);
I get it only the 1st time that the page gets loaded. The same happen if I take ids from
this.dataset.ids
I looked anywhere at the core web module and I can't find a proper API for this and it looks weird (above all on dataset) that we don't have a proper way for getting/working on the current record/s. Even the context and the session do not have any information about that.
Probably I should store this into the view itself on 1st load...
Thanks in advance for any pointers.
try:
this.view.datarecord.id
OpenERP 7 in form view:
debugged using google chrome
Try the combination of the
this.dataset.ids and this.dataset.index
like
curr_id = this.dataset.ids[this.dataset.index]
this might solve your problem.
I'm having some problems trying to get running inAppPurchases inside my iPhone phoneGap-based app.
I got the inAppPurchase-plugin on gitHub https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/InAppPurchaseManager
Then i created my developer account, purchased de u$d 99, and made my inAppPurchase Catalog
Created my iTunes Connect account to get a Test User for this.
I placed all the plugins file where it says... And, if i try to run "alert(typeof window.plugins.inAppPurchaseManager)" it shows "object" so, plugins are being loaded correctly!
The problem appears when i try to do my purchase..
I logout my itunes account, run my binary inside my iphone, and when i make the purchase i should see a prompt asking me for my test account information in order to make a symbolic purchase! But it never happens!
The javascript code (very basic) im trying to run is the following
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady(event) {
window.plugins.inAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {
alert("purchased");
};
window.plugins.inAppPurchaseManager.onRestored = function(originalTransactionIdentifier, productId, originalTransactionReceipt) {
alert("restored");
};
window.plugins.inAppPurchaseManager.onFailed = function(errorCode, errorText) {
alert("error");
};
window.plugins.inAppPurchaseManager.requestProductData(
"com.mycompany.myproduct.myproductid",
function(productId, title, description, price) {
alert("data retrieved");
window.plugins.inAppPurchaseManager.makePurchase(productId, 1);
},
function(id) {
alert("Invalid product id: " + id);
}
);
}
Hope you can help me! thank you!
You need to call js functions like window.plugins.inAppPurchaseManager.onPurchased in html.index for these functions to work.i.e these functions call onPurchased in js and correspondingly it will call obj-C functions.
(js function in index.html)->(js function in js file)->(objective-C function)...is the sequence.
Are you getting any invalid product ID's back? There are a lot of gotchas on Apple's end. Try reading through this guide to find what you need to get the product info request to return valid products.