PageSourceSearch

https://textart.io/gadgets/ascii.figlet.js

js textart.io collected 2026-10-02 14:54:55 UTC 4,743 bytes, 128 lines download raw bytes

1ASCIIGallery= new function() {
2  var BASE_URL = 'https://textart.io/gadgets/';
3  var STYLESHEET = BASE_URL + "css/default.css";
4  var CONTENT_URL = BASE_URL + 'figlet';
5
6  function requestStylesheet(stylesheet_url) {
7    stylesheet = document.createElement("link");
8    stylesheet.rel = "stylesheet";
9    stylesheet.type = "text/css";
10    stylesheet.href = stylesheet_url;
11    stylesheet.media = "all";
12    document.lastChild.firstChild.appendChild(stylesheet);
13  }
14
15  function base64_decode (data) {
16          // From: http://phpjs.org/functions
17          // + original by: Tyler Akins (http://rumkin.com)
18          // + improved by: Thunder.m
19          // + input by: Aman Gupta
20          // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
21          // + bugfixed by: Onno Marsman
22          // + bugfixed by: Pellentesque Malesuada
23          // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
24          // + input by: Brett Zamir (http://brett-zamir.me)
25          // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
26          // * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
27          // * returns 1: 'Kevin van Zonneveld'
28          // mozilla has this native
29          // - but breaks in 2.0.0.12!
30          //if (typeof this.window['atob'] === 'function') {
31          // return atob(data);
32          //}
33          var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
34          var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
35            ac = 0,
36            dec = "",
37            tmp_arr = [];
38
39          if (!data) {
40            return data;
41          }
42
43          data += '';
44
45          do { // unpack four hexets into three octets using index points in b64
46            h1 = b64.indexOf(data.charAt(i++));
47            h2 = b64.indexOf(data.charAt(i++));
48            h3 = b64.indexOf(data.charAt(i++));
49            h4 = b64.indexOf(data.charAt(i++));
50
51            bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
52
53            o1 = bits >> 16 & 0xff;
54            o2 = bits >> 8 & 0xff;
55            o3 = bits & 0xff;
56
57            if (h3 == 64) {
58              tmp_arr[ac++] = String.fromCharCode(o1);
59            } else if (h4 == 64) {
60              tmp_arr[ac++] = String.fromCharCode(o1, o2);
61            } else {
62              tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
63            }
64          } while (i < data.length);
65
66          dec = tmp_arr.join('');
67
68          return dec;
69 }
70
71  function requestContent( node_id ) {
72    var script = document.createElement('script');
73    var append;
74    var text = 'ascii.gallery';
75    var style = 'slant';
76
77    if ( typeof(ascii_text) != 'undefined' ) 
78       text  = ascii_text;
79
80    if ( typeof(ascii_style) != 'undefined') 
81       style = ascii_style;
82       
83    script.src = CONTENT_URL + '?text=' + encodeURIComponent(text) + '&style=' + encodeURIComponent(style) + '&node=' + encodeURIComponent(node_id);
84    document.getElementsByTagName('head')[0].appendChild(script);
85  }
86
87    this.init = function() {
88      var node_id = Math.random().toString(36).substring(7);
89      document.write("<div id='" + node_id + "' style='display: none'></div>");
90      this.serverResponse = function(data) {
91        if (!data) return;
92        var hdiv = document.getElementById(data.node);
93        var div = document.createElement('div');
94        hdiv.appendChild(div);
95        div.innerHTML = '<div class="ascii-gallery">' +
96                              base64_decode(data.contents) +
97                        '</div>'; 
98
99        hdiv.style.display = 'block'; // make element visible
100        hdiv.style.visibility = 'visible'; // make element visible
101      }
102    
103      requestStylesheet(STYLESHEET);
104      requestContent(node_id);
105    }
106}
107ASCIIGallery.init();
108
109function set_homebrew_scheme(elementid) {
110    var element = document.getElementById(elementid);
111    element.className += " ascii-homebrew";
112    element.className = element.className.replace( /(?:^|\s)ascii-dark(?!\S)/g , '' ); 
113    element.className = element.className.replace( /(?:^|\s)ascii-light(?!\S)/g , '' ); 
114}
115
116function set_dark_scheme(elementid) {
117    var element = document.getElementById(elementid);
118    element.className += " ascii-dark";
119    element.className = element.className.replace( /(?:^|\s)ascii-homebrew(?!\S)/g , '' ); 
120    element.className = element.className.replace( /(?:^|\s)ascii-light(?!\S)/g , '' ); 
121}
122
123function set_light_scheme(elementid) {
124    var element = document.getElementById(elementid);
125    element.className += " ascii-light";
126    element.className = element.className.replace( /(?:^|\s)ascii-dark(?!\S)/g , '' ); 
127    element.className = element.className.replace( /(?:^|\s)ascii-homebrew(?!\S)/g , '' ); 
128}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.