Skip to content

Commit

Permalink
Added prototype form submit for evaluation. Not finished, this breaks…
Browse files Browse the repository at this point in the history
… the application.
  • Loading branch information
Bas Wenneker committed May 10, 2010
1 parent 05f718c commit 9aa3da8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 20 deletions.
5 changes: 3 additions & 2 deletions app/controllers/citations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def parse
citation = params[:citation]
parser = params.fetch('parser', DEFAULT_PARSER)

if citation
if citation

# First parse the citation with parscit.
if parser == PARSER_PARSCIT
Expand All @@ -112,13 +112,14 @@ def parse
# Execute the mixing process.
enhanced_record = Bibmix::Bibsonomy::MixingProcess.new(record).execute
end

respond_to do |format|
format.json {
render :json => {
:parsed => record,
:enhanced => enhanced_record
}
}
end
end
end
27 changes: 14 additions & 13 deletions app/views/evaluation/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<%= stylesheet_link_tag 'evaluation' %>

<h1>Evaluation#index</h1>
<h1>Evaluation</h1>
<form id="evaluation-form" method="post" action="">
<div id="citation-container">
Evaluator: <br />
<input type="text" id="evaluator" value="[email protected]"/><br />
Citation: <br />
<input type="hidden" id="citation-id" value=""/><br />
<textarea id="citation">

</textarea><br />
<button id="citation-request-btn">Go!</button>
<input type="text" id="evaluator" name="evaluator" value="[email protected]"/><br />
Citation:
<input type="hidden" id="citation-id" name="citation-id" value=""/><br />
<textarea id="citation" name="citation"></textarea><br />
<input type="radio" name="parser" value="parscit" id="radio-parscit"/> <label for="radio-parscit">parscit</label>
<input type="radio" name="parser" value="freecite" id="radio-freecite"/> <label for="radio-freecite">freecite</label>
</div>

<div id="comparison-container">
Expand All @@ -19,12 +19,13 @@
</div>

<div id="eval-container">
<textarea id="eval-note">

</textarea><br />
<a href="javascript:void(0);" id="eval-ok">Ok</a>, <a href="javascript:void(0);" id="eval-not-ok">Not Ok</a>
<textarea id="eval-note"></textarea><br />
<input type="radio" name="evaluation" id="eval-ok" value="1"/> <label for="eval-ok">OK</label>
<input type="radio" name="evaluation" id="eval-not-ok" value="0"/> <label for="eval-not-ok">Not OK</label>
<br />
<button type="button" id="evaluation-btn">Send</button>
</div>

</form>
<%= javascript_include_tag 'prototype' %>

<%= javascript_include_tag 'evaluation/abstract_comparison_table' %>
Expand Down
50 changes: 47 additions & 3 deletions public/javascripts/evaluation/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,49 @@ var Evaluation = {

'referencePointer': 0,

'defaultParser': 'parscit',

/**
* Evaluation application initialization function.
*/
'init': function()
{
this.loadEvaluationSet();
this.initForm();
this.initEvents();
},

'initForm': function()
{

var parser = null;
if($('radio-parscit').checked){
parser = 'parscit';
}else if($('radio-freecite').checked){
parser = 'freecite';
}else{
parser = this.defaultParser;
$('radio-'+parser).checked = 'checked';
}
},

'initEvents': function()
{

$('citation-request-btn').observe('click', function(){


$('evaluation-btn').observe('click', function(){
this.eval(true);
}.bind(this));
/*
$('eval-not-ok').observe('click', function(){
this.eval(false);
}.bind(this));
*/


/*
$('citation-request-btn').observe('click', function(){
Evaluation.setCurrentItem({
citation: {
'ref': this.innerHTML
Expand All @@ -31,6 +61,7 @@ var Evaluation = {
$('eval-not-ok').observe('click', function(){
this.eval(false);
}.bind(this));
*/
},

/**
Expand Down Expand Up @@ -66,7 +97,20 @@ var Evaluation = {
'eval': function(citationIsOk)
{

new Ajax.Request('/evaluations/new',
Form.request($('evaluation-form'),{
//method: 'get',
//parameters: { evaluation:citationIsOk },
onFail: function(){ alert('Could not send evaluation.'); },
onSuccess: function(transport) {
if(this.references.length < this.referencePointer){
alert('Finished evaluation');
}else{
this.setCurrentItem(this.references[++this.referencePointer]);
}
}.bind(this)
});

/*new Ajax.Request('/evaluations/new',
{
method: 'post',
parameters: {
Expand All @@ -83,7 +127,7 @@ var Evaluation = {
}
}.bind(this)
}
);
);*/
}
};

Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/evaluation/record_comparison_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var RecordComparisonTable = Class.create(AbstractComparisonTable, {
'loadComparisonData': function(item)
{
item = item || this.item;
new Ajax.Request('/citations/parse_with_parscit',
new Ajax.Request('/citations/parse',
{
method: 'post',
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/bibmix

0 comments on commit 9aa3da8

Please sign in to comment.