Created
June 29, 2013 19:06
-
-
Save d1rtym0nk3y/5892276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsetting requesttimeout="999999" enablecfoutputonly="true" /> | |
<cfscript> | |
progress("Importing data", 0); | |
recordcount = 100; | |
for(i=1; i<=recordcount; i++) { | |
// do something | |
sleep(250); | |
progress("Importing data", i, recordcount) | |
} | |
progress("Importing data", 1) | |
</cfscript> | |
<cffunction name="progress"> | |
<cfargument name="type" /> | |
<cfargument name="x" default="0" /> | |
<cfargument name="total" type="numeric" default="1" /> | |
<cfset var key = hash(type) /> | |
<cfset var p = "" /> | |
<cftry> | |
<cfif not isNumeric(x)> | |
<cfset p = x /> | |
<cfelseif x is total> | |
<cfset p = "done" /> | |
<cfelse> | |
<cfset p = fix((x/total)*100) & "%" /> | |
</cfif> | |
<cfcatch> | |
<cfset p = "" /> | |
</cfcatch> | |
</cftry> | |
<cfif not structKeyExists(request, "progress_types")> | |
<cfset request.progress_types = {} /> | |
<cfoutput> | |
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script> | |
</cfoutput> | |
<cfflush /> | |
</cfif> | |
<cfif !structKeyExists(request.progress_types, key)> | |
<cfset request.progress_types[key] = 1 /> | |
<cfoutput> | |
<div>#type# : <span id="type_#key#"></span></div> | |
<script>window.scrollBy(0,500);</script> | |
</cfoutput> | |
</cfif> | |
<cfoutput> | |
<script>$("##type_#key#").text("#p#");</script> | |
</cfoutput> | |
<cfflush /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment