Javascript – Get unique value groupings

I submit a request to a service that returns the following information to me:

                                {
"order": 0,
"idlinea": 1,
"idtrayecto": 1,
"utmy": 4824500,
"utmx": 281405
},
{
"order": 1,
"idlinea": 1,
"idtrayecto": 1,
"utmy": 4824470,
"utmx": 281416
},
{
"order": 2,
"idlinea": 1,
"idtrayecto": 2,
"utmy": 4824481,
"utmx": 281495
},
{
"Order": 3,
"idlinea": 1,
"idtrayecto": 2,
"utmy": 4824487,
"utmx": 281540
}
...

And this increases until all lines are done with their respective rides.

I would like to group the contents of such a wood so that for line 1, path 1, the entire coordinate group is obtained. And so on.

Right now, I've got the unique values ​​of the lines and paths as follows:

                let distinctValues ​​= []

      let infoRoute = {
Line: zero,
travel: zero,
coordinates: []
      }
data.forEach ((route) => {
if (route.idlinea! = infoRoute.line || route.idtrayecto! = infoRoute.journey) {
infoRoute.line = route.idlinea;
infoRoute.journey = route.idtrayecto;
distinctValues.push ([infoRoute.line, infoRoute.journey])
}
}); 

I'll get it already: [[1,1]. [1,2]. [1,3]. [2,1]…]

Problem to delete label value from javascript

I have a label "Test" comimg from .cs [c# code] text = "Data saved successfully". But as soon as I click the Save button, I have to delete the text now. I have 3 required field inspectors. with message [cannot be blank, cannot be blank,cannot be blank,] As a user, I clicked the Save button to delete the text of the label. But must show the required fields validator message

Any suggestions on how to solve it?

Access the source URL in 301 and redirect nginx and javascript

I have two domains

www.abc.com

and

www.pqr.com

,

I would like to redirect the user for all requests from "www.abc.com" to "www.pqr.com".

The redirection works perfectly.

I'd like to post a message to users redirected from www.abc.com to www.pqr.com.

My applications are hosted through the Nginx proxy server.

Guidance is appreciated.

Javascript – problem when deploying PHP code to HTML via js

Hello, I have a problem when I embed my PHP code in my HTML. He is automatically commented. I'm not sure if it serves security, but here is my code:

var edit = & # 39;& # 39 ;;

In the browser it appears to me as commented, where I insert it:
image

It just needs to appear echo ("hello"), this echo will change it for content in html, any solution? I implement permissions per user so they can access specific configurations. These configurations are also printed via js.

Javascript – Attempt to load contents via URL in Drupal 8 into the dialog (modal)

First, I apologize if this issue really seems bazaar. Here is the problem. I have a page that contains both static and dynamic content. In the static part, I attached a link that looks like this:

profile

Works flawlessly. The link is clicked and a modal (dialogue) of Drupal Core (powered by jQuery UI) is displayed.

However; In another part of the page, I inserted content with the following code in the DOM:

$ (".insert") .load (data + ".rlp-detail-more", loadComplete) .attr ("data-research-content", dataResearch);

This code contains exactly the same HTML string as above …

However, when I click on the link, I go to content without overlay / modal / dialog.

And it gets weirder …

If I leave the inserted content open and click on the link below in the static content, both will suddenly work … z. For example, the jquery event handler was somehow appended to the inserted content.

My question is … How can I force an attachment to the event handler.

This question gives you a pretty good understanding of the jQuery dialog event and Drupal 8 integration with the jQuery user interface

Enter image description here

Insert the Javascript value via the PHP variable

I have to enter the value for width and height over a PHP variable.

                window.addEventListener (& # 39; DOMContentLoaded & 39 ;, function () {
var image = document.querySelector (# image #);
var cropper = new Cropper (Image, {
ready: function () {
this.cropper.setCropBoxData ({
"left": 750,
"top": 190,
"width": 500,
"Height": 50
});
},
});

Where

"width": 100,
"Height": 50

For example

"width": $ VALUE,
"Height": $ VALOR2

But this way does not work,

Thanks in advance!

Replace Javascript for image extension in HTML (Webp format for PNG)

Hello

I have included the following Java code in an HTML page to automatically exchange web images for PNG when the browser is on Safari but does not work.
What's happening


javascript – SEO for daily changing content with infinite scroll or more strategy loading

I've implemented a page that contains listings with truncated teaser content. An infinite number of scrolls are executed to display more entries as you scroll through Javascript. The result is something like Quora. When you click an entry, a new page opens with a unique full content URL. This should be indexed by search engines, not the page with the entries, because the entries are constantly changing as new entries are added.

I read the Google recommendation from Mueller, Ohye, Kupke, with whom I made Infinite Scrolling SEO compatible, but I do not think it's for a page with ever-changing entries?

My questions / if you can confirm / comment:

  1. Because the content of my listing page is constantly changing, Mueller's is
    Recommendation is not useful at all, as it has to be content
    constant for at least weeks?
  2. I've read, indexers can not mimic user actions like scrolling,
    Therefore, the user action of infinite scrolling is not selected
    to the top and only the first page is indexed. Then only the first sentence of
    Listing HREF links are indexed?
  3. My infinite scrolling strategy essentially uses a button to load more items
    below the viewport that is fired when you reach the bottom and bottom edges
    Finally, expose the button. Will not the indexer search for it?
    Click the button behind the viewport and click on it. And then on
    Indexing the new individual HREF links? Or is the button Load more
    completely ignored?
  4. So how can you do that kind of SEO-friendly – if you all
    Do you want to index the details when you click on them, not the listing page?
  5. How do Quora and many other similar sites do custom content (which does not use pagination)?

Thank you in advance.

Javascript – Kendo UI inline editing with dynamically changing editor

I have two columns in this demo

  1. Setting type (with drop-down list)
  2. Editor (contains the value of the column)

I want to change that editor Column when the drop-down list value is changed (from setting type Pillar). Example when users select date from the drop down list then the editor Column field should change to date picker.

Can someone help me to solve this problem? It was a week in which I was stuck. Appreciate your help. Here I offer a DEMO IN DOJO

html – JavaScript `localStorage` with` document.cookie` Fallback for static websites

The code

So far, I've been putting things into operation as desired, and I hope new eyes can point to bugs or trifles that can be improved. A live demo is hosted and updated on GitHub Pages, and the source code is just one fork or clone Path….

BrowserStorage.js

Class BrowserStorage {
/ **
* @This BrowserStorage
* /
Constructor() {
this.supports_local_storage = this.supportsLocalStorage ();
this.supports_cookies = this.supportsCookies ();
this.storage_available = (this.supports_cookies || this.supports_local_storage)? true wrong;
}

/ **
* Please use `this.supports_local_storage` within tests instead.
* @returns {boolean}
* /
meetsLocalStorage () {
To attempt {
let key = & test;
leave value = true;
localStorage.setItem (key, value);
localStorage.getItem (key);
localStorage.removeItem (key);
} catch (e) {
return it incorrectly;
}
return true;
}

/ **
* Please use `this.supports_cookies` instead within tests.
* @returns {boolean}
* /
supportsCookies () {
if (navigator.cookieEnabled) returns true;

To attempt {
document.cookie = & # 39; testcookie & # 39 ;;
} catch (e) {
return it incorrectly;
} Finally {
if (document.cookie.indexOf (& # 39; testcookie & # 39;)! = -1) {
this.remove (& # 39; testcookie & # 39;);
return true;
}
return it incorrectly;
}
}

/ **
* Copy of the constructor method that should not contain a type error
* /
constructorRefresh () {
this.supports_local_storage = this.supportsLocalStorage ();
this.supports_cookies = this.supportsCookies ();
this.storage_available = (this.supports_cookies || this.supports_local_storage)? true wrong;
}

/ **
* Receives the specified value from browser memory and URI component encoding on return
* @returns {? boolean |? number |? string}
* @This BrowserStorage
* /
get (key) {
let value = zero;
if (this.supports_local_storage) {
value = localStorage.getItem (key);
} else if (this.supports_cookies) {
let cookie_data = document.cookie.match (& # 39; (^ |;)? & # 39; + key + & # 39; = ([^;]*) (; $) & # 39;);
value = cookie_data? cookie_data[2] : Zero;
}
return encodeURIComponent (value);
}

/ **
* Removes the selected value by key from the browser memory. Note for cookies: The next time you load the page, a full whipe will appear
* @returns {boolean}
* @This BrowserStorage
* /
remove (key) {
if (this.supports_local_storage) {
localStorage.removeItem (key)
return true;
} else if (this.supports_cookies) {
// Note that disabling and expiring in the past is like this
// to remove a cookie the next time the page loads.
this.set (key, & # 39 ;, -7);
return true;
}
return it incorrectly;
}

/ **
* Saves client settings in the browser, _serverless_ in the truest sense of the word
* @peram {string | number} key - _variable name_ to save the value below
* @peram {boolean | number | string} value - is stored either under localStorage or as a cookie
* @peram {number} days_to_live - how long a browser should save cookies
* @returns {boolean}
* @This BrowserStorage
* /
set (key, value, days_to_live = false) {
if (this.supports_local_storage) {
localStorage.setItem (key, value);
return true;
} else if (this.supports_cookies) {
let expires = & # 39; & # 39 ;;

if (days_to_live) {
let date = new Date ();
if (days_to_live == 0) {
date.setTime (date.getTime ());
} else {
date.setTime (date.getTime () + (days_to_live * 24 * 60 * 60 * 1000));
}
expires = & # 39 ;; expires = & # 39; + date.toGMTString ();
}

document.cookie = name + & # 39; = & # 39; + value + expires + & # 39 ;; Path = / & # 39 ;;
return true;
}
return it incorrectly;
}

/ **
* Deletes ** all ** client settings from localStorage or cookies
* @returns {boolean}
* @This BrowserStorage
* /
clear() {
if (this.supports_local_storage) {
localStorage.clear ();
return true;
} else if (this.supports_cookies) {
let cookies = document.cookie.split (& # 39 ;; & # 39;);
for (if i = 0; i <cookies.length; i ++) {
let cookie = cookies[i];
let key = encodeURIComponent (cookie.split (& # 39; = & # 39;)[0].replace (/ (^  s + |  s + $) / g, & # 39; & # 39;));
if (typeof (key) == 'string' = typeof (key) == # number & # 39;
this.remove (key);
} else {
return it incorrectly;
}
}
return true;
}
return it incorrectly;
}

}

main.css

/ **
* 1. Center the element
* 2. Reorient text
* /
Body {
Text orientation: center; / * 1 * /
}

.container__main_content {
maximum width: 80%;
maximum width: 80vw;
Display: Inline block; / * 1 * /
Align text: left; / * 2 * /
}

/ **
* Privacy Policy Footer Stuff
* /
.container__privacy_notice {
Position: fixed;
bottom: 5px;
maximum width: 80%;
maximum width: 80vw;
Background color: light gray;
Align text: left; / * 2 * /
}

.privacy_notice__label {
Background color: black;
Color white;
Font size: 1.5rem;
Upholstery: 5px 10px;
float to the right;
}

.privacy_notice__label: hover {
Color: light gray;
}

/ * Status of the label, if the check box is deactivated * /
.privacy_notice__label :: after {
Content: attr (value);
}


/ **
* Checkbox hacks
* /
.hidden__input {
Display: none;
Visibility: hidden;
Opacity: 0;
Filter: alpha (opacity = 0);
}


/ * Status updates for ticking the checkbox * /
.privacy_notice__checkbox: checked ~ .container__privacy_notice {
Box shadow: not set;
max-width: 1.5rem;
max height: 1.5rem;
}

.privacy_notice__checkbox: checked ~ .container__privacy_notice * {
Visibility: hidden;
Opacity: 0;
Filter: alpha (opacity = 0);
}

.privacy_notice__checkbox: checked ~ .container__privacy_notice .privacy_notice__label :: after {
Content: attr (checked);
}

/ * Status of the label, if the check box is activated * /
.privacy_notice__checkbox: checked ~ .container__privacy_notice :: after {
Content: & # 39;  1F56D & # 39 ;;
Position: absolutely;
bottom: 5px;
left: 5px;
}

/ * Combination of checked and suspended state updates * /
.privacy_notice__checkbox: checked ~ .container__privacy_notice: hover {
maximum width: 80%;
maximum width: 80vw;
maximum height: not set;
}

.privacy_notice__checkbox: checked ~ .container__privacy_notice: hover * {
Visibility: visible;
Opacity: 1;
Filter: Alpha (opacity = 100);
}

index.html



  
    BrowserStorage example
    
    

    
    

    
  

  
    

This is a static site that gives the illusion of remembering a client. Test by accepting the Data protection and then refreshing or Close and reopen a tab that points to the current URL.

Ctrl R or Ctrl shift R updates most desktop browsers.

Then you decline the privacy policy by clicking the Acceptable button again to restore the behavior of this site.

Use Ctrl shift I Debugger on one open Desktop Browser, then navigate to the Storage tab to watch it JavaScript performs the above actions.

This site uses JavaScript and localStorage or cookies of your browser. However, this site is currently doing so to improve your experience here Not Save all data about your activity on the other side.

Check the privacy and security hints about BrowserStorage.js Learn more about using client-side storage and scripts.

Note that I tried to use the webcode option when writing this question, but this resulted in various errors.

ask

My goal is to achieve nearly 100% coverage for browsers that have JavaScript local memory or document.cookie Storage options;

  • in this Day and age Does it make sense to use cookies for a local storage fallback?

  • Is there any reason to use or use the old syntax to get JavaScript OO behavior? class and function Keywords are sufficient?

if there are good arguments for not using class, please include some examples of feature detection to load an alternate version.

  • I keep walking over npm But that seems to be more focused on Node-related JavaScript, so I should consider doing so npm init. or would that pollute your package management system?

If projects like this are a good candidate for npm, then a few tips on OS-independent output methods Git Commands would be excellent.

  • Currently I use encodeURIComponent However, returning values ​​stored in the browser results in unpredictable behavior on Boolean and numeric values ​​(sometimes it's a string, sometimes not) better Way to retrieve values?

At this point, it feels like I need to do a few preliminary checks before returning to achieve consistent behavior.

  • Where did I make mistakes and / or how can code execution be improved without affecting readability?

  • One thing I find annoying about the use Checkbox hacks Is accessibility, is there any? Well Ways to get tab and space/Enter Support?


Thank you, and I hope that, even if that is above, I am one bad influence that we can all learn together why.