Skip to content

Developer

Russell edited this page Sep 23, 2020 · 10 revisions

JavaScript REPL

Begins a loop and evaluates any javascript.

javascript:(function(){ var input = prompt('exit to quit\n>'); while(input !== 'exit'){ alert(eval(input)); console.log(eval(input)); input = prompt('exit to quit\n>'); } })()
(function(){ 
  var io = prompt('exit to quit\n>'); 
  while(io !== 'exit'){ 
    alert(eval(input)); 
    io = prompt('exit to quit\n>'); 
  } 
})()

Todo Functions

Begins a loop with dialog functions, exit will end.

javascript:(function(cache) { var check = confirm('Enter Synchronous Interface?'); if (check === false) { return false; }  else { var input = prompt('running Query, type help for info or exit to quit\n >>'); while (input !== 'exit') {  if (input === 'script') { loadScript(); }   else if (input === 'iframe') { loadIframe(); }   else if (input === 'repl') { runRepl(); }   else if (input === 'help') { alert( 'Commands : \n' +  'add    : add an item to cache.\n' + 'save   : not setupt yet. serialize the cache and store or send\n' +  'delete : remove an item from storage\n' +  'list   : list items in storage\n' +  'iframe : render an iframe into the Document Body\n' +  'script : inject a script into the Document Body\n' +  'repl   : run javascript evaluation mode\n' ) }   else if (input === 'add') { addData(); }   else if (input === 'delete') { deleteData(); }   else if (input === 'list') { listData(); }  var input = prompt('running Query, type help for info or exit to quit\n >>'); } function loadScript() { var src = prompt('file name ?'); var script = document.createElement('script'); script.src = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/1674766/' + src + '.js'; script.type = 'text/javascript'; return document.body.appendChild(script); } function loadIframe() { var src = prompt('path ?'); var iframe = document.createElement('iframe'); iframe.style.width = '80vw'; iframe.style.height = '75vh'; iframe.src = src; return document.body.appendChild(iframe); } function runRepl() { var io = prompt('js>, exit to quit \n >'); while (io !== 'exit') { var result; try { result = eval(io); } catch (er) { result = er.stack; } finally { alert(result); } io = prompt('js>, exit to quit \n >'); } } function addData() { var item = prompt('Enter an item to the cache!'); cache.push(item);  } function deleteData() { var index = prompt('Enter index number to delete!'); cache.splice(index, 1); listData(); } function listData() { var i, len = cache.length, output = ''; for(i = 0;i < len;i++){ output += cache[i] + '\n'; } alert(output); } } } )([]);
(function(cache) {
    var check = confirm('Enter Synchronous Interface?');
    if (check === false) { return false; } 
    else {
        var input = prompt('running Query, type help for info or exit to quit\n >>');
        while (input !== 'exit') {
        
            if (input === 'script') {
                loadScript();
            } 

            else if (input === 'iframe') {
                loadIframe();
            } 

            else if (input === 'repl') {
                runRepl();
            } 

            else if (input === 'help') {
                alert(
                'Commands : \n' + 
                'add    : add an item to cache.\n' +
                'save   : not setupt yet. serialize the cache and store or send\n' + 
                'delete : remove an item from storage\n' + 
                'list   : list items in storage\n' + 
                'iframe : render an iframe into the Document Body\n' + 
                'script : inject a script into the Document Body\n' + 
                'repl   : run javascript evaluation mode\n'
                )
            } 

            else if (input === 'add') {
                addData();
            } 

            else if (input === 'delete') {
                deleteData();
            } 

            else if (input === 'list') {
                listData();
            }
            
            var input = prompt('running Query, type help for info or exit to quit\n >>');
        }
        function loadScript() {
            var src = prompt('file name ?');
            var script = document.createElement('script');
            script.src = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/1674766/' + src + '.js';
            script.type = 'text/javascript';
            return document.body.appendChild(script);
        }
        function loadIframe() {
            var src = prompt('path ?');
            var iframe = document.createElement('iframe');
            iframe.style.width = '80vw';
            iframe.style.height = '75vh';
            iframe.src = src;
            return document.body.appendChild(iframe);
        }
        function runRepl() {
            var io = prompt('js>, exit to quit \n >');
            while (io !== 'exit') {
                var result;
                try {
                    result = eval(io);
                } catch (er) {
                    result = er.stack;
                } finally {
                    alert(result);
                }
                io = prompt('js>, exit to quit \n >');
            }
        }
        function addData() {
            var item = prompt('Enter an item to the cache!');
            cache.push(item);

        }
        function deleteData() {
            var index = prompt('Enter index number to delete!');
            cache.splice(index, 1);
            listData();
        }
        function listData() {
            var i, len = cache.length, output = '';
            for(i = 0;i < len;i++){
                output += cache[i] + '\n';
            }
            alert(output);
        }
    }
}
)([]);

Clone this wiki locally