You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/05/12 23:15:51 UTC
[GitHub] [solr] sonatype-lift[bot] commented on a diff in pull request #859: Ref guide overall version improvement
sonatype-lift[bot] commented on code in PR #859:
URL: https://github.com/apache/solr/pull/859#discussion_r871875679
##########
solr/solr-ref-guide/ui-src/js/07-copy-perma-link.js:
##########
@@ -0,0 +1,51 @@
+;(function () {
+ 'use strict'
+
+ var TRAILING_SPACE_RX = / +$/gm
+ var config = (document.getElementById('site-script') || { dataset: {} }).dataset
+
+ ;[].slice.call(document.querySelectorAll('span.perma-link-copy')).forEach(function (span) {
+ var link, copy, toast, permaLinkText, toolbox
+ link = window.location.href.replace('/latest/', '/' + span.getAttribute('version') + '/')
+ ;(toolbox = document.createElement('div')).className = 'perma-link'
+ if (window.navigator.clipboard) {
+ ;(copy = document.createElement('button')).className = 'copy-button'
+ copy.setAttribute('title', 'Copy Link')
+ ;(permaLinkText = document.createElement('span')).className = 'button-label'
+ permaLinkText.appendChild(document.createTextNode('Permanent Link'))
+ copy.appendChild(permaLinkText)
+ if (config.svgAs === 'svg') {
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
+ svg.setAttribute('class', 'copy-icon')
+ var use = document.createElementNS('http://www.w3.org/2000/svg', 'use')
+ use.setAttribute('href', window.uiRootPath + '/img/octicons-16.svg#icon-clippy')
+ svg.appendChild(use)
+ copy.appendChild(svg)
+ } else {
+ var img = document.createElement('img')
+ img.src = window.uiRootPath + '/img/octicons-16.svg#view-clippy'
+ img.alt = 'copy icon'
+ img.className = 'copy-icon'
+ copy.appendChild(img)
+ }
+ ;(toast = document.createElement('span')).className = 'copy-toast'
+ toast.appendChild(document.createTextNode('Copied!'))
+ copy.appendChild(toast)
+ toolbox.appendChild(copy)
+ }
+ span.appendChild(toolbox)
+ if (copy) copy.addEventListener('click', writeToClipboard.bind(copy, link))
+ })
+
+ function writeToClipboard (link) {
+ var text = link.replace(TRAILING_SPACE_RX, '')
+ window.navigator.clipboard.writeText(text).then(
+ function () {
+ this.classList.add('clicked')
+ this.offsetHeight // eslint-disable-line no-unused-expressions
Review Comment:
*JSC_USELESS_CODE:* Suspicious code. The result of the 'getprop' operator is not being used.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=208451309&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=208451309&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=208451309&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=208451309&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=208451309&lift_comment_rating=5) ]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org