Current date/time is Fri 29 Mar - 8:18

Search found 3 matches for field_id-12

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:
Code:
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+/);
       
if(localStorage.getItem('user'+id)!==null){
ranks[i].innerHTML=localStorage.getItem('user'+id);
get(i+1);
} else {
 
fetch('/u'+id).then(function(response){
return response.text();
}).then(function(html){
var parser=new DOMParser();
var doc=parser.parseFromString(html, "text/html");
try{
var r=doc.querySelector(aranks).innerHTML;
localStorage.setItem('user'+id, r);
if(r!==null){
ranks[i].innerHTML=r;
}
} catch(e){
console.log(e)
}
get(i+1);
}).catch(function(err){
console.log(err);
});
}
       
}
get(0);
})


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.

Okay

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 Thu 8 Aug - 22:34
 
Search in: Scripts Problems Archives
Topic: How to add fields to user list by making JS?
Replies: 30
Views: 1958

Coding Forum Backgrounds Separately

_Twisted_Mods_ wrote:here are all the id's for your profile rows going in order top to bottom

#field_id-7
#field_id-6
#field_id-12
#field_id-4
#field_id-5
#field_id-11
#field_id-9
#field_id-8

here is an example with font color,background color, and a background image

Code:

#field_id-6 {
    color: #ff0000;
    background-color: #000000;
    background-image: url(url/totheimage.jpg);
}


and im not sure what you mean by background for posts because it looks like your post already have a background image


Thank you! I meant that the background of posts is tied with this code:

Code:
.forumline .row1 {  background-image: url('http://i.imgur.com/LTIy7Gg.jpg');}

That code not only implements itself on the index, but also the profile page and the background of the posts. The code you provided me helped maintain the results I need for the profile pages, but I also need another separate one for posts to set a background (or color) of my choice without having the code tied to the rows of the index.
by Flame Melody
on Wed 23 Aug - 6:02
 
Search in: Scripts Problems Archives
Topic: Coding Forum Backgrounds Separately
Replies: 25
Views: 2159

Coding Forum Backgrounds Separately

here are all the id's for your profile rows going in order top to bottom

#field_id-7
#field_id-6
#field_id-12
#field_id-4
#field_id-5
#field_id-11
#field_id-9
#field_id-8

here is an example with font color,background color, and a background image

Code:

#field_id-6 {
    color: #ff0000;
    background-color: #000000;
    background-image: url(url/totheimage.jpg);
}


and im not sure what you mean by background for posts because it looks like your post already have a background image
by _Twisted_Mods_
on Tue 22 Aug - 20:15
 
Search in: Scripts Problems Archives
Topic: Coding Forum Backgrounds Separately
Replies: 25
Views: 2159

Back to top

Jump to: