Primefaces inputtextarea's autocomplete issue - primefaces

I want to close autocomplete component of inputtextarea by clicking anywhere in the inputtextarea.
Now it is working with 'Esc' button.

You can try
<p:inputTextarea ... onclick="pressClick();" onkeydown="presskey();"/>
function pressClick() {
alert("testClick");
var divsToHide = document.getElementsByClassName("ui-autocomplete-panel");
for(var i = 0; i < divsToHide.length; i++)
{
divsToHide[i].style.visibility="hidden";
}
}
function presskey() {
var divsToShow = document.getElementsByClassName("ui-autocomplete-panel");
for(var i = 0; i < divsToShow.length; i++)
{
divsToShow[i].style.visibility="hidden";
}
}

Related

renameCustomField() Change the Label Field Name

SVP i'm newsbe in Appsscript with API PEOPLE
This script don't work : I want to rename "CKD EPI" by "CKD EPI / CROKOFF / CREAT"
Can you tell me what's wrong ?
function renameCustomField() {
var debug = true;
var group = People.PeopleApi.getContactGroups().get("Mygroup").execute();
var oldFieldName = "CKD EPI";
var newFieldName = "CKD EPI / CROKOFF / CREAT";
for (var i = 0; i < group.members.length; i++) {
var contact = group.members[i];
var fields = contact.userDefined;
for (var j = 0; j < fields.length; j++) {
if (fields[j].key === oldFieldName) {
fields[j].key = newFieldName;
if (debug) {
console.log("Renaming field for contact: " + contact.names[0].displayName);
}
}
}
var updateContact = {
resourceName: contact.resourceName,
updatePersonFields: "userDefined",
userDefined: fields
}
People.PeopleApi.updateContact(updateContact).execute();
}
}

Jquery using append/appendTo with time delay

function a(response) {
setTimeout(function () {
for (i = 0; i < response.length; i++) {
if (response[i].hasOwnProperty("text")) {
var b = '<img class="img" src="path of my pic"/><p class="someclass">' + response[i].text + '</p><div class="something"></div>';
$(b).appendTo(".chatwindow").hide().fadeIn(1000);
} } } }
How do I use appendTo/append the content one after the other with a time delay? Instead it is displaying all at once, which I dont want like that.Please help me if i have to change anything?
You can use the delay() method for this:
function appendWithDelay() {
for (i = 0; i < 10; i++) {
var template = '<img class="img" src="https://picsum.photos/100"/>';
$(template).hide().appendTo(".chatwindow").delay(i * 1000).fadeIn(1000);
}
}
appendWithDelay();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="chatwindow"></div>
Place your settimeout function inside the loop and condition
function a(response) {
for (i = 0; i < response.length; i++) {
if (response[i].hasOwnProperty("text")) {
setTimeout(function () {
var b = '<img class="img" src="path of my pic"/><p class="someclass">' + response[i].text + '</p><div class="something"></div>';
$(b).appendTo(".chatwindow").hide().fadeIn(1000);
}, 1000)
}
}
}

Google Apps Script - TypeError: Cannot read property 'length' of undefined

I have a Google Sheets script that is supposed to grab data from an API but I am getting the error
TypeError: Cannot read property 'length' of undefined (line 5, file "draftOrder")
How can I fix this error? I haven't touched this script in years, so I'm not sure what broke.
function draftOrder(ownerRange, numRounds) {
var output = [];
var owners = [];
for (var i = 0; i < ownerRange.length; i++) {
if (ownerRange[i][0] !== '') {
owners.push(ownerRange[i][0]);
}
}
for (var i = 0; i < numRounds; i++) {
if (i % 2 == 0) {
output = output.concat(owners);
} else {
output = output.concat([].concat(owners).reverse());
}
}
return output;
}
Thanks in advance for any help that you can provide. Cheers!
function draftOrder(ownerRange, numRounds) {
var output = [];
var owners = [];
if(ownerRange && numRounds) {//checking for valid inputs
for (var i = 0; i < ownerRange.length; i++) {
if (ownerRange[i][0] !== '') {
owners.push(ownerRange[i][0]);
}
}
for (var i = 0; i < numRounds; i++) {
if (i % 2 == 0) {
output = output.concat(owners);
} else {
output = output.concat([].concat(owners).reverse());
}
}
return output;
}else{
SpreadsheetApp.getUi().alert('Invalid Inputs')
}
}

body.replaceText() in Google Docs

I wrote a function for using a spinText synonyms in docs. Ie. I have a text in the document like this: "{Hello|Hi} Mr {Thomas|Mathew|Andrew}"
Function give me 2 arrays: toreplace[], synonyms[] but the result of
for (var i = 0; i < rangeElements.length; ++i) {
body.replaceText(toreplace[i],synonyms[i]);
}
give me a text like this: Hi|Hi Mr Andrew|Andrew|Andrew but i would like to get "Hi Mr Andrew".
I tried Logger.log(toreplace[0]) and gets "{Hello|Hi}" and Logger.log(synonyms[0]) show "Hi" so it should be translated into body.replaceText('{Hello|Hi}','Hi');
What i am doing wrong?
function synonymize() {
var body = DocumentApp.getActiveDocument().getBody();
var rangeElements = [];
var rangeElement=null;
var start=[];
var end=[];
var lentabs=[];
var str;
var synonyms=[];
var toreplace=[];
var x=0;
while (rangeElement = body.findText('[{].+?[}]',rangeElement))
{
rangeElements.push(rangeElement);
start.push(rangeElement.getStartOffset());
end.push(rangeElement.getEndOffsetInclusive());
}
for (var i = 0; i < rangeElements.length; ++i) {
lentabs[i]=rangeElements[i].getElement().getText().substring(start[i]+1, end[i]).split('|').length
toreplace[i]=rangeElements[i].getElement().getText().substring(start[i], end[i]+1);
min=0;
max=lentabs[i]-1;
rand=Math.floor(Math.random()*(max-min+1)+min)
synonyms.push(rangeElements[i].getElement().getText().substring(start[i]+1, end[i]).split('|')[rand]);
}
for (var i = 0; i < rangeElements.length; ++i) {
body.replaceText(toreplace[i],synonyms[i]);
}
}
Ok. The problem was in the "|" which is treated as a regex pattern. I changed text in the document to "{Hello#Hi} Mr {Thomas#Mathew#Andrew}" and now it's working ok.

Check if current user is the administrator of a certain Google group

I want to go through all the Google groups I am a member of and get the list of all the users of each group :
var list = GroupsApp.getGroups();
for(var i = 0; i< list.length; i++){
for(var key in headerObj){
var text = "";
if(key == "users"){
var tab = list[i].getUsers();
if(tab.length > 0){
text = tab[0].getEmail();
for(var j = 1; j < tab.length; j++){
text += ", " + tab[j].getEmail();
}
}
headerObj[key].push(text);
}
}
}
But I always get this Exception :
You do not have permission to view the member list for the group: "group email"
Is there a way to go through all the Google groups of which, I am the administrator ?
Unfortunatly such a thing is not possible there is however the workaround of a try catch:
function myFunction() {
var allGroups = GroupsApp.getGroups();
for (var i in allGroups){
try {
var users = allGroups[i].getUsers();
for (var j in users){
Logger.log(users[j]);
}
}
catch (e) { }
}
}