The version of vichan running on lainchan.org
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

66 行
1.5KB

  1. if (active_page == 'thread' || active_page == 'index') {
  2. $(document).ready(function(){
  3. if (window.Options && Options.get_tab('general')) {
  4. var selector = '#color-ids>input';
  5. var e = 'change';
  6. Options.extend_tab("general", "<label id='color-ids'><input type='checkbox' /> "+_('Color IDs')+"</label>");
  7. }
  8. else {
  9. var selector = '#color-ids';
  10. var e = 'click';
  11. $('hr:first').before('<div id="color-ids" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+_('Color IDs')+'</a></div>')
  12. }
  13. $(selector).on(e, function() {
  14. if (localStorage.color_ids === 'true') {
  15. localStorage.color_ids = 'false';
  16. } else {
  17. localStorage.color_ids = 'true';
  18. }
  19. });
  20. if (!localStorage.color_ids || localStorage.color_ids === 'false') {
  21. return;
  22. } else {
  23. $('#color-ids>input').attr('checked','checked');
  24. }
  25. function IDToRGB(id_str){
  26. var id = id_str.match(/.{1,2}/g);
  27. var rgb = new Array();
  28. for (i = 0; i < id.length; i++) {
  29. rgb[i] = parseInt(id[i], 16);
  30. }
  31. return rgb;
  32. }
  33. function colorPostId(el) {
  34. var rgb = IDToRGB($(el).text());
  35. var ft = "#fff";
  36. if ((rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 125)
  37. ft = "#000";
  38. $(el).css({
  39. "background-color": "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")",
  40. "padding": "0px 5px",
  41. "border-radius": "8px",
  42. "color": ft
  43. });
  44. }
  45. $(".poster_id").each(function(k, v){
  46. colorPostId(v);
  47. });
  48. $(document).on('new_post', function(e, post) {
  49. $(post).find('.poster_id').each(function(k, v) {
  50. colorPostId(v);
  51. });
  52. });
  53. });
  54. }