This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ | |
| function bytesToSize(bytes) { | |
| var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
| if (bytes == 0) return 'n/a'; | |
| var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | |
| if (i == 0) return bytes + ' ' + sizes[i]; | |
| return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Getting list items based on ODATA Query | |
| function getListItems(url, listname, query, complete, failure) { | |
| // Executing our items via an ajax request | |
| $.ajax({ | |
| url: url + "/_api/web/lists/getbytitle('" + listname + "')/items" + query, | |
| method: "GET", | |
| headers: { "Accept": "application/json; odata=verbose" }, | |
| success: function (data) { | |
| complete(data); // Returns JSON collection of the results | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| <label for="myAnnouncement">Announcement</label> | |
| <input id="myAnnouncement" type="text" /><br /> | |
| <input type="button" value="Post Announcement" /> | |
| </div> | |
| <script type="text/javascript" > | |
| // Use this to delay execution until the file sp.js has loaded. Also a good way to keep your context free of globals. | |
| ExecuteOrDelayUntilScriptLoaded(function() { | |
| // get announcement text |