Skip to content

Instantly share code, notes, and snippets.

@arturcarvalho
Created May 13, 2015 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturcarvalho/2be93470e745a082d640 to your computer and use it in GitHub Desktop.
Save arturcarvalho/2be93470e745a082d640 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/bitavi
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://jashkenas.github.io/underscore/underscore-min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<textarea id="txt-pri" cols="100" rows="25">lorem ipsum lorem&#13;&#10;outrum linhum
</textarea>
<textarea id="txt-sec" cols="100" rows="25">blaem blaum xxxem&#13;&#10;xxxrum blahum
</textarea>
<p></p>
<input id = "btnSubmit" type="submit" value="Update"/>
<ul id='slicedList'>
</ul>
<div id='res1'></div>
<script id="jsbin-javascript">
var update = function() {
var text1 = $('#txt-pri').val().trim();
var text2 = $('#txt-sec').val().trim();
var prim = text1.split(/\n/);
var sec = text2.split(/\n/);
var l = [];
_.each(prim, function(val, i){
var o = {};
o.primary = prim[i];
o.secondary = sec[i];
l.push(o);
});
var res = JSON.stringify(l);
res = res.split("},{").join("},<br/>{"); // add the enters to look cleaner
$('#res1').html(res);
};
$("#btnSubmit").click(function(){
update();
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script>
<script src="//jashkenas.github.io/underscore/underscore-min.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<textarea id="txt-pri" cols="100" rows="25">lorem ipsum lorem&#13;&#10;outrum linhum
</textarea>
<textarea id="txt-sec" cols="100" rows="25">blaem blaum xxxem&#13;&#10;xxxrum blahum
</textarea>
<p></p>
<input id = "btnSubmit" type="submit" value="Update"/>
<ul id='slicedList'>
</ul>
<div id='res1'></div>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">var update = function() {
var text1 = $('#txt-pri').val().trim();
var text2 = $('#txt-sec').val().trim();
var prim = text1.split(/\n/);
var sec = text2.split(/\n/);
var l = [];
_.each(prim, function(val, i){
var o = {};
o.primary = prim[i];
o.secondary = sec[i];
l.push(o);
});
var res = JSON.stringify(l);
res = res.split("},{").join("},<br/>{"); // add the enters to look cleaner
$('#res1').html(res);
};
$("#btnSubmit").click(function(){
update();
});</script></body>
</html>
var update = function() {
var text1 = $('#txt-pri').val().trim();
var text2 = $('#txt-sec').val().trim();
var prim = text1.split(/\n/);
var sec = text2.split(/\n/);
var l = [];
_.each(prim, function(val, i){
var o = {};
o.primary = prim[i];
o.secondary = sec[i];
l.push(o);
});
var res = JSON.stringify(l);
res = res.split("},{").join("},<br/>{"); // add the enters to look cleaner
$('#res1').html(res);
};
$("#btnSubmit").click(function(){
update();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment