forked from mschierberl/varscoper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayScreen.cfm
109 lines (95 loc) · 4.83 KB
/
displayScreen.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<cfset currentFileName = scoperFileName />
<cfparam name="currentFileIteration" default="0">
<cfset currentFileIteration = currentFileIteration + 1 />
<cfset scoperResults = varscoper.getResultsArray() />
<script language="javascript">
function toggleCorrectiveCode(idx){
if (document.getElementById('correctiveCode'+idx).style.display == 'none'){
document.getElementById('correctiveCode'+idx).style.display='';
document.getElementById('showHide'+idx).innerHTML = 'hide corrective code';
}else{
document.getElementById('correctiveCode'+idx).style.display='none';
document.getElementById('showHide'+idx).innerHTML = 'show corrective code';
}
}
</script>
<cfset totalUnscopedVariables = 0 />
<cfloop from="1" to="#arrayLen(scoperResults)#" index="idx">
<cfset totalUnscopedVariables = totalUnscopedVariables + arrayLen(scoperResults[idx].unscopedArray) />
</cfloop>
<cfif ArrayIsEmpty(scoperResults)>
<!--- <cfoutput>Check was successful for (#htmlEditFormat(scoperFileName)#)</cfoutput><br><br> --->
<cfelse>
<cfif isDefined('URL.sendBadStatus')>
<cfheader statuscode="599" statustext="unscoped">
</cfif>
<cfsavecontent variable="varScoperDetails" >
<table border="0" cellpadding="2" cellspacing="0" width="100%" class="scoperTable">
<tr>
<td class="fileTitle" colspan="4">
<cfoutput><a href="fileDisplay.cfm?fileName=#URLEncodedFormat(currentFileName)#&lines=${allLines}" target="varscoper" class="fileTitle">#currentFileName#</a> (#totalUnscopedVariables# unscoped variables) </cfoutput>
</td>
</tr>
<cfset allLines = "" >
<cfloop from="1" to="#arrayLen(scoperResults)#" index="scoperIdx">
<cfset tempUnscopedArray = scoperResults[scoperIdx].unscopedArray />
<cfif NOT ArrayIsEmpty(tempUnscopedArray)>
<tr>
<td colspan="3" class="functionCell" >
<strong>
<cfoutput>
<span style="float:right;">
<a href="###currentFileIteration#_#scoperIdx#" onclick="toggleCorrectiveCode('#currentFileIteration#_#scoperIdx#');">
<span style="font-size: 10px;" id="showHide#currentFileIteration#_#scoperIdx#">show corrective code</span>
</a>
</span>
#htmlEditFormat("<cffunction name='#scoperResults[scoperIdx].functionName#'>")#
<cfif structKeyExists(scoperResults[scoperIdx],"LineNumber") AND scoperResults[scoperIdx].LineNumber NEQ 1>
<cfset currLine = scoperResults[scoperIdx].LineNumber >
<a href="fileDisplay.cfm?fileName=#URLEncodedFormat(currentFileName)#&lines=${allLines}##line#currLine#" target="varscoper" >line: #scoperResults[scoperIdx].LineNumber#</a>
<cfset allLines = listAppend(allLines, currLine) >
</cfif>
</cfoutput>
</strong>
</td>
</tr>
<!--- CorrectiveCode Block --->
<cfoutput>
<tbody id="correctiveCode#currentFileIteration#_#scoperIdx#" style="display:none;">
<tr>
<td colspan="3" align="center" bgcolor="##E2DDB5">Disclaimer: Each function should be inspected individually to determine if the intended scope should be local(var).</td>
</tr>
<tr>
<th class="codeCell" colspan="2" align="right">Corrective Code:</th>
<td class="codeCell" bgcolor="##E2DDB5">
<cfloop from="1" to="#arrayLen(tempUnscopedArray)#" index="unscopedIdx">
<cfif structKeyExists(tempUnscopedArray[unscopedIdx],"LineNumber") AND tempUnscopedArray[unscopedIdx].LineNumber NEQ 1>
<cfoutput>#htmlEditFormat("<cfset var " & trim(tempUnscopedArray[unscopedIdx].VariableName) & " = '' />")#<br></cfoutput>
</cfif>
</cfloop>
</td>
</tr>
</tbody>
</cfoutput>
<cfloop from="1" to="#arrayLen(tempUnscopedArray)#" index="unscopedIdx">
<cfoutput>
<tr>
</cfoutput>
<td class="varNameCell" align="right"><cfoutput>#tempUnscopedArray[unscopedIdx].VariableName#</cfoutput></td>
<cfif structKeyExists(tempUnscopedArray[unscopedIdx],"LineNumber") AND tempUnscopedArray[unscopedIdx].LineNumber NEQ 1>
<cfset currLine = tempUnscopedArray[unscopedIdx].LineNumber >
<td class="varNameCell" align="right">
<cfoutput><a href="fileDisplay.cfm?fileName=#URLEncodedFormat(currentFileName)#&lines=${allLines}##line#currLine#" target="varscoper" >line: #tempUnscopedArray[unscopedIdx].LineNumber#</a></cfoutput>
<cfset allLines = listAppend(allLines, currLine) >
</td>
</cfif>
<td class="contextCell" ><cfoutput>#htmlEditFormat(left(tempUnscopedArray[unscopedIdx].VariableContext,100))#</cfoutput></td>
</tr>
</cfloop>
</cfif>
</cfloop>
</table><br><br>
</cfsavecontent>
<cfoutput>#replaceNoCase(varScoperDetails, "${allLines}", allLines, "ALL")#</cfoutput>
</cfif>
<cfflush>