Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | /* Author: Sotaro KARASAWA <sotarok@crocos.co.jp> */ import 'scrollpos-styler' export default class Crowi { static createErrorView = (msg: string) => { $('#main').prepend($('<p class="alert-message error">' + msg + '</p>')) } static linkPath = (revisionPath?: string) => { var $revisionPath = revisionPath || '#revision-path' var $title = $($revisionPath) var pathData = $('#content-main').data('path') if (!pathData) { return } var realPath = pathData.trim() if (realPath.substr(-1, 1) == '/') { realPath = realPath.substr(0, realPath.length - 1) } var path = '' var pathHtml = '' var splittedPath = realPath.split(/\//) splittedPath.shift() splittedPath.forEach((sub: string) => { path += '/' pathHtml += ' <a href="' + Crowi.escape(path) + '">/</a> ' if (sub) { path += sub pathHtml += '<a href="' + Crowi.escape(path) + '">' + Crowi.escape(sub) + '</a>' } }) if (path.substr(-1, 1) != '/') { path += '/' pathHtml += ' <a href="' + Crowi.escape(path) + '" class="last-path">/</a>' } $title.html(pathHtml) } static correctHeaders = (contentId: string) => { // h1 ~ h6 の id 名を補正する var $content = $(contentId || '#revision-body-content') var i = 0 $('h1,h2,h3,h4,h5,h6', $content).each(function() { var id = 'head' + i++ $(this).attr('id', id) $(this).addClass('revision-head') $(this).append('<span class="revision-head-link"><a href="#' + id + '"><i class="mdi mdi-link-variant"></i></a></span>') }) } static revisionToc = (contentId, tocId) => { var $content = $(contentId || '#revision-body-content') var $tocId = $(tocId || '#revision-toc') var $tocContent = $('<div id="revision-toc-content" class="revision-toc-content collapse"></div>') $tocId.append($tocContent) $('h1', $content).each(function() { var id = $(this).attr('id') var title = $(this).text() var selector = '#' + id + ' ~ h2:not(#' + id + ' ~ h1 ~ h2)' var $toc = $('<ul></ul>') var $tocLi = $('<li><a href="#' + id + '">' + title + '</a></li>') $tocContent.append($toc) $toc.append($tocLi) $(selector).each(function() { var id2 = $(this).attr('id') var title2 = $(this).text() var selector2 = '#' + id2 + ' ~ h3:not(#' + id2 + ' ~ h2 ~ h3)' var $toc2 = $('<ul></ul>') var $tocLi2 = $('<li><a href="#' + id2 + '">' + title2 + '</a></li>') $tocLi.append($toc2) $toc2.append($tocLi2) $(selector2).each(function() { var id3 = $(this).attr('id') var title3 = $(this).text() var $toc3 = $('<ul></ul>') var $tocLi3 = $('<li><a href="#' + id3 + '">' + title3 + '</a></li>') $tocLi2.append($toc3) $toc3.append($tocLi3) }) }) }) } static escape = (s: string) => s .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/'/g, ''') .replace(/"/g, '"') static unescape = (s: string) => s .replace(/ /g, ' ') .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/'/g, "'") .replace(/"/g, '"') // original: middleware.swigFilter static userPicture = user => { if (!user) { return '/images/userpicture.png' } if (user.image && user.image != '/images/userpicture.png') { return user.image } return '/images/userpicture.png' } static modifyScrollTop = () => { var offset = 10 var hash = window.location.hash if (hash === '') { return } var pageHeader = document.querySelector('#page-header') if (!pageHeader) { return } var pageHeaderRect = pageHeader.getBoundingClientRect() var sectionHeader = document.querySelector(hash) if (sectionHeader === null) { return } var timeout = 0 if (window.scrollY === 0) { timeout = 200 } setTimeout(() => { if (!sectionHeader) return var sectionHeaderRect = sectionHeader.getBoundingClientRect() if (sectionHeaderRect.top >= pageHeaderRect.bottom) { return } window.scrollTo(0, window.scrollY - pageHeaderRect.height - offset) }, timeout) } static findHashFromUrl = url => { var match if ((match = url.match(/#(.+)$/))) { return '#' + match[1] } return '' } static unhighlightSelectedSection = hash => { if (!hash || hash == '' || !hash.match(/^#head.+/)) { // とりあえず head* だけ (検索結果ページで副作用出た return true } $(hash).removeClass('highlighted') } static highlightSelectedSection = hash => { if (!hash || hash == '' || !hash.match(/^#head.+/)) { // とりあえず head* だけ (検索結果ページで副作用出た return true } $(hash).addClass('highlighted') } } $(function() { const crowi = window.crowi const crowiRenderer = window.crowiRenderer var pageId = $('#content-main').data('page-id') var isSeen = $('#content-main').data('page-is-seen') var pagePath = $('#content-main').data('path') var isSharePage = !!$('#content-main').data('is-share-page') Crowi.linkPath() $('[data-toggle="popover"]').popover() $('[data-toggle="tooltip"]').tooltip() $('[data-tooltip-stay]').tooltip('show') $('#toggle-sidebar').click(function(e) { var $mainContainer = $('.main-container') if ($mainContainer.hasClass('aside-hidden')) { $('.main-container').removeClass('aside-hidden') $.cookie('aside-hidden', 0, { expires: 30, path: '/' }) } else { $mainContainer.addClass('aside-hidden') $.cookie('aside-hidden', 1, { expires: 30, path: '/' }) } return false }) if ($.cookie('aside-hidden') == 1) { $('.main-container').addClass('aside-hidden') } $('.copy-link').on('click', function() { $(this).select() }) $('#create-page').on('shown.bs.modal', function(e) { // quick hack: replace from server side rendering "date" to client side "date" var today = new Date() var month = ('0' + (today.getMonth() + 1)).slice(-2) var day = ('0' + today.getDate()).slice(-2) var dateString = today.getFullYear() + '/' + month + '/' + day $('#create-page-today .page-today-suffix').text('/' + dateString + '/') $('#create-page-today .page-today-input2').data('prefix', '/' + dateString + '/') $('#create-page-today .form-control.page-today-input2').focus() }) $('#create-page-today').submit(function(e) { var prefix1 = $('input.page-today-input1', this).data('prefix') var input1 = $('input.page-today-input1', this).val() var prefix2 = $('input.page-today-input2', this).data('prefix') var input2 = $('input.page-today-input2', this).val() if (input1 === '') { prefix1 = 'メモ' } if (input2 === '') { prefix2 = prefix2.slice(0, -1) } top.location.href = prefix1 + input1 + prefix2 + input2 return false }) $('#create-page-under-tree').submit(function(e) { var name = String($('input', this).val()) if (!name.match(/^\//)) { name = '/' + name } if (name.match(/.+\/$/)) { name = name.substr(0, name.length - 1) } top.location.href = name return false }) // rename const rename = (data, newPageNameCheck) => $.ajax({ type: 'POST', url: '/_api/pages.rename', data, dataType: 'json', }).done(function(res) { if (!res.ok) { newPageNameCheck.html('<i class="mdi mdi-alert"></i> ' + res.error) newPageNameCheck.addClass('alert-danger') } else { var page = res.page newPageNameCheck.removeClass('alert-danger') // $('#newPageNameCheck').html('<img src="/images/loading_s.gif"> 移動しました。移動先にジャンプします。'); // fix newPageNameCheck.html('<img src="/images/loading_s.gif"> Page moved! Redirecting to new page location.') setTimeout(function() { top.location.href = page.path + '?redirectFrom=' + pagePath }, 1000) } }) $('#renamePage').on('shown.bs.modal', function(e) { $('#newPageName').focus() }) $('#renamePageForm, #unportalize-form, #portalize-form').submit(function(e) { rename($(this).serialize(), $(this).find('.new-page-name-check')) e.preventDefault() return false }) // delete $('#delete-page-form').submit(function(e) { $.ajax({ type: 'POST', url: '/_api/pages.remove', data: $('#delete-page-form').serialize(), dataType: 'json', }).done(function(res) { if (!res.ok) { $('#delete-errors').html('<i class="mdi mdi-alert"></i> ' + res.error) $('#delete-errors').addClass('alert-danger') } else { var page = res.page top.location.href = page.path } }) return false }) $('#revert-delete-page-form').submit(function(e) { $.ajax({ type: 'POST', url: '/_api/pages.revertRemove', data: $('#revert-delete-page-form').serialize(), dataType: 'json', }).done(function(res) { if (!res.ok) { $('#delete-errors').html('<i class="mdi mdi-alert"></i> ' + res.error) $('#delete-errors').addClass('alert-danger') } else { var page = res.page top.location.href = page.path } }) return false }) $('#unlink-page-form').submit(function(e) { $.ajax({ type: 'POST', url: '/_api/pages.unlink', data: $('#unlink-page-form').serialize(), dataType: 'json', }).done(function(res) { if (!res.ok) { $('#delete-errors').html('<i class="mdi mdi-alert"></i> ' + res.error) $('#delete-errors').addClass('alert-danger') } else { var page = res.page top.location.href = page.path + '?unlinked=true' } }) return false }) $('#create-portal-button').on('click', function(e) { $('.portal').removeClass('d-none') $('.content-main').addClass('on-edit') $('.portal a[data-toggle="tab"][href="#edit-form"]').tab('show') var path = $('.content-main').data('path') if (path != '/' && $('.content-main').data('page-id') == '') { var upperPage = path.substr(0, path.length - 1) $.get('/_api/pages.get', { path: upperPage }, function(res) { if (res.ok && res.page) { $('#portal-warning-modal').modal('show') } }) } }) $('#portal-form-close').on('click', function(e) { $('.portal').addClass('d-none') $('.content-main').removeClass('on-edit') return false }) // list-link $('.page-list-link-path').each(function() { const $link = $(this) const path = $link.attr('data-path') const shortPath = $link.attr('data-short-path') || '' if (path !== undefined && shortPath !== undefined) { const pathPrefix = path.slice(0, -shortPath.length) $link.html(`${Crowi.escape(pathPrefix)}<strong>${Crowi.escape(shortPath)}</strong>`) } }) // for list page $('a[data-toggle="tab"][href="#view-timeline"]').on('show.bs.tab', function() { var isShown = $('#view-timeline').data('shown') if (isShown == 0) { $('#view-timeline .timeline-body').each(function() { var id = $(this).attr('id') var contentId = '#' + id + ' > script' var revisionBody = '#' + id + ' .revision-body' var $revisionBody = $(revisionBody) // var revisionPath = '#' + id + ' .revision-path' var markdown = Crowi.unescape($(contentId).html()) var parsedHTML = crowiRenderer.render(markdown, $revisionBody.get(0)) $revisionBody.html(parsedHTML) $('.template-create-button', $revisionBody).on('click', function() { var path = $(this).data('path') var templateId = $(this).data('template') var template = $('#' + templateId).html() crowi.saveDraft(path, template) top.location.href = path }) }) $('#view-timeline').data('shown', 1) } }) $('#register-form input[name="registerForm[username]"]').change(function(e) { var username = $(this).val() $('#input-group-username').removeClass('has-error') $('#help-block-username').html('') $.getJSON('/_api/check_username', { username: username }, function(json) { if (!json.valid) { $('#help-block-username').html('<i class="mdi mdi-alert"></i> This User ID is not available.<br>') $('#input-group-username').addClass('has-error') } }) }) // omg /login/invited $('#invited-form input[name="invitedForm[username]"]').change(function(e) { var username = $(this).val() $('#input-group-username').removeClass('has-error') $('#help-block-username').html('') $.getJSON('/_api/check_username', { username: username }, function(json) { if (!json.valid) { $('#help-block-username').html('<i class="mdi mdi-alert"></i> This User ID is not available.<br>') $('#input-group-username').addClass('has-error') } }) }) // moved from view /me/index.html $('#pictureUploadForm input[name=userPicture]').on('change', async function() { // clear message before process change $('#pictureUploadFormMessage') .removeClass() .empty() const $form = $('#pictureUploadForm') const formElement = $form[0] as HTMLFormElement const formInputElement = formElement.elements[0] as HTMLInputElement // check cancel/abort if (formInputElement.files && formInputElement.files.length === 0) return const fd = new FormData(formElement) // Like first aid, we'll drop this function with react+cropper.js after. const picture = fd.get('userPicture') as File const { name: pictureName, type: pictureType } = picture let pictureSource: ImageBitmap | HTMLImageElement | null = null try { pictureSource = await ((): Promise<ImageBitmap | HTMLImageElement> => { if ('createImageBitmap' in window) return createImageBitmap(picture) return new Promise((resolve, reject) => { const element = document.createElement('img') const objectURL = URL.createObjectURL(picture) element.addEventListener('load', () => { URL.revokeObjectURL(objectURL) resolve(element) }) element.addEventListener('error', reject) element.src = objectURL }) })() } catch (e) { $('#pictureUploadFormMessage') .removeClass() .addClass('alert alert-danger') .html(e.message) return } /** * @param {string} image * @param {number} size square size in px * @param {string} type output mime-type * @param {number} [quality=0.95] output quality * @returns {Promise<Blob>} */ const convert = (image, size, type, quality = 0.95): Promise<Blob | null> => { const [w, h] = [image.naturalWidth || image.width, image.naturalHeight || image.height] const s = w > h ? h : w /** * 正方形に整形、中央寄せ * 現在 img に対して `vertical-align: middle` が指定されているので、この変換器を入れても何も問題がない */ const canvas = (() => { if ('OffscreenCanvas' in window) return new OffscreenCanvas(s, s) const element = document.createElement('canvas') element.width = element.height = s return element })() const ctx = canvas.getContext('2d') as CanvasRenderingContext2D ctx.drawImage(image, (w - s) / 2, (h - s) / 2, s, s, 0, 0, s, s) /** * 1/2 単位で、だいたいのサイズにする * フィルターの性能不足があり、直接変換するとジャギーなどが発生することがある (らしい) * https://stackoverflow.com/questions/17861447/html5-canvas-drawimage-how-to-apply-antialiasing */ while (canvas.height / 2 > size) { const ctx = canvas.getContext('2d') as CanvasRenderingContext2D // Save current canvas state to pettern const pattern = ctx.createPattern(canvas, 'no-repeat') as CanvasPattern const { width, height } = canvas // Resize to 1/4 (and canvas state will clear) canvas.width /= 2 canvas.height /= 2 ctx.scale(0.5, 0.5) ctx.fillStyle = pattern ctx.fillRect(0, 0, width, height) } // Offscrean canvas if (!(canvas instanceof HTMLElement)) { return canvas.convertToBlob({ type, quality }) } // HTML Element return new Promise(resolve => { canvas.toBlob(resolve, type, quality) }) } try { const acceptTypes = ['image/jpeg', 'image/png'] // If convertable image without format that can't be output, choose jpeg const targetType = (acceptTypes.includes(pictureType) && pictureType) || 'image/jpeg' const suffix = acceptTypes.includes(pictureType) ? '' : '.compact.jpg' const blob = await convert(pictureSource, 128, targetType) if (blob) { fd.set('userPicture', blob, pictureName + suffix) } } catch (e) { $('#pictureUploadFormMessage') .removeClass() .addClass('alert alert-danger') .html(e.message) return } if ($(this).val() == '') { return false } $('#pictureUploadFormProgress').html('<img src="/images/loading_s.gif"> Uploading ...') $.ajax($form.attr('action') as string, { type: 'post', processData: false, contentType: false, data: fd, dataType: 'json', success: function(data) { if (data.status) { $('#settingUserPicture').attr('src', data.url + '?time=' + new Date()) $('#pictureUploadFormMessage') .removeClass() .addClass('alert alert-success') .html('Updated.') } else { $('#pictureUploadFormMessage') .removeClass() .addClass('alert alert-danger') .html('Failed to update profile picture.') } $('#pictureUploadFormProgress').html('') }, }) return false }) if (pageId) { // if page exists var $rawTextOriginal = $('#raw-text-original') if ($rawTextOriginal.length > 0) { var markdown = Crowi.unescape($('#raw-text-original').html()) var revisionBody = $('#revision-body-content') var parsedHTML = crowiRenderer.render(markdown, revisionBody.get(0)) revisionBody.html(parsedHTML) $('.template-create-button').on('click', function() { var path = $(this).data('path') var templateId = $(this).data('template') var template = $('#' + templateId).html() crowi.saveDraft(path, template) top.location.href = path }) Crowi.correctHeaders('#revision-body-content') Crowi.revisionToc('#revision-body-content', '#revision-toc') } // header var $headerWrap = $('#page-header').parent() if ($headerWrap.length > 0) { const headerHeight = $('.crowi-header').outerHeight() || 0 const pageGrantHeight = $('.page-grant').outerHeight() || 0 $headerWrap.attr('data-sps-offset', headerHeight + pageGrantHeight) $('.stopper').on('click', e => { $headerWrap.removeClass('sps sps--abv sps--blw') return false }) } const AddToLikers = function(users) { $.each(users, function(i, user) { $likerList.append(CreateUserLinkWithPicture(user)) }) } const CreateUserLinkWithPicture = function(user) { var $userHtml = $('<a>') $userHtml.data('user-id', user._id) $userHtml.attr('href', '/user/' + user.username) $userHtml.attr('title', user.name) var $userPicture = $('<img class="picture picture-xs picture-rounded">') $userPicture.attr('alt', user.name) $userPicture.attr('src', Crowi.userPicture(user)) $userHtml.append($userPicture) return $userHtml } const MarkLiked = function() { $likeButton.addClass('active') $likeButton.data('liked', 1) $likeCount.text(parseInt($likeCount.text()) + 1) } const MarkUnLiked = function() { $likeButton.removeClass('active') $likeButton.data('liked', 0) $likeCount.text(parseInt($likeCount.text()) - 1) } // Like var $likeButton = $('.like-button') var $likeCount = $('#like-count') $likeButton.click(function() { var liked = $likeButton.data('liked') var token = $likeButton.data('csrftoken') if (!liked) { $.post('/_api/likes.add', { _csrf: token, page_id: pageId }, function(res) { if (res.ok) { MarkLiked() } }) } else { $.post('/_api/likes.remove', { _csrf: token, page_id: pageId }, function(res) { if (res.ok) { MarkUnLiked() } }) } return false }) var $likerList = $('#liker-list') var likers = $likerList.data('likers') if (likers && likers.length > 0) { var users = crowi.findUserByIds(likers.split(',')) if (users) { AddToLikers(users) } } if (!isSeen && !isSharePage) { $.post('/_api/pages.seen', { page_id: pageId }, function(res) { // ignore unless response has error if (res.ok && res.seenUser) { $('#content-main').data('page-is-seen', 1) } }) } // presentation var presentaionInitialized = false var $b = $('body') $(document) .on('click', '.toggle-presentation', function(e) { var $a = $(this) e.preventDefault() $b.toggleClass('overlay-on') if (!presentaionInitialized) { presentaionInitialized = true $('<iframe />') .attr({ src: $a.attr('href'), }) .appendTo($('#presentation-container')) } }) .on('click', '.fullscreen-layer', function() { $b.toggleClass('overlay-on') }) } // end if pageId // hash handling $('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', function() { window.history.pushState('', 'History', '#revision-history') }) $('a[data-toggle="tab"][href="#edit-form"]').on('show.bs.tab', function() { window.history.pushState('', 'Edit', '#edit-form') }) $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', function() { window.history.pushState('', '', location.href.replace(location.hash, '')) }) $(document).on('click', '#external-share .dropdown-menu', function(e) { e.stopPropagation() }) }) window.addEventListener('load', function(e) { const crowi = window.crowi // hash on page if (location.hash) { if (location.hash == '#edit-form') { $('a[data-toggle="tab"][href="#edit-form"]').tab('show') } if (location.hash == '#revision-history') { $('a[data-toggle="tab"][href="#revision-history"]').tab('show') } } if ((crowi && crowi.users) || crowi.users.length == 0) { var totalUsers = crowi.users.length var $listLiker = $('.page-list-liker') $listLiker.each(function(i, liker) { var count = $(liker).data('count') || 0 if (count / totalUsers > 0.05) { $(liker).addClass('popular-page-high') // 5% } else if (count / totalUsers > 0.02) { $(liker).addClass('popular-page-mid') // 2% } else if (count / totalUsers > 0.005) { $(liker).addClass('popular-page-low') // 0.5% } }) var $listSeer = $('.page-list-seer') $listSeer.each(function(i, seer) { var count = $(seer).data('count') || 0 if (count / totalUsers > 0.1) { // 10% $(seer).addClass('popular-page-high') } else if (count / totalUsers > 0.05) { // 5% $(seer).addClass('popular-page-mid') } else if (count / totalUsers > 0.02) { // 2% $(seer).addClass('popular-page-low') } }) } Crowi.highlightSelectedSection(location.hash) Crowi.modifyScrollTop() }) window.addEventListener('hashchange', function(e) { Crowi.unhighlightSelectedSection(Crowi.findHashFromUrl(e.oldURL)) Crowi.highlightSelectedSection(Crowi.findHashFromUrl(e.newURL)) Crowi.modifyScrollTop() // hash on page if (location.hash) { if (location.hash == '#edit-form') { $('a[data-toggle="tab"][href="#edit-form"]').tab('show') } if (location.hash == '#revision-history') { $('a[data-toggle="tab"][href="#revision-history"]').tab('show') } } if (location.hash == '' || location.hash.match(/^#head.+/)) { $('a[data-toggle="tab"][href="#revision-body"]').tab('show') } }) |