<!-- RUBY-BACKUP · part 325 -->
 within the scroll */
    var cats = [
      {n:'Blocks', m:function(c){ return /^b \d/.test(c); }},
      {n:'Lattice', m:function(c){ return /^[gufw] \d/.test(c); }},
      {n:'Views', m:function(c){ return /^v\d/.test(c) || /^(vfront|vback|vleft|vright|vtop|vclose|vfar|vzoomout|vreset|vme|vtoggle|look|see)/.test(c); }},
      {n:'Shapes', m:function(c){ return /^s\d/.test(c) || /^(connector|iconnector)/.test(c); }},
      {n:'Colors', m:function(c){ return /^color /.test(c); }},
      {n:'Sky', m:function(c){ return /^(day|night|dawn|storm|cosmic|cave|rain|clouds|ember|aurora|whiteout)/.test(c); }},
      {n:'Templates', m:function(c){ return /^(tower|keep|gate|house|hall|bridge|chapel|cathedral|tenshu|fountain|banner|torch|castle|wall |kingdom|dome|arch|sine)/.test(c); }},
      {n:'Nature', m:function(c){ return /^(tree|pine|flower|grove|bush|mushroom|rock|pond)/.test(c); }},
      {n:'Player', m:function(c){ return /^(walk|fly|body|crown|king|nokings|spiral|sgo|attach|wear|b1$|invite|mirror|send|take|portal)/.test(c); }},
      {n:'Castle', m:function(c){ return /^(castle|tower|keep|gate|wall|kingdom|myhome|turret|greattower|curtain|gatehouse2|donjon|battlements|spire |b 20|b 10|b 8|b 6|b 5|b 4|b 3|f 8|f 6|u 8|g 8)/.test(c); }},
      {n:'Architect', m:function(c){ return /^(column|doric|ionic|arcade|colonnade|portico|rotunda|buttress|obelisk|cupola)/.test(c); }},
      {n:'Utils', m:function(c){ return /^(oops|wipe|linework|save|load|go|help|views|updates|did|whoiam|saveme|loadme|lock|unlock|anchors|newmap|solidify|handers|copy|paste|image3d|upload3d|collect)/.test(c); }},
    ];
    function showCodes(list, title){
      p.innerHTML = '';
      var back = document.createElement('button');
      back.innerHTML = '← ' + title;
      back.style.cssText = 'display:block;width:100%;margin:4px 0;padding:10px;background:gold;color:#000;border:none;border-radius:4px;font-size:16px;font-weight:bold;';
      back.onclick = function(){ showCats(); };
      p.appendChild(back);
      var cnt = document.createElement('div');
      cnt.innerHTML = list.length + ' codes';
      cnt.style.cssText = 'color:#888;font-size:12px;margin:4px 0;text-align:center;';
      p.appendChild(cnt);
      list.forEach(function(c){
        var b = document.createElement('button');
        b.innerHTML = c;
        b.style.cssText = 'display:block;width:100%;margin:4px 0;padding:10px;background:#222;color:gold;border:1px solid #444;border-radius:4px;font-size:16px;'; b.title = c;
        b.onclick = function(){ if(typeof Mainframe!=="undefined" && Mainframe.run) Mainframe.run(c); };
        p.appendChild(b);
      });
      p.scrollTop = 0;
    }
    function showCats(){
      p.innerHTML = '';
      var t = document.createElement('div');
      t.innerHTML = 'Choose a scroll';
      t.style.cssText = 'color:gold;font-size:18px;text-align:center;margin:8px 0;font-weight:bold;';
      p.appendChild(t);
      cats.forEach(function(cat){
        var list = codes.filter(cat.m);
        if(!list.length) return;
        var b = document.createElement('button');
        b.innerHTML = cat.n + ' (' + list.length + ')';
        b.style.cssText = 'display:block;width:100%;margin:6px 0;padding:14px;background:#2a2a1a;color:gold;border:2px solid gold;border-radius:6px;font-size:18px;font-weight:bold;';
        b.onclick = function(){ showCodes(list, cat.n); };
        p.appendChild(b);
      });
      /* uncategorized */
      var used = {};
      cats.forEach(function(cat){ codes.filter(cat.m).forEach(function(c){ used[c]=1; }); });
      var rest = codes.filter(function(c){ return !used[c]; });
      if(rest.length){
        var b = document.createElement('button');
        b.innerHTML = 'More (' + rest.length + ')';
        b.style.cssText = 'display:block;width:100%;margin:6px 0;padding:14px;background:#1a1a2a;color:#aaf;border:2px solid #66f;border-radius:6px;font-size:18px;font-weight:bold;';
        b.onclick = function(){ showCodes(rest, 'More'); };
        p.appendChild(b);
      }
    }
    showCats();
    document.body.appendChild(p);
  };
  document.body.appendChild(btn);
})();

})();

/* hide the fake loader — the world is here */
if(typeof window.hideFakeLoader==='function'){ setTimeout(window.hideFakeLoader, 1500); }
/* streets load on start, every time — locked in */
/* AMBIENT MUSIC — procedural, generated live */
var _musicCtx = null, _musicOn = false, _musicNodes = [];
function toggleMusic(){
  try{
    if(!_musicCtx){
      _musicCtx = new (window.AudioContext || window.webkitAudioContext)();
    }
    if(_musicCtx.state==='suspended') _musicCtx.resume();
    _musicOn = !_musicOn;
    var btn = document.getElementById('musicbtn');
    if(btn) btn.style.opacity = _musicOn ? '1' : '0.4';
    if(_musicOn){
      startAmbient();
      if(typeof codeStatus==='function') codeStatus('music on');
    }else{
      stopAmbient();
      if(typeof codeStatus==='function') codeStatus('music off');
    }
  }