$("#btnExtractFunctions").click(extractFunctionNames);
function extractFunctionNames() {
var lines = $("#coding").val().split("\n");
//alert(lines.length);
var functionNames = [];
var i;
var linesLength = lines.length;
for (i = 0; i < linesLength; i++) {
var line = lines[i];
if (line.indexOf("function") > 0 // line contains function
&&
line.indexOf("define") < 0 // it is not define line
&&
line.indexOf("\//") < 0 // not part of docu
&&
line.indexOf("spread") < 0 // it is not a spread function
&&
line.indexOf("fail") < 0 // it is not a fail function
&&
line.indexOf("catch") < 0 // it is not a catch function
&&
line.indexOf("then") < 0) // not part of promise chain
{
line = line.replace("{", " ");
line = line.trim();
functionNames.push(line);
$("#functionNames").append("<span data-line='" + i + "'>" + line + "</br></span>");
}
}
console.log(lines.length);
// console.log(functionNames);
}
function scrollToLine($textarea, lineNumber) {
var lineHeight = parseInt($textarea.css('line-height'));
$textarea.scrollTop(lineNumber * lineHeight);
}
function Jump(line)
{
var ta = document.getElementById("coding");
var lineHeight = ta.clientHeight / ta.rows;
var jump = (line - 1) * lineHeight;
ta.scrollTop = jump;
}
var textArea = $("textarea");
$(document).on('click','span',function(){
// code here
//alert("hello span");
var line = $(this).attr("data-line");
//alert(line);
//scrollToLine(textArea, line);
Jump(line);
// hiliter('function', '#coding');
//doSearch('function');
var textarea = document.getElementById("coding");
var val = textarea.value;
var start = val.indexOf("function") + 5;
var end = val.indexOf("oEditor");
// setSelection(textarea, start, end);
});
function...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.