8 – Setting value of form element from $form_state not working

I need to track previous values of a few form elements on a form to detect when they change to invalidate some other options on the page. Essentially, if the value of these fields change a field that controls pagination should reset.

I’m trying to accomplish this with this:

$values = $form_state->getValues();
$form('element1') = (
      '#type' => 'radios',
      '#title' => $this->t('Element 1'),
      '#options' => (
        // Omitted for brevity
      ),
      '#weight' => '0',
      '#ajax' => (
        'callback' => ($this, 'my_callback'),
        'disable-refocus' => true
      )
    );

// dump($values('element1'));
$form('element1_previous') = (
      '#type' => 'value',
      '#value' => (isset($values('element1'))) ? $values('element1') : 'none',
    );

No matter what I do the value of $values('element1_previous) is none. If I uncomment the dump() statement right before it I can see the value of $values('element1') changing each time AJAX is submitted so the value is there.

If I do something like:

$form('element1_previous') = (
          '#type' => 'value',
          '#value' => rand()
        );

I can see $values('element1_previous') being set to a different integer each AJAX submission. I just can’t assign the value of $form('element1') to that field.

What am I doing wrong? Is there a better way I could handle this?

html – Localization of multi style text element in Vue

After following up this question, I’m thinking if there’s a better/shorter way to write this text element that has part with different style, while allowing localizations:

<p>
    <span class="has-text-grey">{{ $store.releaseList != null ? $store.releaseList.length : 0 }}</span>
    <span> versions released</span>
</p>  

With vue-i18n:

<p v-html="$t('downloads.releases.table.versions-total')
    .replace('{0}', '<span class=has-text-grey>{1}</span>')
    .replace('{1}', $store.releaseList != null ? $store.releaseList.length : 0)">
</p>  

The localizable text would be {0} versions released.

I could set the localizable text to <span class=has-text-grey>{0}</span> versions released, but that would make the life of the translators (usually people without knowledge about HTML) a bit more difficult.

Is there any better built in way to add support for localizations in a multi-styled text?

USB Flash Disk with Security Element

I am thinking of buying USB flash disk with Security Element(stores Private-Key/Secret-Key/X.509-Certificates) and some encrypted data(8 Megabyte). The disk has to be protected against cloning and possibly maintains logs of insert history with UNIX timestamp & USB Host ID when inserted.

I found YubiKey & NitroKey, but they do not have additional storage. Is there a USB Device like that satisfy above requirements.

(Or) Is there any cost effective SoC+Security Element Over USB with flash storage available to implement my requirement using Opensource?

Thanks

html – How to make this div element the size of the img contained within it? [css]

I am attempting to create a tooltip, to appear when hovering on an image within a table.
However when I add the div to put a container for the tooltip, it adds extra spacing to my table, as seen in the first row (not applied to subsequent rows).

Why is the div 118 x 66 size as shown instead of the size of the image within it (59×59
)? It creates unnecessary spacing.

Oversized horitionzal dimension

html

CSS for tooltip

Tooltip in action

syntax – differences between element wise summation and element wise products

I am really new to Julia, and so I am going to ask a very very elementary question. I understand the logic of the dot (.) to make element-wise operation however, I am perplexed by this very simple piece of code

array_try_op = (1, 2, 3, 4)
array_sum2 = array_try_op .+ 2
array_sum2_wrong = array_try_op + 2
array_prod2 = array_try_op .* 2
array_prod2_wrong = array_try_op * 2

Indeed, when I try to perform array_sum2_wrong = array_try_op + 2 I correctly get an error message, but on the contrary array_prod2_wrong = array_try_op * 2 does not return any error message, and actually returns the same result of array_prod2 = array_try_op .* 2

Why this is the case?

Thank you all!

array – Enumerating over matrix element values in Table

I have a $N$ dimensional array $M$, and a function $f({M_{i}})$ in terms of the array elements, where each matrix element $M_{i}$ can be 0 or 1. I’d like to construct a table

Table(f({M_{ij}}), {M_{1},0,1},{M_{2},0,1},...,{M_{N},0,1})

For a given N, I can write down the code to construct the table, but for general N, it there a convenient way to write the above code? Namely, I’d like to keep N as an input variable.

javascript – Jquery get element with class name using get() function

You don’t need jQuery for this, here are a few methods:

// This will return a NodeList containing all your `li` elements with a class of `active`.
document.querySelectorAll('li.active');

You mentioned you can’t use $('li.active') (why?) so this may not work for you. If this is the case you could loop through each li looking for the active class:

const lists = document.querySelectorAll('li');

And then filter that NodeList by turning it into an array and filtering it:

Array.from(lists).filter(listElement => listElement.classList.contains('active'));

The result will be an array containing all your lis with the class of active.

sharepoint online – Change color of selected element in react and set first one as default

I am trying below code which i picked from stack only i am using this code to change color of selected item its working fine but i also want to set color of first element always selected once page load

                        var List = React.createClass({
                          getInitialState: function(){
                            return { active: null}
                          },

                          toggle: function(position){
                            if (this.state.active === position) {
                              this.setState({active : null})
                            } else {
                              this.setState({active : position})
                            }
                          },

                          myColor: function(position) {
                            if (this.state.active === position) {
                              return "blue";
                            }
                            return "";
                          },

                          render: function () {
                            return (
                              <div>
                                <li style={{background: this.myColor(0)}} onClick={() => {this.toggle(0)}}>one</li>
                                <li style={{background: this.myColor(1)}} onClick={() => {this.toggle(1)}}>two</li>
                                <li style={{background: this.myColor(2)}} onClick={() => {this.toggle(2)}}>three</li>
                              </div>
                            );
                          }
                        });
                        ReactDOM.render(
                            <List/>,
                            document.getElementById('app')
                        );

optics – Is this a bubble in my lens element?

If bubbles are something you’re really interested in there’s Standards for them:

Hoya Group Optics Division – Internal Quality of Products

ISO 19742:2018(en) – Optics and photonics — Optical materials and components — Test method for bubbles and inclusions in infrared optical materials

Schott Glass – TIE—28 Bubbles and Inclusions in Optical Glass, Technical Information Advanced Optics, Schott, 2016 (.PDF)

TIE-28 – Bubbles and Inclusions in Optical Glass

  1. Generation of Bubbles in Optical Glass

The compositions of glasses are frequently given in form of oxides. In reality however raw materials used for melting may be carbonates or hydrogen-carbonates and others. Melting of such raw materials produces reaction gases forming bubbles in the melt.

These bubbles will be removed with the refining process, which is part of all glass melting. During the refining process the glass temperature is increased. The solubility of the gas components decreases. Bubbles will be formed and grow much more rapidly. The elevated temperature decreases the
viscosity of the glass supporting the bubbles to move up and vanish from the melt.

Residual fine bubbles, which do not succeed to leave the melt, will be removed by chemical reactions caused by refining agents. These are elements, which change their valency during cooling down. When such an element searches for a chemical binding partner, it will take the gas of the tiny bubbles and dissolve it back into the glass. The gas atoms still will be present in the glass but not disturbing anymore.

Residual bubbles in optical glass may come from different sources. In most cases they come from non-perfect refining.

Nevertheless a certain amount of gaseous bubbles within the glass melt during the melting process is essential to achieve a good homogenization of the melt. Ascending bubbles lead to an additional convection movement of the glass melt and therefore improve the homogenization process.

To inspect for bubbles this is the recommended setup: place the glass on a black surface and shine the light from the side, unfortunately that involves removing the lens. You can probably get acceptable results leaving the lens in place and using a laser pointer at an angle to see if there’s a reflective spot.

Lens inspection

TIE-28 – Bubbles and Inclusions in Optical Glass

  1. Inspection of Bubbles and Inclusions

The inclusion quality will be assessed by visual inspection. To visualize the bubbles and inclusions the following measurement setup is used in general (figure 5). The glass is placed on a black background and illuminated from the side. The glass is viewed from above by looking through it toward the black background. The bubbles and inclusions become visible as bright spots. This arrangement is very sensitive for the quantification of bubbles and inclusions. To determine the sizes either comparison standards or microscopes are used. The evaluation includes all bubbles and inclusions with dimensions ≥ 0.03 mm. Figure 6 shows a typical view using this measurement setup.

It matters where on the lens and which lens of the group whether or not there will be a big problem. Any inclusion anywhere on a lens reduces the contrast in that area, if it is imaged then it might be detectable.

Where it matters

TIE-28 – Bubbles and Inclusions in Optical Glass

  1. The Influence of Bubbles and Inclusions
    on Optical Application

In theory every part of a lens has the same imaging properties (if one may neglect image aberrations). For example covering a lens completely with only letting the light pass through a tiny spot in the upper corner one can still see the complete image but with less intensity. In figure 4 a) very simplified part of an optical system is displayed. This optical system consists of two lenses. The first lens is positioned at an intermediate image plane with the image of an arrow. The second lens images the arrow to the final image plane. Additionally four light rays are constructed. It can be seen clearly that independent from another the two upper rays and the two lower rays both image the tip of the arrow correctly. The position of the first lens in this optical system is an image plane. The position of the second lens is a pupil.

In figure 4 b) the influence of bubbles and inclusions that are located in lenses near the pupils of an optical system can be seen. They do not disturb the shape of the final image but they reduce the image contrast and intensity because part of the light is scattered. The size of this effect depends on the amount of bubbles and inclusions per area of the glass.

Bubbles and inclusions located in optical elements near the image plane can be harmful, because they might be visible in the final image (depending e.g. on inclusion size and image detector pixel size and sensitivity). This is displayed in figure 4 c). The inclusion within the first lens can be seen in the final image.

In reality lens systems consist of many different lenses and are much more complicated than the displayed example. Therefore the designer has to take into account individually the possible bubbles and inclusions in the optical system for any lens.

It could be a bubble, or it could be a fleck of platinum from the melting tank.

Theming: How to Render a Web Form Element in a Twig File Template to Display HTML

I want to override the HTML screen for submitting web forms. Therefore, I have copied this file "webform-submit.html.twig" into my template folder and renamed it to: "webform-submit – testform – html.html.twig"

Now how do I print every element of my web form?
It is written in the file:

  • Available variables:
      • elements: an array of elements to display in view mode.
      • webform_submission: submission of the web form.

I tried {{elements.surname}} but it doesn't work.

I also installed the TWIG module.