Advertisement
SSYT

Variabile suplimentare pentru template-uri

Mar 31st, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // V1.0
  2. $(function() {
  3.     var u = _userdata, l = _lang;
  4.     var content = $('html').get(); // document.getElementsByName('html'); - not work, i don't know
  5.     for (i = 0; i < content.length; i++) {
  6.         content[i].innerHTML = content[i].innerHTML
  7.         .replace(/\{IM_ONLINE\}/g, u.session_logged_in)
  8.         .replace(/\{USER_NAME\}|\{.USER_NAME\}/g, u.username)
  9.         .replace(/\{AVATAR\}|\{.AVATAR\}/g, u.avatar)
  10.         .replace(/\{USER_PRIVATE_MSG\}|\{.USER_PRIVATE_MSG\}/g, u.user_nb_privmsg)
  11.         .replace(/\{USER_REPUTATION\}|\{.USER_REPUTATION\}/g, u.point_reputation)
  12.         .replace(/\{USERID\}|\{.USERID\}/g, "/u"+u.user_id)
  13.         .replace(/\{USER_POST\}|\{.USER_POST\}/g, u.user_posts)
  14.         .replace(/\{USER_LEVEL\}|\{.USER_LEVEL\}/g, u.user_level)
  15.         .replace(/\{RANK_TITLE\}|\{.RANK_TITLE\}/g, l.rank_title);
  16.     }
  17. });
  18.  
  19. // v2.0
  20. function html_variables(tag, variable) {
  21.     var c = $('html'), f = 0; for(f; f < c.length; f++) c[f].innerHTML = c[f].innerHTML.replace(tag, variable);
  22. };
  23.  
  24. $(function() {
  25.     html_variables("\{USER_NAME\}", _userdata.username); // Get user name of html tags
  26.     html_variables("\{.USER_NAME\}", _userdata.username); // Get user name on html template :D
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement