Islam_Messaadi
Mega Contributor

Code block : Client script [incident table] | Type : onCellEdit

 - assign our new code to : list_content_changed [list view update] &  record [insert&update new values] event listeners.

 - you can access to the events list through the  DevTool console [in my case Chrome F12] :   console.table(NOW.CustomEvent.events,['name']);

 - we can optimize the size of the new Javascript code by Minify it : [Static Script on page size , our code 67739 - 64638 ~~ 3000 bytes]

 

64638 bytes 13.9% unused -Blinker
67739 bytes 13.9% unused +Blinker (Formatted)
67274 bytes 13.8% unused +Blinker (Minify)

+Blinker SNOW [incident List view] Page Performance :

find_real_file.png

-Blinker SNOW [incident List view] Page Performance :

find_real_file.png

var $doc = [top.gsft_main.document,top.document], ttable = $doc[0].querySelector('#sys_target').value,tmp ='';
function putMark(){
	//create marquee element ...
	if ($doc[0].querySelector('#info')) return;
    var marquee = $doc[0].createElement("marquee");
	marquee.id = 'info';
	$doc[0].querySelector('div.list_message_row').appendChild(marquee); //#incident_breadcrumb
    $doc[0].querySelector('#info').innerHTML= tmp; 
}
(function(){

//table info ...	
function getCount(table){
		var gr = new GlideRecord(table);
		gr.query();
		return gr.rows.length || 0;
	}
var table = " Table Name : [<span class=ssp>"+ ttable + '</span>]  Row Counts : [<span class=ssp>'+getCount(ttable)+'</span>]';

tmp = 'User Name : [' + " <span class=ssp>" + NOW.user.name + " </span>"+
	  '] User Roles : [' +" <span class=ssp>"+ NOW.user.allRoles+ " </span>"
		  + '] User Id : [' + " <span class=ssp>"+NOW.user.userID+ ' </span>] ' + table;

	
var css = '#info{border: 2px solid ;border-color: #d1222b transparent;font-family: Roboto, sans-serif;color:#fff;'+
	   'font-size:14px ;background-color:#333}'+'span.ssp {color: #02ff0f }'+
		'.textelem { font-weight: bold ; color:#333}'+
		'.elementC , .elementC td a.linked{animation: pulsec 1s infinite;} @keyframes pulsec {0% {color: #ffcccc}'+
        '100% { color: #FF1700}}'+
		'.elementW , .elementW td a.linked{animation: pulsew 1s infinite;} @keyframes pulsew {0% {color: #fff600}'+
        '100% { color: #729900}}';

    //create style element ...
    var customStyle = $doc[0].createElement("style");
	customStyle.type = 'text/css';
	customStyle.appendChild($doc[0].createTextNode(css));
	$doc[0].head.appendChild(customStyle); 
	putMark();
})();

function blink(){
 putMark();
 var targList = $doc[0].querySelectorAll('div[class=list2_cell_background]');
 targList.forEach(function(e){

	if(e.parentElement.parentElement.classList.contains('list_odd')){
		e.parentElement.parentElement.classList.toggle('list_odd',false);
		}else e.parentElement.parentElement.classList.toggle('list_even',false);

	if(e.parentElement.textContent[0]=='1'){
		e.parentElement.parentElement.classList.add('elementC',"textelem");
		}else e.parentElement.parentElement.classList.add('elementW',"textelem");
	});
}

function refresh(){
	$doc[0].location.reload();
}

top.gsft_main.CustomEvent.observe('list_content_changed',blink);
top.gsft_main.CustomEvent.observe('record',refresh);
blink();
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {if (newValue != oldValues) callback(true);}

find_real_file.png

 

Comments
JohnQ1
Tera Contributor

Wow this is cool.  I can see some really good use cases for this.  Maybe setup so that certain incidents blink when some specific action required.  

Nice WORK!

Islam_Messaadi
Mega Contributor

Thank you ^^ yes actually you can handle any event triggered on the page or database operations and assign a specific functionality to execute for Ex : sound-effect if some new records get inserted....

var Audio = new Audio("base64:................");
Audio.play();
JohnQ1
Tera Contributor

Excellent!  

Thank you

GS3
Tera Contributor

That is really impressive but I could not make it work in my instence. I insert your server side code into a Script Include and called it through onCellEdit client script with Ajax, but this is not working. Do you have the code for the Client script by any change?, I would like to review it.

Version history
Last update:
‎01-24-2019 02:00 AM
Updated by: