| |
| var sharePointPlugin = undefined; |
|
|
| function onLoad() { |
| |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| function getSharePointPlugin() { |
| if( sharePointPlugin !== undefined ) { |
| return sharePointPlugin; |
| } |
| sharePointPlugin = null; |
|
|
| var plugin = document.getElementById("winFirefoxPlugin"); |
|
|
| if ( plugin && typeof plugin.EditDocument === "function" ) { |
| window.console && console.log("Using embedded custom SharePoint plugin."); |
| sharePointPlugin = plugin; |
| } else if( "ActiveXObject" in window ){ |
| plugin = null; |
| try { |
| plugin = new ActiveXObject("SharePoint.OpenDocuments.3"); |
| } catch(e) { |
| try { |
| plugin = new ActiveXObject("SharePoint.OpenDocuments.2"); |
| } catch(e2) { |
| try { |
| plugin = new ActiveXObject("SharePoint.OpenDocuments.1"); |
| } catch(e3) { |
| window.console && console.warn("Could not create ActiveXObject('SharePoint.OpenDocuments'): (requires IE <= 11 and matching security settings."); |
| } |
| } |
| } |
| if( plugin ){ |
| window.console && console.log("Using native SharePoint plugin."); |
| sharePointPlugin = plugin; |
| } |
| } |
| return sharePointPlugin; |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| |
| function openWebDavDocument(opts) { |
| var ofe_link = opts.ofe + opts.href, |
| url = opts.href; |
|
|
| var plugin = getSharePointPlugin(); |
| var res = false; |
|
|
| if( plugin ) { |
| try { |
| res = plugin.EditDocument(url); |
| if( res === false ) { |
| window.console && console.warn("SharePoint plugin.EditDocument(" + url + ") returned false"); |
| } |
| } catch(e) { |
| window.console && console.warn("SharePoint plugin.EditDocument(" + url + ") raised an exception", e); |
| } |
| } |
| if ( res === false ) { |
| if( ofe_link ) { |
| window.console && console.log("Could not use SharePoint plugin: trying " + ofe_link); |
| window.open(ofe_link, "_self"); |
| res = true; |
| } |
| } |
| return res; |
| } |
|
|
|
|
| |
| |
| |
| function onClickTable(event) { |
| var target = event.target || event.srcElement, |
| opts = { |
| href: target.href, |
| ofe: target.getAttribute("data-ofe") |
| }; |
|
|
| if( target.className === "msoffice" ){ |
| if( openWebDavDocument(opts) ){ |
| |
| return false; |
| } |
| } |
| } |