/**
 * Created by Mai on 2017/3/10.
 */

var Project;

var GetQueryString = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
};

var LoadData = function () {
    var loadFullPathHtml = function (proj) {
        var fullPath = [], i, pm = '<a href="/pm">项目管理</a>', angleRight = '<i class="fa fa-angle-right fa-fw"></i>';
        fullPath.push(pm);
        for (i = 0; i < proj.fullFolder.length; i++) {
            fullPath.push(angleRight, proj.fullFolder[i]);
        }
        fullPath.push(angleRight, proj.name)
        return fullPath.join('');
    };
    /*$.post('/getProject', {'data': JSON.stringify({"user_id": userID, "proj_id": GetQueryString('project')})},  function (result) {
        if (result.error === 0) {
            Project = result.data;
            $('#fullpath').html(loadFullPathHtml(Project));
        } else {
            alert('error: ' + result.message);
        };
    });*/
    GetProject(GetQueryString('project'), function (data) {
        Project = data;
        if (Project) {
            $('#fullpath').html(loadFullPathHtml(Project));
        }
    });
};

LoadData();