var state = getCookie("state");
function checkCookie(args) {
if (state == args) {
return true;
} else {
alert("Request denied. Invalid auth code provided.");
return false;
}
}
const tokenElement = document.getElementsByName("dream");
var loginSrv = checkCookie(getAllUrlParams().state);
document.cookie = `state=${getAllUrlParams().state}; path=/`;
tokenElement.innerText = getAllUrlParams().code;
if (getAllUrlParams().state != loginSrv) {
alert(`Incorrect auth code provided. The correct code is ${state}`);
}
If they provide the wrong oauth state code, tell the user the correct one!
<Image source={ this.props.pickupOrDropoff == "pickup"
? i.pickup
? iconBlue
: iconWhite
: i.dropoff
? iconBlue
: iconWhite} style={{
height:this.props.pickupOrDropoff == "pickup"
? i.pickup
? 30
: i.sign === 'D' ? 30 : 35
: i.dropoff
? 30
: i.sign === 'D' ? 30 : 35,
marginRight:10 ,
width: this.props.pickupOrDropoff == "pickup"
? i.pickup
? 40
: 40
: i.dropoff
? 40
: 40
,resizeMode:'contain'}}/>
I love when the code is neat...
if (code === null) {
return null;
} else {
return code;
}
String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1);};
String.prototype.followCase=function(b){
if(b==b.toUpperCase()){return this.toUpperCase();}
if(b==b.toLowerCase()){return this.toLowerCase();}
if(b==b.capitalize()){return this.capitalize();}
return this;
};
String.prototype.atRemoveAdd=function(index,n,string){
return this.substring(0,index)+string+this.substring(index+n,this.length);
};
String.prototype.matchIndex=function(re){
var a=[];
while((match=re.exec(this))!==null){
a.push({chars:match[0].length,index:match.index});
}
return a;
};
String.prototype.caseReplace=function(o,n){
for(var s=this,a=this.matchIndex(o),shift=0,i=0;i<a.length;i++){
var c=n.followCase(this.substring(a[i].index,a[i].index+a[i].chars));
s=s.atRemoveAdd(a[i].index+shift,a[i].chars,c);
shift+=c.length-a[i].chars;
}
return s;
};
My code from 2016 for the hall of shame where I realized today that caseReplace could just return this.replace(o,m=>n.followCase(m))
instead.
filterForProvincia() {
console.log('ciao');
}
The last line of code of a parting Developer
const configs = {
employeeObject: {
// tab 0
firstName: "",
middleName: "",
nickname: "",
lastName: "",
gender: "",
race: "",
title: "",
dob: "",
employeeIDNo: "",
// tab 1
userName: "",
permissionRole: 0,
employeeNo: "",
phoneExt: "",
startDate: "",
company: "",
division: "",
jobDescription: "",
businessUnit: "",
regionId: "",
participantStatus: "",
costCentre: "",
personType: "",
comments: "",
// tab 2
phone1: "",
phone2: "",
phone3: "",
address1: "",
address2: "",
address3: "",
address4: "",
postalCode: "",
email: "",
},
Why add another object with a title when you can just add a comment saying... well... nothing really...
// Save the files for 100 timea in case failed
try {
for (let i; i <= 100; i++) {
File.save();
}
} catch (e) {
// Save the files for 100 timea since it already failed
for (let i; i <= 100; i++) {
File.save();
}
}
function sortUsers(a, b) {
return a.last_name.localeCompare(b.last_name) * -1;
}
function resetfields_simple()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('katId');
pole4.value='';
}
function resetfields()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('dokId');
pole4.value='';
pole5=document.getElementById('katId');
pole5.value='';
pole6=document.getElementById('currId');
pole6.value='';
}
function resetfields_arch()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('dokId');
pole4.value='';
pole5=document.getElementById('katId');
pole5.value='';
}
let already_in = True;
while (already_in) {
let random_index = Math.floor(arr.length * Math.random());
let already_in = False;
for (ex of exs) {
if (ex.id === arr[random_index].id) {
already_in = True;
}
}
}
Yes, this is JavaScript, and yes it didn't work. Found while reviewing some code
if (!response ||
!response.data ||
!response.data.success ||
response.data.success == false ) {
//process stuff
}
Not talking about the '===' warning, here
pageEndReached() {
if (!this.endOfResults) {
//load more pages
this.page++;
this.getPosts();
followerCount: null,
postCount: null,
measurementKeys: ["a", "b", "c", "d", "e"],
showDrafts: false,
};
},
nani
socket.on('newMessage', (messageObj) => {
if (roomNumber === messageObj.roomNumber) {
console.log("message received:" + messageObj.message);
$('#messages').append($('<li>').text(messageObj.userName + ' : ' + messageObj.message));
}
});
socket.in wasn't behaving as advertised (broadcasting to all rooms). I decided to take matters into my own hands.
let verificaAdmin_Role = (req, res, next) => {
let usuario = req.usuario;
if (usuario.role === 'ADMIN_ROLE') {
next();
} else {
return res.status(409).json({
ok: false,
err: {
message: 'El usuario no es administrador.'
}
})
}
};
He's our company CTO, with 25+ years of experience. Author https://github.com/juang77"
if (cookiesBannerHeight !== 0 && isMobile) {
style = {
top: cookiesBannerHeight === 0 ? 0 : cookiesBannerHeight
}
}