1/* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 5 */ 6var ip = location.host; 7 8function getOcSymbolsDerivative() { 9 var instname = $("#inst").val(); 10 if (instname == 'OPTIDX' || instname == 'OPTSTK') { 11 $("#opt_drivative").css("display", "block"); 12 $("#optstrike_drivative").css("display", "block"); 13 } else { 14 $("#opt_drivative").css("display", "none"); 15 $("#optstrike_drivative").css("display", "none"); 16 } 17 18// postData = {'instrument_type': instname}; 19 $.ajax({ 20 type: "post", 21 dataType: "json", 22 url: globalRequestUrl, 23 data: {'instrument_type': instname, action: "getOcSymbols"}, 24 success: function(data) { 25 var output = []; 26 var i = 1; 27 var selvalue; 28 $.each(data, function(key, value) 29 { 30 if (i == 1) { 31 selvalue = key; 32 } 33 output.push('<option value="' + key + '">' + value + '</option>'); 34 i++; 35 }); 36 $('#index_stock').html(output.join('')); 37 $("#index_stock").val(selvalue); 38 getOcexpiriesDerivative(); 39 } 40 }); 41 42} 43function getOcexpiriesDerivative() { 44 var inst = $("#inst").val();
45 var index = $("#index_stock").val(); 46 $.ajax({ 47 type: "post", 48 dataType: "json", 49 url: globalRequestUrl, 50 data: {'instrument_type': inst, 'index_stock_name': index, action: "getOcexpiries"}, 51 success: function(data) { 52 var output = []; 53 var i = 1; 54 var selvalue; 55 $.each(data, function(key, value) 56 { 57 if (i == 1) { 58 selvalue = key; 59 } 60 output.push('<option value="' + key + '">' + value + '</option>'); 61 i++; 62 }); 63 $('#expiry_date').html(output.join('')); 64 $("#expiry_date").val(selvalue); 65 if (inst == 'OPTIDX' || inst == 'OPTSTK') { 66 optstrikeDataDerivative(); 67 } 68 } 69 }); 70 71} 72 73function optstrikeDataDerivative() { 74 var inst = $("#inst").val(); 75 var index = $("#index_stock").val(); 76 var opttype = $("#opttype").val(); 77 var expiry_date = $("#expiry_date").val(); 78 $.ajax({ 79 type: "post", 80 dataType: "json", 81 url: globalRequestUrl, 82 data: {'instrument_type': inst, 'index_stock_name': index, 'opttype': opttype, 'expiry_date': expiry_date, action: "optstrikeData"}, 83 success: function(data) { 84 var output = []; 85 var i = 1; 86 var selvalue; 87 $.each(data, function(key, value) 88 { 89 if (i == 1) { 90 selvalue = key; 91 } 92 output.push('<option value="' + key + '">' + value + '</option>'); 93 i++; 94 }); 95 $('#opt_strike_derivative').html(output.join('')); 96 $("#opt_strike_derivative").val(selvalue); 97 } 98 }); 99} 100$("#getderivativedata").click(function() { 101 var instrument_type = $("#inst").val(); 102 var index_stock_name = btoa($("#index_stock").val()); 103 var expiry_date = $("#expiry_date").val(); 104 var expdate = expiry_date.replace(/-/g, '/'); 105 var timef = format_time(expdate); 106 var d = new Date(expdate); 107 var month = d.getMonth() + 1; 108 expdate = month + "/" + d.getDate() + "/" + d.getFullYear() + " " + timef; 109 var ip = location.host; 110 if (instrument_type == 'FUTIDX' || instrument_type == 'FUTSTK') { 111 var opttype = 'XX'; 112 var optstriketype = '0'; 113 } else { 114 var opttype = $("#opttype").val(); 115 var optstriketype = $("#opt_strike_derivative").val(); 116 } 117 var coName = $("#select2-index_stock-container").attr('title'); 118 coName = coName.replace(/ {1,}/g, '-'); 119 var url = 'http://' + ip + '/app/index.php/market/Snapshot/DerivativeSnapshot?instname=' + instrument_type + '&symbol=' + index_stock_name + '&expdate=' + expdate + '&opttype=' + opttype + '&strikeprice=' + optstriketype + '&coName=' + coName; 120 if (typeof (url) != 'undefined' && url != null) 121 { 122 location.href = url; 123 } 124 // window.location = url; 125// return false; 126}); 127$("#getMfSchemeData").click(function() { 128 var category = $('#category option:selected').html(); 129 var mfscheme = $("#scheme").val(); 130 var schemeName = $("#select2-scheme-container").attr('title'); 131 schemeName = schemeName.replace(/ {1,}/g, '-'); 132 schemeName = schemeName.replace(/-{1,}/g, '-'); 133 var url = "http://" + ip + "/app/index.php/market/MutualFundSnapshot/" + toTitleCase(category) + "Largecap/schemeCode/" + mfscheme + "/schemeName/" + schemeName; 134 135 if (typeof (url) != 'undefined' && url != null) 136 { 137 location.href = url; 138 } 139}); 140//$(document).ready(function() { 141/*(function($) { 142 var recData; 143 $.fn.autoComplete = function() { 144 var requestData = {}; 145 $(this).autocomplete({ 146 //source: availableTags, 147 source: function(request, response) { 148 //requestData.term = request; 149 $.ajax({ 150 dataType: "json", 151 url: baseUrl + "temp/GetQuote", 152 data: request, 153 success: function(data) { 154 recData = data; 155 response(data); 156 }, 157 error: function(data) { 158 console.log("error"); 159 } 160 }); 161 }, 162 open: function(event, ui) { 163 $(this).autocomplete("widget").css({ 164 "width": 800, 165 }); 166 }, 167 select: function(event, ui) { 168 var cocode; 169 var selItem = ui.item.value; 170 $.each(recData, function(index, v) { 171 if (selItem == v) { 172 cocode = index; 173 $("#quotecocode").val(cocode); 174 $("#quotevalue").val(selItem); 175 } 176 }); 177 console.log("hi"); 178 var a = $('.search-tabs li').find('.active').attr('data-val'); 179 $("#quotetype").val(a); 180 } 181 }); 182 183 }; 184 })(jQuery); */ 185function addZero(i) { 186 if (i < 10) { 187 i = "0" + i; 188 } 189 return i; 190} 191function format_time(date_obj) { 192 // formats a javascript Date object into a 12h AM/PM time string 193 var d = new Date(date_obj); 194 var hour = d.getHours(); 195 var minute = d.getMinutes(); 196 var seconds = addZero(d.getSeconds()); 197 var amPM = (hour > 11) ? "PM" : "AM"; 198 if (hour > 12) { 199 hour -= 12; 200 } else if (hour == 0) { 201 hour = "12"; 202 } 203 if (minute < 10) { 204 minute = "0" + minute; 205 } 206 return hour + ":" + minute + ":" + seconds + " " + amPM; 207} 208var recData; 209 210//Stock - [Equity] 211$(".equity-stock").autocomplete({ 212 highlightClass: "highlight-color", 213 source: function(request, response) { 214 if (request['term'].length <= 2 && request['term'].length > 0) { 215 var noResult = {label: "Please enter minimum 3 characters for search"}; 216 response(noResult); 217 } else { 218 $.ajax({ 219 type: "post", 220 dataType: "json", 221 url: globalRequestUrl, 222 data: {data: request, action: "getCompanyQuote"}, 223 success: function(data) { 224 recData = data; 225 if (data == "") { 226 var noResult = {label: "No results found"}; 227 response(noResult); 228 } else { 229// response(data); 230 response($.map(data, function(value, key) { 231 return { 232 label: value.name, 233 value: value.name, 234 exchange: value.ext, 235 cocode: value.cocode, 236 coname: value.coName 237 }; 238 })); 239 } 240 }, 241 error: function(data) { 242 console.log("error"); 243 } 244 }); 245 } 246 }, 247 change: function(event, ui) { 248 if (this.value === '') { 249 $("#quotecocode").val(''); 250 $("#quotevalue").val(''); 251 $("#quotetype").val(''); 252 } 253 }, 254 response: function(event, ui) { 255 if (ui.content.length === 0 || ui.content.length > 0) { 256 $("#quotecocode").val(''); 257 $("#quotevalue").val(''); 258 $("#quotetype").val(''); 259 $("#quote_exchange").val(''); 260 $("#quote_expdate").val(''); 261 } 262 }, 263 open: function(event, ui) { 264 $(this).autocomplete("widget").css({ 265 "width": ($(this).width() + 42 + "px") 266 }); 267 }, 268 select: function(event, ui) { 269 var cocode = ui.item.cocode; 270 var selItem = ui.item.value; 271 var exchange = ui.item.exchange; 272 var coname = ui.item.coname; 273 coname = coname.replace(/ {1,}/g, '-'); 274 coname = coname.replace('&', 'and'); 275 if (selItem == "No results found" || selItem == "Please enter minimum 3 characters for search") { 276 return false;
277 } 278 $("#quote_exchange").val(exchange); 279 $("#quotecocode").val(cocode); 280 $("#quotevalue").val(selItem); 281 var a = $('.search-tabs li').find('.active').attr('data-val'); 282 $("#quotetype").val(a); 283 url = "http://" + ip + "/app/index.php/market/snapshot/stocksnapshot/exchange/" + exchange + "/coCode/" + cocode + "/coName/" + coname; 284 if (typeof (url) != 'undefined' && url != null) 285 { 286 location.href = url; 287 } 288 } 289}); 290$(".index-name").autocomplete({ 291 highlightClass: "highlight-color", 292 source: function(request, response) { 293 if (request['term'].length <= 2 && request['term'].length > 0) { 294 var noResult = {label: "Please enter minimum 3 characters for search"}; 295 response(noResult); 296 } else { 297 $.ajax({ 298 type: "post", 299 dataType: "json", 300 url: globalRequestUrl, 301 data: {data: request, action: "getIndexQuoteCode"}, 302 success: function(data) { 303 if (data == "") { 304 var noResult = {label: "No results found"}; 305 response(noResult); 306 } else { 307 response($.map(data, function(value, key) { 308 return { 309 label: value.name, 310 value: value.name, 311 exchange: value.exchange, 312 linkValue: value.id 313 }; 314 })); 315 } 316 }, 317 error: function(data) { 318 console.log("error"); 319 } 320 }); 321 } 322 }, 323 change: function(event, ui) { 324 if (this.value === '') { 325 $("#quotecocode").val(''); 326 $("#quotevalue").val(''); 327 $("#quotetype").val(''); 328 $("#quote_exchange").val(''); 329 $("#quote_expdate").val(''); 330 } 331 }, 332 response: function(event, ui) { 333 if (ui.content.length === 0 || ui.content.length > 0) { 334 $("#quotecocode").val(''); 335 $("#quotevalue").val(''); 336 $("#quotetype").val(''); 337 $("#quote_exchange").val(''); 338 $("#quote_expdate").val(''); 339 } 340 }, 341 open: function(event, ui) { 342 $(this).autocomplete("widget").css({ 343 "width": ($(this).width() + 42 + "px") 344 }); 345 }, 346 select: function(event, ui) { 347 var cocode, index_exchange; 348 var selItem = ui.item.value; 349 cocode = ui.item.linkValue; 350 index_exchange = ui.item.exchange; 351 if (selItem == "No results found" || selItem == "Please enter minimum 3 characters for search") { 352 return false; 353 } 354 $("#quotecocode").val(cocode); 355 $("#quotevalue").val(selItem); 356 $("#quote_exchange").val(index_exchange); 357 var a = $('.search-tabs li').find('.active').attr('data-val'); 358 $("#quotetype").val(a); 359 var indexName = selItem.replace(/ {1,}/g, '-'); 360 url = "http://" + ip + "/app/index.php/market/snapshot/IndexSnapshot/exchange/" + index_exchange.toLowerCase() + "/indexCode/" + cocode + "/indexName/" + indexName; 361 if (typeof (url) != 'undefined' && url != null) 362 { 363 location.href = url; 364 } 365 } 366}); 367 368$(".d-contract").autocomplete({ 369 highlightClass: "highlight-color", 370 source: function(request, response) { 371 if (request['term'].length <= 2 && request['term'].length > 0) { 372 var noResult = {label: "Please enter minimum 3 characters for search"}; 373 response(noResult); 374 } else { 375 $.ajax({ 376 type: "post", 377 dataType: "json", 378 url: globalRequestUrl, 379 data: {data: request, action: "getDerivativeContract"}, 380 success: function(data) { 381 if (data == "") { 382 var noResult = {label: "No results found"}; 383 response(noResult); 384 } else { 385 response($.map(data, function(value, key) { 386 return { 387 label: value.value, 388 value: value.value, 389 symbol: value.symbol, 390 expdate: value.expdate, 391 OptType: value.OptType, 392 InstName: value.InstName,
393 strikeprice: value.strikeprice 394 }; 395 })); 396 } 397 }, 398 error: function(data) { 399 console.log("error"); 400 } 401 }); 402 } 403 }, 404 change: function(event, ui) { 405 if (this.value === '') { 406 $("#quotecocode").val(''); 407 $("#quotevalue").val(''); 408 $("#quotetype").val(''); 409 $("#quote_exchange").val(''); 410 $("#quote_expdate").val(''); 411 $("#quote_OptType").val(''); 412 } 413 }, 414 response: function(event, ui) { 415 if (ui.content.length === 0 || ui.content.length > 0) { 416 $("#quotecocode").val(''); 417 $("#quotevalue").val(''); 418 $("#quotetype").val(''); 419 $("#quote_exchange").val(''); 420 $("#quote_expdate").val(''); 421 } 422 }, 423 open: function(event, ui) { 424 $(this).autocomplete("widget").css({ 425 "width": ($(this).width() + 42 + "px") 426 }); 427 }, 428 select: function(event, ui) { 429 if (ui.item.value == "No results found" || ui.item.value == "Please enter minimum 3 characters for search") { 430 return false; 431 } 432 var strikeprice, symbol, expdate, OptType; 433 var selItem = ui.item.InstName; 434 strikeprice = ui.item.strikeprice; 435 expdate = ui.item.expdate; 436 symbol = btoa(ui.item.symbol); 437 OptType = ui.item.OptType; 438 expdate = expdate.replace(/-/g, '/'); 439 var timef = format_time(expdate); 440 var d = new Date(expdate); 441 var month = d.getMonth() + 1; 442 expdate = month + "/" + d.getDate() + "/" + d.getFullYear() + " " + timef; 443 $("#quotecocode").val(strikeprice); 444 $("#quotevalue").val(selItem); 445 $("#quote_exchange").val(symbol); 446 $("#quote_expdate").val(expdate); 447 $("#quote_OptType").val(OptType); 448 var a = $('.search-tabs li').find('.active').attr('data-val'); 449 $("#quotetype").val(a); 450 var coName = atob(symbol); 451 coName = coName.replace(/ {1,}/g, '-'); 452 url = "http://" + ip + "/app/index.php/market/Snapshot/DerivativeSnapshot?instname=" + selItem + "&symbol=" + symbol + "&expdate=" + expdate + "&opttype=" + OptType + "&strikeprice=" + strikeprice + "&coName=" + coName; 453 if (typeof (url) != 'undefined' && url != null) 454 { 455 location.href = url; 456 } 457 } 458}); 459$(".mf-scheme").autocomplete({ 460 highlightClass: "highlight-color", 461 source: function(request, response) { 462 if (request['term'].length <= 2 && request['term'].length > 0) { 463 var noResult = {label: "Please enter minimum 3 characters for search"}; 464 response(noResult); 465 } else { 466 $.ajax({ 467 type: "post", 468 dataType: "json", 469 url: globalRequestUrl, 470 data: {data: request, action: "getMfSchemeName"}, 471 success: function(data) { 472 if (data == "") { 473 var noResult = {label: "No results found"}; 474 response(noResult); 475 } else { 476 recData = data; 477 response($.map(data, function(value, key) { 478 return { 479 label: value.mf_sch_name, 480 value: value.mf_sch_name, 481 mf_code: value.mf_code, 482 main_category: value.main_category 483 }; 484 })); 485 } 486 }, 487 error: function(data) { 488 console.log("error"); 489 } 490 }); 491 } 492 }, 493 change: function(event, ui) { 494 if (this.value === '') { 495 $("#quotecocode").val(''); 496 $("#quotevalue").val(''); 497 $("#quotetype").val(''); 498 $("#quote_exchange").val(''); 499 $("#quote_expdate").val(''); 500 $("#quote_OptType").val(''); 501 } 502 }, 503 response: function(event, ui) { 504 if (ui.content.length === 0 || ui.content.length > 0) { 505 $("#quotecocode").val(''); 506 $("#quotevalue").val(''); 507 $("#quotetype").val(''); 508 $("#quote_exchange").val(''); 509 $("#quote_expdate").val(''); 510 } 511 }, 512 open: function(event, ui) { 513 $(this).autocomplete("widget").css({ 514 "width": ($(this).width() + 42 + "px") 515 }); 516 }, 517 select: function(event, ui) { 518 if (ui.item.value == "No results found" || ui.item.value == "Please enter minimum 3 characters for search") { 519 return false;
520 } 521 var mf_code, main_category; 522 var selItem = ui.item.value; 523 mf_code = ui.item.mf_code; 524 main_category = ui.item.main_category; 525 $("#quotecocode").val(mf_code); 526 $("#quotevalue").val(selItem); 527 $("#quote_exchange").val(main_category); 528 var a = $('.search-tabs li').find('.active').attr('data-val'); 529 $("#quotetype").val(a); 530 var schemeName = selItem.replace(/ {1,}/g, '-'); 531 schemeName = schemeName.replace(/-{1,}/g, '-'); 532 url = "http://" + ip + "/app/index.php/market/MutualFundSnapshot/" + toTitleCase(main_category) + "Largecap/schemeCode/" + mf_code + "/schemeName/" + schemeName; 533 if (typeof (url) != 'undefined' && url != null) 534 { 535 location.href = url; 536 } 537 } 538}); 539$(".search-inp-clear").click(function() { 540 $("#quotecocode").val(''); 541 $("#quotevalue").val(''); 542 $("#quotetype").val(''); 543 $("#quote_exchange").val(''); 544 $("#quote_expdate").val(''); 545 $("#quote_OptType").val(''); 546}); 547function toTitleCase(str) 548{ 549 return str.replace(/\w\S*/g, function(txt) { 550 return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); 551 }); 552} 553$(".search-inpbtn").click(function() { 554 var url; 555 var code = $("#quotecocode").val(); 556 var type = $("#quotetype").val(); 557 var ext = $("#quote_exchange").val(); 558 var value = $("#quotevalue").val(); 559 var OptType = $("#quote_OptType").val(); 560 var expdate = $("#quote_expdate").val(); 561 expdate = expdate.replace(/-/g, '/'); 562 var timef = format_time(expdate); 563 var d = new Date(expdate); 564 var month = d.getMonth() + 1; 565 expdate = month + "/" + d.getDate() + "/" + d.getFullYear() + " " + timef; 566 567 if (type == "equity" || type == "equity1") { 568 url = "http://" + ip + "/app/index.php/market/snapshot/stockSnapshot/exchange/" + ext + "/coCode/" + code; 569 } else if (type == "derivatives" || type == "derivatives1") { 570 url = "http://" + ip + "/app/index.php/market/Snapshot/DerivativeSnapshot?instname=" + value + "&symbol=" + ext + "&expdate=" + expdate + "&opttype=" + OptType + "&strikeprice=" + code + "&coName=" + ext; 571 } else if (type == "index" || type == "index1") { 572 url = "http://" + ip + "/app/index.php/market/snapshot/IndexSnapshot/exchange/" + ext.toLowerCase() + "/indexCode/" + code; 573 } else if (type == "mf" || type == "mf1") { 574 url = "http://" + ip + "/app/index.php/market/MutualFundSnapshot/" + toTitleCase(ext) + "Largecap/schemeCode/" + code; 575 } 576 577 if (typeof (url) != 'undefined' && url != null) 578 { 579 location.href = url; 580 } 581 582}); 583function getAmc() { 584 $.ajax({ 585 type: "post", 586 dataType: "json", 587 url: globalRequestUrl, 588 data: {action: "getAMC"}, 589 success: function(data) { 590 var output = []; 591 var i = 1; 592 var selvalue; 593 $.each(data, function(key, value) 594 { 595 if (i == 1) { 596 selvalue = value.id; 597 } 598 output.push('<option value="' + value.id + '">' + value.name + '</option>'); 599 i++; 600 }); 601 $('#amc').html(output.join('')); 602 $("#amc").val(selvalue); 603 } 604 }); 605 606} 607function getMfCategory() { 608 $.ajax({ 609 type: "post", 610 dataType: "json", 611 url: globalRequestUrl, 612 data: {action: "getCategoryMaster"}, 613 success: function(data) { 614 var output = []; 615 var i = 1; 616 var selvalue; 617 $.each(data, function(key, value) 618 { 619 if (i == 1) { 620 selvalue = key; 621 } 622 output.push('<option value="' + key + '">' + value + '</option>'); 623 i++; 624 }); 625 $('#category').html(output.join('')); 626 $("#category").val(selvalue); 627 getMfSubCategory(); 628 } 629 }); 630 631} 632function getMfSubCategory() { 633 var category = $("#category").val(); 634 var amc = $("#amc").val(); 635 $.ajax({ 636 type: "post", 637 dataType: "json", 638 url: globalRequestUrl, 639 data: {'category': category, 'amc': amc, action: "getSubCategoryMaster"}, 640 success: function(data) { 641 var output = []; 642 output.push('<option value=""> Select</option>'); 643 $.each(data, function(key, value) 644 { 645 output.push('<option value="' + key + '">' + value + '</option>'); 646 }); 647 $('#subcat').html(output.join('')); 648 getMfScheme(); 649 } 650 }); 651 652} 653function getMfScheme() { 654 var amc = $("#amc").val(); 655 var category = $("#category").val(); 656 var subcat = $("#subcat").val(); 657 $.ajax({ 658 type: "post", 659 dataType: "json", 660 url: globalRequestUrl, 661 data: {'amc': amc, 'category': category, 'subcat': subcat, action: "getMfCallScheme"}, 662 success: function(data) { 663 if (data !== 'undefined' && data !== null) { 664 var output = []; 665 var i = 1; 666 var selvalue; 667 $.each(data, function(key, value) 668 { 669 if (i == 1) { 670 selvalue = key; 671 } 672 output.push('<option value="' + key + '">' + value + '</option>'); 673 i++; 674 }); 675 $('#scheme').html(output.join('')); 676 $("#scheme").val(selvalue); 677 } else { 678 $('#scheme').html(''); 679 $("#scheme").select2('val', ''); 680 } 681 } 682 }); 683} 684 685$(document).ready(function() { 686 $('.search-tabs li').click(function() { 687 var a = $(this).find('.active').attr('data-val'); 688 if (a == "derivatives") { 689 $('.d-contract').focus(); 690 getOcSymbolsDerivative(); 691 } else if (a == "mf") { 692 $('.mf-scheme').focus(); 693 getAmc(); 694 getMfCategory(); 695 } else if (a == "index") { 696 $('.index-name').focus(); 697 } else { 698 $('.equity-stock').focus(); 699 } 700 }); 701});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.