Abulafia List to HTML generator

This frontend of this generator is based on Angus Warman's. This version uses Abulafia's format for random lists. To use the original version of this generator, click here.

Step 1:

Write your list in the following text area, and click "Generate Code".
Click the "Test" button to get a randomly drawn sample from your list.

Button Label:

              Check this box to activate button on page load.


Step 2:

Paste the following code snippet in your page wherever you want the button to appear. In blogger, you can switch to the HTML tab while composing a post and just plop it in.






Examples

Basic Formatting



Nested Lists





More Examples



The previous version of this generator required the following code to be placed at the top of the page. It is no longer necessary.
<script>
function parse_list(inputText) {
    var listMap = {'main':[]};
    var activeList = 'main';
    var lines = inputText.split('\n');
    for(var i = 0; i < lines.length ; i++){
        var line = lines[i];
        if (line == '') {
            continue;
            }
        else if (line.charAt(0)=='{' && line.charAt(line.length-1)=='}') {
            line = line.replace('{','');
            line = line.replace('}','');
            listMap[line] = [];
            activeList = line;
            }
        else {
            listMap[activeList].push(line);
            }
        }
    return listMap
    }
function r(items){return items[Math.floor(Math.random()*items.length)];}
function draw_item(itemMap){
    var output = r(itemMap['main']);
    keys = Object.keys(itemMap);
    var reps = 0;
    while (reps < 40){
        for(var i = 0; i < keys.length ; i++){
            output = output.replace('['+keys[i]+']', r(itemMap[keys[i]]));
                }
        reps ++;
        }
    return output;
    }
</script>

No comments:

Post a Comment