1

I launched UrbanCode Deploy server. I installed agent on the same hardware. Agent don't connect:

Connecting to wss://localhost:7918 TCP connection complete: сhannel=8e24500b uri=wss://localhost:7918 connection=127.0.0.1:60981->127.0.0.1:718 SSL handshake complete: ch=8e24500b local=/127.0.0.1:60981 remote=localhost/127.0.0.1:7918 proto=TLSv1.2 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 peer=CN=mycomp pubkey fp=1C.....8E Loading pin certificate from disk: file=c:\agent\public-keys\localhost.crt Reconnecting in 3000 ms

Server:

Transport Connection to: tcp://127.0.0.1:60981 failed

If I change port then no any connect, so port 7918 - correct. If I delete .crt file then agent creates it again and load so path and rights is correct.

Windows 10.

J. Doe
  • 29
  • 6
  • I think your requirement needs support of JS or jQuery – Sinto Jul 07 '18 at 06:33
  • This is not something PHP is meant for. You will need to use JS or JQuery as @Sinto said. – CodeSpent Jul 07 '18 at 06:41
  • You are right. Corrected question tag – J. Doe Jul 07 '18 at 06:43
  • 1
    You just need to toggle a boolean variable when `Esc` is pressed and use and an `if` statement to check it when `PgUp/PgDown` keys fire an event, that you're listening for with `.addEventListener`. – Chris Jul 07 '18 at 06:54
  • I see it. My main problem is How scroll to next highlighted phrase (also I need replace spaces in phrase I suppose) – J. Doe Jul 07 '18 at 07:59
  • Noticed the mistake I made in my answer, should be fixed and working now. – icecub Jul 07 '18 at 08:19

1 Answers1

0

Took me a while to write, but this is the best I can come up with. It's not 100% perfect (switching between scrolling up and down requires 2 keypresses), but aside from that it works as expected. Explanation in code comments:

function handleKeyPress(event){
    // Prevent default browser action on PageUp, PageDown, ArrowUp, ArrowDown and Esc
    if([27, 33, 34, 38, 40].indexOf(event.keyCode) > -1) {
        event.preventDefault();
    }
    // Get key name
    const keyName = event.key;

    // Scrolling up
    if(keyName === 'PageUp' || keyName === 'ArrowUp'){
        // First anchor detected
        if(currAnchor === 0){
            return false;
        } else {
            currAnchor--;
            location.hash = anchorLinks[currAnchor].id;
        }
    } else if(keyName === 'PageDown' || keyName === 'ArrowDown'){
        if(currAnchor <= lastAnchor){
            location.hash = anchorLinks[currAnchor].id;
            currAnchor++;
        // Last anchor detected
        } else {
            return false;
        }
    } else if(keyName === 'Escape'){
        // Remove the event listener
        document.removeEventListener('keypress', handleKeyPress, true);
    }
}

// Get all divs (just an example. Best to use a class to only select what you need)
const anchorLinks = document.getElementsByTagName("div");
// Get last index of array
const lastAnchor = anchorLinks.length;
// Current anchor position
let currAnchor = 0;

// Add event listener for keypress
document.addEventListener('keypress', handleKeyPress, true);
icecub
  • 7,964
  • 5
  • 34
  • 63
  • I will try to test now :-) See You later. – J. Doe Jul 07 '18 at 10:38
  • @J.Doe Please make sure to check the checkmark next to the answer that solved your problem. This is a way of showing your appreciation to the person that helped you out and makes sure your question doesn't remain unanswered forever. This doesn't have to be my answer. It's just an explanation on how Stack Overflow works, as it seems you're new here. – icecub Jul 07 '18 at 11:04
  • ok I will check. Can You explain me how I should get anchors in HTML? Should I embrace anchors by
    surely?
    – J. Doe Jul 08 '18 at 06:14
  • @J.Doe I don't think the element matters. It's just the `id` that does. – icecub Jul 08 '18 at 18:11
  • Thanks for support! Please look like I solved part task. I corrected my question. – J. Doe Jul 08 '18 at 23:57
  • BTW all kind location. methods for scrolling DON'T WORK for me :-( I don't know why (fresh FF and Chrome though). I searched in internet and spent a lot hours... – J. Doe Jul 09 '18 at 00:01
  • @J.Doe You keep changing your question with new questions, making the answer look like it makes no sense at all. You never accept the answer, just keep on asking. I'm done working on this. Good luck. – icecub Jul 09 '18 at 11:23
  • My first Ask contented two questions: 1. about ArrowUp\Down and 2. PgDn\PgUp. I have found decision on first (BTW 100% - switching between scrolling up and down NOT requires 2 keypresses). So I feel right (IMHO) to change my Ask by removing first question. Please don't offend, but try to help. – J. Doe Jul 10 '18 at 10:58
  • @J.Doe Thank you for showing your support. Now please explain me how words are invisble? Do you mean words that are too far down or words that are made invisible with CSS like `display: none;`? – icecub Jul 11 '18 at 15:48
  • Sorry for delay. I meant off screen words. So I used:[link](https://stackoverflow.com/a/7557433) decision: – J. Doe Jul 16 '18 at 19:44
  • ` function scrollPgDown() { let pos = highlighted.reduce((p, el, i) => (!p && i > currentElemIndex && !isElementInViewport(el)) ? i : p, false); if (pos) { currentElemIndex = pos; scroll(positions[currentElemIndex]); } } function isElementInViewport(el) { var rect = el.getBoundingClientRect(); return ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth) ) } – J. Doe Jul 16 '18 at 19:44