

var __sendToServer = function(url) {
    if (url == null) url = "pathService.asmx/"; //http://localhost:59431/web
    this.url = url;

    this.cutFiles = function(srcPath, targetPath, files, refleshFolder) {
    var url = this.url + "cutFiles";
    var json_data = "{srcPath:'" + srcPath + "',targetPath:'" + targetPath + "',files:'" + files + "'}";
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',

            success: function(data) {
                if (data.d) refleshFolder();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
    this.copyFiles = function(srcPath, targetPath, files, refleshFolder) {
    var url = this.url + "copyFiles";
        var json_data = "{srcPath:'" + srcPath + "',targetPath:'" + targetPath + "',files:'" + files + "'}";
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',

            success: function(data) {
                if (data.d) refleshFolder();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
    this.reNameMyPublicFolder = function(path, newName,refleshFolderName) {
        var url = this.url + "reNameMyPublicFolder";
        var json_data = "{path:'" + path + "',newName:'" + newName + "'}"; 
        $.ajax({
        type: "POST",
        contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',
            
            success: function(data) {
                if (data.d) refleshFolderName();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
    this.newSubFolder = function(path, newName, refleshFolder) {
        
        var url = this.url + "newFolder";
        var json_data = "{path:'" + path + "',newName:'" + newName + "'}";
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',

            success: function(data) {
                if (data.d) refleshFolder();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
    this.cutFolder = function(srcPath, targetPath, refleshFolder) {
    var url = this.url + "cutFolder";
    var json_data = "{srcPath:'" + srcPath + "',targetPath:'" + targetPath + "'}";
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',

            success: function(data) {
                if (data.d) refleshFolder();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
    this.deleteFolder = function(path, refleshFolder) {

    var url = this.url + "deleteFolder";
        var json_data = "{path:'" + path + "'}";
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: url,
            data: json_data,

            dataType: 'json',

            success: function(data) {
                if (data.d) refleshFolder();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // 通常 textStatus 和 errorThrown 之中 + " Name:" +  JSON.parse(data).d.Name
                // 只有一个会包含信息
                alert(XMLHttpRequest.responseText);
            }
        });

    };
};
var send = new __sendToServer();