(and yes I know there is grep -n 'function' *.js but I like things I can see in browser)
<?php
header("Content-Type:text/plain") ;
$files=glob('*.js');
$searchfor = 'function';
foreach($files as $file) {
print $file.PHP_EOL;
$contents=file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $contents, $matches)){
print count($matches[0])." total functions".PHP_EOL;
print implode("\n", $matches[0]);
}
}
?>
Example out:
main.js
37 total functions
function checkExists(myVar) {
function consoleLogTime(input) {
function debugMsg(input) {
function getQuerystring(key, default_)
function selectCustomer(input) {
function listCreate(arrayValues, arrayText, myClass) {
function optionListCreate(arrayValues, arrayText) {
function validateEmail(x) {
function checkEmailExists(email) {
success: function(result) {
error: function(result) {
function passwordReset(email) {
success: function(result) {
error: function(result) {
function listArray(myArray) {
function getJsonTable(url, table, tag) {
$.getJSON(url+'?table='+table, function(data){
$.each(data, function(index,item) {
$(document).ready(function(){
success: function(result) {
error: function(result) {
$('#signin').click(function() {
$('#signup').click(function() {
$("#passwordReset").click(function() {
$("#emailB").blur(function() {
$('.mytype').click(function() {
$("#passwordconfirmB").keyup(function() {
$("#passwordconfirmB").blur(function() {
$("#workorder").ready(function() {
$("select").ready(function() {
$("#bids").change(function() {
$("#about").click(function() {
$('.submit').click(function() {
success: function(result) {
error: function(result) {
$("#selectacustomer").click(function() {
$(".customerSelect").click(function() {