{"id":64,"date":"2014-01-08T15:05:09","date_gmt":"2014-01-08T15:05:09","guid":{"rendered":"http:\/\/bmail.pk\/?p=64"},"modified":"2014-01-08T15:05:09","modified_gmt":"2014-01-08T15:05:09","slug":"share-price-live-data","status":"publish","type":"post","link":"https:\/\/www.kapco.com.pk\/?p=64","title":{"rendered":"SHARE PRICE &#8211; LIVE DATA"},"content":{"rendered":"<style type=\"text\/css\">\n\t<!--\n\t.style3 {font-family: Arial, Helvetica, sans-serif, Century; font-size: 10px; }\n\t.style5 {font-family: Arial, Helvetica, sans-serif, Century; font-size: 10px; font-weight: bold; }\n\tbody {\n\t\tmargin-left: 0px;\n\t\tmargin-top: 5px;\n\t\tmargin-right: 0px;\n\t\tmargin-bottom: 0px;\n\t}\n\t.box{\n\t\tfont-size: 10px;\n\t\tcolor: #000;\n\t\tbackground: #FAFF8C;\n\t\tborder: 1px solid #E3F6CE;\n\t}\n\t-->\n\t<\/style>\n<p>\t<!-- #################### START AJAX CALL ################################### --><br \/>\n\t\t<script type=\"text\/javascript\" src=\"scripts\/jquery.js\"><\/script><br \/>\n\t\t<script type = \"text\/javascript\" >\n\t\t\tfunction addCommas( sValue ){\n\t\t\t\tvar sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');\n\t\t\t\twhile(sRegExp.test(sValue)) {\n\t\t\t\t\tsValue = sValue.replace(sRegExp, '$1,$2');\n\t\t\t\t}\n\t\t\t\treturn sValue;\n\t\t\t}\n\t\t\tfunction trim(s){\n\t\t\t\tif(!s || typeof s != 'string')\n\t\t\t\t\treturn null;\n\t\t\t\treturn s.replace(\/^[\\s]+\/,'').replace(\/[\\s]+$\/,'').replace(\/[\\s]{2,}\/,' ');\n\t\t\t}\n\t\/\/ ############################ SETUP FOR XMLHTTP OBJECT ######################\n\t\t\tfunction getXMLHttpRequestObject(){\n\t\t\tvar xmlhttp;\n\t\t\tif (!xmlhttp && typeof XMLHttpRequest != 'undefined') {\n\t\t\ttry {\n\t\t\t  xmlhttp = new XMLHttpRequest();\n\t\t\t} catch (e) {\n\t\t\t  xmlhttp = false;\n\t\t\t}\n\t\t\t}\n\t\t\treturn xmlhttp;\n\t\t\t}\n\t\/\/ ############################ SETUP A VARIABLE FOR XMLHTTP OBJECT ###############\n\t\t\tvar http = new getXMLHttpRequestObject();\n\t\/\/ ######## CALLING AT FIRST TIME TO LOAD DATA - ON BODY LOAD - #####################\n\t\tloadData()\n\t\tfunction loadData(){\n\t\t\t\/\/var url = \"..\/market_ticker\/feed\/tmp.php\"; \/\/ local use \/ testing\n\t\t\tvar url = \"..\/market_ticker\/feed\/getfeed.php\";\n\t\t\tvar parameters = \"WebKey=686220&m=1\";\n\t\t\thttp.open(\"POST\", url, true);\n\t\t\thttp.setRequestHeader(\"Content-type\", \"application\/x-www-form-urlencoded\");\n\t\t\thttp.setRequestHeader(\"Content-length\", parameters .length);\n\t\t\thttp.setRequestHeader(\"Connection\", \"close\");\n\t\t\thttp.onreadystatechange = function() {\/\/Handler function for call back on state change.\n\t\t\t\tif(http.readyState == 4) {\n\t\/\/\t\t\t\talert(http.responseText);\n\t\t\t\t\tAjaxResponsekse7(http.responseText);\n\t\t\t\t} \/\/ end -- if(http.readyState == 4)\n\t\t\t}\/\/ end -- http.onreadystatechange = function()\n\t\t\thttp.send(parameters);\n\t\t} \/\/ end -- function loadData()\n\t\t\tfunction AjaxResponsekse7(response){\n\/\/alert(\"Rresponse :\"+response);\n\t\t\t\tresponse\t= response.split(\"|\");\n\t\t\t\tvar data1 \t= response[1];\n\t\t\t\tif(response[0] == \"-1\" || Right(response[0],2) == \"0~\")\n\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById(\"symbol\").innerHTML = response[1];\n\t\t\t\t\t\tdocument.getElementById(\"symbol\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"opnRate\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"curRate\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"lstRate\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"loRate\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"Hi\").innerHTML = \"\";\n\t\t\t\t\t\tdocument.getElementById(\"volume\").innerHTML = \"\";\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\tdata1 \t\t= data1.split(\",\");\n\t\t\t\t\t\tvar symbol \t= trim(data1[0]);\n\t\t\t\t\t\tsymbol \t\t= symbol.substr(12);\n\t\t\t\t\t\topenRate \t= trim(data1[1]);\n\t\t\t\t\t\topenRate \t= parseFloat(openRate);\n\t\t\t\t\t\topenRate \t= openRate.toFixed(2);\n\t\t\t\t\t\tcurrRate \t= trim(data1[2]);\n\t\t\t\t\t\tcurrRate \t= parseFloat(currRate);\n\t\t\t\t\t\tcurrRate \t= currRate.toFixed(2);\n\t\t\t\t\t\tlastRate \t= trim(data1[3]);\n\t\t\t\t\t\tlastRate \t= parseFloat(lastRate);\n\t\t\t\t\t\tlastRate \t= lastRate.toFixed(2);\n\t\t\t\t\t\tlow\t\t \t= trim(data1[4]);\n\t\t\t\t\t\tlow \t\t= parseFloat(low);\n\t\t\t\t\t\tlow \t\t= low.toFixed(2);\n\t\t\t\t\t\thigh\t \t= trim(data1[5]);\n\t\t\t\t\t\thigh \t\t= parseFloat(high);\n\t\t\t\t\t\thigh \t\t= high.toFixed(2);\n\t\t\t\t\t\tvol\t \t\t= trim(data1[6]);\n\t\t\t\t\t\tvol\t\t\t= addCommas(vol);\n\t\t\t\t\t\tdocument.getElementById(\"symbol\").innerHTML = symbol;\n\t\t\t\t\t\tdocument.getElementById(\"opnRate\").innerHTML = openRate;\n\t\t\t\t\t\tdocument.getElementById(\"curRate\").innerHTML = currRate;\n\t\t\t\t\t\tdocument.getElementById(\"lstRate\").innerHTML = lastRate;\n\t\t\t\t\t\tdocument.getElementById(\"loRate\").innerHTML = low;\n\t\t\t\t\t\tdocument.getElementById(\"Hi\").innerHTML = high;\n\t\t\t\t\t\tdocument.getElementById(\"volume\").innerHTML = vol;\n\t\t\t\t}\n\t\t\t} \/\/ AjaxResponsekse7(response){\n\t\/\/ ############################# TIMER ########################################\n\t\t\tsetInterval( \"loadData()\", 6000 );\n\t\t\t\tfunction Left(str, n){\n\t\t\t\t    if (n <= 0)\n\t\t\t\t        return \"\";\n\t\t\t\t    else if (n > String(str).length)\n\t\t\t\t        return str;\n\t\t\t\t    else\n\t\t\t\t        return String(str).substring(0,n);\n\t\t\t\t}\n\t\t\t\tfunction Right(str, n){\n\t\t\t\t    if (n <= 0)\n\t\t\t\t       return \"\";\n\t\t\t\t    else if (n > String(str).length)\n\t\t\t\t       return str;\n\t\t\t\t    else {\n\t\t\t\t       var iLen = String(str).length;\n\t\t\t\t       return String(str).substring(iLen, iLen - n);\n\t\t\t\t    }\n\t\t\t\t}\n\t\t<\/script><br \/>\n\t<!-- #################### ENDS AJAX CALL ################################### --><br \/>\n\t<body><\/p>\n<div id=\"contentdiv1\">\n<table width=180 border=0 cellpadding=1 cellspacing=1 bgcolor=#66CC99>\n<tr>\n<td width=108 height=20 bgcolor=#CDF3CF><span class=style3>Symbol<\/span><\/td>\n<td width=65 bgcolor=#FFFFFF>\n<div align=center><span class=style5><\/p>\n<div id=\"symbol\"><img src=img\/ajax-loader.gif><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>Last Day Close price<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"lstRate\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>Open Price<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"opnRate\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>Current Price<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"curRate\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>High<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"Hi\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>Low<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"loRate\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td height=20 bgcolor=#CDF3CF><span class=style3>Volume Traded<\/span><\/td>\n<td bgcolor=#FFFFFF>\n<div align=right><span class=style5><\/p>\n<div id=\"volume\"><\/div>\n<p><\/span><\/div>\n<\/td>\n<\/tr>\n<\/table><\/div>\n<p>\t<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Symbol Last Day Close price Open Price Current Price High Low Volume Traded<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":0,"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kapco.com.pk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}