Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
1 lines (1 sloc) 4.11 KB
javascript:void%20function(){%22use%20strict%22;window.spUserCustomActions={},window.spUserCustomActions.init=function(){function%20t(t,e){var%20o=_spPageContextInfo.webAbsoluteUrl,n=o+%22/_api/site/userCustomActions%22;SP.SOD.registerSod(%22sp.requestexecutor.js%22,o+%22/_layouts/15/sp.requestexecutor.js%22),SP.SOD.executeFunc(%22sp.requestexecutor.js%22,%22SP.RequestExecutor%22,function(){var%20s=new%20SP.RequestExecutor(o);s.executeAsync({url:n,method:%22GET%22,headers:{Accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(e){var%20o=JSON.parse(e.body);t%26%26t(o.d.results),window.tolle=o,console.log(o)},error:e})})}function%20e(t){var%20e=t.map(function(t){var%20e=t.ScriptSrc%3F%22ScriptSrc%22:%22ScriptBlock%22;return[%22%3Cdiv%3E%22,e,'%3Cinput%20type=%22text%22%20value=%22',t.ScriptSrc||t.ScriptBlock,'%22%3E%3Ca%20href=%22javascript:alert(%26quot;Not%20Implemented%20Yet%26quot;);%22%3E%26%23x2716;%3C/a%3E%3C/div%3E'].join(%22%22)});return%20e.join(%22%22)}function%20o(t){var%20o=[%22%3Cdiv%3EPlease%20click%20on%20the%20link%20for%20you%20web%20part%20to%20see%20all%20user%20custom%20actions%3C/div%3E%22,'%3Cdiv%3EThe%20tool%20is%20provided%20as%20is.%20Author:%20Anatoly%20Mironov%20%40mirontoli,%202016-03-17.%20See%20the%20details%20on%20my%20blog:%20%3Ca%20href=%22http://chuvash.eu%22%3ESee%20all%20User%20Custom%20Actions%3C/a%3E%3C/div%3E%3Ch3%3ESite%20User%20Custom%20Actions%3C/h3%3E'].join(%22%22),n=[%22%3Cdiv%3EAdd%20new%20user%20custom%20action%20ScriptBlock.%20You%20can%20also%20load%20scripts%20and%20css%20in%20this%20scriptblock.%3Cbr%3E%22,'%3Ctextarea%20id=%22new-uca%22%3E%3C/textarea%3E%3Cbr%3E%3Cinput%20type=%22button%22%20value=%22Add%20new%22%20onclick=%22spUserCustomActions.submitUserCustomAction()%22%3E%3C/div%3E'].join(%22%22),s=[%22%3Cdiv%3EAdd%20new%20site%20action%20(title%20and%20url).%20For%20example:%20Documents%20-%20~site/Shared%2520Documents/Forms/AllItems.aspx%3Cbr%3E%22,'Title:%20%3Cinput%20type=%22text%22%20id=%22new-siteaction-title%22%3EUrl:%20%3Cinput%20type=%22text%22%20id=%22new-siteaction-url%22%3E%3Cinput%20type=%22button%22%20value=%22Add%20new%22%20onclick=%22spUserCustomActions.submitSiteAction()%22%3E%3C/div%3E'];return[o,e(t),n,s].join(%22%22)}function%20n(t){var%20e=document.createElement(%22div%22);e.innerHTML=o(t),OpenPopUpPageWithDialogOptions({title:%22Administer%20User%20Custom%20Actions%22,html:e,allowMaximized:!0,showClose:!0,autoSize:!0})}function%20s(){console.log(%22error.arguments%22,arguments)}function%20i(){t(n,s)}spUserCustomActions.submitUserCustomAction=function(){var%20t=document.getElementById(%22new-uca%22),e=t.value;console.log(e);var%20o=_spPageContextInfo.webAbsoluteUrl,n=o+%22/_api/site/userCustomActions%22,s=new%20SP.RequestExecutor(o);s.executeAsync({url:n,method:%22POST%22,body:%22{%20'__metadata':%20{%20'type':%20'SP.UserCustomAction'%20},%20'Location':'ScriptLink',%20'Sequence':'101',%20'Title':'Open%20Shared%20Docs','Description':'',%20ScriptBlock:%20'%22+e+%22'%20}%22,headers:{accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(){console.log(%22submitted%22,arguments)},error:function(){console.log(%22nope%22,arguments)}})},spUserCustomActions.submitSiteAction=function(){var%20t=document.getElementById(%22new-siteaction-title%22),e=document.getElementById(%22new-siteaction-url%22),o=t.value,n=e.value,s=_spPageContextInfo.webAbsoluteUrl,i=s+%22/_api/site/userCustomActions%22,c=new%20SP.RequestExecutor(s);c.executeAsync({url:i,method:%22POST%22,body:%22{%20'__metadata':%20{%20'type':%20'SP.UserCustomAction'%20},%20'Location':'Microsoft.SharePoint.StandardMenu',%20'Group':'SiteActions',%20'Sequence':'101',%20'Title':'%22+o+%22',%20'Description':'Added%20by%20javascript',%20'Url':'%22+n+%22'%20}%22,headers:{accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(){console.log(%22submitted%20site%20action%22,o,n,arguments)},error:function(){console.log(%22site%20action%20submission%20failed%22,arguments)}})},i()},window.spUserCustomActions.init()}();