Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Upgrage js for updating form page.
Browse files Browse the repository at this point in the history
  • Loading branch information
nyumatova committed Jul 31, 2011
1 parent bd62704 commit bbba584
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
9 changes: 9 additions & 0 deletions project/sass/partials/_form.sass
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ $default-text-shadow-blur: 0
+single-text-shadow
text-decoration: none

.dialogue .lock-botton
color: #888

.dialogue .report
margin: 1em 0 0 0
font-size: 1.4em
Expand Down Expand Up @@ -55,6 +58,12 @@ $default-text-shadow-blur: 0
image: image-url("action-error.png")
color: $dark-color

.not-valid #id_url
border-color: $ref-color

.not-valid #info
color: $ref-color

.result
margin: 2.5em 0 0 0
display: none
Expand Down
27 changes: 21 additions & 6 deletions project/static/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,43 +239,58 @@ pre {
}

/* line 31, ../../sass/partials/_form.sass */
.dialogue .lock-botton {
color: #888888;
}

/* line 34, ../../sass/partials/_form.sass */
.dialogue .report {
margin: 1em 0 0 0;
font-size: 1.4em;
}
/* line 35, ../../sass/partials/_form.sass */
/* line 38, ../../sass/partials/_form.sass */
.dialogue .report p {
background-image: url('/static/images/action-waiting.png?1312010126');
background-repeat: no-repeat;
background-position: 0 15px;
padding: 10px 0 0 22px;
color: #bbbbbb;
}
/* line 43, ../../sass/partials/_form.sass */
/* line 46, ../../sass/partials/_form.sass */
.dialogue .report .done {
background-image: url('/static/images/action-done.png?1312004913');
color: #23272a;
}
/* line 48, ../../sass/partials/_form.sass */
/* line 51, ../../sass/partials/_form.sass */
.dialogue .report .working {
background-image: url('/static/images/ajax-loader.gif?1312096230');
color: #23272a;
}
/* line 53, ../../sass/partials/_form.sass */
/* line 56, ../../sass/partials/_form.sass */
.dialogue .report .error {
background-image: url('/static/images/action-error.png?1312013270');
color: #23272a;
}

/* line 58, ../../sass/partials/_form.sass */
/* line 61, ../../sass/partials/_form.sass */
.not-valid #id_url {
border-color: #bd2500;
}

/* line 64, ../../sass/partials/_form.sass */
.not-valid #info {
color: #bd2500;
}

/* line 67, ../../sass/partials/_form.sass */
.result {
margin: 2.5em 0 0 0;
display: none;
font-size: 1.1em;
text-align: center;
}

/* line 64, ../../sass/partials/_form.sass */
/* line 73, ../../sass/partials/_form.sass */
.view {
display: block;
}
Expand Down
46 changes: 36 additions & 10 deletions project/static/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ $(document).ajaxSend(function(event, xhr, settings) {
}
});

function lockForm() {
$('#id_url').attr('disabled','disabled');
$('.button').attr('disabled','disabled').addClass('lock-botton');
}

function unlockForm() {
$('#id_url').removeAttr('disabled');
$('.button').removeAttr('disabled').removeClass('lock-botton');
}

function updateDatta() {
$.ajax({
url: __get_status_url__,
Expand All @@ -42,39 +52,48 @@ function updateDatta() {
success: function (data) {
var msg = $('#adding').text();
if (data.queue == 'working') {
msg = 'Adding the project to the task queue...';}
lockForm();
msg = 'Adding the project to the task queue...';}
else if (data.queue == 'done') {
msg = 'Adding the project to the task queue completed successfully';}
else if (data.queue == 'error') {
msg = 'Got an error when adding the project to the task queue';}
msg = 'Got an error when adding the project to the task queue';
unlockForm();}
$('#adding').removeClass('working done error').addClass(data.queue).text(msg);

msg = $('#cloning').text();
if (data.cloning == 'working') {
lockForm();
msg = 'Cloning the project...';}
else if (data.cloning == 'done') {
msg = 'Cloning the project completed successfully';}
else if (data.cloning == 'error') {
msg = 'Got an error when cloning the project';}
msg = 'Got an error when cloning the project';
unlockForm();}
$('#cloning').removeClass('working done error').addClass(data.cloning).text(msg);

msg = $('#parsing').text();
if (data.parsing == 'working') {
lockForm();
msg = 'Parsing the source code...';}
else if (data.parsing == 'done') {
msg = 'Parsing the source code completed successfully';}
else if (data.parsing == 'error') {
msg = 'Got an error when parsing the source code';}
msg = 'Got an error when parsing the source code';
unlockForm();}
$('#parsing').removeClass('working done error').addClass(data.parsing).text(msg);

msg = $('#analyzing').text();
if (data.analyzing == 'working') {
lockForm();
msg = 'Analyzing the source code...';}
else if (data.analyzing == 'done') {
msg = 'Analyzing the source code completed successfully';
$('#result').addClass('view');}
$('#result').addClass('view');
unlockForm();}
else if (data.analyzing == 'error') {
msg = 'Got an error when analyzing the source code';}
msg = 'Got an error when analyzing the source code';
unlockForm();}
$('#analyzing').removeClass('working done error').addClass(data.analyzing).text(msg);
}
});
Expand All @@ -89,20 +108,27 @@ $(function(){
context: this,
success: function (data) {
if (data.status == 'ok') {
$('#id_url').css('border-color', '#D9D9D9');
$('#info').text("You'll have access to the results within 30 days").css('color', '#23272A');
$(this).parent().removeClass('not-valid');
lockForm();
$('#info').text("You'll have access to the results within 30 days");
$('#result').removeClass('view');
$('#result a').attr('href', data.url);
}
else {
$('#id_url').css('border-color', '#BD2500');
$('#info').text(data.error).css('color', '#BD2500');
$(this).parent().addClass('not-valid');
$('#info').text(data.error);
unlockForm();
}
}
});
return false;
});

$('#id_url').focus(function() {
$('.dialogue').removeClass('not-valid');
$('#info').text("You'll have access to the results within 30 days");
});

var timeout = 1000;
updateDatta();
setInterval(updateDatta, timeout);
Expand Down

0 comments on commit bbba584

Please sign in to comment.