<commit_before><!--  

Copyright 2015 <NAME>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License. 

-->

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>RelaxNG Playground</title>
  <link rel="stylesheet" href="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/tlvince/bootstrap-theme-cosmo/cosmo.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/github.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/lib/codemirror.js"></script>
  <link rel="stylesheet" href="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/lib/codemirror.css"/>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/mode/javascript/javascript.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/codemirror.net/addon/mode/simple.js"></script>
  <script src="main.js"></script>
  <script src="example.js"></script>
  <script>

function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}

function validateCode(codeMirrors) {
	$('#theoutput').prop("class", "alert alert-info");
	$('#theoutput').text("compiling...");
	var relaxngcode = codeMirrors["relaxng"].getValue();
	var inputcode = codeMirrors["xml"].getValue();
	var validateFunc = gofunctions["ValidateRelaxNG"];
	var translateFunc = gofunctions["TranslateRelaxNG"];
	var res = validateFunc(relaxngcode, inputcode);
	if (res.indexOf("Error: ") === 0) {
		res = res.replace("Error: ", "");
		$('#theoutput').prop("class", "alert alert-danger");
		$('#theoutput').text(res);
	} else {
		var relapsecode = translateFunc(relaxngcode);
		if (res == "true") {
			$('#theoutput').prop("class", "alert alert-success");
			$('#theoutput').text("valid");
			$('#outputlefttextarea').text(relapsecode);
		} else if (res == "false") {
			$('#theoutput').prop("class", "alert alert-warning");
			$('#theoutput').text("invalid");
			$('#outputlefttextarea').text(relapsecode);
		} else {
			$('#theoutput').prop("class", "alert alert-danger");
			$('#theoutput').text(res);
		}
	}
}

function reportError(err) {
	$('#theoutput').prop("class", "alert alert-danger");
	$('#theoutput').text(err);
}

function saveCode(codeMirrors) {
	var saving = {
        "description": "saved relaxng src",
        "public": true,
        "files": {}
    }
    for (key in codeMirrors) {
    	saving["files"][key+"src"] = {}
    	saving["files"][key+"src"]["content"] = codeMirrors[key].getValue();
    }
	var github = new Github({});
	var gist = github.getGist();
	gist.create(saving, function(err, rest) {
    	if (err == undefined) {
    		window.location.assign("./index.html?gist="+rest.id+"&share=true");
    	} else {
    		reportError(err);
    	}
    });
}

function loadCode(codeMirrors) {
	var github = new Github({});
	var gist = github.getGist(gistText);
	gist.read(function(err, content) {
		if (err == undefined) {
			for (key in codeMirrors) {
				codeMirrors[key].setValue(content.files[key+"src"].content);
			}
		} else {
			reportError(err);
		}
	});
}

function displayShareBox() {
	var linkText = window.location.href.replace("&share=true", "");
	$("#thelink").val(linkText);
	$("#thelink").prop("type", "text");
	var theLinkBox = document.getElementById("thelink");
    theLinkBox.onfocus = function() {
        theLinkBox.select();

        // Work around Chrome's little problem
        theLinkBox.onmouseup = function() {
            // Prevent further mouseup intervention
            theLinkBox.onmouseup = null;
            return false;
        };
    };
    theLinkBox.focus();
}

function setHeightAuto() {
	var codeMirrors = $(".CodeMirror");
	for (var i = 0; i < codeMirrors.length; i++) {
    	codeMirrors[i].style.height = "auto";
	}
}

function setHeightDefault() {
	var codeMirrors = $(".CodeMirror");
	for (var i = 0; i < codeMirrors.length; i++) {
    	codeMirrors[i].style.height = "25em";
	}
}

function setDefaults(codeMirrors) {
	codeMirrors["xml"].setValue(defaults["xml"]);
	codeMirrors["relaxng"].setValue(defaults["relaxng"]);
}

function init() {
	gistText = getUrlParameter("gist");
	share = getUrlParameter("share");
	var relaxngCodeMirror = CodeMirror(document.getElementById("lefttextarea"), {
  		mode:  "xml",
  		value: 'loading...',
  		viewportMargin: Infinity
	});
	var codeMirrors = {"relaxng": relaxngCodeMirror};
	var xmlCodeMirror = CodeMirror(document.getElementById("righttextarea"), {
  		mode:  "xml",
  		value: 'loading...',
  		viewportMargin: Infinity
	});
	codeMirrors["xml"] = xmlCodeMirror;
	$("#inputheading").text("xml input");

	if (gistText == undefined) {
		setDefaults(codeMirrors);
	} else {
		loadCode(codeMirrors);
		if (!(share == undefined)) {
			displayShareBox();
	    }
	}

	$("#saveButton").click(function(ev) { 
		saveCode(codeMirrors);
	});

	setHeightDefault();
	$("#autosizeButton").click(function(ev) {
		ev.preventDefault();
		wasChecked = $("#autosizeButton").hasClass("active");
		if (wasChecked) {
			$("#autosizeButton").removeClass("active");
			setHeightDefault();
		} else {
			$("#autosizeButton").addClass("active");
			setHeightAuto();
		}
	});

	for (var key in codeMirrors) {
		codeMirrors[key].on('keyup', function(instance, event) {
    		validateCode(codeMirrors);
		});		
	}

}

</script>

</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://github.com/katydid/relaxng">The RelaxNG Playground</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input id="thelink" readonly="true" class="form-control" autofocus="true" style="width: 30cm" type="hidden"/>
        </div>
      </form>
     <!--  <ul class="navbar-form navbar-left">
      	<div class="pull-down">
     		<li><textarea rows="1" autofocus="true" spellcheck="false" id="thelink" readonly="true" style="width: 30cm" hidden></textarea></li>
     	</div>
      </ul> -->
      <ul class="nav navbar-nav navbar-right">
      	<li id="autosizeButton"><a href="#">Autosize</a></li>
        <li><a href="#" id="saveButton">Share</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<!--<a href="https://github.com/katydid/katydid"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>-->
<p></p>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<h3><a href="http://www.relaxng.org/spec-20011203.html#simplification">Simplified</a> RelaxNG</h3>	
			</div>
		</div>
	</div>
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-10">
				<h3 class="rightheading" id="inputheading">input</h3>	
			</div>
			<div class="col-xs-2"></div>
		</div>
	</div>
</div>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<div id="lefttextarea"></div>
			</div>
		</div>
	</div>
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-10">
				<div id="righttextarea"></div>
			</div>
			<div class="col-xs-2"></div>
		</div>
	</div>
</div>
<p></p>
<p></p>
<div class="row">
	<div class="col-xs-1"></div>
	<div class="col-xs-10 text-center">
	<div id="theoutput"></div>
	</div>
	<div class="col-xs-1"></div>
</div>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<h3>Relapse</h3>	
			</div>
		</div>
	</div>
	<div class="col-xs-6">
	</div>
</div>
<div class="row">
	<div class="col-xs-1"></div>
	<div class="col-xs-10">
		<div id="outputleft">
		<textarea id="outputlefttextarea" style="height: 25em">
		</textarea>
		</div>
	</div>
	<div class="col-xs-1"></div>
</div>
<div class="row">
	<div class="col-xs-1"></div><commit_msg>uneditable relapse text area in playground<commit_after><!--  

Copyright 2015 <NAME>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License. 

-->

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>RelaxNG Playground</title>
  <link rel="stylesheet" href="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/tlvince/bootstrap-theme-cosmo/cosmo.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/github.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/lib/codemirror.js"></script>
  <link rel="stylesheet" href="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/lib/codemirror.css"/>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/CodeMirror-5.19.0/mode/javascript/javascript.js"></script>
  <script src="https://cdn.rawgit.com/katydid/play/gh-pages/vendor/codemirror.net/addon/mode/simple.js"></script>
  <script src="main.js"></script>
  <script src="example.js"></script>
  <script>

function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}

function validateCode(codeMirrors) {
	$('#theoutput').prop("class", "alert alert-info");
	$('#theoutput').text("compiling...");
	var relaxngcode = codeMirrors["relaxng"].getValue();
	var inputcode = codeMirrors["xml"].getValue();
	var validateFunc = gofunctions["ValidateRelaxNG"];
	var translateFunc = gofunctions["TranslateRelaxNG"];
	var res = validateFunc(relaxngcode, inputcode);
	if (res.indexOf("Error: ") === 0) {
		res = res.replace("Error: ", "");
		$('#theoutput').prop("class", "alert alert-danger");
		$('#theoutput').text(res);
	} else {
		var relapsecode = translateFunc(relaxngcode);
		if (res == "true") {
			$('#theoutput').prop("class", "alert alert-success");
			$('#theoutput').text("valid");
			$('#outputlefttextarea').text(relapsecode);
		} else if (res == "false") {
			$('#theoutput').prop("class", "alert alert-warning");
			$('#theoutput').text("invalid");
			$('#outputlefttextarea').text(relapsecode);
		} else {
			$('#theoutput').prop("class", "alert alert-danger");
			$('#theoutput').text(res);
		}
	}
}

function reportError(err) {
	$('#theoutput').prop("class", "alert alert-danger");
	$('#theoutput').text(err);
}

function saveCode(codeMirrors) {
	var saving = {
        "description": "saved relaxng src",
        "public": true,
        "files": {}
    }
    for (key in codeMirrors) {
    	saving["files"][key+"src"] = {}
    	saving["files"][key+"src"]["content"] = codeMirrors[key].getValue();
    }
	var github = new Github({});
	var gist = github.getGist();
	gist.create(saving, function(err, rest) {
    	if (err == undefined) {
    		window.location.assign("./index.html?gist="+rest.id+"&share=true");
    	} else {
    		reportError(err);
    	}
    });
}

function loadCode(codeMirrors) {
	var github = new Github({});
	var gist = github.getGist(gistText);
	gist.read(function(err, content) {
		if (err == undefined) {
			for (key in codeMirrors) {
				codeMirrors[key].setValue(content.files[key+"src"].content);
			}
		} else {
			reportError(err);
		}
	});
}

function displayShareBox() {
	var linkText = window.location.href.replace("&share=true", "");
	$("#thelink").val(linkText);
	$("#thelink").prop("type", "text");
	var theLinkBox = document.getElementById("thelink");
    theLinkBox.onfocus = function() {
        theLinkBox.select();

        // Work around Chrome's little problem
        theLinkBox.onmouseup = function() {
            // Prevent further mouseup intervention
            theLinkBox.onmouseup = null;
            return false;
        };
    };
    theLinkBox.focus();
}

function setHeightAuto() {
	var codeMirrors = $(".CodeMirror");
	for (var i = 0; i < codeMirrors.length; i++) {
    	codeMirrors[i].style.height = "auto";
	}
}

function setHeightDefault() {
	var codeMirrors = $(".CodeMirror");
	for (var i = 0; i < codeMirrors.length; i++) {
    	codeMirrors[i].style.height = "25em";
	}
}

function setDefaults(codeMirrors) {
	codeMirrors["xml"].setValue(defaults["xml"]);
	codeMirrors["relaxng"].setValue(defaults["relaxng"]);
}

function init() {
	gistText = getUrlParameter("gist");
	share = getUrlParameter("share");
	var relaxngCodeMirror = CodeMirror(document.getElementById("lefttextarea"), {
  		mode:  "xml",
  		value: 'loading...',
  		viewportMargin: Infinity
	});
	var codeMirrors = {"relaxng": relaxngCodeMirror};
	var xmlCodeMirror = CodeMirror(document.getElementById("righttextarea"), {
  		mode:  "xml",
  		value: 'loading...',
  		viewportMargin: Infinity
	});
	codeMirrors["xml"] = xmlCodeMirror;
	$("#inputheading").text("xml input");

	if (gistText == undefined) {
		setDefaults(codeMirrors);
	} else {
		loadCode(codeMirrors);
		if (!(share == undefined)) {
			displayShareBox();
	    }
	}

	$("#saveButton").click(function(ev) { 
		saveCode(codeMirrors);
	});

	setHeightDefault();
	$("#autosizeButton").click(function(ev) {
		ev.preventDefault();
		wasChecked = $("#autosizeButton").hasClass("active");
		if (wasChecked) {
			$("#autosizeButton").removeClass("active");
			setHeightDefault();
		} else {
			$("#autosizeButton").addClass("active");
			setHeightAuto();
		}
	});

	for (var key in codeMirrors) {
		codeMirrors[key].on('keyup', function(instance, event) {
    		validateCode(codeMirrors);
		});		
	}

}

</script>

</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://github.com/katydid/relaxng">The RelaxNG Playground</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input id="thelink" readonly="true" class="form-control" autofocus="true" style="width: 30cm" type="hidden"/>
        </div>
      </form>
     <!--  <ul class="navbar-form navbar-left">
      	<div class="pull-down">
     		<li><textarea rows="1" autofocus="true" spellcheck="false" id="thelink" readonly="true" style="width: 30cm" hidden></textarea></li>
     	</div>
      </ul> -->
      <ul class="nav navbar-nav navbar-right">
      	<li id="autosizeButton"><a href="#">Autosize</a></li>
        <li><a href="#" id="saveButton">Share</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<!--<a href="https://github.com/katydid/katydid"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>-->
<p></p>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<h3><a href="http://www.relaxng.org/spec-20011203.html#simplification">Simplified</a> RelaxNG</h3>	
			</div>
		</div>
	</div>
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-10">
				<h3 class="rightheading" id="inputheading">input</h3>	
			</div>
			<div class="col-xs-2"></div>
		</div>
	</div>
</div>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<div id="lefttextarea"></div>
			</div>
		</div>
	</div>
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-10">
				<div id="righttextarea"></div>
			</div>
			<div class="col-xs-2"></div>
		</div>
	</div>
</div>
<p></p>
<p></p>
<div class="row">
	<div class="col-xs-1"></div>
	<div class="col-xs-10 text-center">
	<div id="theoutput"></div>
	</div>
	<div class="col-xs-1"></div>
</div>
<div class="row">
	<div class="col-xs-6">
		<div class="row">
			<div class="col-xs-2"></div>
			<div class="col-xs-10">
				<h3>Relapse</h3>	
			</div>
		</div>
	</div>
	<div class="col-xs-6">
	</div>
</div>
<div class="row">
	<div class="col-xs-1"></div>
	<div class="col-xs-10">
		<div id="outputleft">
		<textarea id="outputlefttextarea" style="height: 25em" readonly>
		</textarea>
		</div>
	</div>
	<div class="col-xs-1"></div>
</div>
<div class="row">
	<div class="col-xs-1"></div>
{'fraction_non_alphanumeric': 0.1992734820965231, 'fraction_numerical': 0.024494032174364296, 'mean_word_length': 3.887395384225209, 'pattern_counts': {'":': 8, '<': 351, '<?xml version=': 0, '>': 345, 'https://': 24, 'lorem ipsum': 0, 'www.': 4, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2589854', 'n_tokens_mistral': 7371, 'n_tokens_neox': 6809, 'n_words': 1231}