Posts

JS - function to get URL parameter

var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } };

JS - read data from table to array

var dataArray = new Array; var i = 0; var strAux = {}; $("table[summary='InfoSuporte']").find("td").each(function() { if(($(this).children('div').length) == 0){ i++; //console.log($(this).html()); if(i==1) { strAux["columnA"] = $(this).html(); } if(i==2) { strAux["columnB"] = $(this).html(); } if(i==3) { strAux["columnC"] = $(this).html(); } if(i==4) { strAux["columnD"] = $(this).html(); } if(i==5) { strAux["columnE"] = $(this).html(); } if(i%5 == 0){ dataArray.push(strAux); strAux = {}; i=0; } } });

Sharepoint - Utils in JS

Functions to help to configurations in JS Get user login info    function getWebUserData() {         var context = new SP.ClientContext.get_current();         var web = context.get_web();         var currentUser = web.get_currentUser(); var loginName = currentUser.get_loginName(); console.log(loginName);     }     ExecuteOrDelayUntilScriptLoaded(getWebUserData(), "sp.js"); Get if user has permissions to read SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { // function to get if user as permission to edit list function getCurrentUserPermission() {  var web,clientContext,currentUser,oList,perMask; clientContext = new SP.ClientContext.get_current(); web = clientContext.get_web(); currentUser = web.get_currentUser();  oList = web.get_lists().getByTitle('InfoSuporte'); clientContext.load(oList,'EffectiveBasePermissions');...

React - table with search and sort

Create a table in React and adding search filter and sort <script src="./Scripts/angular.min.js"></script> <div ng-app="myApp">     <div id='controlerID' ng-controller='myControllerARR' style='padding-top: 10px;'>         <div style='float: left'>Search:             <input type='text' ng-model='searchCriteria' style='padding: 0px 6px!important;' />         </div>         <div style='float: right'>Order by:                <select ng-model='SortOrder' style='margin-bottom: 0px;'>                 <option value='+Nome'>Nome (asc)</option>                 <option value='-Nome'>Nome (dec)</option>                 <option value='+City'>City (a...

C#/JS/JQuery - download a file with a loading panel

Easy way to use export a document in C # and maintain the loading functionality. First add the functions of add / get cookies https://utilitiesforprogrammers.blogspot.pt/2018/01/jsjquery-cookies.html Second add the loading panel https://utilitiesforprogrammers.blogspot.pt/2018/01/jsjquery-loading.html Now in your event of export add the cookie to track that the process is ended          protected void btnExport(object sender, EventArgs e)         {             try             {                 byte[] bytes = Export();                 this.Page.Response.AppendCookie(new HttpCookie("fileDownloadToken", "1"));                               this.Page.Response.Clear();               ...

JS/JQuery - Loading

Adicionar um loading à webapplication, a funcionar de forma autónoma. Para isto, bastará clocar o seguinte código na masterpage. <style>     .loading {     position:fixed;     width:100%;     left:0;right:0;top:0;bottom:0;     background-color: rgba(255,255,255,0.7);     z-index:9999;     }         .loading::after {         content:'';         position:absolute;         left:48%;top:40%;         width:70px;         height:70px;         border: 10px dotted #a33038;         border-top-color:transparent;         border-radius:50%;         -webkit-animation: spin .8s linear infinite;         animation: spin .8s linear infinite;         } </style> ...

JS/JQuery - Cookies

Work with cookies the easy way. function setCookieWithTime(key, value, expires) { document .cookie = key + '=' + value + ';expires=' + expires.toGMTString(); } function setCookie(key, value) { var expires = new Date(); expires.setTime(expires.getTime() + (5 * 1000)); document .cookie = key + '=' + value + ';expires=' + expires.toGMTString(); } function getCookie(key) { var keyValue = document .cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; }