Template:Bielefeld Recipes 2010

From 2010.igem.org

(Difference between revisions)
 
(One intermediate revision not shown)
Line 74: Line 74:
     $.get(  
     $.get(  
             "http://www.igem-bielefeld.de/recipes/comment.php",  
             "http://www.igem-bielefeld.de/recipes/comment.php",  
-
             { rid: "1", author: "author", title: "title", text: "text" },  
+
             {rid: $("#"+form_id+" #rid").val() ,author:$("#"+form_id+" #author").val(),title:$("#"+form_id+" #title").val(),text:$("#"+form_id+" #text").val()},  
             function(data){  
             function(data){  
-
                 alert(data);  
+
                 alert($("#"+form_id).attr("id"));  
             }  
             }  
         );  
         );  
Line 88: Line 88:
var statusHTML = "";
var statusHTML = "";
   for (var i=0; i<recipeList.length-1; i++) {
   for (var i=0; i<recipeList.length-1; i++) {
 +
    var rid = recipeList[i].rid;
     var author = recipeList[i].author;
     var author = recipeList[i].author;
     var title = recipeList[i].title;
     var title = recipeList[i].title;
     var text = recipeList[i].text;
     var text = recipeList[i].text;
     var taste = recipeList[i].taste;
     var taste = recipeList[i].taste;
 +
    var comments = recipeList[i].comments;
 +
 +
    var r0 = recipeList[i].r0 * 1;
 +
    var r1 = recipeList[i].r1 * 1;
 +
    var r2 = recipeList[i].r2 * 1;
 +
    var r3 = recipeList[i].r3 * 1;
 +
    var r4 = recipeList[i].r4 * 1;
 +
    var r5 = recipeList[i].r5 * 1;
 +
 +
    var rSum = r0+r1+r2+r3+r4+r5;
 +
       $('#recipe_container').append('<a name="'+title+'"></a><h3 style="clear:both;"> <span class="mw-headline"> <b>'+title+'</b> </span></h3>');
       $('#recipe_container').append('<a name="'+title+'"></a><h3 style="clear:both;"> <span class="mw-headline"> <b>'+title+'</b> </span></h3>');
Line 104: Line 116:
           $('#reviews_'+i).append("<div id='reviewBox_"+i+"' class='review_box' title='Other chefs voted...'></div>");
           $('#reviews_'+i).append("<div id='reviewBox_"+i+"' class='review_box' title='Other chefs voted...'></div>");
               $('#reviewBox_'+i).append("<div id='reviewVoting_"+i+"' style='height:14px;padding-left:15px;margin-bottom:4px;'></div>");
               $('#reviewBox_'+i).append("<div id='reviewVoting_"+i+"' style='height:14px;padding-left:15px;margin-bottom:4px;'></div>");
-
                   $('#reviewVoting_'+i).append("<form id='reviewForm_"+i+"'></form>");
+
                   $('#reviewVoting_'+i).append("<form id='reviewForm_"+i+"' name='"+rid+"'></form>");
                     $('#reviewForm_'+i).append('<input class="auto-submit-star" type="radio" name="recipeRating_'+i+'" value="1"/>');
                     $('#reviewForm_'+i).append('<input class="auto-submit-star" type="radio" name="recipeRating_'+i+'" value="1"/>');
                     $('#reviewForm_'+i).append('<input class="auto-submit-star" type="radio" name="recipeRating_'+i+'" value="2"/>');
                     $('#reviewForm_'+i).append('<input class="auto-submit-star" type="radio" name="recipeRating_'+i+'" value="2"/>');
Line 114: Line 126:
               $('#reviewBox_'+i).append("<div id='review5_"+i+"' style='position:relative;width:110px;height:10px'>5</div>");
               $('#reviewBox_'+i).append("<div id='review5_"+i+"' style='position:relative;width:110px;height:10px'>5</div>");
                 $('#review5_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
                 $('#review5_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
-
                 $('#review5_'+i).append("<div class='histogram' style='width:28.875px; background-color:#4444ff'></div>");
+
                 $('#review5_'+i).append("<div class='histogram' style='width:"+(60*r5/rSum)+"px; background-color:#4444ff'></div>");
-
                 $('#review5_'+i).append("<div style='position:absolute;top:0px;right:5px;'>(77)</div>");
+
                 $('#review5_'+i).append("<div style='position:absolute;top:0px;right:5px;'>("+r5+")</div>");
               $('#reviewBox_'+i).append("<div id='review4_"+i+"' style='position:relative;width:110px;height:10px'>4</div>");
               $('#reviewBox_'+i).append("<div id='review4_"+i+"' style='position:relative;width:110px;height:10px'>4</div>");
                 $('#review4_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
                 $('#review4_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
-
                 $('#review4_'+i).append("<div class='histogram' style='width:7.875px; background-color:#4444ff'></div>");
+
                 $('#review4_'+i).append("<div class='histogram' style='width:"+(60*r4/rSum)+"px; background-color:#4444ff'></div>");
-
                 $('#review4_'+i).append("<div style='position:absolute;top:0px;right:5px;'>(21)</div>");
+
                 $('#review4_'+i).append("<div style='position:absolute;top:0px;right:5px;'>("+r4+")</div>");
               $('#reviewBox_'+i).append("<div id='review3_"+i+"' style='position:relative;width:110px;height:10px'>3</div>");
               $('#reviewBox_'+i).append("<div id='review3_"+i+"' style='position:relative;width:110px;height:10px'>3</div>");
                 $('#review3_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
                 $('#review3_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
-
                 $('#review3_'+i).append("<div class='histogram' style='width:16.5px; background-color:#4444ff'></div>");
+
                 $('#review3_'+i).append("<div class='histogram' style='width:"+(60*r3/rSum)+"px; background-color:#4444ff'></div>");
-
                 $('#review3_'+i).append("<div style='position:absolute;top:0px;right:5px;'>(44)</div>");
+
                 $('#review3_'+i).append("<div style='position:absolute;top:0px;right:5px;'>("+r3+")</div>");
               $('#reviewBox_'+i).append("<div id='review2_"+i+"' style='position:relative;width:110px;height:10px'>2</div>");
               $('#reviewBox_'+i).append("<div id='review2_"+i+"' style='position:relative;width:110px;height:10px'>2</div>");
                 $('#review2_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
                 $('#review2_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
-
                 $('#review2_'+i).append("<div class='histogram' style='width:4.875px; background-color:#4444ff'></div>");
+
                 $('#review2_'+i).append("<div class='histogram' style='width:"+(60*r2/rSum)+"px; background-color:#4444ff'></div>");
-
                 $('#review2_'+i).append("<div style='position:absolute;top:0px;right:5px;'>(13)</div>");
+
                 $('#review2_'+i).append("<div style='position:absolute;top:0px;right:5px;'>("+r2+")</div>");
               $('#reviewBox_'+i).append("<div id='review1_"+i+"' style='position:relative;width:110px;height:10px'>1</div>");
               $('#reviewBox_'+i).append("<div id='review1_"+i+"' style='position:relative;width:110px;height:10px'>1</div>");
                 $('#review1_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
                 $('#review1_'+i).append("<div class='histogram' style='width:60px; background-color:#9999ff'></div>");
-
                 $('#review1_'+i).append("<div class='histogram' style='width:1.875px; background-color:#4444ff'></div>");
+
                 $('#review1_'+i).append("<div class='histogram' style='width:"+(60*r1/rSum)+"px; background-color:#4444ff'></div>");
-
                 $('#review1_'+i).append("<div style='position:absolute;top:0px;right:5px;'>(5)</div>");
+
                 $('#review1_'+i).append("<div style='position:absolute;top:0px;right:5px;'>("+r1+")</div>");
-
     $('#recipe_container').append( insert_form_comment(i) );
+
     $('#recipe_container').append( "<br />"+insert_form_comment(rid,comments) );
   } // for-Schleife Ende
   } // for-Schleife Ende
-
 
}
}
Line 147: Line 158:
   // 'value' is the value selected
   // 'value' is the value selected
   // 'element' points to the link element that received the click.
   // 'element' points to the link element that received the click.
-
   alert("The value in " + this.form.id + " selected was '" + value + "'\n\nWith this callback function I can automatically submit the form with this code:\nthis.form.submit();");
+
   alert("The value in " + this.form.name + " selected was '" + value + "'\n\nWith this callback function I can automatically submit the form with this code:\nthis.form.submit();");
    
    
 +
  $.get(
 +
            "http://www.igem-bielefeld.de/recipes/rate.php",
 +
            {stars: value, rid: this.form.name, author:wgUserName},
 +
            function(data){
 +
                alert($("#"+form_id).attr("id"));
 +
            }
 +
        );
 +
   // To submit the form automatically:
   // To submit the form automatically:
   //this.form.submit();
   //this.form.submit();

Latest revision as of 13:46, 4 October 2010