(function($){
	$.fn.cpGetMaterials = function() {
		var el = $(this);
		var lesson_id = $(el).data("lesson_id");
		$.ajax({
			type: "post",
			url: "contents/plugins/classroom_plus/ajax.php",
			data: {action: "cp_get_materials", lesson_id: lesson_id}
		}).done(function(data){
			try {
				data = JSON.parse(data);
				$(el).html(data.display_html);
				setTimeout(function(){
					$(el).cpGetMaterials();
				}, 10000);
			}
			catch (err) {
				console.log(err);
				console.log(data);
			}
			finally {}
		})
	}
})(jQuery);

jQuery(document).ready(function($){
	$("#materials").cpGetMaterials();
	$(document).on("click", "#tabs-icons-text-0-tab", function(){
		$("#display-streams").html("");
		var data = $("#display-streams").data();
		data.count = 0;
		data.offset = 0;
		console.log(data);
		$("#display-streams").queryLoaderApi(data);
	})
})