RichardCrypt

来自个人维基
跳转至: 导航搜索

SoulLC old:

// num to symbols
text.value.replace(/[0123]/g, d=>[..."✔🔘⚡🎵"][Number(d)])
// decrypt
var str = text.value
var symbols = [ ..."✔🔘⚡🎵" ]
var table = [
  ..."0123456789abcdefghijklmnopqrstuvwxyz",
  "高中楼", "科教楼", "初中楼", "体育馆",
  "AP楼", "操场", "食堂", "宿舍",
  ...new Array(4).fill(null),
  "课间", ...new Array(15).fill(null)
]
 
var len = str.length
var buf = []
var ans = []
for (let i = 0; i < len; ) {
  var digit = null
  symbols.some((symbol, val) => {
    if (str.substr(i, symbol.length) === symbol) {
      i += symbol.length
      buf.push(val)
 
      if (buf.length === 3) {
        var val = buf[0] << 4 | buf[1] | buf[2] << 2
        ans.push(table[val])
        buf.length = 0
      }
 
      return true
    }
  }) || i++
}
 
ans.join(" ")