javascript - Change color of specific word got from script -
i'm trying adapt code change color of single word, don't know how.
the original code is
crypt_single_getpar = eval('(' + httpget("https://api.cryptonator.com/api/ticker/" + crypt_single_base_currency.match(/.*?\(([0-9a-z]+)\)/i)[1] + "-" + crypt_single_target_currency.match(/.*?\(([0-9a-z]+)\)/i)[1]) + ')');
and
if (crypt_single_getpar.success != false) { if (crypt_single_getpar.ticker.price > 1) crypt_single_price = math.round(crypt_single_getpar.ticker.price * 100) / 100; else crypt_single_price = crypt_single_getpar.ticker.price var crypt_single_text_style = '<font style="color:#cc0000;"><b>↓</b></font>'; if (crypt_single_getpar.ticker.change >= 0) { crypt_single_text_style = '<font style="color:#009900;"><b>↑</b></font>'; } document.write('\ <div class="cryptonatorwidget" style="border-radius:4px;padding:10px;' + crypt_single_style + '">\ <div><font style="font-size:90%;">' + crypt_single_base_currency + '</font>\ <b>' + crypt_single_price + '</b> ' + crypt_single_target_currency.match(/.*?\(([0-9a-z]+)\)/i)[1] +'\ </div>');
the result in white. ( couldn't post image due not having minimum reputation)
decred (dcr) [current value] btc
and i'm trying change color this
decred (dcr) [current value] [green]btc[green]
i tried achieve result
document.write('\ <div class="cryptonatorwidget" style="border-radius:4px;padding:10px;' + crypt_single_style + '">\ <div><font style="font-size:90%;">' + crypt_single_base_currency + '</font>\ <b>' + crypt_single_price + '</b> ' + <span style="color:#2ed7a2;">' + crypt_single_target_currency.match(/.*?\(([0-9a-z]+)\)/i)[1] + '</span>\ </div>');
but disappeared in web page.
could me?
thanks.
ps: also, told me never use eval in wordpress (in case, text widget). how without eval?
lau
thanks help.
in time, found error ^^
crypt_single_display_time = false; function httpget(theurl) { var xmlhttp = null; xmlhttp = new xmlhttprequest(); xmlhttp.open( "get", theurl, false ); xmlhttp.send( null ); return xmlhttp.responsetext; } function formatnumberlength(num, length) { var r = "" + num; while (r.length < length) { r = "0" + r; } return r; } crypt_single_base_currency = typeof crypt_single_base_currency == "undefined" ? "bitcoin (btc)" : crypt_single_base_currency; crypt_single_target_currency = typeof crypt_single_target_currency == "undefined" ? "us dollar (usd)" : crypt_single_target_currency; crypt_single_background_color = typeof crypt_single_background_color == "undefined" ? "#ffffff" : crypt_single_background_color; crypt_single_transperency = typeof crypt_single_transperency == "undefined" ? true : crypt_single_transperency; crypt_single_border_width = typeof crypt_single_border_width == "undefined" ? 1 : crypt_single_border_width; crypt_single_border_color = typeof crypt_single_border_color == "undefined" ? "#cccccc" : crypt_single_border_color; crypt_single_border_corners = typeof crypt_single_border_corners == "undefined" ? "rounded" : crypt_single_border_corners; crypt_single_font_family = typeof crypt_single_font_family == "undefined" ? "arial" : crypt_single_font_family; crypt_single_font_size = typeof crypt_single_font_size == "undefined" ? "medium" : crypt_single_font_size; crypt_single_font_color = typeof crypt_single_font_color == "undefined" ? "#000000" : crypt_single_font_color; crypt_single_display_time = typeof crypt_single_display_time == "undefined" ? true : crypt_single_display_time; crypt_single_getpar = eval('(' + httpget("https://api.cryptonator.com/api/ticker/" + crypt_single_base_currency.match(/.*?\(([0-9a-z]+)\)/i)[1] + "-" + crypt_single_target_currency.match(/.*?\(([0-9a-z]+)\)/i)[1]) + ')'); crypt_single_month_name = new array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); crypt_single_date = new date(crypt_single_getpar.timestamp * 1000); crypt_single_day = formatnumberlength(crypt_single_date.getdate(), 2); crypt_single_month = crypt_single_month_name[crypt_single_date.getmonth()]; crypt_single_year = crypt_single_date.getfullyear(); crypt_single_hour = formatnumberlength(crypt_single_date.gethours(), 2); crypt_single_minutes = formatnumberlength(crypt_single_date.getminutes(), 2); crypt_single_seconds = formatnumberlength(crypt_single_date.getseconds(), 2); crypt_single_time_zone = "utc+0:00"; if (crypt_single_transperency) crypt_single_background_color = 'transparent'; switch (crypt_single_font_size) { case 'small': crypt_single_font_size = "90%"; break; case 'medium': crypt_single_font_size = "110%"; break; case 'large': crypt_single_font_size = "150%"; break; } crypt_single_style = 'background: ' + crypt_single_background_color + '; border: ' + crypt_single_border_width + 'px solid ' + crypt_single_border_color + ';' + 'font-family: ' + crypt_single_font_family +'; font-size: ' + crypt_single_font_size + '; color: ' + crypt_single_font_color + ';'; if (crypt_single_border_corners == "square") { crypt_single_style += "-webkit-border-radius: 0 !important; -moz-border-radius: 0 !important; border-radius: 0 !important;"; } if (crypt_single_getpar.success != false) { if (crypt_single_getpar.ticker.price > 1) crypt_single_price = math.round(crypt_single_getpar.ticker.price * 100) / 100; else crypt_single_price = crypt_single_getpar.ticker.price var crypt_single_text_style = '<font style="color:#cc0000;"><b>↓</b></font>'; if (crypt_single_getpar.ticker.change >= 0) { crypt_single_text_style = '<font style="color:#009900;"><b>↑</b></font>'; } document.write('\ <div class="cryptonatorwidget" style="border-radius:4px;padding:10px;' + crypt_single_style + '">\ <div><font style="font-size:90%;">' + crypt_single_base_currency + '</font>\ <b>' + crypt_single_price + '</b><span style="color:green";> ' + crypt_single_target_currency.match(/.*?\(([0-9a-z]+)\)/i)[1] +' </span>\ </div>'); } else { document.write('\ <div class="cryptonatorwidget" style="border-radius:4px;padding:10px;' + crypt_single_style + '">\ <b>nenhum preço disponível</b>\ </div>'); } if (crypt_single_display_time && crypt_single_getpar.success != false) document.write('<div style="font-size:70%;opacity:0.6;padding-top:10px;">\ updated ' + crypt_single_day + ' ' + crypt_single_month + ' ' + crypt_single_year + ' ' + crypt_single_hour + ':' + crypt_single_minutes + ':' + crypt_single_seconds + ' ' + crypt_single_time_zone + '\ </div>'); document.write('<div id="cryptoticker" style="font-size:10px;opacity:0.6;padding-top:10px;"><span>powered <a href="https://www.arkhad.com" style="color:' + crypt_single_font_color + ';" target="_blank">arkhad</a></span></div>\ </div>');
div#cryptoticker span { display: none; }
i'm missing cannot find :/
Comments
Post a Comment