document.getElementById("id").valid not working in higher versions of firefox - firefox-addon

I am working on a firefox plugin that uses firebreath framework. The plugin checks whether the firebreath dll is registered using the following code.
if(document.getElementByID("dllID").valid)
{
alert("Dll registered");
}
else
{
alert("Condition failed");
}
The code works fine for firefox upto version 28.
For higher versions the condition always fails. Can anyone help me in this??

I've never heard of the valid attribute. What are you trying to accomplish exactly? If it is for form validation, you probably need to deal with validation objects https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation#The_HTML5_constraint_validation_API
if (document.getElementbyID("dllID").validity.valid){
...
} else {
....
}
Whats more, is this api seems to be present in FF29+ so it probably deprecated the plain valid attribute you are used to

Try .hasAttribute, .getAttribute, and .setAttribute
document.getElementByID("dllID").hasAttribute('valid')
Without these, is usually for XBL properties but things like id work too.

Related

How to load a Firefox addon on page load?

I'm using
chrome.tabs.onUpdated.addListener(function(){ });
on chrome, but it dos not work on Firefox, I have seen
browser.tabs.onUpdated.addListener(listener[, extraParameters])
on Firefox documentation, but I'm not sure how to use it, can someone give me an example?
chrome & browser API
You can use both chrome.* and browser.* API in Firefox.
chrome.* returns a callback function (although that is due to change to support Promise in manifest v3).
browser.* returns a Promise.
In case of *.addListene(), they always return a callback function.
Therefore, in Firefox the following are similar (and you can use either).
chrome.tabs.onUpdated.addListener(function(){
// do something
});
browser.tabs.onUpdated.addListener(function(){
// do something
});
browser.tabs.onUpdated.addListener() in Firefox can also have optional extraParameters but from your example it seems you might not need it.
ref:
chrome.tabs.onUpdated
browser.tabs.onUpdated

Check device type via user_agent (rails)

I want to know whether my users are browsing a page in my rails application with
a tablet or
a mobile device or
a desktop computer
I digged through many different solutions. Here are my favorites:
The ua-parser gem: https://github.com/ua-parser/uap-ruby which seems to be very clean but unfortunately it always plots Other when I use parsed_string.device - I can detect the OS and browser with it very well.
Writing it from scratch
Writing from scratch ended up in sth like this:
if request.user_agent.downcase.match(/mobile|android|iphone|blackberry|iemobile|kindle/)
#os = "mobile"
elsif request.user_agent.downcase.match(/ipad/)
#os = "tablet"
elsif request.user_agent.downcase.match(/mac OS|windows/)
#os = "desktop"
end
However, what I miss is a complete documentation of the user agent 'device' definitions.
For example:
What patterns do I need to look at if my user is browsing on a tablet/mobile device or desktop? I can't just guess and checking e.g. the ua-parser regex is not helping me either (very complicated): https://github.com/tobie/ua-parser/blob/master/regexes.yaml
Is there any simple solution to solve my problem?
How does google analytics do it? I tried to research but could not find it. They're also displaying devices (desktop/tablet/mobile).
The browser gem has a suggestion to do this, but until that is added you could still use the gem to figure it out by using browser.device?
I'm looking to do the 2nd option, because I need it as lean-n-mean as possible. There'se a lot of information in the User-Agent string, that I just don't need. And I don't want a function that tries to parse it all. Just simply: bot, desktop, tablet, mobile and other.
It's kind of a lot to read, but I'm looking for keywords using this extensive list.
So far, the following keywords seems to work for me. It's regular expressons in php, but you'll get the idea.
//try to find crawlers
// https://developers.whatismybrowser.com/useragents/explore/software_type_specific/crawler/
if (preg_match('/(bot\/|spider|crawler|slurp|pinterest|favicon)/i', $userAgent) === 1)
return ['type' => 'crawler'];
//try to find tablets
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/tablet/
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/ebook-reader/
if (preg_match('/(ipad| sm-t| gt-p| gt-n|wt19m-fi|nexus 7| silk\/|kindle| nook )/i', $userAgent) === 1)
return ['type' => 'tablet'];
//try to find mobiles
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/mobile/
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/phone/
if (preg_match('/(android|iphone|mobile|opera mini|windows phone|blackberry|netfront)/i', $userAgent) === 1)
return ['type' => 'mobile'];
//try to find desktops
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/computer/
if (preg_match('/(windows nt|macintosh|x11; linux|linux x86)/i', $userAgent) === 1)
return ['type' => 'desktop'];
return ['type' => 'other'];

Omniture Saint.ImportCreateJob

This is a very specific Omniture API question. Thought I'd check here if anyone encountered this problem since Omniture forum was not of much help -
Sending the following parameters to Omniture API Explorer here - https://developer.omniture.com/en_US/get-started/api-explorer#Saint.ImportCreateJob seems to work fine.
{
"check_divisions":"1",
"description":"OSRA job description: MyReportID, Products, 51",
"email_address":"my#email.com",
"export_results":"0",
"header":["Field1", "Field2"],
"overwrite_conflicts":"1",
"relation_id":51,
"report_suite_array":["MyReportID"],
"c_view":"SomeReportName"
}
But the call fails in the actual code with a 'Bad Request'. It seems like c_view parameter is expecting a certain value. The only documentation for c_view is that it expects a report name. I've tried report names and other values with no luck. Would appreciate any pointers from Omniture API users.
Thanks.
try using the relevant value from the classification_view chart. I know this is what you need for using the get/save classifications methods (I have used those methods, but not the Saint.ImportCreateJob method).
c_value is not required, so unless you plan on using it, it does not need to be present. It is supposed to be a classification_view https://developer.omniture.com/en_US/documentation/omniture-administration/r-classification-view.
It takes some trial and error to get this api working.
Here is an example of a call I use that works using the REST api over Java:
Request:
{
"check_divisions":1,
"description":"Report Test 1",
"email_address":"cdegroot#adobe.com",
"export_results":"0",
"overwrite_conflicts":0,
"relation_id":65,
"report_suite_array":["cdgdev"],
"header":["Key","Survey","Survey^Question","Survey^Question^Response","Engagement Index","Survey > Question > Response"]
}
Response:
"3387166"
Kind Regards C.

notify() is not working in IE8

I am working on a web app based on Sproutcore 1.9.1. To retrieve data from server it
makes a SC.Request.getUrl() request, which works fine in all the browsers except IE8.
For IE8 when the request is like this:
SC.Request.getUrl("'http://example.com/some/path')
.set('isJSON', YES)
.async(false) // made async false to work in IE
.notify(this, 'someMethodDidComplete', { query: query, store: store})
.send();
works fine. But when the request is :
SC.Request.getUrl("'http://example.com/some/path')
.set('isJSON', YES)
.notify(this, 'someMethodDidComplete', { query: query, store: store})
.send();
it works fine for other browsers but for IE8, it is not working. After spending some
time with the issue i found out that the finishrequest() is not invoking. For doing so
what I did is made 'asynchronous false' and then it works. Now I don't know what to do.
Please suggest me something on this and why normal request is not working.
thanks in advance.
This problem is known (https://github.com/sproutcore/sproutcore/issues/866) and seems to be fixed, at least on SC master.
As a side note, you include the query and store in an object as parameter to .notify(). You don't need to do this, you can simply include them as extra parameters and your notify function will be called with those extra parameters:
.notify(this,this.notifier,query,store)
and somewhere else in the file:
notifier: function(result,query,store){ }

SmartGWT throws JavaScriptException: (null): null

When using GWT 2.0.x and SmartGWT 2.2
Code as simple as:
public class SmartGwtTest implements EntryPoint {
public void onModuleLoad() {
IButton button = new IButton("say hello");
}
}
will generate the exception.
com.google.gwt.core.client.JavaScriptException: (null):
This only happens in hosted (devmode)
ant hosted
I also suspect that maybe the GWT Development Plugin might have something to do with it.
Have you found a similar problem? How did you solve it?
Not an answer but a workaround was to use compile the app.
And use it that way.
ant build
Although compilation takes a long time because it generates several permutations of the code. ie different versions for different browser to make compilation faster you can set your target browser while testing.
to do that in your ModuleName.gwt.xml file add the following line:
<set-property name="user.agent" value="gecko"/>
<!-- to test with firefox -->
That will make compilation faster.
Hope this helps someone.
OK, so I was getting this in Firefox in hosted mode and it turned out that a widget was set to have width100 but there was not enough room on the screen to render the widget (my browser was not maximized).
I think this resulted in a negative width being set and this ambiguous Javascript exception was thrown as a result. Maximizing the browser alleviated the issue, you might want to try setting a width to begin with and using resize handlers to render your widget properly.

Resources