Commits

tbrugz  committed 9f37d3a

web: js: some refactoring

  • Participants
  • Parent commits 2931ebc

Comments (0)

Files changed (1)

File web/js/queryon-b.js

 
-var tables;
-var views;
 var baseUrl;
 
 var relationsHash = {};
 		success: function(data) {
 			tables = data.table;
 			if(tables) { console.log('Load was performed. '+tables.length+' tables loaded'); }
-			writeTables(containerId);
+			writeRelations(containerId, tables);
 		}
 	});
 	$.ajax({
 		success: function(data) {
 			views = data.view;
 			if(views) { console.log('Load was performed. '+views.length+' views loaded'); }
-			writeViews(containerId);
+			writeRelations(containerId, views);
 		}
 	});
 }
 		+ ((obj.remarks!=null && obj.remarks!="" && obj.remarks!="null")?" - "+obj.remarks:"");
 }
 
-function writeTables(containerId) {
-	if(!tables) { return; }
-	for(var i=0;i<tables.length;i++) {
-		var id = getId(tables[i]);
-		//var id = tables[i].schemaName+'.'+tables[i].name;
-		$(containerId).append("<option name='"+id+"'>"+getDescription(tables[i])+"</option>");
-		relationsHash[id] = tables[i];
-	}
-}
-
-function writeViews(containerId) {
-	console.log('write views [#'+views.length+'] to '+containerId);
-	if(!views) { return; }
-	for(var i=0;i<views.length;i++) {
-		var id = getId(views[i]);
-		$('#'+containerId).append("<option value='"+id+"'>"+getDescription(views[i])+"</option>");
-		relationsHash[id] = views[i];
+function writeRelations(containerId, relations) {
+	if(!relations) { return; }
+	console.log('write relations [#'+relations.length+'] to '+containerId);
+	for(var i=0;i<relations.length;i++) {
+		var id = getId(relations[i]);
+		$('#'+containerId).append("<option value='"+id+"'>"+getDescription(relations[i])+"</option>");
+		relationsHash[id] = relations[i];
 	}
 }