Developers Jos Posted November 26, 2017 Developers Share Posted November 26, 2017 2 minutes ago, oemript said: Do you have any suggestions? It is common courtesy in our forums to be patient and wait at least 24 hours before bumping a thread. ... and honestly get very bored hearing this broken record without any effort from you at all! Jos Earthshine 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
oemript Posted November 26, 2017 Author Share Posted November 26, 2017 (edited) Referring to following Reference coding, I would like to know on what is the following script language. _eTTE : function(id, type, name, fn) function(result) For Javascript, function go() {} is defined like that, the above example of function is different from Javascript format. Does anyone have any suggestions on what script language it is? Thanks, to everyone very much for any suggestions (^v^) Reference: view-source:https://www.hkex.com.hk/lhkexw/js/equity.js //export to excel future that.$equity_future.find(".ete").on('click',function(){ that._exportFutures(); }); //export futures _exportFutures: function() { var that=this; var span=that.$hsirow.find(".interval").attr("data-id"); var interval=that.$hsirow.find(".hsichart").attr("data-id"); var ric=that.$equity_future.find("table#equity_future").attr("data-id"); that.$pageobj.loaddata("getchartdata2", "getchartdata2", { "span": span, "int": interval, "ric": ric, "token": LabCI.getToken() }, function(result) { // console.log(result.data.datalist); var html=''; var flag=that.$hsirow.find(".hsichart .period.selected").html(); if(flag == '1 D' || flag == '5 D'){ html+='<tr>'+ '<th class="">Time</th>'+ '<th class="">Last Traded Price</th>'+ '<th class="">Volume</th>'+ '<th class="">Open Interest</th>' + '</tr>'; html+=that._exportFuturesHtml(result.data.datalist,0); }else{ html+='<tr>'+ '<th class="">Time</th>'+ '<th class="">Settlement Price</th>'+ '<th class="">Volume</th>'+ '<th class="">Open Interest</th>' + '</tr>'; html+=that._exportFuturesHtml(result.data.datalist,1); } that.$equity_future.find("#equity_future_export").html(html); //export that._eTTE('equity_future_export','xlsx',''+that.product+'_Futures'); // (1)'equity_future_export', (2)'xlsx',(3)''+that.product+'_Futures'); // there is only 3 parameters instead of 4, would it be correct? }, 0, { datatype: "jsonp" }); }, _s2ab : function(s){ if(typeof ArrayBuffer !== 'undefined') { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; return buf; }else{ var buf = new Array(s.length); for (var i=0; i!=s.length; ++i) buf[i] = s.charCodeAt(i) & 0xFF; return buf; } }, _eTTE : function(id, type, name, fn){ // id = equity_future_export // type = xlsx // name = where is "'+that.product+'_Futures" defined? There is no _Futures function here. // fn = where is "fn" defined? there is only 3 parameter when calling eTTE function? so no fn? var that=this; var wb = XLSX.utils.table_to_book(document.getElementById(id), {sheet:"Sheet JS"}); // what is wb as returned result? var wbout = XLSX.write(wb, {bookType:type, bookSST:true, type: 'binary'}); // what is wbout as returned result? var fname = fn || name + '.' + type; // what is fname as returned result? fn or ???.xlsx try { saveAs(new Blob([that._s2ab(wbout)],{type:"application/octet-stream"}), fname); } catch(e) { if(typeof console != 'undefined') console.log(e, wbout); } return wbout; }, Edited November 26, 2017 by oemript Link to comment Share on other sites More sharing options...
Developers Jos Posted November 26, 2017 Developers Share Posted November 26, 2017 28 minutes ago, oemript said: Does anyone have any suggestions on what script language it is? You seriously think we can answer that after posting this snippet? ... and yes... I do have my arrows aimed at you and it will not take much longer before this thread is closed. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
oemript Posted November 26, 2017 Author Share Posted November 26, 2017 (edited) I don't post only this snippet, the whole scripting is already shown on #9. I re-post the whole coding back to #22 for more description. I need to understand line by line first, in order to learn the requirement to download the file. Do you have any suggestions? I sincerely want to solve this problem, and hope someone give me a warm hand Thanks, to everyone very much for any suggestions (^v^) Edited November 26, 2017 by oemript Link to comment Share on other sites More sharing options...
mikell Posted November 26, 2017 Share Posted November 26, 2017 1 hour ago, oemript said: Thanks, to everyone very much for any suggestions By any chance, did you try automation using the _IE* functions, to select in the page the object whose id is "ete" and to click on it ? All this javascript stuff is a pretty nice maze ... Link to comment Share on other sites More sharing options...
oemript Posted November 26, 2017 Author Share Posted November 26, 2017 22 minutes ago, mikell said: By any chance, did you try automation using the _IE* functions, to select in the page the object whose id is "ete" and to click on it ? All this javascript stuff is a pretty nice maze ... view-source:https://www.hkex.com.hk/lhkexw/js/equity.js Based on "export to excel future", the id "ete" would redirect to _exportFutures() as shown below, that is what I find, would it be correct? The next step is to digest line by line to understand the download process, and the highlight area is what I don't understand on what is doing during the download process. Furthermore, the structure of defining function seems not matching following Javascript structure Different Structure : _eTTE : function(id, type, name, fn) Different Structure : function(result) Javascript Structure : function go() {} is defined like that, the above example of function is different from Javascript format. The first question is to know on whether following script is Javascript or not before understanding each line by line. Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) //export to excel future that.$equity_future.find(".ete").on('click',function(){ that._exportFutures(); }); //export futures _exportFutures: function() { var that=this; var span=that.$hsirow.find(".interval").attr("data-id"); var interval=that.$hsirow.find(".hsichart").attr("data-id"); var ric=that.$equity_future.find("table#equity_future").attr("data-id"); that.$pageobj.loaddata("getchartdata2", "getchartdata2", { "span": span, "int": interval, "ric": ric, "token": LabCI.getToken() }, function(result) { // console.log(result.data.datalist); var html=''; var flag=that.$hsirow.find(".hsichart .period.selected").html(); if(flag == '1 D' || flag == '5 D'){ html+='<tr>'+ '<th class="">Time</th>'+ '<th class="">Last Traded Price</th>'+ '<th class="">Volume</th>'+ '<th class="">Open Interest</th>' + '</tr>'; html+=that._exportFuturesHtml(result.data.datalist,0); }else{ html+='<tr>'+ '<th class="">Time</th>'+ '<th class="">Settlement Price</th>'+ '<th class="">Volume</th>'+ '<th class="">Open Interest</th>' + '</tr>'; html+=that._exportFuturesHtml(result.data.datalist,1); } that.$equity_future.find("#equity_future_export").html(html); //export that._eTTE('equity_future_export','xlsx',''+that.product+'_Futures'); // (1)'equity_future_export', (2)'xlsx',(3)''+that.product+'_Futures'); // there is only 3 parameters instead of 4, would it be correct? }, 0, { datatype: "jsonp" }); }, _s2ab : function(s){ if(typeof ArrayBuffer !== 'undefined') { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; return buf; }else{ var buf = new Array(s.length); for (var i=0; i!=s.length; ++i) buf[i] = s.charCodeAt(i) & 0xFF; return buf; } }, _eTTE : function(id, type, name, fn){ // id = equity_future_export // type = xlsx // name = where is "'+that.product+'_Futures" defined? There is no _Futures function here. // fn = where is "fn" defined? there is only 3 parameter when calling eTTE function? so no fn? var that=this; var wb = XLSX.utils.table_to_book(document.getElementById(id), {sheet:"Sheet JS"}); // what is wb as returned result? var wbout = XLSX.write(wb, {bookType:type, bookSST:true, type: 'binary'}); // what is wbout as returned result? var fname = fn || name + '.' + type; // what is fname as returned result? fn or ???.xlsx try { saveAs(new Blob([that._s2ab(wbout)],{type:"application/octet-stream"}), fname); } catch(e) { if(typeof console != 'undefined') console.log(e, wbout); } return wbout; }, Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 26, 2017 Moderators Share Posted November 26, 2017 oemript, This is an AutoIt forum. If you have a question about AutoIt code then please open a new thread, but asking us to translate this other code into AutoIt (which is presumably what you want, although as you are far from clear about anything at all I am not sure) is just not going to happen. Thread locked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts