October CMS turn october to laravel

This parses october definitions to laravel definitions

by Michael Dibbets

HTML

Just paste the october definitions here 
<BR/>
<textarea id="fut" onchange="runme(this)"></textarea>
<pre id="showmethemoney">
</pre>

CSS

textarea {
   width:600px;
   height:200px;
}
#showmethemoney {
   background:#000;
   font-family:Terminal, FixedSys, Courier New, Courier, Sans Serif;
   color:lime;
    padding:20px;
    border:2px inset gold;
}

JavaScript

function getsubpart(text) {
    var start = text.indexOf('$');
    var end = text.indexOf(';');
    var ret = text.substring(start, end-start+1);
    if(text.length > 0) {
    	return ret;
    }
    return false;
}
function getFunctionType(what) {
    var $ = what.indexOf("$");
    var end = what.indexOf('=');
    var name = what.substring($+1,end-$).trim();
    return name;
}
function getRelationNameStartIndex(what) {
    return what.indexOf('\'',what.indexOf('[',what.indexOf('=')))+1;
}
function getRelationNameEndIndex(what) {
    return what.indexOf('\'',getRelationNameStartIndex(what));
    }
function getRelationName(what) {
    var $ = getRelationNameStartIndex(what);
    var end = getRelationNameEndIndex(what);
    return what.substring($,end);
}
function runme(what) {
    var text = what.value.split('\n').join('')
    			.split('\r').join('')
    			.split('\t').join('')
    			.split('public').join('').split(' ').join('').split(' ').join('').trim();
    clearOutput();
    var part,count=1;
    while(part = getsubpart(text)) {
        text = text.split(part).join('');
        addOutput(getFunctionType(part) + "('"+getRelationName(part)+"');");
        count++;
        if(count>100){throw new Error("too many loops!")}
    }
    
    
    
    
    
}
function addOutput(str) {
    document.getElementById('showmethemoney').appendChild(document.createTextNode(str));
}
function clearOutput() {
    document.getElementById('showmethemoney').innerHTML = '';
}