PageSourceSearch

https://wglh.com/static/js/watch_stocks.js?v=20260903

js wglh.com collected 2026-10-08 11:02:19 UTC 10,572 bytes, 282 lines download raw bytes

1let btnWatchObj = $('#btn_add_watch_stock')
2
3function add_watch_stock(symbol) {
4    if(!window.is_authenticated){
5        window.location.href = $('#a_login').attr('href');
6        return;
7    }
8
9    $.ajax({
10            url: "/DoAddWatchStock/",
11            data:{'symbol': symbol},
12            dataType:"json",
13            type:"POST",
14            success:function(data) {
15                if(data.success){
16                    $(btnWatchObj).html(getBtnWatchText());
17                    $(btnWatchObj).removeClass('btn-outline-primary');
18                    $(btnWatchObj).addClass('btn-outline-primary');
19                    $(btnWatchObj).unbind("click");
20                    $(btnWatchObj).click(function(){
21                        delete_watch_stock(symbol);
22                    });
23
24                    if(!!data.group){
25                        var cookieGroupTip = 'watch_add_group_tip';
26                        if(typeof($.cookie(cookieGroupTip)) == "undefined"){
27                            if(data.group.indexOf(',')>-1){
28                                showAlertDialog('自选添加成功', '已添加到<strong>所有分组</strong>,您可以在自选股页面设置默认分组。', 'Success');
29                                $.cookie(cookieGroupTip, '1', { expires: 30, path: '/' });
30                            }
31                            else{
32                                showAlertDialog('自选添加成功', '已添加到<strong>默认分组</strong>,您可以在自选股页面更改默认分组。', 'Success');
33                                $.cookie(cookieGroupTip, '1', { expires: 30, path: '/' });
34                            }
35                        }
36                    }
37                }
38                else{
39                    if(data.msg == 'stock 404'){
40                        showAlertDialog('自选股添加失败', '自选股添加失败,未找到该股票。', 'Error');
41                    }
42                    else if(data.msg == 'user 404'){
43                        showAlertDialog('自选股添加失败', '自选股添加失败,用户未登录。', 'Error');
44                    }
45                    else if(data.msg == '500'){
46                        showAlertDialog('自选股添加失败', '自选股添加失败,服务器错误。', 'Error');
47                    }
48                    else {
49                        showAlertDialog('自选股添加失败', data.msg, 'Error');
50                    }
51                }
52             }
53    });
54}
55
56// 自选股下拉
57function setMyWatchDrop(stocks, dropdown) {
58    if(stocks.length == 0){
59        $(dropdown).html('<div class="ps-3">添加自选后,可在当前位置快速切换股票的信息。</div>');
60        return;
61    }
62
63    var html = '';
64    var template = '<a href="{0}">{1}</a>';
65    var current_path = $('.current_path').html().toLocaleLowerCase();
66    for(var i=0;i<stocks.length;i++){
67        var k = stocks[i].split('@');
68        if(k[2]=='stock'){
69            var url = '';
70            if(current_path.indexOf('new/')>-1 || current_path.indexOf('comment/')>-1){
71                url = '/stock/news/' + k[0].toLowerCase() + '/';
72            }
73            else{
74                url = current_path.substring(0, current_path.length-9) + k[0].toLowerCase() + '/';
75            }
76            html += template.format(url, k[1]);
77        }
78    }
79
80    if(html == ''){
81        $(dropdown).html('<div class="ps-3">添加自选后,可在当前位置快速切换股票的信息。</div>');
82    }
83    else{
84        html += '<div class="text-secondary text-center mt-3">可在自选股页面,对股票进行排序</div>';
85        $(dropdown).html(html);
86    }
87}
88
89function setMyWatchDrop2(stocks, dropdown) {
90    if(stocks.length == 0){
91        $(dropdown).html('<div class="ps-3">添加自选后,可在当前位置快速切换股票的信息。</div>');
92        return;
93    }
94
95    var html = '';
96    var template = '<a href="{0}">{1}</a>';
97    var cur_path = $('.current_path').html().toLocaleLowerCase();
98    for(var i=0;i<stocks.length;i++){
99        let k = stocks[i].split('@')
100        let tempS = k[0].toLowerCase()
101        let isCN = tempS[0] == 's' ? true : false
102        if(isCN){
103            tempS = tempS.substring(1);
104        }
105
106        if(k[2]=='stock'){
107            var url = '';
108            if(cur_path.indexOf('new/')>-1 || cur_path.indexOf('comment/')>-1){
109                url = '/stock/news/' + tempS + '/';
110            }
111            else{
112                url = cur_path.substring(0, cur_path.length-8) + tempS + '/';
113            }
114
115            
116
117            html += template.format(url, k[1]);
118        }
119    }
120
121    if(html == ''){
122        $(dropdown).html('<div class="ps-3">
122添加自选后,可在当前位置快速切换股票的信息。</div>');
123    }
124    else{
125        html += '<div class="text-secondary text-center mt-3">可在自选股页面,对股票进行排序</div>';
126        $(dropdown).html(html);
127    }
128}
129
130function bind_watch_stock() {
131    $.ajax({
132        url: "/GetWatchStocksSymbol/",
133        dataType:"json",
134        type:"GET",
135        success: function (data) {
136            if (data.success) {
137                showTopTip(data)
138                setWatchBtn(data.list_watch_stocks, data.list_watch_stocks_name)
139                let hasFun = false
140                try{
141                    if (!!customWatchFun) {
142                        hasFun = true
143                    }
144                }catch(e){
145                }
146                if(hasFun){
147                    customWatchFun(data);
148                }
149            }
150        }
151    });
152}
153
154function setWatchBtn(list_watch_stocks, list_watch_stocks_name) {
155    var current_symbol = $('.current_symbol').html()
156    
157    let html_authenticated = $('.user_is_authenticated').html()
158    window.is_authenticated = html_authenticated == '1' || html_authenticated == '2' ? true : false
159
160    if (!window.is_authenticated || !current_symbol || current_symbol == '') {
161        $('#btn_add_watch_stock').attr('disabled', 'disabled')
162    }
163    else {
164        if (list_watch_stocks.length == 0 || list_watch_stocks.indexOf(current_symbol) == -1) { 
165            $(btnWatchObj).unbind("click");
166            $(btnWatchObj).click(function(){
167                add_watch_stock(current_symbol);
168            });
169        }
170        else {
171            $(btnWatchObj).html(getBtnWatchText());
172            $(btnWatchObj).attr('title', '点击取消自选');
173            $(btnWatchObj).removeClass('btn-outline-primary');
174            $(btnWatchObj).addClass('btn-outline-primary');
175            $(btnWatchObj).unbind("click");
176            $(btnWatchObj).click(function(){
177                delete_watch_stock(current_symbol);
178            });
179        }
180        
181        var dropdown = $('.my_watchs_drop .dropdown-menu:first');
182        if($(dropdown).length==1){
183            setMyWatchDrop(list_watch_stocks_name, dropdown);
184        }
185    }
186}
187
188function delete_watch_stock(symbol) {
189    if(!window.is_authenticated){
190        window.location.href = $('#a_login').attr('href');
191        return;
192    }
193
194    $.ajax({
195            url: "/DoDeleteWatchStock/",
196            data:{'symbol': symbol},
197            dataType:"json",
198            type:"POST",
199            success:function(data) {
200                if(data.success){
201                    if($(btnWatchObj).hasClass('btn')){
202                        $(btnWatchObj).html('&nbsp;&nbsp;+&nbsp;自&nbsp;选&nbsp;&nbsp;');
203                        $(btnWatchObj).attr('title', '点击添加自选');
204                        $(btnWatchObj).addClass('btn-outline-primary');
205                        $(btnWatchObj).removeClass('btn-outline-primary');
206                        $(btnWatchObj).unbind("click");
207                        $(btnWatchObj).click(function(){
208                            add_watch_stock( symbol);
209                        });
210                    }
211                    else{
212                        $(btnWatchObj).parent().parent().hide(1000);
213                    }
214                }
215                else{
216                    if(data.msg == 'user 404'){
217                        showAlertDialog('移除自选股失败', '移除自选股失败,用户未登录。', 'Error');
218                    }
219                    else if(data.msg == '500'){
220                        showAlertDialog('移除自选股失败', '移除自选股失败,服务器错误。', 'Error');
221                    }
222                    else{
223                        showAlertDialog('移除自选股失败', '移除自选股失败,未知错误。', 'Error');
224                    }
225                }
226             }
227    });
228}
229
230function delWatchSymbol(obj, symbol) {
231    $.ajax({
232            url: "/DoDeleteWatchStock/",
233            data:{'symbol': symbol},
234            dataType:"json",
235            type:"POST",
236            success:function(data) {
237                if(data.success){
238                    $(obj).parent().parent().hide(1000);
239                }
240                else{
241                    if(data.msg == 'user 404'){
242                        showAlertDialog('移除自选股失败', '移除自选股失败,用户未登录。', 'Error');
243                    }
244                    else if(data.msg == '500'){
245                        showAlertDialog('移除自选股失败', '移除自选股失败,服务器错误。', 'Error');
246                    }
247                    else{
248                        showAlertDialog('移除自选股失败', '移除自选股失败,未知错误。', 'Error');
249                    }
250                }
251             }
252    });
253}
254
255function getBtnWatchText(){
256    if($('.is_mobile:first').html() == 'True'){
257        return '√ 已加';
258    }
259    else{
260        return '&nbsp;√&nbsp;已加自选';
261    }
262}
263
264(function () {
265    if ($('.top_tip').length == 1) {
266        let stoWatch = localStorage.getItem(localStorageKeyWatch)
267        let stoTJ = localStorage.getItem(localStorageKeyTJ)
268        if (!!stoWatch) {
269            $('.top_tip .watchs').html(stoWatch)
270        }
271
272        if (!!stoTJ) {
273            $('.top_tip .tj').html(stoTJ)
274        }
275    }
276    
277    bind_watch_stock();
278    var url = window.location.href.toLowerCase();
279    if(url.indexOf('user/watch') > -1){
280        setTimeout("window.location.href='/';", 60 * 60 * 1000);
281    }
282})();

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.