修訂 | 4f66465183e77b916ac802a5c9d78bf894c0cee9 (tree) |
---|---|
時間 | 2018-04-11 21:57:13 |
作者 | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2431 topicpath-title: ensure a.textContent == page
@@ -250,7 +250,11 @@ EOS; | ||
250 | 250 | $plugin_prop = <<<EOS |
251 | 251 | <input type="hidden" class="plugin-name" value="$h_plugin" /> |
252 | 252 | EOS; |
253 | - | |
253 | + // Page name | |
254 | + $h_page_name = htmlsc($page); | |
255 | + $page_name_data = <<<EOS | |
256 | +<input type="hidden" class="page-name" value="$h_page_name" /> | |
257 | +EOS; | |
254 | 258 | // AutoTicketLink |
255 | 259 | $filtered_ticket_link_sites = array(); |
256 | 260 | foreach ($ticket_link_sites as $s) { |
@@ -287,6 +291,7 @@ EOS; | ||
287 | 291 | <div id="pukiwiki-site-properties" style="display:none;"> |
288 | 292 | $site_props |
289 | 293 | $plugin_prop |
294 | +$page_name_data | |
290 | 295 | $ticketlink_data |
291 | 296 | $external_link_cushion_data |
292 | 297 | $topicpath_data |
@@ -467,7 +467,13 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
467 | 467 | }); |
468 | 468 | } |
469 | 469 | function makeTopicpathTitle() { |
470 | - var topicpathE = document.querySelector('#pukiwiki-site-properties .topicpath-links'); | |
470 | + if (!document.createDocumentFragment || !window.JSON) return; | |
471 | + var sitePropE = document.querySelector('#pukiwiki-site-properties'); | |
472 | + if (!sitePropE) return; | |
473 | + var pageNameE = sitePropE.querySelector('.page-name'); | |
474 | + if (!pageNameE || !pageNameE.value) return; | |
475 | + var pageName = pageNameE.value; | |
476 | + var topicpathE = sitePropE.querySelector('.topicpath-links'); | |
471 | 477 | if (!topicpathE || !topicpathE.value) return; |
472 | 478 | var topicpathLinks = JSON.parse(topicpathE.value); |
473 | 479 | if (!topicpathLinks) return; |
@@ -477,6 +483,7 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
477 | 483 | if (!aList || aList.length > 1) return; |
478 | 484 | var a = titleH1.querySelector('a'); |
479 | 485 | if (!a) return; |
486 | + if (a.textContent !== pageName) return; | |
480 | 487 | var fragment = document.createDocumentFragment(); |
481 | 488 | for (var i = 0, n = topicpathLinks.length; i < n; i++) { |
482 | 489 | var path = topicpathLinks[i]; |