SVN: toys/rsget.pl/data: main.css main.js
sparky
sparky at pld-linux.org
Fri Sep 11 18:59:08 CEST 2009
Author: sparky
Date: Fri Sep 11 18:59:08 2009
New Revision: 10567
Added:
toys/rsget.pl/data/main.css
toys/rsget.pl/data/main.js
Log:
- files used by http interface
Added: toys/rsget.pl/data/main.css
==============================================================================
--- (empty file)
+++ toys/rsget.pl/data/main.css Fri Sep 11 18:59:08 2009
@@ -0,0 +1,190 @@
+html {
+ background: #333;
+}
+body {
+ width: 900px;
+ margin: 10px;
+ margin-left: auto;
+ margin-right: auto;
+ border: 10px solid #555;
+ padding: 5px;
+ background: #777;
+}
+fieldset {
+ border: 10px solid #999;
+ padding: 5px;
+ margin: 5px;
+ background: #bbb;
+}
+input, textarea {
+ border: 10px solid #ddd;
+ padding: 5px;
+ margin: 5px;
+ background: #fff;
+}
+input {
+ width: 150px;
+ margin-left: 700px;
+}
+legend {
+ border: 10px solid #999;
+ border-top: 0;
+ border-bottom: 0;
+ background: #bbb;
+}
+ul {
+ border: 10px solid #ddd;
+ padding: 5px;
+ margin: 5px;
+ background: #fff;
+ list-style: none;
+}
+li:first-child {
+ border-top: 0;
+}
+li {
+ border-top: 2px solid #ddd;
+ clear: both;
+}
+
+#log li {
+ border-color: #ddd;
+}
+
+#f_status ul {
+ display: block;
+ height: 100px;
+}
+#f_status ul li {
+ display: block;
+ height: 25px;
+ width: 266px;
+ border: 1px solid #EEE;
+ margin: 1px;
+ float: left;
+ text-align: center;
+ clear: none;
+}
+a, a:visited {
+ color: inherit;
+ font-weight: bold;
+ text-decoration: none;
+}
+a:focus, a:hover {
+ text-decoration: underline;
+}
+
+li.active, li.file, li.uri, li.comment {
+ display: block;
+ border: 2px solid black;
+ margin-top: 3px;
+ margin-bottom: 3px;
+ padding: 1px;
+ clear: both;
+}
+li.comment {
+ color: #44F;
+ border-color: #AAF;
+}
+.flist li.file {
+ margin-bottom: 0;
+}
+.flist li.uri {
+ margin-top: 0;
+ margin-bottom: 0;
+ margin-left: 50px;
+}
+span.logo {
+ display: block;
+ float: right;
+ margin-left: 3px;
+ height: 40px;
+ font-size: 30px;
+ text-align: right;
+}
+div.info {
+ display: block;
+ overflow: hidden;
+}
+div.href {
+ display: block;
+ overflow: hidden;
+}
+div.info span.size {
+ display: block;
+ float: right;
+}
+.flist li div span.cmd {
+ display: block;
+ float: left;
+ font-weight: bold;
+ width: 60px;
+}
+li.green {
+ background: #AFA;
+ border-color: #2F2;
+}
+li.red {
+ background: #FAA;
+ border-color: #F22;
+}
+li.blue {
+ background: #AAF;
+ border-color: #22F;
+}
+li.orange {
+ background: #FCA;
+ border-color: #F82;
+}
+
+.error {
+ color: #F00;
+ font-weight: bold;
+}
+
+div.progress {
+ clear: both;
+ position: relative;
+ border: 1px solid;
+ border-color: inherit;
+ height: 25px;
+ width: 98%;
+ background: transparent;
+ margin-left: auto;
+ margin-right: auto;
+}
+li.green div.progress {
+ background: #DFD;
+}
+li.red div.progress {
+ background: #FDD;
+}
+li.blue div.progress {
+ background: #DDF;
+}
+li.orange div.progress {
+ background: #FDC;
+}
+
+div.progress div {
+ position: absolute;
+ background: #2F2;
+ height: 25px;
+}
+div.progress span {
+ position: absolute;
+ display: block;
+ width: 100%;
+ text-align: center;
+}
+
+.tools {
+ font-size: 75%;
+ font-weight: bold;
+}
+.tools span {
+ cursor: pointer;
+}
+.tools span:hover {
+ text-decoration: underline;
+}
Added: toys/rsget.pl/data/main.js
==============================================================================
--- (empty file)
+++ toys/rsget.pl/data/main.js Fri Sep 11 18:59:08 2009
@@ -0,0 +1,117 @@
+
+function ajax_post( link, post, callback )
+{
+ var req = new XMLHttpRequest();
+
+ req.onreadystatechange = function () {
+ if ( req.readyState != 4 )
+ return;
+
+ var d = req.responseXML;
+ callback( d ? d.lastChild.lastChild : null );
+ };
+
+ req.open( "POST", link, true );
+ req.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
+ req.setRequestHeader( 'Content-Length', post.length );
+ req.setRequestHeader( 'Connection', 'close' );
+ req.send( post );
+}
+
+function make_post( obj )
+{
+ var post = [];
+ for ( var key in obj ) {
+ post.push( escape( key ) + "=" + escape( obj[ key ] ) );
+ }
+ return post.join( "&" );
+}
+
+var last_update = {};
+var update_uri = null;
+function init_main()
+{
+ update_uri = "/update";
+ window.setInterval( update, 750 );
+}
+
+function init_add( id )
+{
+ last_update.id = id;
+ update_uri = "/add_update";
+ window.setInterval( update, 800 );
+}
+
+function update()
+{
+ ajax_post( update_uri, make_post( last_update ), update_page );
+ delete last_update.exec;
+}
+
+function update_page( body )
+{
+ if ( !body )
+ return;
+ {
+ var script = body.lastChild;
+ script.parentNode.removeChild( script );
+ var update = eval( script.lastChild.nodeValue + "\nupdate" );
+ for ( var key in update ) {
+ last_update[ key ] = update[ key ];
+ }
+ }
+ var ne;
+ while ( ne = body.firstChild ) {
+ ne.parentNode.removeChild( ne );
+ if ( ne.nodeName == "#text" )
+ continue;
+ var id = ne.getAttribute( 'id' );
+ var old = document.getElementById( id );
+ if ( !old )
+ continue;
+
+ old.parentNode.replaceChild( ne, old );
+ if ( id == "f_dllist" || id == "f_addlist" || id == "f_listask" )
+ add_DL_commands( ne );
+ }
+}
+
+function add_DL_commands( list )
+{
+ var divs = list.getElementsByTagName( 'div' );
+ for ( var i = 0; i < divs.length; i++ ) {
+ var div = divs[ i ];
+ var cl = div.getAttribute( 'class' );
+ if ( !cl || cl != 'tools' )
+ continue;
+
+ var spans = div.getElementsByTagName( 'span' );
+ for ( var j = 0; j < spans.length; j++ ) {
+ var span = spans[ j ];
+ span.addEventListener( 'click', send_command, false );
+ }
+ }
+}
+
+function send_command( event )
+{
+ var cmd = this.firstChild.nodeValue;
+ var target = this.parentNode.parentNode.getAttribute( 'id' );
+ if ( cmd == "!REMOVE" ) {
+ var c = confirm( "Remove " + target + " ?" );
+ if ( !c )
+ return;
+ }
+ last_update.exec = cmd + ":" + target;
+}
+
+
+
+var alerted = {};
+function a( data )
+{
+ if ( alerted[ data ] )
+ return;
+ alerted[ data ] = 1;
+ alert( data );
+}
More information about the pld-cvs-commit
mailing list