$(function() {
    refreshPages();
    $('#createPageB').on('click', create_PageBus);
});


function create_PageBus() {
    $('#page_title').css('background', '#FFF');
    var title = $('#page_title').val();
    if(!title) {
        $('#page_title').css('background', '#FAA');
        return;
    }


    $.ajax({
		url:'/api/createPageBus',
		type:'GET',
		dataType:'json',
        data:{title:title},
		success:function(data, status, xhr) {
            $('#page_title').val('');
            populatePages(data.pages);
		},
		error:function(xhr, status, error) {
		alert(xhr.responseText);
		console.error(xhr, status, error);
		}
	});
}

function refreshPages() {
    $.ajax({
		url:'/api/get_pages',
		type:'GET',
		dataType:'json',
		success:function(data, status, xhr) {
            populatePages(data.pages);
		},
		error:function(xhr, status, error) {
		alert(xhr.responseText);
		console.error(xhr, status, error);
		}
	});
}

function populatePages(pages) {
    console.log(pages);
    var Pages_str = '';
    for(var page in pages) {
        Pages_str += '<a href="/pages/'+pages[page].id+'">'+pages[page].title+'</a>'+(pages[page].admin ? '<span>(admin)</span>': '')+'<br>';

    }
    $('#pages').html(Pages_str);
}


@@ -1033,24 +1033,85 @@
 in pages) %7B%0A
+%3C%3C%3C%3C%3C%3C%3C HEAD:MyLittleBuisness/web/static/js/createPageBus.js%0A
         Page
@@ -1241,16 +1241,279 @@
 %3Cbr%3E';%0A%0A
+=======%0A        //console.log(pages%5Bpage%5D);%0A        Pages_str += '%3Ca href=%22/pages/'+pages%5Bpage%5D.id+'%22%3E'+pages%5Bpage%5D.title+'%3C/a%3E'+(pages%5Bpage%5D.admin ? '%3Cspan%3E(admin)%3C/span%3E': '')+'%3Cbr%3E';%0A%3E%3E%3E%3E%3E%3E%3E parent of 7620a93... uodate:MyLittleBuisness/web/static/js/userIN.js%0A
     %7D%0A  

Revert "uodate"