Angular working well with IE7 document Mode 7. It's also working well with IE8 document Mode 8, but with IE8 document mode 7 not working.
This is the error:
{
description: "Member not found.
",
message: "Member not found.
",
name: "Error",
number: -2147352573
}
And this is the line where the error is throw:
this.$$element.attr(attrName, value);
Member not found
I'm using Angular 1.2.9. How can i fix it?
i have found the solution. Just check if (msie && msie <= 8) and it's work also in IE7.
I have also changed jqLiteRemoveClass and jqLiteAddClass
function jqLiteRemoveClass(element, cssClasses) {
if (msie && msie <= 8) {
if (cssClasses) {
forEach(cssClasses.split(' '), function(cssClass) {
element.className = trim(
(" " + element.className + " ")
.replace(/[\n\t]/g, " ")
.replace(" " + trim(cssClass) + " ", " ")
);
});
}
} else {
if (cssClasses && element.setAttribute) {
forEach(cssClasses.split(' '), function(cssClass) {
element.setAttribute('class', trim(
(" " + (element.getAttribute('class') || '') + " ")
.replace(/[\n\t]/g, " ")
.replace(" " + trim(cssClass) + " ", " "))
);
});
}
}
}
function jqLiteAddClass(element, cssClasses) {
if (msie && msie <= 8) {
if (cssClasses) {
forEach(cssClasses.split(' '), function(cssClass) {
if (!jqLiteHasClass(element, cssClass)) {
element.className = trim(element.className + ' ' + trim(cssClass));
}
});
}
} else {
if (cssClasses && element.setAttribute) {
var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
.replace(/[\n\t]/g, " ");
forEach(cssClasses.split(' '), function(cssClass) {
cssClass = trim(cssClass);
if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) {
existingClasses += cssClass + ' ';
}
});
element.setAttribute('class', trim(existingClasses));
}
}
}
Related
I want to log when a member has been updated for example a new avatar or nickname. I can log it to a console but when I try to send it to a channel it fails. There are no errors in console. I have tried using multiple accounts and different channels but still no result or any errors in console.
client.on('guildMemberUpdate', async (oldMember, newMember) => {
const guild = newMember.guild;
var Changes = {
unknown: 0,
addedRole: 1,
removedRole: 2,
username: 3,
nickname: 4,
avatar: 5
}
var change = Changes.unknown
var removedRole = ''
oldMember.roles.every(function (value) {
if (newMember.roles.cache.find('id', value.id) == null) {
change = Changes.removedRole
removedRole = value.name
}
})
var addedRole = ''
newMember.roles.every(function (value) {
if (oldMember.roles.cache.find('id', value.id) == null) {
change = Changes.addedRole
addedRole = value.name
}
})
if (newMember.user.username != oldMember.user.username) {
change = Changes.username
}
if (newMember.nickname != oldMember.nickname) {
change = Changes.nickname
}
if (newMember.user.avatarURL() != oldMember.user.avatarURL()) {
change = Changes.avatar
}
var log = guild.channels.cache.get(`755216180603650059`)
if (log != null) {
switch (change) {
case Changes.unknown:
log.send('**[User Update]** ' + newMember)
break
case Changes.addedRole:
log.send('**[User Role Added]** ' + newMember + ': ' + addedRole)
break
case Changes.removedRole:
log.send('**[User Role Removed]** ' + newMember + ': ' + removedRole)
break
case Changes.username:
log.send('**[User Username Changed]** ' + newMember + ': Username changed from ' +
oldMember.user.username + '#' + oldMember.user.discriminator + ' to ' +
newMember.user.username + '#' + newMember.user.discriminator)
break
case Changes.nickname:
log.send('**[User Nickname Changed]** ' + newMember + ': ' +
(oldMember.nickname != null ? 'Changed nickname from ' + oldMember.nickname +
+newMember.nickname : 'Set nickname') + ' to ' +
(newMember.nickname != null ? newMember.nickname + '.' : 'original username.'))
break
case Changes.avatar:
log.send('**[User Avatar Changed]** ' + newMember)
break
}
}
})
Based off Levi_OP's comment
if (a != b) {
//...
}
needs to turn into:
if (a !== b) {
//...
}
Javascript we had for Unified interface of Dynamics 365 to format phone numbers was working perfectly until the latest update, now it only works in custom interface and has stopped working in UI, anybody has any idea how this can be fixed?
var XXX = window.XXX || {};
(function() {
// Code to run in the form OnLoad event
this.formOnLoad = function(executionContext) {
var formContext = executionContext.getFormContext();
// display the form level notification as an INFO
formContext.ui.setFormNotification(message, "INFO", myUniqueId);
// Wait for 5 seconds before clearing the notification
window.setTimeout(function() {
formContext.ui.clearFormNotification(myUniqueId);
}, 5000);
}
// Code to run in the attribute OnChange event
this.mobilePhoneFormatting = function(executionContext) {
var formContext = executionContext.getFormContext();
var mobilePhone = formContext.getAttribute("mobilephone").getValue();
var formatPhone = "";
try {
if (mobilePhone != null) {
var phoneNumbers = mobilePhone.replace(/\D/g, '');
if (phoneNumbers.length == 10) { //10 digit case. Output adds +1 and proper format
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10));
} else if (phoneNumbers.length == 11) { //11 digit case. Output proper format
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11));
} else if (phoneNumbers.length == 14) { //14 digit case. Without Country code and with extension
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10) + " x" + phoneNumbers.substring(10, 14));
} else if (phoneNumbers.length == 15) { //15 digit case. With Country code and extension
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11) + " x" + phoneNumbers.substring(11, 15));
} else if (phoneNumbers.length == 4) { //4 digit case. Extension Only
formatPhone = ("x" + phoneNumbers.substring(0, 4));
} else {
formatPhone = mobilePhone;
}
formContext.getAttribute("mobilephone").setValue(formatPhone);
formContext.data.entity.save();
}
} catch (err) {
txt = "There was an error formatting the Phone Number.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
}
So I've had a search around, and can't for the life of me understand why this would work perfectly in one browser, and not in the others. On line 13 I'm getting this error in Safari:
On Firefox, I don't get any errors, but the Script breaks in the same fashion. I've tried making the for loop for ( var p in productFamily ) or for ( let p of productFamily ) but it just breaks the script.
Am I looping incorrectly?
Here is my code:
$(window).load(function(){
// All possible families are defined here...
var productFamily = ["Beaches","Leios","Lull"];
// All possible product types are defined here...
var productType = ["Shelter","Restroom"];
// All possible product sizes are defined here...
var sizeRange = ["4x4","4x8","6x4","6x8","8x4","8x6"];
// Here we loop through each Family, Type and Size...
for ( let p in productFamily ) {
for ( let t in productType ) {
for ( let i in sizeRange ) {
// Get all of the select types...
$('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' Size]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Frame]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Fasteners]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Roof]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Column Infill]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Soffit and Sunscreen]"],'+
'select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Columns]"]').change(function(){
// Get the values of all the selects as they change...
var mySizeSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' Size]"]').val();
var myFrameSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Frame]"]').val();
var myFastenersSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Fasteners]"]').val();
var myColumnSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Columns]"]').val();
var myInfillSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Column Infill]"]').val();
var myRoofSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Roof]"]').val();
var mySoffitSelection = $('select[name="properties[' + productFamily[p] + ' ' + productType[t] + ' ' + sizeRange[i] + ' Soffit and Sunscreen]"]').val();
var empty;
// This changes the formatting of the size selection...
if ( mySizeSelection == "4x4" ) {
mySizeSelection = "44";
} else if ( mySizeSelection == "4x8" ) {
mySizeSelection = "48";
} else if ( mySizeSelection == "6x4" ) {
mySizeSelection = "64";
} else if ( mySizeSelection == "6x8" ) {
mySizeSelection = "68";
} else if ( mySizeSelection == "8x4" ) {
mySizeSelection = "84";
} else {
mySizeSelection = "86";
}
// This changes the formatting of the Frame selection...
if ( myFrameSelection == "Galvanised" ) {
myFrameSelection = "G";
} else if ( myFrameSelection = "Painted" ) {
myFrameSelection = "P";
} else {
myFrameSelection = "G";
}
// This changes the formatting of the Column selection...
if ( myColumnSelection == "Galvanised" ) {
myColumnSelection = "G";
} else if ( myColumnSelection = "Painted" ) {
myColumnSelection = "P";
} else {
myColumnSelection = "G";
}
// This changes the formatting of the Roof selection...
if ( productFamily[p] == "Beaches" ) {
if ( myRoofSelection == "Colorbond" ) {
myRoofSelection = "C";
} else if ( myRoofSelection == "Polycarbonite" ) {
myRoofSelection = "C";
} else if ( myRoofSelection == "None" ) {
myRoofSelection = "C";
} else {
myRoofSelection = "C";
}
} else {
if ( myRoofSelection == "Colorbond" ) {
myRoofSelection = "C";
} else if ( myRoofSelection == "Polycarbonite" ) {
myRoofSelection = "P";
} else if ( myRoofSelection == "None" ) {
myRoofSelection = "N";
} else if ( myRoofSelection == "Galvanised" ) {
myRoofSelection = "G";
} else if ( myRoofSelection == "Painted" ) {
myRoofSelection = "P";
} else {
myRoofSelection = "C";
}
}
// This changes the formatting of the Infill selection...
if ( myInfillSelection == "Yes" ) {
myInfillSelection = "I";
} else if ( (myInfillSelection == "No") || (myInfillSelection == "None" ) ) {
myInfillSelection = "N";
} else if ( myInfillSelection == "Solid Colour" ) {
myInfillSelection = "S";
} else if ( myInfillSelection == "Timber" ) {
myInfillSelection = "T";
} else {
myInfillSelection = "N";
}
// This changes the formatting of the Fastener selection...
if ( myFastenersSelection == "Galvanised" ) {
myFastenersSelection = "G";
} else if ( myFastenersSelection = "Stainless Steel") {
myFastenersSelection = "G";
} else {
myFastenersSelection = "G";
}
// This changes the formatting of the Soffit selection...
if ( mySoffitSelection == "Miniorb Soffit / No Sunscreen" ) {
mySoffitSelection = "CN";
} else if ( mySoffitSelection == "Timber Soffit / No Sunscreen" ) {
mySoffitSelection = "TN";
} else if ( mySoffitSelection == "Aluminium Soffit / No Sunscreen" ) {
mySoffitSelection = "AN";
} else if ( mySoffitSelection == "Miniorb Soffit / Miniorb Sunscreen" ) {
mySoffitSelection = "CC";
} else if ( mySoffitSelection == "Timber Soffit / Timber Sunscreen" ) {
mySoffitSelection = "TT";
} else if ( mySoffitSelection == "Aluminium Soffit / Aluminium Sunscreen" ) {
mySoffitSelection = "AA";
} else {
mySoffitSelection = "CN";
}
// If a Lull family item is selected, the src attribute url is updated... "C" is a hard-coded placeholder for Footing choices (between Cast-In or Slab Fixed), hence the "C" - Cast-In.
if ( productFamily[p] == "Lull" ) {
// If all choices have been chosen...
if ( mySizeSelection || myFrameSelection || myFastenersSelection ) {
var url = "//placeholder.com.au/"+ productFamily[p] + "_" + productType[t] + "/" + productFamily[p].toUpperCase() + "_" + mySizeSelection + myFrameSelection + "C" + myFastenersSelection + ".jpg";
$('.product-main-image img').attr("src",url);
console.log(url);
} else {
console.log("All options must be chosen.");
}
// If a Leios family item is selected, the src attribute url is updated... "C" is a hard-coded placeholder for Footing choices (between Cast-In or Slab Fixed), hence the "C" - Cast-In.
} else if ( productFamily[p] == "Leios" ) {
// If all choices have been chosen...
if ( mySizeSelection || myColumnSelection || myFrameSelection || myRoofSelection || myInfillSelection || myFastenersSelection ) {
var url = "//placeholder.com.au/"+ productFamily[p] + "_" + productType[t] + "_V3/" + productFamily[p].toUpperCase() + "_" + mySizeSelection + myColumnSelection + myFrameSelection + myRoofSelection + myInfillSelection + "C" + myFastenersSelection + ".jpg";
$('.product-main-image img').attr("src",url);
console.log(url);
} else {
console.log("All options must be chosen.");
}
// If a Beaches family item is selected, the src attribute url is updated... "C" is a hard-coded placeholder for Footing choices (between Cast-In or Slab Fixed), hence the "C" - Cast-In.
} else if ( productFamily[p] == "Beaches" ) {
// If all choices have been chosen...
if ( mySizeSelection || myFrameSelection || myRoofSelection || mySoffitSelection || myInfillSelection || myFastenersSelection ) {
var url = "//placeholder.com.au/"+ productFamily[p] + "_" + productType[t] + "/" + productFamily[p].toUpperCase() + "_" + mySizeSelection + myFrameSelection + myRoofSelection + mySoffitSelection + myInfillSelection + "C" + myFastenersSelection + ".jpg";
$('.product-main-image img').attr("src",url);
console.log(url);
} else {
console.log("All options must be chosen.");
}
} else {
console.log("No product family showing up...");
}
console.log("\n///////////////////////////////// END OF ON-CHANGE LOOP /////////////////////////////////\n\n");
}); // End of On change function.
} // End of sizeRange loop.
} // End of productType loop.
} // End of productFamily loop.
});
#Barmar hit the nail on the head - the type of for loop I was attempting was part of ES6 and not supported by all browsers, I ended up using the forEach function, courtesy of this link.
Here is a snippet of how I've used it in my script:
productFamily.forEach(function (value, p) {
productType.forEach(function (value, t) {
sizeRange.forEach(function (value, i) {
I can't figure out why this snippet logs false. I'm convinced it should log to true. What am I doing wrong?
var hasElb = function(string12b,char12b) {
var el = [];
for (var i = 0; i < string12b.length; i++ ) {
if (string12b[i] === char12b) {
el += char12b;
}
}
if (el[0] === char12b) {
console.log(true + " el[0] = " + el[0] + " and char12b = " + char12b);
}
else {
console.log(false + " el[0] = " + el[0] + " and char12b = " + char12b);
}
};
hasElb([1,3,5,7,9,11],7);
To add an element to an array, you use .push(), not +=:
if (string12b[i] === char12b) {
el.push(char12b);
}
I am coding a quiz and need to have it display a certain answer depending on the score.
I had this working when I just had the score being displayed, but now that I have added in the if else, it has stopped working and I am getting an unterminated string constant
$total_score = $first_question + $second_question + $third_question + $fourth_question + $fifth_question + $sixth_question + $seventh_question + $eighth_question + $ninth_question + $tenth_question + $eleventh_question + $twelfth_question + $thirteenth_question + $fourteenth_question + $fifthteenth_question + $sixteenth_question ;
});
$("#btn").click(function() {
$('#reveal').html("<h3><strong>Total score</strong> " + $total_score +"</h3>");
if ($total_score >= 13) {
$('#answer').html("<h3><strong>13-16: Answer</strong></h3>");
} else if ($total_score >=9 && $total_score <= 12) {
$('#answer').html("<h3><strong>9-12: answer</strong></h3>");
} else if ($total_score >=5 && $total_score <= 8) {
$('#answer').html("<h3><strong>5-8: answer</strong></h3>");
} else {
$('#answer').html("<h3><strong> everything else</strong></h3>");
}
});
In addition to the line breaks as #Spork noted, you need to remove the extraneous "})" after the $total_score calculation:
$total_score = $first_question + $second_question + $third_question + $fourth_question + $fifth_question + $sixth_question + $seventh_question + $eighth_question + $ninth_question + $tenth_question + $eleventh_question + $twelfth_question + $thirteenth_question + $fourteenth_question + $fifthteenth_question + $sixteenth_question ;
/* must remove the following:
});
*/
$("#btn").click(function() {
$('#reveal').html("<h3><strong>Total score</strong> " + $total_score +"</h3>");
if ($total_score >= 13) {
$('#answer').html("<h3><strong>13-16: Answer </strong></h3>");
} else if ($total_score >=9 && $total_score <= 12) {
$('#answer').html("<h3><strong>9-12: answer </strong></h3>");
} else if ($total_score >=5 && $total_score <= 8) {
$('#answer').html("<h3><strong>5-8: answer </strong></h3>");
} else {
$('#answer').html("<h3><strong> everything else</strong></h3>");
}
});
Javascript treats line ends roughly as semicolons (;), so you cannot have multi-line strings as you have in your script. Remove them, and it'll be okay.