background-color: #722872 !important;
height: 80px;
border-color: #592059;
}
#banner {
background-color: #722872 !important;
height: 80px;
border-color: #592059;
}
:star2: 1267 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
anyone know why when you click the "online" button and then the "all" button on my twitch viewer, the "offline" shows up for a split second before the "online" section does? ideally, i'd like a smooth transition without the offline users coming up briefly before the online...
@bethqiang - I don't know if this would help, I was experimenting with your project but had to reload and lost my changes. Any time your use a jQuery selector like $('#online')
, it will search the DOM to find the element or elements that it corresponds to. I don't know enough detail about how jquery works to know if it does multi-threading, searching for both of those at the same time and perhaps sometime returning the "offline" first? I tried making a class "allUsers" and using that selector.
The other thing I was trying, when I had to reload and lost it, was to cache the results of the jquery selector and the use that - var allUsers = $("#online #offline");
I think would cache the results, not sure about the order, though? I'll try it and see, perhaps fork it so I can save it in case I need to reload.
function makeFriendlyDates(arr) {
var arr0 =arr.pop();
arr0= arr0.split(/-/);
for(i=0;i<arr0.length;i++){
switch (arr0[1]) {
case 01:
arr0[1] = "Janurary";
break;
case 02:
arr0[1] = "February";
break;
case 03:
arr0[1] = "March";
break;
}}
return arr0;
}
makeFriendlyDates(['2016-01-01', '2016-02-04']);
Hello FIrends Im back!.. In this problem Ive seperated the date format and am gonna try using switch statements to convert the numbers to words.. It says "Octal literals are not allowed in strict mode." When i do this though... Is this workable or have I made a mistake somewhere??:star2: 1274 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
function makeFriendlyDates(arr) {
var arr0 =arr.shift();//create first date
arr0= arr0.split(/-/);
for(i=0;i<arr0.length;i++){
switch (arr0[1]) {
case "01":
arr0[1] = "Janurary";
break;
case "02":
arr0[1] = "February";
break;
case "03":
arr0[1] = "March";
break;
case "04":
arr0[1] = "April";
break;
case "05":
arr0[1] = "May";
break;
case "06":
arr0[1] = "June";
break;
case "07":
arr0[1] = "July";
break;
case "08":
arr0[1] ="August";
break;
case "09":
arr0[1] ="September";
break;
case "10":
arr0[1] ="October";
break;
case "11":
arr0[1] ="November";
break;
case "12":
arr0[1] ="December";
break;
}switch (arr0[2]) {
case "01":
case "21":
case "31":
arr0[2] =arr0[2]+ 'st';
break;
case "02":
case "22":
arr0[2] =arr0[2]+'nd';
break;
case "03":
case "23":
arr0[2] =arr0[2]+ 'rd';
break;
default:
arr0[2] =arr0[2]+ 'th';
break;
}
}
return arr0;
}
makeFriendlyDates(['2016-07-12', '2016-07-04']);
This coe is returning 12thththth for some reason.. I have a feeling its to do with the for loop running 3 times but Im not sure.. Any ideas?
function makeFriendlyDates(arr) {
var arr0 =arr.shift();//create first date
arr0= arr0.split(/-/);
var arr1=arr.pop();//second date
arr1=arr1.split(/-/);
for(i=0;i<arr0.length;i++){ // Loop through Dates
switch (arr0[1]) { //For each case convert them to months
case "01":
arr0[1] = "Janurary";
break;
case "02":
arr0[1] = "February";
break;
case "03":
arr0[1] = "March";
break;
case "04":
arr0[1] = "April";
break;
case "05":
arr0[1] = "May";
break;
case "06":
arr0[1] = "June";
break;
case "07":
arr0[1] = "July";
break;
case "08":
arr0[1] ="August";
break;
case "09":
arr0[1] ="September";
break;
case "10":
arr0[1] ="October";
break;
case "11":
arr0[1] ="November";
break;
case "12":
arr0[1] ="December";
break;
}switch (arr0[2]) { //Then for each day date convert to days
case "01":
case "21":
case "31":
arr0[2] =parseInt(arr0[2])+ 'st';
break;
case "02":
case "22":
arr0[2] =parseInt(arr0[2])+'nd';
break;
case "03":
case "23":
arr0[2] =parseInt(arr0[2])+ 'rd';
break;
default: //With this default that adds "th"
arr0[2] =parseInt(arr0[2])+ 'th';
break;
} // FIRST DATES
//Here starts THE SECOND DATEs Conversion------------------------------------------------------
switch (arr1[2]) {
case "01":
arr1[2] = "Janurary";
break;
case "02":
arr1[2]= "February";
break;
case "03":
arr1[2] = "March";
break;
case "04":
arr1[2] = "April";
break;
case "05":
arr1[2] = "May";
break;
case "06":
arr1[2] = "June";
break;
case "07":
arr1[2] = "July";
break;
case "08":
arr1[2] ="August";
break;
case "09":
arr1[2] ="September";
break;
case "10":
arr1[2] ="October";
break;
case "11":
arr1[2] ="November";
break;
case "12":
arr1[2] ="December";
break;
}switch (arr1[2]) {
case "01":
case "21":
case "31":
arr1[2] =parseInt(arr1[2])+ 'st';
break;
case "02":
case "22":
arr1[2] =parseInt(arr1[2])+'nd';
break;
case "03":
case "23":
arr1[2] =parseInt(arr1[2])+ 'rd';
break;
default:
arr1[2] =parseInt(arr1[2])+ 'th';
break;
}
}
return arr0 +" "+ arr1;
}
makeFriendlyDates(['2016-07-12', '2016-07-02']);
Ok so Ive managed to get the dates converted but for some reason the second date tries becomes NaNth if its under 15.. I dont get it as both dates are coded the same