-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSpPropertyBag-Bookmarklet.js
1 lines (1 loc) · 3.57 KB
/
SpPropertyBag-Bookmarklet.js
1
javascript:(function()%7Bwindow.spPropertyBag%3D%7B%7D%2Cwindow.spPropertyBag.init%3Dfunction()%7B%22use%20strict%22%3Bfunction%20e(e)%7Bvar%20t%2Co%2Cn%3D%5B%5D%3Bfor(t%20in%20e)e.hasOwnProperty(t)%26%26(o%3Dtypeof%20e%5Bt%5D%2C%22string%22%3D%3D%3Do%26%26n.push(%7Bprop%3At%2Cvalue%3Ae%5Bt%5D.replace(%2F%22%2Fg%2C%22%26quot%3B%22)%7D))%3Bn.sort(function(e%2Ct)%7Breturn%20e.prop.localeCompare(t.prop)%7D)%3Bvar%20p%2Ci%3Ddocument.createElement(%22div%22)%2Cd%3D'%3Chr%3E%3Ctable%20style%3D%22margin%3A%201em%3B%22%3E'%3Bfor(p%3D0%3Bp%3Cn.length%3Bp%2B%2B)d%2B%3D%22%3Ctr%3E%22%2Cd%2B%3D'%3Ctd%20style%3D%22text-align%3A%20right%3B%20padding-top%3A%2015px%3B%22%3E%3Cb%3E'%2Bn%5Bp%5D.prop%2B%22%3C%2Fb%3E%3C%2Ftd%3E%22%2Cd%2B%3D'%3Ctd%20style%3D%22padding-top%3A%2015px%3B%22%3E%3Cinput%20id%3D%22prop'%2Bp%2B'%22%20style%3D%22width%3A240px%3B%20%22%20type%3D%22text%22%20value%3D%22'%2Bn%5Bp%5D.value%2B'%22%3E%3C%2Finpu%3E%3C%2Ftd%3E'%2Cd%2B%3D'%3Ctd%20style%3D%22padding-top%3A%2015px%3B%22%3E%3Cbutton%20onclick%3D%22window.spPropertyBag.setProperty(%5C''%2Bn%5Bp%5D.prop%2B%22'%2C'prop%22%2Bp%2B%22')%3B%20return%20false%3B%5C%22%3EUpdate%3C%2Fbutton%3E%3C%2Ftd%3E%22%2Cd%2B%3D'%3Ctd%20style%3D%22padding-top%3A%2015px%3B%22%3E%3Cbutton%20style%3D%22color%3A%20red%3B%20min-width%3A%201em%3B%22%20onclick%3D%22window.spPropertyBag.deleteProperty(%5C''%2Bn%5Bp%5D.prop%2B%22'%2C'prop%22%2Bp%2B%22')%3B%20return%20false%3B%5C%22%3EX%3C%2Fbutton%3E%3C%2Ftd%3E%22%2Cd%2B%3D%22%3C%2Ftr%3E%22%3Bd%2B%3D%22%3C%2Ftable%3E%22%2Cd%2B%3D%22%3Chr%3E%3Ch3%3EAdd%20a%20new%20property%3A%3C%2Fh3%3E%22%2Cd%2B%3D'%3Cdiv%20style%3D%22margin%3A%201em%3B%20padding-bottom%3A%202em%3B%22%3EKey%3A%20%3Cinput%20id%3D%22newKey%22%3E%3C%2Finpu%3E'%2Cd%2B%3D'%26nbsp%3B%26nbsp%3B%26nbsp%3BValue%3A%20%3Cinput%20id%3D%22newValue%22%3E%3C%2Finpu%3E'%2Cd%2B%3D'%26nbsp%3B%3Cbutton%20onclick%3D%22window.spPropertyBag.addProperty()%3B%20return%20false%3B%22%3EAdd%3C%2Fbutton%3E%3C%2Fdiv%3E'%2Cd%2B%3D%22%3Cdiv%3E%3C%2Fdiv%3E%22%2Ci.innerHTML%3Dd%2COpenPopUpPageWithDialogOptions(%7Btitle%3A%22Property%20Bag%20Editor%22%2Chtml%3Ai%2CallowMaximized%3A!0%2CshowClose%3A!0%2CautoSize%3A!0%2CdialogReturnValueCallback%3Afunction()%7Br%26%26window.location.reload()%7D%7D)%7Dvar%20t%3Dnew%20SP.ClientContext.get_current%2Co%3Dt.get_web()%2Cn%3Do.get_allProperties()%3Bt.load(o)%2Ct.load(n)%3Bvar%20r%3D!1%3Bt.executeQueryAsync(function()%7Be(n.get_fieldValues())%7D%2Cfunction(e%2Ct)%7BSP.UI.Notify.addNotification(%22Failed%20to%20get%20web%20properties...%3Cbr%3E%22%2Bt.get_message())%7D)%2Cwindow.spPropertyBag.executeChanges%3Dfunction()%7Bt.get_web().update()%2Ct.executeQueryAsync(function()%7Bconsole.log(%22Web%20properties%20successfully%20modified%22)%7D%2Cfunction()%7Bconsole.error(%22Failed%20to%20set%20web%20property!%22)%7D)%7D%2Cwindow.spPropertyBag.setProperty%3Dfunction(e%2Ct)%7Bvar%20o%3Ddocument.getElementById(t).value%3Bn.set_item(e%2Co)%2Cwindow.spPropertyBag.executeChanges()%7D%2Cwindow.spPropertyBag.deleteProperty%3Dfunction(e%2Ct)%7Bif(confirm(%22Are%20you%20sure%20you%20want%20to%20remove%20this%20property%3F%22))%7Bvar%20o%3Ddocument.getElementById(t).parentNode.parentNode%3Bo.parentNode.removeChild(o)%2Cn.set_item(e)%2Cwindow.spPropertyBag.executeChanges()%2Cr%3D!0%7D%7D%2Cwindow.spPropertyBag.addProperty%3Dfunction()%7Bvar%20e%3Ddocument.getElementById(%22newKey%22).value%2Ct%3Ddocument.getElementById(%22newValue%22).value%3Bdocument.getElementById(%22newValue%22).value%3D%22%22%2Cdocument.getElementById(%22newKey%22).value%3D%22%22%2Cn.set_item(e%2Ct)%2Cwindow.spPropertyBag.executeChanges()%7D%7D%2Cwindow.spPropertyBag.init()%7D)()