[FIX] linkedin: catch library error

bzr revid: chm@openerp.com-20130130154857-2avus5m64n4tj7t2
This commit is contained in:
Christophe Matthieu 2013-01-30 16:48:57 +01:00
parent 1bb9d9982d
commit e914b45c10
2 changed files with 23 additions and 2 deletions

View File

@ -31,11 +31,31 @@ openerp.web_linkedin = function(instance) {
tag.type = 'text/javascript';
tag.src = "http://platform.linkedin.com/in.js";
tag.innerHTML = 'api_key : ' + self.api_key + '\nauthorize : true\nscope: r_network r_basicprofile'; // r_contactinfo r_fullprofile r_emailaddress';
// error catcher for library exception
var crashmanager = false;
var $head = $("head:first");
var DOMNodeInserted = function (event) {
if(event.srcElement.previousSibling == tag) {
console.debug("LinkedIn JavaScript userspace inserted.");
crashmanager = window.onerror;
window.onerror = function() {
crashmanager("You have a Linkedin error integration.\nPlease check your API Domain and your API Key's configuration", "", "");
window.onerror = crashmanager;
};
$head.off("DOMNodeInserted", DOMNodeInserted);
}
};
$head.on("DOMNodeInserted", DOMNodeInserted);
window.setTimeout(function () {$head.off("DOMNodeInserted", DOMNodeInserted);}, 60000);
// end
document.getElementsByTagName('head')[0].appendChild(tag);
self.linkedin_added = true;
$(tag).load(function() {
$(tag).load(function(event) {
console.debug("LinkedIn JavaScript inserted.");
IN.Event.on(IN, "frameworkLoaded", function() {
if(crashmanager) window.onerror = crashmanager;
console.debug("LinkedIn DOM node inserted and frameworkLoaded.");
});
IN.Event.on(IN, "systemReady", function() {

View File

@ -34,8 +34,9 @@
<li>Log into LinkedIn.</li>
<li>Add a new application and fill the form:
<ul>
<li>JavaScript API Domain: <field name="server_domain" readonly="1" style="width:0"/></li>
<li>Website URL: <field name="server_domain" readonly="1" style="width:0;white-space: nowrap;"/></li>
<li>The programming tool is Javascript</li>
<li>JavaScript API Domains: <field name="server_domain" readonly="1" style="width:0;white-space: nowrap;"/></li>
</ul>
</li>
<li>Copy the <strong>API key</strong> here: