I'm having issues getting my stock quote to work since Google did some changes at their end. I have read the information on this link
google finance json stock quote stopped working but it didn't help.
The earlier URL to fetch information was this
https://finance.google.com/finance/info?client=ig&q= and as we know it no longer works.
Below is my code. Can someone kindly help please!
var gstock = ["BOM:500209", "PPY:000001"];
for (var i = 0; i < gstock.length; i++) {
$.getJSON("https://finance.google.com/finance?client=ig&q=" + gstock[i] + "&callback=?", function (response) {
var stockInfo = response[0];
var stockString = '<div class="stockWrapper"> ';
stockString += '<span class="stockDirectionValue' + getGlyph(stockInfo.cp) + '"> ' + '</span>';
stockString += '<span class="stockText">BSE:</span>';
stockString += '<span class="stockPrice">' + stockInfo.l + '</span>';
stockString += '<span class="stockChange">' + stockInfo.c + '</span>';
stockString += '</div>';
$('.stockBSE').prepend(stockString);
});
}
google seems to have changed their interface url from:
http://www.google.com/finance...
to:
http://finance.google.com/finance...
Related
Please refer to this link
http://aspsolution.net/Code/5/5215/How-to-loop-through-ViewBag-List-in-Jquery/#
I followed what is written in the website. However the Json.Result doesn't appear. I tried to include this one (#using Newtonsoft.Json) in the html but it's still not appearing. Why is that? Is there any solution for this?
This is my script:
fillDatatable();
function fillDatatable() {
var cart = #Html.Raw(Json.Result(#ViewBag.cart));
alert(cart.Items.ItemID);
}
Edited:
if (PurchaseOrder != "") {
var tableHTML = '';
$.each(PurchaseOrder, function (index, value) {
tableHTML += "<tr>";
tableHTML += "<td>" + value.items.itemID + "</td>";
tableHTML += "<td>" + value.items.itemModelDescription + "</td>";
tableHTML += "<td>";
tableHTML += "<input id='UnitPrice" + value.items.ItemID + "' class='form-control b-r-xl text-right' value='" + value.items.itemUnitPrice + "' oninput='return change_unitprice('" + value.items.itemID + "')' />";
tableHTML += "</td>";
tableHTML += "<td>";
tableHTML += " </tr>";
});
$("#TableRecords").html(tableHTML);
}
See my HTML inside the loop where you can see change_unitprice function. I'm trying to pass the value of an id there, but according to the result of console it is undefined? Why is that?
The example you are referencing does not contain the code you included to the question. It describes how to use Json.Encode() to obtain data from the ViewBag field. Possible problems why your code doesn't work are:
Using not defined the cart field.
Using the Items property that does not defined.
Trying to work with HTML document that does not loaded yet.
Therefore, use function from this example as is:
<script>
$(document).ready(function(){
var StockList =#Html.Raw(Json.Encode(#ViewBag.StockList));
if (StockList != '') {
var tableHtml;
$.each(StockList, function( index, value ) {
tableHtml +="<tr><td>" + value.stockId + "</td><td>" + value.StockName + "</td><td>" + value.StockPrice + "</td></tr>";
});
$("#output").html(tableHtml);
}
})
</script>
If it does not work (probably because of the jquery disable by Layout = null; line in the Index.cshtml ) add the following line after the <head> tag:
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.2.min.js"></script>
For additional information see the following post: https://stackoverflow.com/a/10779161/6630084
I think the simplest method that works for complex object would be like this:
#Html.Raw(Json.Encode(ViewBag.cart))
How can I get the name and model of the system processor CPU in the inject content script?
Is there a way to access chrome.system.cpu in inject content script?
I saw this code from David Christian who wrote in the popup.js file that it works but I do not know how I can access its function in the inject content script.
Please help me.
// David Christian
// System info Chrome extension
var systemInformation = {
requestInfo: function() {
chrome.system.cpu.getInfo(function (cpuInfo){
var elem = document.getElementById('cpu');
var info = cpuInfo.modelName + "<br>";
info += "Architecture: " + cpuInfo.archName + "<br>";
info += "Cores: " + cpuInfo.numOfProcessors.toString() + "<br>";
// info += "Features: " + cpuInfo.features + "<br>";
info += "<table><tr><th>#</th><th>User (ms)</th><th>Kernel (ms)</th><th>Idle (ms)</th><th>Total (ms)</th></tr>";
for (var i=0; i < cpuInfo.processors.length; i++){
info += "<tr><td>" + i + "</td>";
info += "<td>" + cpuInfo.processors[i].usage.user + "</td>";
info += "<td>" + cpuInfo.processors[i].usage.kernel + "</td>";
info += "<td>" + cpuInfo.processors[i].usage.idle + "</td>";
info += "<td>" + cpuInfo.processors[i].usage.total + "</td><tr>";
}
elem.innerHTML = info + "</table>";
});
chrome.system.memory.getInfo(function (ramInfo){
var elem = document.getElementById('ram');
elem.innerHTML = (ramInfo.availableCapacity / 1073741824).toFixed(2)
+ "gb / " + Math.round(ramInfo.capacity / 1073741824).toFixed(2)
+ "gb (" + ((ramInfo.availableCapacity / ramInfo.capacity) * 100.0).toFixed(2).toString() + "% available)";
});
}
};
// Start getting system data as soon as page is ready..
document.addEventListener('DOMContentLoaded', function () {
// Ensure that we have a display straight away
systemInformation.requestInfo();
// Update the display every 3 seconds
setInterval(systemInformation.requestInfo, 3000);
});
I would like to add headers per below but I unable to do so. I searched everywhere but still nothing. I'm still very new to this but any help would be appreciated. Can you assist?
function myFunction(response) {
var arr = JSON.parse(response);
var i;
var out = "<table>";
for(i = 0; i < arr.length; i++) {
out += "<tr><td>" +
arr[i].id +
"</td><td>" +
arr[i].bkname +
"</td><td>" +
arr[i].pbname +
"</td><td>" +
arr[i].year +
"</td><td>" +
arr[i].type +
"</td><td>" +
arr[i].con +
"</td></tr>";
}
out += "</table>"
document.getElementById("id01").innerHTML = out;
}
Put the header in the initial value of out
var out = "<table><tr><th>ID</th><th>BKName</th><th>PBName</th><th>Year</th><Type</th><th>Con</th></tr>";
Hope someone could help with this small task. I have an array of text blocks that have a DateTime value assigned to them. I would like to publish those text blocks sorted by DateTime so that the latest updated item is always on top.
Here is the script:
function jsonCallBack(data) {
var strRows = "";
$.each(data.News, function(i, item) {
var htmlNewsBody = item["htmlNewsBody"];
var maxLength = 120
var trimmedString = htmlNewsBody.substr(0, maxLength);
trimmedString = trimmedString.substr( 0, Math.min( trimmedString.length,
trimmedString.lastIndexOf(" ") ) );
strRows += "<div id='nrNewsItem-" + i + "'>";
strRows += "<h3>" + item["txtTitle"] + "</h3>";
strRows += "<p>" + item["dtDateTime"] + "</p>";
strRows += "<p>" + trimmedString + "...</p>";
strRows += "</div>"
});
$("#printHere").html(strRows);
};
Also have a working jsFiddle with JSON data.
You can add a custom compare method:
function compare(a,b) {
if (a.dtDateTime < b.dtDateTime) {
return 1;
}
if (a.dtDateTime > b.dtDateTime) {
return -1;
}
return 0;
}
Then in your function:
function jsonCallBack(data) {
data.News.sort(compare);
....
I have developed an application in which i need to generate a Slip containing all the information entered by the user. To show the slip, i created a new widget screen on which i used a QTextBrowser to display the information.
I have used QTextBrowser->SetHtml to display the information, format the information etc.The information includes "the Hard Coded titles" as well as "information stored in the database sqlite".
Its running fine on my system (PC) but when i uploaded it on my friends system (PC), I got a blank slip. It happens for few slips then it starts displaying the slip.
Here's my function :-
void PrintRecieptInfo::createHtml()
{
htmlString.clear();
const QStringList childGroup = settings->childGroups();
if (childGroup.length() < MAXGROUPINRECIEPTSETTINGS){
return;
}
initRecieptInfo();
htmlString = "<table align='center' border='yes' width='450'>";
if (rItem[1].status){
if ((rItem[0].status) && (rItem[0].text != "")){
htmlString.append( "<tr><th colspan = '5'><font size='2'><img src='" + rItem[0].text + "'>" + rItem[1].text + "</th></tr>");
}
else {
htmlString.append( "<tr><th colspan = '5'><font size='1'>" + rItem[1].text + "</th></tr>");
}
}
if (rItem[2].status){
htmlString.append("<tr><th colspan = '5'><font size='1'>" + rItem[2].text + "</th></tr>");
}
if (rItem[3].status){
htmlString.append("<tr><th colspan = '5'><font size='1'>" + rItem[3].text + "</th></tr>");
}
if (rItem[4].status){
htmlString.append("<tr><th colspan = '5'><font size='1'>" + rItem[4].text + "</th></tr>");
}
htmlString.append("<tr><td colspan='5'><hr></td></tr>");
for (int i = 5 ; i < MAXMEMBER; i++){
if (rItem[i].status){
htmlString.append("<tr><td width='80'>" + rItem[i].title + "</td><td width='80'>" + rItem[i].text + "</td><td width='50'></td>");
int tempIndex = i+1;
while(!rItem[tempIndex].status){
tempIndex++;
if (tempIndex > MAXMEMBER){
break;
}
}
if (tempIndex < MAXMEMBER){
htmlString.append("<td width='80'>" + rItem[tempIndex].title + "</td><td width='80'>" + rItem[tempIndex].text + "</td>");
htmlString.append("</tr>");
}
i = tempIndex;
}
}
htmlString.append("<tr><th colspan='5'><hr></th></tr>");
htmlString.append("<tr><th></th></tr>");
htmlString.append("<tr><td></td><td></td><td></td><td></td><td align='right'>Operator Signature</td></tr>");
htmlString.append("</table>");
ui->printSlip_textBrowser->setHtml(htmlString);
}
Can anyone guide me some solution for this issue ??
Are you using Windows? If yes, it sounds like you need to copy QTDIR/plugins/imageformats directory from your computer to computer of your friend.