Current date/time is August 15th 2020, 1:38 pm

Search found 1 match for field_id-10

How to add fields to user list by making JS?

@Occultist wrote:There are some comments in my code(lines 8, 9 and 10). When you put the code in the templates, it gets minified. Normally, those comments automatically close themselves, but when the entire code is on a single line, the comment basically spans the whole line, making more than half of the code a comment.

This code solves that issue:
function query(e){
return document.querySelector(e);
function _query(e){
return document.querySelectorAll(e);
document.addEventListener('DOMContentLoaded', function(){
var users=_query('.avatar-mini>div>a');
var ranks=_query('.ranks');
var aranks='#field_id-9>dd>.field_uneditable';       
var len=users.length;
function get(i){
if(i==len) return false;
var id=users[i].getAttribute('href').match(/\d+/);
} else {
return response.text();
var parser=new DOMParser();
var doc=parser.parseFromString(html, "text/html");
var r=doc.querySelector(aranks).innerHTML;
localStorage.setItem('user'+id, r);
} catch(e){

My code looks like vanilla js because that's what it is. The original js, which is faster then any framework, be it jquery, vue, angular or whatever else.
Honestly speaking, if you did really work with those frameworks you mentioned, you would not only have been able to fix the issue with the comments, but you would have been able to code this entire script by yourself.

You are just a magician!

Thanks so much buddy ...!

Well, you know, I usually use ready-made solutions and rarely write my own, because there is not enough knowledge in the codes. I am more a web designer and builder than an encoder, since I switched to training frameworks and javascript + php only at the beginning of this year. More precisely in the month of March.


I apologize for my stupid question, but in order not to ask a thousand questions later, I immediately want to know how to duplicate this code?

For example, I need to load five fields. For example :

#field_id-9 #field_id-10 #field_id-11 #field_id-12 #field_id-13

How then to write codes?
That which is separately clear. But there clearly need to change the variables? Please show.

By the way, your code will definitely work quietly? Since I want to bring this method to 30 different sites.
by Storyteller of Wonderland
on August 8th 2019, 10:34 pm
Search in: Scripts Problems Archives
Topic: How to add fields to user list by making JS?
Replies: 30
Views: 1336

Back to top

Jump to: