The if statement gives me the correct information for swipeDirection and swipeLength and I've obtained both the results of the IF and the ELSE except for the image changing.
if ( (swipeDirection = 'down') && (swipeLength >= 180) ) {
touchEnabledElement.style.backgroundimage = 'railroadtracks.png';
document.getElementById('message').innerHTML = "IF" + 'Start H:' + startX + ' V:' + startY + '<br>' + ' End H:' + curX + ' V:' + curY + '<br>' + "Swipe Length: " + swipeLength + '<br>' + 'Swipe Angle: ' + swipeAngle + '°' + '<br>' + 'Swipe Direction: ' + swipeDirection + '<br><br><span style="font-size:.5em;">(Please wait for green screen before swiping again)<\/span>';
} else {
document.getElementById('message').innerHTML = "ELSE" + 'Start H:' + startX + ' V:' + startY + '<br>' + ' End H:' + curX + ' V:' + curY + '<br>' + "Swipe Length: " + swipeLength + '<br>' + 'Swipe Angle: ' + swipeAngle + '°' + '<br>' + 'Swipe Direction: ' + swipeDirection + '<br><br><span style="font-size:.5em;">(Please wait for green screen before swiping again)<\/span>';
touchEnabledElement.style.backgroundimage = 'railroadtracks2.png';
Try .backgroundImage (NB: capital "i")
The property is backgroundImage not backgroundimage, and the syntax of a URL in CSS is url(railroadtracks.png) not just railroadtracks.png
You're assigning (=) instead of comparing (==) here:
if ( (swipeDirection = 'down') && (swipeLength >= 180) ) {
Did you mean to do swipeDirection = 'down' instead of swipeDirection == 'down'?
Related
The line in question is...
if(listContent[Source].properties === ""
I need it to check if the "Source" key has any value. It's currently not outputting anything. What is proper syntax for this?
Here is the full code:
if (visibleFeatures) {
var uniqueFeatures = getUniqueFeatures(visibleFeatures, "arrayIndex");
for (var i = 0; i < uniqueFeatures.length; i++) {
if (listContent[Source].properties === "") {
listContent += '<div class="dealer"><h3>' + uniqueFeatures[i].properties.Name + '</h3><p class="address">' + uniqueFeatures[i].properties.Address + '<br>' + uniqueFeatures[i].properties.City + ', ' + uniqueFeatures[i].properties.State + ' ' + uniqueFeatures[i].properties.Zip + '</p><p class="phone">' + uniqueFeatures[i].properties.Phone + '</p></div>';
} else {
listContent += '<div class="dealer"><h3>' + uniqueFeatures[i].properties.Name + '</h3><p class="address">' + uniqueFeatures[i].properties.Address + '<br>' + uniqueFeatures[i].properties.City + ', ' + uniqueFeatures[i].properties.State + ' ' + uniqueFeatures[i].properties.Zip + '</p><p class="phone">' + uniqueFeatures[i].properties.Phone + '</p><p class="bl-map-link">' + uniqueFeatures[i].properties.Source + '</p></div>';
}
}
Thank you guys so much for all the help. I was able to figure out my error.
!!uniqueFeatures[i].properties.Source
The !! is what made the difference. I'm still researching why this works and why this doesn't if (strValue === "").
The function is replicating each item that I place in. It runs through all of the panels, and places the additional items each time it runs. I have tried using the if statement that is placed but it is not working. I am placing the entire code block, but the issue starts at the let x = -1 variable. The full code block is strictly for reference. Please let me know if there is anything additional that I can provide. Additionally, .first() will not work for this instance.
function getRecordUI( alias, type, id, viewtype, version ) {
// Get record model from Data Model Registry
if ( type ) {
getJSONUIModel( type,
function ( data ) {
displayRecordSections( alias, type, id, version, viewtype, data );
},
function (error) {
console.log("Error getting UI model for type " + type);
console.log(error);
displayRecordSections( alias, type, id, version, viewtype, null );
});
} else {
displayRecordSections( alias, type, id, version, viewtype, null );
}
let x = -1;
lastName = "";
$("#panels-region .panel-heading").each(function () {
x++
let curName = $(this).attr("name")
if(!$('<a id="panels-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '"> ' + curName + '</a>')) {
$('<a id="panels-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '"> ' + curName + '</a>').insertAfter("#panels-sidebar" + lastName.replace(/ |\//g, "_"))
break;
}
lastName = "-" + curName;
});
$("#graph-region .panel-heading h4").each(function () {
x++
let curName = $(this).text().replace("Collapse panelExpand panel", "")
if(!$('<a id="tree_viewers-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '"> ' + curName + '</a>')) {
$('<a id="tree_viewers-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '"> ' + curName + '</a>').insertAfter("#tree_viewers-sidebar" + lastName.replace(/ |\//g, "_"))
break;
}
lastName = "-" + curName
});
$(".menu-links a").css("padding", "0px 8px")
$(".panel-body").css("background-color", "white")
$("#panels-region .panel-wrapper .panel-default").css("background-color", "white")
}
var query =
'SELECT '
+ prefix + 'threads.tid as _tid, '
+ prefix + 'threads.fid as _cid, '
+ prefix + 'threads.firstpost as _pid, '
+ prefix + 'threads.views as _viewcount, '
+ prefix + 'threads.subject as _title, '
+ prefix + 'threads.dateline as _timestamp, '
+ prefix + 'threads.sticky as _pinned, '
+ prefix + 'posts.uid as _uid, '
+ prefix + 'posts.tid as _post_tid, '
+ prefix + 'posts.message as _content, '
+ 'IF(filetype like "image%", CONCAT("/uploads/files/MyBBAttachment/", attachname), NULL) as _images, '
+ 'IF(filetype like "image%", GROUP_CONCAT(filename SEPARATOR ","), NULL) as _imgnames, '
+ 'IF(filetype not like "image%", CONCAT("/uploads/files/MyBBAttachment/", attachname), NULL) as _attachments, '
+ 'IF(filetype not like "image%", GROUP_CONCAT(filename SEPARATOR ","), NULL) as _attachnames '
+ 'FROM ' + prefix + 'posts LEFT JOIN ' + prefix + 'attachments ON (' + prefix + 'posts.pid = ' + prefix + 'attachments.pid), ' + prefix + 'threads '
+ 'WHERE ' + prefix + 'threads.firstpost=' + prefix + 'posts.pid '
+ 'GROUP BY ' + prefix + 'posts.pid'
+ (start >= 0 && limit >= 0 ? 'LIMIT ' + start + ',' + limit : '');
Above query doesn't work in Node.js, I get following error:
{ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0,600000' at line 1
But when I run similar thing in PHPMyAdmin, it works:
SELECT mybb_threads.tid as _tid, mybb_threads.fid as _cid, mybb_threads.firstpost as _pid, mybb_threads.views as _viewcount, mybb_threads.subject as _title, mybb_threads.dateline as _timestamp, mybb_threads.sticky as _pinned, mybb_posts.uid as _uid, mybb_posts.tid as _post_tid, mybb_posts.message as _content
FROM mybb_posts LEFT JOIN mybb_attachments ON mybb_posts.pid = mybb_attachments.pid, mybb_threads
where mybb_threads.firstpost=mybb_posts.pid
group by mybb_posts.pid
LIMIT 0, 100
How do I make var query work?
You're missing a whitespace before the limit keyword:
+ (start >= 0 && limit >= 0 ? ' LIMIT ' + start + ',' + limit : '');
// Here -----------------------^
I don't understand why my placement of the first /span (_S) in the defFD variable is creating a new position in the array. I want to set one color for the portion dayname[i] and another after the span variable ND. But when I put the /span (_S) after the dayname section (before ND) in that position it splits the dayname into array position [0] and the rest into pos [1]. Why?
The result of the above code looks like this for the Day forecast: defFD = ["Wednesday Jan 5-", "A foggy day with a high of 47º. Hum 47%. Winds ESE at 10mph. Prec 10% chance.] I need there to be a single long string at position [0] without being split after "Wednesday Jan 5". I've come at this from several angles. Need fellow pros to help.
// STYLING VARIABLES for EXTRA DATA
var DN = '<span style= color:' + ( (where == "day") ? font_color_night : font_color_day ) + '>'; //Day-Night Color Swap
var ND = '<span style= color:' + ( (where == "day") ? font_color_day : font_color_night ) + '>'; //Night-Day Color Swap
var _S = "</span>"; //remove styling
// BUILD WEATHER DATA
var defFD = [];
for (i=0; i < (ForecastDays)+1; i++) {
defFD[i] = DN + obj.dayname[i] + " " + Suffix(dates[i]) + "- " + _S
+ ND + convertTxtDay(obj.day_desc[i]) + ((obj.code[i] == 24 && obj.day_desc[i].indexOf("wind") == -1) ? " and windy " : " ")
+ "with a high of " + obj.high[i] + "°" + Unit + ". "
+ "Hum " + obj.day_humidity[i] + "%. "
+ "Winds " + obj.day_cardinal[i] + " at " + obj.day_speed[i] + windspeedunit + ". "
+ ((obj.pop[i] != 0) ? "Prec." + obj.pop[i]+ "% chance." : "") + _S + "<P>"
;
defFN[i] = DN + obj.dayname[i] + nighttext + "- " + _S
+ ND + convertTxtNight(obj.ndesc[i]) + ((obj.code[i] == 24 && obj.ndesc[i].indexOf("wind") == -1) ? " and windy " : " ")
+ "with a low of " + obj.low[i] + "°" + Unit + ". "
+ "Hum " + obj.nhum[i] + "%. "
+ "Winds " + obj.ncard[i] + " at " + obj.nspeed[i] + windspeedunit + ". "
+ ((obj.npop[i] != 0) ? "Prec." + obj.npop[i]+ "% chance." : "") + _S + "<P>"
;
if (DayOnly == false) { defForecast.push(defFD[i], defFN[i]); } //move day & night alternating into 1 array
else { defForecast.push(defFD[i]); }
} ```
It looks like you might be missing the quotation marks around your style attributes:
var DN = '<span style="color:' + ( (where == "day") ? font_color_night : font_color_day ) + '">';
var ND = '<span style="color:' + ( (where == "day") ? font_color_day : font_color_night ) + '">';
It seems like what solves my issue is to simply add the /span's both at the end and not the middle.. Though no idea why I can't add an /span in the middle of the variable declaration without it adding a new array position.
var DN = '<span style="color:' + ( (where == "day") ? font_color_night : font_color_day ) + '">';
var ND = '<span style="color:' + ( (where == "day") ? font_color_day : font_color_night ) + '">';
var _S = "</span>"; //remove styling
defFD[i] = DN + (other variables here) +
ND + (other variables here) +
_S + _S;
I want to try and print ".00" after the variables cache.todayHigh and cache.todayLow are whole numbers.
if (ddimgtooltip.showTips) {
// update tooltip
tip = 'High ' + strings.baro_info + ': ' + cache.todayHigh + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTH +
' <br> ' + strings.minimum_info + ' ' + strings.baro_info + ': ' + cache.todayLow + ' ' + data.pressunit + ' ' + strings.at + ' ' + data.TpressTL;
if (cache.trendVal !== -9999) {
tip += '<br>' + strings.baro_trend_info + ': ' + baroTrend(cache.trendVal, data.pressunit, true) + ' ' +
(cache.trendValRnd > 0 ? '' : '') + cache.trendValRnd + ' ' + data.pressunit + '/hr';
}
$('#imgtip5_txt').html(tip);
}
e.g. 1017 hPa to 1017.00 hPa.
Is this possible?
Thanks,
William
Try this,
var yvalue = '1702 hpa';
var num = yvalue.replace(/[^0-9]+/ig,"");
value = Number(num).toFixed(2);
var fvalue= value +' '+yvalue.split(' ')[1]
console.log(fvalue);