N
N
Nikolay L2019-05-27 09:21:18
Bluetooth
Nikolay L, 2019-05-27 09:21:18

How to set up wireless access to Raspberry Pi Zero W via Bluetooth?

Raspbian Lite installed. How to access the raspberry terminal using the built-in bluetooth module?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Sokolov, 2017-06-06
@arturka_v_10

The logic is not clear, but the code can be simplified like this:

var tRish = "tits_rish_a1 tits_rish_a2 tits_rish_a3";
var tRishClasses = tRish.split(' ').map(e=>'.' + e).join(', '); // список классов .tits_rish_a1, .tits_rish...
var tClick = "#tits_click_a1, #tits_click_a2, #tits_click_a3";
$(function() {
  
  function onClick(e) {
    var n = (n = this.id.match(/b(\d+)/)) ? n[1] : null; // n == 1, 2 или 3
    if(!n) return;
    
    $(tClick).removeClass(tRish).addClass( 'tits_rish_a' + n);
    // $(tClick).attr('id', 'tits_click_a' + n); // id менять некошерно!
    $(tRishClasses).attr('style', '');
  }
  
  $('#b1, #b2, #b3').on('click', onClick);
});

One function handles clicks. Determines the number from the id of the clicked element #b2 => 2and then uses the resulting number to compose the classes/id.

A
Alexei Kochetkov, 2017-06-06
@AngelOfSnow

Are you making a porn banner?

A
Alexey Sklyarov, 2017-06-06
@0example

Without HTML, it is unlikely that you will understand what you want to do at all. You get 3, formally, identical blocks (judging by the ID), to which, formally, 3 identical classes are applied. Why don't you just make ONE CLASS to which ONE class applies? And in CSS through: nth-child already specify styles for different positions of this class?

S
Stalker_RED, 2017-06-06
@Stalker_RED

Hello, I am superficially familiar with js and jq. What's more, I can't tell them apart.

It's pretty easy with this: jQuery is made from (written in) javascript.
If we imagine that jQuery is such a cool Lego castle with dragons and princesses, then javascript is the very details of which the castle consists. And from these parts you can assemble not only a castle, but also an airport or an oil refinery, for example.
If you change the id of html elements, this very often causes confusion and something breaks. Imagine that someone is running around the university and changing classroom numbers - even if he himself remembered what he changed where, then the rest can get lost. It's better not to do that at all.
And you should not give the same ID to several elements - not only is this prohibited by the specifications - this also breaks scripts, when searching by ID, they find only the first of several identical elements.
And besides, when changing the id, the handler will not change. They are hung not on the ID, but on the element itself.
Using the same auditorium example, it's like saying "hey guys, take this projector to auditorium #2" and then swap signs #2 and #3" while expecting the projector to follow the sign on its own. (Hint: it will not be transferred).
how to shorten it
Most likely, all your code can be replaced with something in 10 lines (one handler on the parent element, changing the class instead of changing the id), but I don’t quite understand what you are trying to do, and therefore I can’t tell you exactly how to change it.

N
Nazar Mokrinsky, 2017-06-06
@nazarpc

Your code does not make sense, you change the id of the elements, set the same for several elements at once, which cannot be done (formally it will work, but not as it should).
About shorthand - you can pass multiple selectors to jQuery:

$("#tits_click_a1, #tits_click_a2, #tits_click_a3")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question