Repository for interacting with SharePoint via JavaScript.
These files are intended to be use individually and included in SharePoint pages via a Script Editor web part (of course, you could put the JS code directly into the SE web part). For an actual deployment, I would package the functionality together into a single JS file which is referenced in the masterpage for the SP site rather than referencing the code on each individual page. Basically, I'm just trying to get you started with individual features, and you can decide how best to incorporate that into your environment.
Well, you're going to need SharePoint. I'm developing all of this code on SharePoint Online using classic SharePoint. Modern SharePoint is a different beast and is not referenced here.
As an example, you could do the following to use the Like.js code:
- Upload the Like.js file to your SiteAssets folder.
- Make sure you have the rating system enabled and set to Like for the library in question.
- Include a Script Editor web part on the page in question.
- Insert this in the Script Editor contents:
<script src="../SiteAssets/Like.js"></script>
This file creates a GUI interface on SharePoint pages which allows the user to like or unlike the page via asychronous JavaScript calls. This is vastly better than the default SharePoint like/unlike functionality, which only allows users to like a page while viewing list items from within a library view. The code performs the following:
- On page load, determines how many, if any, likes the page has and displays appropriate verbiage at the top of the page.
- Allows people to like/unlike the page without navigating elsewhere.
I have chosen to use the SharePoint ms-descriptiontext DIV to hold the information. This is the DIV which displays the default SP "Last Modified at" text, so it made sense to me to use this DIV for the like information. Obviously, you can change this by editing the code.
To give credit where credit is due, the following page got me started on creating this functionality. I feel my implementation is quite a bit more advanced, but this did get me started.
http://npatro.com/using-like-and-rating-functionality-in-sharepoint-2013-pages/