File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ function post_xhr(){
1818 }
1919 //echo(json_encode($scores));
2020
21- $ i = 0 ;
21+ $ i = 1 ;
2222 $ total = 0 ;
2323 $ positive = 0 ;
2424 $ negative = 0 ;
@@ -42,12 +42,13 @@ function post_xhr(){
4242 // echo $positive;
4343 // echo "\n";
4444 // echo $negative;
45+ // echo "\n";
4546
4647 if ((($ negative +1 )/($ positive +1 )) > 0.5 ){
47- echo (10 *$ total + 5 - 2 * ($ negative +1 )/($ positve +1 )
48+ echo (10 *$ total/ $ i + 5 - ($ negative +1 )/($ positive +1 ));
4849 }
4950 else {
50- echo (10 *$ total + 5 + 2 * ($ negative +1 )/($ positve +1 )
51+ echo (10 *$ total/ $ i + 5 + ($ negative +1 )/($ positive +1 ));
5152 }
5253
5354 }
Original file line number Diff line number Diff line change @@ -14,13 +14,17 @@ $(document).ready(function(){
1414 data :data ,
1515 complete :function ( msg ) {
1616 console . log ( msg . responseText ) ;
17+ var score = msg . responseText ;
18+ score = ( Math . round ( parseFloat ( score ) * 10 ) ) / 10 ;
19+ $ ( "div.result" ) . append ( '<span><h1>' + score + '</h1></span>' ) ;
20+ $ ( "#ajax-loader" ) . remove ( ) ;
1721 }
1822 } )
19- $ ( 'form' ) . append ( '<br/><br/><img src="public/images/ajax-loader.gif"/>' ) ;
20- $ ( '#results' ) . append ( '<div class="result row"><div class="span4"></div></div>' ) ;
23+ $ ( 'form' ) . append ( '<div id="ajax-loader"><br/><br/><img src="public/images/ajax-loader.gif"/></div>' ) ;
2124 $ ( '#results' ) . empty ( )
22- var imgSrc = $ ( "#source" ) . val ( ) ;
23- $ ( '#results' ) . append ( '<div class="result row"><img style="height:120px" src="public/images/' + imgSrc + '.jpg"></div>' ) ;
25+ $ ( '#results' ) . append ( '<div class="result row"><div class="span4"></div></div>' ) ;
26+ // var imgSrc = $("#source").val();
27+ // $('#results').append('<div class="result row"><img style="height:120px" src="public/images/'+imgSrc+'.jpg"></div>');
2428 } ) ;
2529
2630} ) ;
Original file line number Diff line number Diff line change 3030 </div >
3131 </div >
3232 </header >
33- <div id = " results" >
33+ <div id = " results" style = " text-align:center " >
3434 </div >
3535 </body >
3636</html >
You can’t perform that action at this time.
0 commit comments