if (json.job_status == 'completed') {
percentage = 100;
}
- var bgproperty = (parseInt(percentage)*2-300)+"px 0px";
+ var bgproperty = (parseInt(percentage/2)*3-300)+"px 0px";
$("#jobprogress").css("background-position",bgproperty);
$("#jobprogresspercent").text(percentage);
data: inputs.join('&'),
url: f.action,
dataType: 'json',
- type: 'post',
+ type: 'post',
success: function(json) {
jobID = json.jobID;
inBackgroundJobProgressTimer = false;
--- /dev/null
+Test templates, to be used with test scripts
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Tools › Stage MARC Records For Import</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="file-upload.inc" -->
+<!-- TMPL_INCLUDE NAME="background-job.inc" -->
+<style type="text/css">
+ #uploadpanel,#fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
+ #fileuploadstatus,#jobstatus { margin:.4em; }
+ #fileuploadprogress,#jobprogress{ width:150px;height:10px;border:1px solid #666;background:url('/intranet-tmpl/prog/img/progress.png') -300px 0px no-repeat; }</style>
+<script type="text/javascript">
+//<![CDATA[
+$(document).ready(function(){
+});
+function CheckForm(f) {
+ submitBackgroundJob(f);
+ return false;
+}
+
+//]]>
+</script>
+</head>
+<body>
+<div id="doc3" class="yui-t2">
+
+<form method="post" action="progressbarsubmit.pl">
+<input type="hidden" name="submitted" id="submitted" value="1" />
+<input type="hidden" name="runinbackground" id="runinbackground" value="" />
+<input type="hidden" name="completedJobID" id="completedJobID" value="" />
+
+<input type="button" id="mainformsubmit" onclick="return CheckForm(this.form);" value="Start" />
+
+ <div id="jobpanel">
+ <div id="jobstatus">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
+ <div id="jobfailed"></div>
+ </div>
+
+</form>
+</div>
+
+<div>
+Completed: <span id="completed"><!-- TMPL_VAR NAME="completedJobID" --> </span>
+</div>
+</body>
--- /dev/null
+A collection of cgi and command line scripts that are useful for some testing,
+but for one reason or another cannot be made into automated test in t.
+Use with templates in koha-tmpl/intranet-tmpl/prog/en/modules/test
--- /dev/null
+#!/usr/bin/perl
+
+# Script for testing progressbar, part 1 - initial screem
+# it is split into two scripts so we can use firebug to debug it
+
+# Koha library project www.koha.org
+
+# Licensed under the GPL
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+#use warnings; FIXME - Bug 2505
+
+# standard or CPAN modules used
+use CGI;
+use CGI::Cookie;
+
+# Koha modules used
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::BackgroundJob;
+
+my $input = new CGI;
+my $dbh = C4::Context->dbh;
+$dbh->{AutoCommit} = 0;
+
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "test/progressbar.tmpl",
+ query => $input,
+ type => "intranet",
+ debug => 1,
+ });
+
+output_html_with_http_headers $input, $cookie, $template->output;
+
+exit 0;
+
+
--- /dev/null
+#!/usr/bin/perl
+
+# Script for testing progressbar, part 2 - json submit handler
+# and Z39.50 lookups
+
+# Koha library project www.koha.org
+
+# Licensed under the GPL
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+#use warnings; FIXME - Bug 2505
+
+# standard or CPAN modules used
+use CGI;
+use CGI::Cookie;
+
+# Koha modules used
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::BackgroundJob;
+
+my $input = new CGI;
+
+my $submitted=$input->param('submitted');
+my $runinbackground = $input->param('runinbackground');
+my $jobID = $input->param('jobID');
+my $completedJobID = $input->param('completedJobID');
+
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "test/progressbar.tmpl",
+ query => $input,
+ type => "intranet",
+ debug => 1,
+ });
+
+my %cookies = parse CGI::Cookie($cookie);
+my $sessionID = $cookies{'CGISESSID'}->value;
+if ($completedJobID) {
+} elsif ($submitted) {
+ my $job = undef;
+ if ($runinbackground) {
+ my $job_size = 100;
+ $job = C4::BackgroundJob->new($sessionID, undef, $ENV{'SCRIPT_NAME'}, $job_size);
+ $jobID = $job->id();
+
+ # fork off
+ if (my $pid = fork) {
+ # parent
+ # return job ID as JSON
+
+ # prevent parent exiting from
+ # destroying the kid's database handle
+ # FIXME: according to DBI doc, this may not work for Oracle
+
+ my $reply = CGI->new("");
+ print $reply->header(-type => 'text/html');
+ print "{ jobID: '$jobID' }";
+ exit 0;
+ } elsif (defined $pid) {
+ # if we get here, we're a child that has detached
+ # itself from Apache
+
+ # close STDOUT to signal to Apache that
+ # we're now running in the background
+ close STDOUT;
+ close STDERR;
+
+ foreach (1..100) {
+ sleep 1;
+ $job->progress( $_ );
+ }
+ $job->finish();
+ } else {
+ # fork failed, so exit immediately
+ die "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
+ }
+
+ }
+} else {
+ # initial form
+ die "We should not be here";
+}
+
+exit 0;
+
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use C4::Search;
+
+my @SEARCH = (
+ { operators => [
+ 'and',
+ 'and'
+ ],
+ operands => [
+ 'shakespeare, "(william)"',
+ 'dream'
+ ],
+ indexes => [
+ 'au,wrdl',
+ 'ti',
+ 'kw'
+ ],
+ limits => [
+ 'yr,st-numeric=2000-'
+ ],
+ sort_by => [
+ 'relevance'
+ ],
+ lang => 'en',
+ },
+);
+
+
+foreach ( @SEARCH ) {
+ my ($expected, @mismatch);
+ my( $error,
+ $query,
+ $simple_query,
+ $query_cgi,
+ $query_desc,
+ $limit,
+ $limit_cgi,
+ $limit_desc,
+ $stopwords_removed,
+ $query_type )
+ = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0, $_->{lang} );
+
+ die $error if $error;
+
+ $expected = $_->{query};
+ push @mismatch, "Query: $query (not: $expected)" unless $query eq $expected;
+
+ $expected = $_->{simple_query};
+ push @mismatch, "Simple Query: $simple_query (not: $expected)" unless $simple_query eq $expected;
+
+ $expected = $_->{query_cgi};
+ push @mismatch, "Query CGI: $query_cgi (not: $expected)" unless $query_cgi eq $expected;
+
+ $expected = $_->{query_desc};
+ push @mismatch, "Query desc: $query_desc (not: $expected)" unless $query_desc eq $expected;
+
+ $expected = $_->{limit};
+ push @mismatch, "Limit: $limit (not: $expected)" unless $limit eq $expected;
+
+ $expected = $_->{limit_cgi};
+ push @mismatch, "Limit CGI: $limit_cgi (not: $expected)" unless $limit_cgi eq $expected;
+
+ $expected = $_->{limit_desc};
+ push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
+
+ $expected = $_->{stopwords_removed};
+ push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected;
+
+ $expected = $_->{query_type};
+ push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
+
+ die map "$_\n", @mismatch if @mismatch;
+}