JSFiddle - React, Tailwind, and code Playground

by Andrea Ercolino

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/yepnope/1.5.4/yepnope.min.js"></script>

JavaScript

$(function() {

    $.proxyGet('http://disco-tools.eu/disco2_portal/terms.php', function(data) {

        $.ajaxSetup({
            beforeSend: useProxyWhenNeeded()
        });

        convert_relative_urls_to_absolute();
        var remote_scripts = remove_scripts();
        $('body').append(data);
        monkey_patch_indexOf();
        remote_scripts.shift();  // ignore jQuery
        yepnope({load: remote_scripts});
        remove_noise();

        window.disco       = window.disco       || {};
        window.disco.nodes = window.disco.nodes || {};
        var count = 0;
        $('body').prepend('<div>Limit: <input id="limit" type="text" size="5" /> <a id="run" href="#">Run</a></div>');
        $('#run').click(function (e) {
            e.preventDefault();
            
            count = $('#limit').val() * 1 || 1;
            var start = $('.rootList li:first').get(0);
            download(start);
        });
        
        //---

        function monkey_patch_indexOf() {
            var String_prototype_indexOf = String.prototype.indexOf;
            String.prototype.indexOf = function(sub) {
                var value = this.toString();
                var jsfiddle_update = /\/\w{5,5}(\/\d+)?\/show\/$/;
                var jsfiddle_run    = '/_display/';
                if (jsfiddle_update.test(value) || jsfiddle_run == value) {
                    value = '/disco2_portal/terms.php';
                }
                var result = String_prototype_indexOf.apply(value, arguments);
                return result;
            };
            console.log('Monkey patched String.prototype.indexOf !!');
        }

        function useProxyWhenNeeded() {
            var reqno = 0;
            return function( jqXHR, settings ) {
                var url = settings.url;
                console.log('Request ' + (++reqno) + ': ' + settings.type + ' ' + url + ' .');
                if (url.indexOf('ajax/ajaxCalls.php') == 0) {
                    url =...