← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 485: build the javascript that embed the AudioPlayers on server-side

 

------------------------------------------------------------
revno: 485
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Sat 2013-01-05 16:42:32 +0100
message:
  build the javascript that embed the AudioPlayers on server-side
  
  - move all show_results js functions into document_ready
  - kill the javascript results retrieving 
modified:
  src/alfanous-django/templates/base.html
  src/alfanous-django/wui/static/js/hash.js


--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git

Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous-django/templates/base.html'
--- src/alfanous-django/templates/base.html	2013-01-05 14:01:59 +0000
+++ src/alfanous-django/templates/base.html	2013-01-05 15:42:32 +0000
@@ -68,19 +68,31 @@
 				$("#down").overlay().load();
 			});
 			
-
-
-						
+			// Corners
+			$(".details_label").corner("3px");
+			$("#search_words").corner("30px");
+			$("#suggestions").corner("30px");
+			
+			$(document).scrollTop($("#search_result").position().top);
+			
+
+
 			// Mouad
-			// if ( ! read_hash () ) {
-				read_params();
-			// }
+			read_params();
+			
+			{% block JS_Embedding_AudioPlayers %}
+				{% for ayaresult_id, ayaresult_content in  	results.search.ayas.items %}
+					AudioPlayer.embed("audioplayer_{{ ayaresult_id }}", {soundFile: "{{  ayaresult_content.aya.recitation }}", titles: "{{ ayaresult_content.identifier.sura_name }}-{{ ayaresult_content.identifier.aya_id}}" });
+				{% endfor %}
+			{% endblock %}
+				
+
 		});
 
 		function build_search_link(param,query,filter)
 				{
 					var new_param = param; 
-                                        new_param.action="search";
+                           new_param.action="search";
 					new_param.page = 1;
 					new_param.sortedby = "mushaf";
 					if (filter) new_param.query = "(" + $("#search_box").val() + ") + " + query;
@@ -88,7 +100,7 @@
 					return "<a class='no_decoration' href=\""+ get_url_without_params()+ "?"+ build_params( new_param )+ "\">" 
 				}
 		
-		function get_results (param) {
+		function get_results (param) { // this function will be used to require suggestions
 			if ($.trim(param.query) != "" && param.action == "search") {
 				$.ajax({
 					url: "/jos2/", // http://www.alfanous.org/jos2
@@ -110,24 +122,7 @@
 		};
 
 
-		function show_results (json, param) {
-
-			if (json.search.interval.total) {
-			
-				for( i = json.search.interval.start; i <= json.search.interval.end; i++) {
-					AudioPlayer.embed("audioplayer_"+ i, {soundFile: json.search.ayas[i].aya.recitation, titles: json.search.ayas[i].sura.name+"-"+json.search.ayas[i].aya.id});
-				}
-
-			}
-
-			// Corners
-			$(".details_label").corner("3px");
-			$("#search_words").corner("30px");
-			$("#suggestions").corner("30px");
-			
-			$(document).scrollTop($("#search_result").position().top);
-
-		}
+		function show_results (json, param) {		}
 
 		function addto_searchbar(){
 			window.external.AddSearchProvider("/static/alfanous-opensearch.xml");

=== modified file 'src/alfanous-django/wui/static/js/hash.js'
--- src/alfanous-django/wui/static/js/hash.js	2013-01-05 14:01:59 +0000
+++ src/alfanous-django/wui/static/js/hash.js	2013-01-05 15:42:32 +0000
@@ -71,7 +71,7 @@
 		var param_string = document.URL.slice ( idx + 1 );
 		if ( param_string.length > 0 ) {
 			var params = parse_params ( param_string );
-			search_for ( params );
+			//search_for ( params );
 			return true;
 		}
 	}
@@ -121,38 +121,15 @@
 	// parent.location.hash = build_hash ( params );
 	// window.location = get_url_without_params () + "?" + build_params ( params );
 	//$("#search_box").val( params.query );
-	//$("#recitation").val( params.recitation ); 
-	//$("#translation").val( params.translation );
-	//$("#sortedby").val( params.sortedby );
-	//$("#view").val( params.view );
 	
 }
 
+
 function redirect_to_params ( params ) {
 	window.location = get_url_without_params () + "?" + build_params ( params );
 }
 
-function search_for ( param ) {
-	set_search_params ( param );
-	for ( key in defaultParams ) {
-		if ( defaultParams.hasOwnProperty ( key ) && ! param.hasOwnProperty ( key ) ) {
-			param[key] = defaultParams[key];
-		}
-	}
-	
-	update_share_links ();
-	get_results ( param );
-}
-
-function read_hash () {
-	var hash = parent.location.hash;
-
-	if ( hash.length > 1 ) {
-		search_for ( parse_hash ( hash ) );
-		return true;
-	}
-	return false;
-}
+
 
 function update_share_links () {
 	for ( var class_name in share_links ) {