function makeAndRenderNewProject() {

        var myNewProject = {
            "id": "",
            "title": "Name your new list",
            "participants": [],
            "tasks": []
        };

        // add to projects array (not done by renderProject), to the beginning
        gpostmile.projects.unshift(myNewProject);

        // new/empty active/selected project, needs to be done before renderProjects because renderProject adds the project arg to the projects
        Y.fire('postmile:renderProject', myNewProject, true);

        // dismiss menu just in case we're creating a new project because the user selected 'create' from the menu
        // could make a menu-specific callback to do just this
        var myProjectsMenu = Y.one("#projects-menu");
        myProjectsMenu.addClass('menu-hidden');

        function confirmAddedProject(response, myarg) { // response has id, rev, status

            if (response.status === 'ok') {

                myNewProject.rev = response.rev;

                myNewProject.id = response.id;
                gpostmile.projects[myNewProject.id] = myNewProject; // needs to be added to projects keys again with new id 


                if (!myNewProject.requestedSuggestions && myNewProject.id !== "") {

                    myNewProject.requestedSuggestions = true;
                    getJson("/project/" + myNewProject.id + "/suggestions",
						function (suggestions, projectId) { Y.fire('postmile:renderSuggestions', suggestions, projectId); }, myNewProject.id);

                } else {

                    // clear even if no suggestions
                    Y.fire('postmile:renderSuggestions', myNewProject.suggestions, myNewProject.id);

                }

                if (!myNewProject.requestedTips && myNewProject.id !== "") {

                    myNewProject.requestedTips = true; // just to say we tried
                    getJson("/project/" + myNewProject.id + "/tips",
						function (tips, projectId) { Y.fire('postmile:renderTips', tips, projectId); }, myNewProject.id);

                } else {

                    // clear even if no suggestions
                    Y.fire('postmile:renderTips', myNewProject.tips, myNewProject.id);

                }

                // need to renderProjects menu for both adding and changing project names
                // just to repop the menu of projects with prop id, do not set and render last/active project
                renderProjects(gpostmile.projects, false);

                document.location.href = document.location.href.split('#')[0] + '#project=' + myNewProject.id;

            } else {

                Y.log('error adding project ' + JSON.stringify(response));

            }
        }

        var json = '{"title":"' + myNewProject.title + '"}';
        putJson("/project", json, confirmAddedProject);

    }
// create a new project to render
create a new project to render
create a new project to render
function makeAndRenderNewProject() {
        var myNewProject = {
            "id": "",
            "title": "Name your new list",
            "participants": [],
            "tasks": []
        };
        gpostmile.projects.unshift(myNewProject);
        Y.fire('postmile:renderProject', myNewProject, true);
        var myProjectsMenu = Y.one("#projects-menu");
        myProjectsMenu.addClass('menu-hidden');
        function confirmAddedProject(response, myarg) { 
            if (response.status === 'ok') {
                myNewProject.rev = response.rev;
                myNewProject.id = response.id;
                gpostmile.projects[myNewProject.id] = myNewProject; 
                if (!myNewProject.requestedSuggestions && myNewProject.id !== "") {
                    myNewProject.requestedSuggestions = true;
                    getJson("/project/" + myNewProject.id + "/suggestions",
						function (suggestions, projectId) { Y.fire('postmile:renderSuggestions', suggestions, projectId); }, myNewProject.id);
                } else {
                    Y.fire('postmile:renderSuggestions', myNewProject.suggestions, myNewProject.id);
                }
                if (!myNewProject.requestedTips && myNewProject.id !== "") {
                    myNewProject.requestedTips = true; 
                    getJson("/project/" + myNewProject.id + "/tips",
						function (tips, projectId) { Y.fire('postmile:renderTips', tips, projectId); }, myNewProject.id);
                } else {
                    Y.fire('postmile:renderTips', myNewProject.tips, myNewProject.id);
                }
                renderProjects(gpostmile.projects, false);
                document.location.href = document.location.href.split('#')[0] + '#project=' + myNewProject.id;
            } else {
                Y.log('error adding project ' + JSON.stringify(response));
            }
        }
        var json = '{"title":"' + myNewProject.title + '"}';
        putJson("/project", json, confirmAddedProject);
    }
function makeAndRenderNewProject ( ) { var myNewProject = { "id" : "" , "title" : "Name your new list" , "participants" : [ ] , "tasks" : [ ] } ; gpostmile . projects . unshift ( myNewProject ) ; Y . fire ( 'postmile:renderProject' , myNewProject , true ) ; var myProjectsMenu = Y . one ( "#projects-menu" ) ; myProjectsMenu . addClass ( 'menu-hidden' ) ; function confirmAddedProject ( response , myarg ) { if ( response . status === 'ok' ) { myNewProject . rev = response . rev ; myNewProject . id = response . id ; gpostmile . projects [ myNewProject . id ] = myNewProject ; if ( ! myNewProject . requestedSuggestions && myNewProject . id !== "" ) { myNewProject . requestedSuggestions = true ; getJson ( "/project/" + myNewProject . id + "/suggestions" , function ( suggestions , projectId ) { Y . fire ( 'postmile:renderSuggestions' , suggestions , projectId ) ; } , myNewProject . id ) ; } else { Y . fire ( 'postmile:renderSuggestions' , myNewProject . suggestions , myNewProject . id ) ; } if ( ! myNewProject . requestedTips && myNewProject . id !== "" ) { myNewProject . requestedTips = true ; getJson ( "/project/" + myNewProject . id + "/tips" , function ( tips , projectId ) { Y . fire ( 'postmile:renderTips' , tips , projectId ) ; } , myNewProject . id ) ; } else { Y . fire ( 'postmile:renderTips' , myNewProject . tips , myNewProject . id ) ; } renderProjects ( gpostmile . projects , false ) ; document . location . href = document . location . href . split ( '#' ) [ 0 ] + '#project=' + myNewProject . id ; } else { Y . log ( 'error adding project ' + JSON . stringify ( response ) ) ; } } var json = '{"title":"' + myNewProject . title + '"}' ; putJson ( "/project" , json , confirmAddedProject ) ; }
create a new project to render
create a new project to render
// add to projects array (not done by renderProject), to the beginning // new/empty active/selected project, needs to be done before renderProjects because renderProject adds the project arg to the projects // dismiss menu just in case we're creating a new project because the user selected 'create' from the menu // could make a menu-specific callback to do just this // response has id, rev, status // needs to be added to projects keys again with new id  // clear even if no suggestions // just to say we tried // clear even if no suggestions // need to renderProjects menu for both adding and changing project names // just to repop the menu of projects with prop id, do not set and render last/active project