aboutsummaryrefslogtreecommitdiffstats
path: root/demos/progressbar/download.html
blob: 0528fc63bbe05eba90e8d64da433a2cee923cd7c (plain)
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
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery UI Progressbar - Download Dialog</title>
	<link rel="stylesheet" href="../../themes/base/all.css">
	<link rel="stylesheet" href="../demos.css">
	<script src="../../external/requirejs/require.js"></script>
	<script src="../bootstrap.js" data-modules="dialog">
		var progressTimer,
			progressbar = $( "#progressbar" ),
			progressLabel = $( ".progress-label" ),
			dialogButtons = [{
				text: "Cancel Download",
				click: closeDownload
			}],
			dialog = $( "#dialog" ).dialog({
				autoOpen: false,
				closeOnEscape: false,
				resizable: false,
				buttons: dialogButtons,
				open: function() {
					progressTimer = setTimeout( progress, 2000 );
				},
				beforeClose: function() {
					downloadButton.button( "option", {
						disabled: false,
						label: "Start Download"
					});
				}
			}),
			downloadButton = $( "#downloadButton" )
				.button()
				.on( "click", function() {
					$( this ).button( "option", {
						disabled: true,
						label: "Downloading..."
					});
					dialog.dialog( "open" );
				});

		progressbar.progressbar({
			value: false,
			change: function() {
				progressLabel.text( "Current Progress: " + progressbar.progressbar( "value" ) + "%" );
			},
			complete: function() {
				progressLabel.text( "Complete!" );
				dialog.dialog( "option", "buttons", [{
					text: "Close",
					click: closeDownload
				}]);
				$(".ui-dialog button").last().trigger( "focus" );
			}
		});

		function progress() {
			var val = progressbar.progressbar( "value" ) || 0;

			progressbar.progressbar( "value", val + Math.floor( Math.random() * 3 ) );

			if ( val <= 99 ) {
				progressTimer = setTimeout( progress, 50 );
			}
		}

		function closeDownload() {
			clearTimeout( progressTimer );
			dialog
				.dialog( "option", "buttons", dialogButtons )
				.dialog( "close" );
			progressbar.progressbar( "value", false );
			progressLabel
				.text( "Starting download..." );
			downloadButton.trigger( "focus" );
		}
	</script>
	<style>
	#progressbar {
		margin-top: 20px;
	}

	.progress-label {
		font-weight: bold;
		text-shadow: 1px 1px 0 #fff;
	}

	.ui-dialog-titlebar-close {
		display: none;
	}
	</style>
</head>
<body>

<div id="dialog" title="File Download">
	<div class="progress-label">Starting download...</div>
	<div id="progressbar"></div>
</div>
<button id="downloadButton">Start Download</button>

<div class="demo-description">
<p>Download dialog progressbar demo.</p>
</div>
</body>
</html>
lass="p">, "target", "*.war")) warFiles.extend(glob(join(resultDir, artifactId, "*", "target", "*.war"))) for warFile in warFiles: if len(warFiles) == 1: deployName = "%s.war" % (name) else: deployName = "%s-%d.war" % (name, warFiles.index(warFile)) print("Copying .war file %s as %s to result folder" % (basename(warFile), deployName)) copy(warFile, join(resultDir, deployName)) copiedWars.append(join(resultDir, deployName)) return copiedWars # Recursive pom.xml update script def updateRepositories(path, repoIds = None, repoUrl = repo): # If versions are not supplied, parse arguments if repoIds is None: repoIds = getArgs() # Read pom.xml pomXml = join(path, "pom.xml") if isfile(pomXml): # pom.xml namespace workaround root = ElementTree.parse(pomXml).getroot() nameSpace = root.tag[1:root.tag.index('}')] ElementTree.register_namespace('', nameSpace) # Read the pom.xml correctly tree = ElementTree.parse(pomXml) # NameSpace needed for finding the repositories node repoNode = tree.getroot().find("{%s}repositories" % (nameSpace)) else: return if repoNode is not None: print("Add staging repositories to " + pomXml) if hasattr(repoIds, "framework") and repoIds.framework is not None: # Add framework staging repository addRepo(repoNode, "repository", "vaadin-%s-staging" % (repoIds.version), repoUrl % (repoIds.framework)) # Find the correct pluginRepositories node pluginRepo = tree.getroot().find("{%s}pluginRepositories" % (nameSpace)) if pluginRepo is None: # Add pluginRepositories node if needed pluginRepo = ElementTree.SubElement(tree.getroot(), "pluginRepositories") if hasattr(repoIds, "plugin") and repoIds.plugin is not None: # Add plugin staging repository addRepo(pluginRepo, "pluginRepository", "vaadin-%s-plugin-staging" % (repoIds.version), repoUrl % (repoIds.plugin)) # Overwrite the modified pom.xml tree.write(pomXml, encoding='UTF-8') # Recursive pom.xml search. for i in listdir(path): file = join(path, i) if isdir(file): updateRepositories(join(path, i), repoIds, repoUrl) # Add a repository of repoType to given repoNode with id and URL def addRepo(repoNode, repoType, id, url): newRepo = ElementTree.SubElement(repoNode, repoType) idElem = ElementTree.SubElement(newRepo, "id") idElem.text = id urlElem = ElementTree.SubElement(newRepo, "url") urlElem.text = url # Get a logfile for given artifact def getLogFile(artifact, resultDir = resultPath): return open(join(resultDir, "%s.log" % (artifact)), 'w') def removeDir(subdir): if '..' in subdir or '/' in subdir: # Dangerous relative paths. return rmtree(join(resultPath, subdir)) def mavenInstall(pomFile, jarFile = None, mvnCmd = mavenCmd, logFile = sys.stdout): cmd = [mvnCmd, "install:install-file"] cmd.append("-Dfile=%s" % (jarFile if jarFile is not None else pomFile)) cmd.append("-DpomFile=%s" % (pomFile)) print("executing: %s" % (" ".join(cmd))) subprocess.check_call(cmd, stdout=logFile)