|  | 
| 1 | 1 | /** | 
| 2 |  | - * Copyright (C) 2015, 2018 Akela <akela88@bk.ru> | 
|  | 2 | + * Copyright (C) 2015, 2017, 2018 Akela <akela88@bk.ru> | 
| 3 | 3 |  * Copyright (C) 2025 Nikita Tseykovets <tseikovets@rambler.ru> | 
| 4 | 4 |  * This file is part of UrqW. | 
| 5 | 5 |  * SPDX-License-Identifier: GPL-2.0-or-later | 
| @@ -245,8 +245,47 @@ Parser.prototype.openLinks = function(line) { | 
| 245 | 245 | 
 | 
| 246 | 246 |             if (exp.indexOf('|') > 0) { | 
| 247 | 247 |                 var exptmp = exp.split('|'); | 
| 248 |  | -                command = exptmp.slice(1).join('|').trim(); | 
|  | 248 | +                command = exptmp[1].trim(); | 
| 249 | 249 |                 text = exptmp[0].trim(); | 
|  | 250 | + | 
|  | 251 | +                // Link with drop-down menu | 
|  | 252 | +                if ((exp.match(/\|/g) || []).length > 1) { | 
|  | 253 | +                    var command2 = exptmp[2].split(','); | 
|  | 254 | + | 
|  | 255 | +                    var links = []; | 
|  | 256 | +                    var action = ''; | 
|  | 257 | +                    var label; | 
|  | 258 | +                    for (var i = 0; i < command2.length; i++) { | 
|  | 259 | +                        label = command + '_' + command2[i].trim(); | 
|  | 260 | +                        if (Game.getVar('hide_' + label) > 0) { | 
|  | 261 | +                            continue; | 
|  | 262 | +                        } | 
|  | 263 | +                        if (Game.getLabel(label)) { | 
|  | 264 | +                            action = label; | 
|  | 265 | +                        } else { | 
|  | 266 | +                            action = ''; | 
|  | 267 | +                            // The label was not found, so there is no such action. | 
|  | 268 | +                            // You can execute something here, for example: | 
|  | 269 | +                            // action = `pln You cannot ${command2[i].trim()} ${command}!`; | 
|  | 270 | +                        } | 
|  | 271 | + | 
|  | 272 | +                        var actionNum = GlobalPlayer.link(action); | 
|  | 273 | +                        links.push(`<li><a data-action="${actionNum}" class="button" href="#">${command2[i].replace(/_/g, ' ').trim()}</a></li>`); | 
|  | 274 | +                    } | 
|  | 275 | + | 
|  | 276 | +                    if (links.length == 0) { | 
|  | 277 | +                        return text; | 
|  | 278 | +                    } else { | 
|  | 279 | +                        return '<span class="dropdown dropdownmenulinks">' + | 
|  | 280 | +                            '<a href="#" class="dropdown dropdown-toggle" type="button" id="dropdownMenu' + actionNum + '" data-toggle="dropdown">' + | 
|  | 281 | +                            text + | 
|  | 282 | +                            '</a>' + | 
|  | 283 | +                            '<ul class="dropdown-menu">' + | 
|  | 284 | +                            links.join('') + | 
|  | 285 | +                            '</ul>' + | 
|  | 286 | +                            '</span>'; | 
|  | 287 | +                    } | 
|  | 288 | +                } | 
| 250 | 289 |             } else { | 
| 251 | 290 |                 command = exp.trim(); | 
| 252 | 291 |                 text = exp; | 
|  | 
0 commit comments