<commit_before>var sakai = sakai || {};

sakai.siteswow = function(tuid,placement,showSettings){

	var me = false;
	var rootel = $("#" + tuid);
	var count = 0;

	if (showSettings) {
	
		$("#mainSitesContainer", $("#" + tuid)).html("No settings available");
	
	}
	else {
	
		sdata.widgets.WidgetLoader.insertWidgets(tuid);
		$("#" + tuid + " #create_new_site_link").bind("click", function(ev){
			createNewSite();
		});
		
		var createNewSite = function(){
			$("#" + tuid + " #createsitecontainer").show();
			sakai.createsite.initialise();
		}
		
		me = sdata.me;
		sdata.Ajax.request({
			httpMethod: "GET",
			url: "/rest/sites?sid=" + Math.random(),
			onSuccess: function(data){
				loadSiteList(data, true);
			},
			onFail: function(status){
				loadSiteList("", false);
			}
		});
		
		var loadSiteList = function(response, exists){
			//var needsCreatingPersonalSite = true;
			var needsCreatingPersonalSite = false;
			if (exists) {
				var json = eval('(' + response + ')');
				var newjson = {};
				newjson.entry = [];
				if (json.entry) {
					for (var i = 0; i < json.entry.length; i++) {
						var site = json.entry[i];
						if (site.id.substring(0, 1) != "~") {
							newjson.entry[newjson.entry.length] = site;
						}
					}
				}
				doRender(newjson);		
			}
		}
		
	}
	
	var doRender = function(newjson){
		if (newjson.entry.length == 0){
			$("#" + tuid + " #sitelistwow").html("<span style='text-align:left; padding: 10px'>You aren't a member of any sites yet</span>");
		} else {
			$("#" + tuid + " #sitelistwow").html(sdata.html.Template.render('sitelistwow_template', newjson));
		}
	}

};<commit_msg>SAK-15773<commit_after>var sakai = sakai || {};

sakai.siteswow = function(tuid,placement,showSettings){

	var me = false;
	var rootel = $("#" + tuid);
	var count = 0;

	if (showSettings) {
	
		$("#mainSitesContainer", $("#" + tuid)).html("No settings available");
	
	}
	else {
	
		sdata.widgets.WidgetLoader.insertWidgets(tuid);
		$("#" + tuid + " #create_new_site_link").bind("click", function(ev){
			createNewSite();
		});
		
		var createNewSite = function(){
			$("#" + tuid + " #createsitecontainer").show();
			sakai.createsite.initialise();
		}
		
		me = sdata.me;
		sdata.Ajax.request({
			httpMethod: "GET",
			url: "/rest/sites?sid=" + Math.random(),
			onSuccess: function(data){
				loadSiteList(data, true);
			},
			onFail: function(status){
				loadSiteList("", false);
			}
		});
		
		var loadSiteList = function(response, exists){
			//var needsCreatingPersonalSite = true;
			var needsCreatingPersonalSite = false;
			if (exists) {
				var json = eval('(' + response + ')');
				var newjson = {};
				newjson.entry = [];
				if (json.entry) {
					for (var i = 0; i < json.entry.length; i++) {
						var site = json.entry[i];
						if (site.id.substring(0, 1) != "~") {
							newjson.entry[newjson.entry.length] = site;
						}
					}
				}
				doRender(newjson);		
			}
		}
		
	}
	
	var doRender = function(newjson){
		if (newjson.entry.length == 0){
			$("#" + tuid + " #sitelistwow").html("<span style='font-size:0.95em'>You aren't a member of any sites yet</span>");
		} else {
			$("#" + tuid + " #sitelistwow").html(sdata.html.Template.render('sitelistwow_template', newjson));
		}
	}

};
{'fraction_non_alphanumeric': 0.19162045594577942, 'fraction_numerical': 0.0061614294516327784, 'mean_word_length': 3.16816431322208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2895117', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1160, 'n_words': 212}