weechatRN

Weechat relay client for iOS using websockets https://github.com/mhoran/weechatRN
git clone http://git.hanabi.in/repos/weechatRN.git
Log | Files | Refs | README | LICENSE

colorizer.js (1136B)


      1 import { sha256 } from "js-sha256";
      2 
      3 const AVAILABLE_COLORS = [
      4   "#3E4141",
      5   "#F1F1F0",
      6   "#554141",
      7   "#654141",
      8   "#DAACDF",
      9   "#FFCF85",
     10   "#80AAC6",
     11   "#B4C978",
     12   "#CADFFE",
     13   "#E7E6A0",
     14   "#F66864",
     15   "#929292",
     16   "#03FCFE",
     17   "#F2C6F7",
     18   "#E3F6FF",
     19   "#9CC4DF",
     20   "#CDE28C",
     21   "#73DFFD",
     22   "#DF82FC",
     23   "#06DEFD",
     24   "#00DA9A",
     25   "#38ACE2",
     26   "#72DA9B",
     27   "#72FDFE",
     28   "#35C240",
     29   "#16BEA1",
     30   "#00D825",
     31   "#0ABFFC",
     32   "#00F72C",
     33   "#99FABF",
     34   "#72FABE",
     35   "#BCFBBF",
     36   "#DF9DBC",
     37   "#00F99C",
     38   "#BDC1FD",
     39   "#71F72D",
     40   "#98F82F",
     41   "#BDE0FE",
     42   "#BCF830",
     43   "#FFA3FD",
     44   "#BDBB9A",
     45   "#FFBB2A",
     46   "#BDDB9C",
     47   "#E664FC",
     48   "#BDFEFE",
     49   "#DFFEFF",
     50   "#BD9CBC",
     51   "#E866B6",
     52   "#DEFA9E",
     53   "#FFC3FE",
     54   "#DF7BBC",
     55   "#FFE1FE",
     56   "#FFDEBF",
     57   "#FF7DBC",
     58   "#FF7620",
     59   "#FFDB2F",
     60   "#FEF935",
     61   "#FFFB9E",
     62   "#FFFFFF"
     63 ];
     64 
     65 const sessionCache = {};
     66 
     67 export const hashNickToColor = nick => {
     68   if (sessionCache[nick]) {
     69     return sessionCache[nick];
     70   }
     71 
     72   const hash = parseInt(sha256(nick), 16);
     73   const nickColor = AVAILABLE_COLORS[hash % AVAILABLE_COLORS.length];
     74   sessionCache[nick] = nickColor;
     75 
     76   return nickColor;
     77 };