1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-16 15:52:47 +01:00
imapsync/X/progress.html

124 lines
3.0 KiB
HTML
Raw Normal View History

2017-09-23 23:54:48 +02:00
<!DOCTYPE html>
<html>
<head>
<title>Imapsync online</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
-->
</head>
<body>
<h1>Imapsync online</h1>
2019-07-03 01:25:47 +02:00
<input
data-toggle="tooltip" data-placement="top" title="It is usually an email address or its left part before @"
type="text" class="form-control input-lg" id="user1" name="user1" tabindex="1"
placeholder="Enter source login name">
<pre id="user2">
</pre>
2017-09-23 23:54:48 +02:00
<button type="button"
2018-05-07 16:04:23 +02:00
onclick="imapsync('?lalala=zzz&host1=sss&user1=uuu&password1=uuu&host2=ttt&user2=uuu&password2=uuu&simulong=22&debugenv=on', handleRun)"
2017-09-23 23:54:48 +02:00
>Run imapsync
</button>
<!--
&debugcgi=on&debugenv=on
-->
<button type="button"
onclick="abort( '?host1=&user1=&password1=&host2=&user2=&password2=&abort=on' )"
>Abort imapsync
</button>
<h2>Console of imapsync run</h2>
<pre id="console">
</pre>
<h2>Console of abort</h2>
<pre id="abort">
</pre>
<h2>Log of imapsync run</h2>
<pre id="output" >
</pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
2019-07-03 01:25:47 +02:00
$("#user2").text("toto");
$("#user1").val("RRRR");
2017-09-23 23:54:48 +02:00
var readyStateStr = {
0: "Request not initialized",
1: "Server connection established",
2: "Response headers received",
3: "Processing request",
4: "Finished and response is ready"
} ;
function imapsync( querystring, cFunction ) {
var xhr ;
xhr = new XMLHttpRequest( ) ;
var timerRefreshLog = setInterval( function() { refreshLog( xhr ) }, 3000 ) ;
xhr.onreadystatechange = function( ) {
cFunction( this, timerRefreshLog ) ;
} ;
2018-05-07 16:04:23 +02:00
xhr.open( "GET", "/cgi-bin/imapsync" + querystring, true ) ;
2017-09-23 23:54:48 +02:00
xhr.send( ) ;
}
function handleRun( xhr, timerRefreshLog ) {
$( "#console" ).text( "Status: " + xhr.status + " " + xhr.statusText + ".\n"
+ "State: " + readyStateStr[ xhr.readyState ] + "\n" ) ;
if ( xhr.status == 200 && xhr.readyState == 4 ) {
var headers = xhr.getAllResponseHeaders( ) ;
$( "#console" ).append( "\n" + headers + "\n" ) ;
clearInterval( timerRefreshLog ) ;
refreshLog( xhr ) ; // a last time
}
}
function refreshLog( xhr ) {
$( "#output" ).html( xhr.responseText ) ;
}
function abort( querystring ) {
var xhr ;
xhr = new XMLHttpRequest( ) ;
xhr.onreadystatechange = function( ) {
handleAbort( this ) ;
} ;
2018-05-07 16:04:23 +02:00
xhr.open( "GET", "/cgi-bin/imapsync" + querystring, true ) ;
2017-09-23 23:54:48 +02:00
xhr.send( ) ;
}
function handleAbort( xhr ) {
$( "#abort" ).text( "Status: " + xhr.status + " " + xhr.statusText + ".\n"
+ "State: " + readyStateStr[ xhr.readyState ] + "\n" ) ;
if ( xhr.status == 200 && xhr.readyState == 4 ) {
var headers = xhr.getAllResponseHeaders( ) ;
$( "#abort" ).append( "\n" + headers + "\n" ) ;
$( "#abort" ).append( xhr.responseText ) ;
}
}
</script>
</body>
</html>