Changeset 881 for pro-violet-viettel


Ignore:
Timestamp:
Apr 6, 2015 5:13:24 PM (10 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/www/deploy/20150304/assets/js/manager.js

    r880 r881  
    2323                                if (o.navigationbar == undefined)
    2424                                    o.navigationbar = null;
    25                                
     25
    2626                                if (o.oTree == undefined)
    2727                                    o.oTree = null;
     
    6060                                    act: null
    6161                                };
    62                                
     62
    6363                                var aryPath = [];
    64                                
     64
    6565                                if (o.homeNode == undefined)
    6666                                    o.homeNode = null;
     
    208208                                        manager: oContainer
    209209                                    });
    210                                    
     210
    211211                                    self.setHomeNode();
    212                                    
     212
    213213                                    self.refreshStatusBar();
    214214                                };
     
    322322                                        });
    323323                                    });
    324                                    
     324
    325325                                    $(document).on({
    326326                                            ajaxStart: function() { $("body").addClass("loading"); },
    327                                             ajaxStop: function() { $("body").removeClass("loading"); }   
     327                                            ajaxStop: function() { $("body").removeClass("loading"); }
    328328                                        });
    329                                    
     329
    330330                                    sendCommand({
    331331                                        postdata: null,
     
    357357                                }
    358358
    359                                 var searchItemsByParent = function (parentID,
    360                                         type) {
     359                                var searchItemsByParent = function (parentID, type) {
    361360                                    var data = {};
    362361                                    var aryItem = [];
     
    415414
    416415                                }
    417                                
     416
    418417                                var btnDownloadClick = function () {
    419418                                    var items = o.oGrid.getHighLightItem();
     
    439438                                    self.redirectPost(url, {
    440439                                              data: JSON.stringify(items)
    441                                           }); 
    442        
    443 
    444                                    
     440                                          });
     441
     442
     443
    445444                                }
    446445
     
    600599                                    return bootbox.dialog(promptOptions);
    601600                                }
    602                                
     601
    603602                                var uploadDone = function (result) {
    604603
    605604                                }
    606                                
     605
    607606                                var btnPreviewClick = function () {
    608607                                    var items = o.oGrid.getHighLightItem();
     
    707706                                    var content = "KhÃŽng hỗ trợ xem trước loại tệp này, vui lòng tải xuống và xem trên máy";
    708707                                     bootbox.alert(content);
    709                                    
     708
    710709                                }
    711710
     
    791790
    792791                                                            }
    793                                                         }, 
     792                                                        },
    794793                                                        fail: function (e, data) {
    795794                                                            // Something has
     
    932931
    933932                                    var items = [];
     933                                    var aryDupplicated = [];
     934                                    var messageText = '';
    934935
    935936                                    var destination = self.getTreeCurrentNode();
    936                                     if (oClipBoard.act != 'copy') {
    937                                         /*$(oClipBoard.items).each(
     937                                    /*if (oClipBoard.act != 'copy') {
     938                                        $(oClipBoard.items).each(
    938939                                                function (index) {
    939940                                                    var node = new Object;
    940941                                                    if (this.type == 'directory')
    941942                                                        buildTreeFromParent(this.id, node);
    942                                                        
     943
    943944                                                    else {
    944945                                                        node.id = this.id;
     
    947948
    948949                                                    items[index] = node;
    949                                                 });*/
    950                                        
    951                                     } else {
     950                                                });
     951
     952                                    } else {*/
     953                                        var destinationChildDirs = searchItemsByParent(destination, 'directory');
     954                                        var destinationChildFiles = searchItemsByParent(destination, 'file');
     955
    952956                                        items = oClipBoard.items;
    953                                     }
    954                                    
     957
     958                                        for (var i = 0; i < items.length; i++) {
     959                                                if (items[i].type == 'directory' ) {
     960                                                        for (var d = 0; d < destinationChildDirs.length; d++) {
     961                                                                if (destinationChildDirs[d].name == items[i].name) {
     962                                                                        aryDupplicated.push(items[i]);
     963                                                                }
     964                                                        }
     965                                                }
     966
     967                                                if (items[i].type == 'file' ) {
     968                                                        for (var f = 0; f < destinationChildFiles.length; f++) {
     969                                                                if (destinationChildFiles[f].name == items[i].name) {
     970                                                                        aryDupplicated.push(items[i]);
     971                                                                }
     972                                                        }
     973                                                }
     974                                        }
     975                                    //}
     976
    955977                                    for (var i = 0; i < items.length; i++) {
    956978                                        if (items[i].type == 'directory') {
     
    960982                                    }
    961983
     984                                    if (aryDupplicated.length > 0) {
     985                                        if (aryDupplicated.length > 1){
     986                                                messageText = 'Các thư mục (files) ';
     987                                                for (var m = 0; m < aryDupplicated.length; m++) {
     988                                                        messageText += '<strong>' + aryDupplicated[m].name  + '</strong>, ';
     989                                                }
     990                                        }
     991                                        else {
     992                                                var type = aryDupplicated[0].type;
     993                                                messageText = type == 'directory' ? 'Thư mục <strong>' + aryDupplicated[0].name + '</strong>' : 'File <strong>' + aryDupplicated[0].name + '</strong>';
     994                                        }
     995
     996                                        messageText += ' đã tồn tại, bạn có muốn ghi đÚ lên khÃŽng?';
     997
     998                                        var confirmOptions = {
     999                                                message: messageText,
     1000                                                buttons: {
     1001                                                    confirm: {
     1002                                                        label: "Ghi đÚ"
     1003                                                    },
     1004                                                    cancel: {
     1005                                                        label: "Há»§y bỏ"
     1006                                                    }
     1007                                                },
     1008                                                callback: function (result) {
     1009                                                        console.log(result);
     1010                                                }
     1011                                        }
     1012
     1013                                        bootbox.confirm(confirmOptions);
     1014                                    }
     1015                                }
     1016
     1017                                var pasteComplete = function (items, destination) {
     1018                                        if (items.length == 0 || destination == null) return false;
    9621019                                    var postdata = {
    963                                         act: oClipBoard.act,
    964                                         destination: destination,
    965                                         data: JSON.stringify(items)
    966                                     };
    967                                     var script = oClipBoard.act;
    968 
    969                                     sendCommand({
    970                                         postdata: postdata,
    971                                         script: script,
    972                                         callbackSuccess: function (parseData) {
    973                                             if (oClipBoard.act == 'copy') {
    974                                                 $(parseData.DIRECTORIES).each(
    975                                                         function (index) {
    976                                                             o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this;
    977                                                         });
    978 
    979                                                 $(parseData.FILES).each(
    980                                                         function (index) {
    981                                                             o.data.FILES[$(o.data.FILES).length] = this;
    982                                                         });
    983 
    984                                                 o.data.DIRECTORIES.sort(function (a, b) {
    985                                                     return a.parentID - b.parentID;
    986                                                 });
    987 
    988                                                 o.oTree.setData(o.data.DIRECTORIES);
    989                                                 o.oGrid.setData(o.data);
    990                                                 o.oTree.createCopyNode(parseData.DIRECTORIES);
    991                                                 o.oGrid.reloadGrid();
    992                                             } else if (oClipBoard.act == 'move') {
    993 
     1020                                            act: oClipBoard.act,
     1021                                            destination: destination,
     1022                                            data: JSON.stringify(items)
     1023                                        };
     1024                                        var script = oClipBoard.act;
     1025
     1026                                        sendCommand({
     1027                                            postdata: postdata,
     1028                                            script: script,
     1029                                            callbackSuccess: function (parseData) {
     1030                                                if (oClipBoard.act == 'copy') {
     1031                                                    $(parseData.DIRECTORIES).each(
     1032                                                            function (index) {
     1033                                                                o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this;
     1034                                                            });
     1035
     1036                                                    $(parseData.FILES).each(
     1037                                                            function (index) {
     1038                                                                o.data.FILES[$(o.data.FILES).length] = this;
     1039                                                            });
     1040
     1041                                                    o.data.DIRECTORIES.sort(function (a, b) {
     1042                                                        return a.parentID - b.parentID;
     1043                                                    });
     1044
     1045                                                    o.oTree.setData(o.data.DIRECTORIES);
     1046                                                    o.oGrid.setData(o.data);
     1047                                                    o.oTree.createCopyNode(parseData.DIRECTORIES);
     1048                                                    o.oGrid.reloadGrid();
     1049                                                } else if (oClipBoard.act == 'move') {
     1050
     1051                                                }
     1052
     1053                                                oClipBoard.act == '';
     1054                                                oClipBoard.items = null;
    9941055                                            }
    995 
    996                                             oClipBoard.act == '';
    997                                             oClipBoard.items = null;
    998                                         }
    999                                     });
     1056                                        });
    10001057                                }
    10011058
     
    10211078                                        var childDirs = [];
    10221079                                        var childFiles = [];
    1023                                        
     1080
    10241081                                        for(var i = 0; i < o.data.DIRECTORIES.length; i++) {
    10251082                                                aryDirs[i] = o.data.DIRECTORIES[i];
    10261083                                        }
    1027                                        
     1084
    10281085                                        for (var i = 0; i < aryDirs.length; i++) {
    10291086                                                if (aryDirs[i].parentID == parentID) {
     
    10341091                                                }
    10351092                                        }
    1036                                        
     1093
    10371094                                        return branch;
    10381095                                }
    1039                                
     1096
    10401097                                this.searchParents = function (objDir) {
    10411098                                        var parentID = objDir.parentID;
    1042                                         var aryDirs = [];                                       
    1043                                        
     1099                                        var aryDirs = [];
     1100
    10441101                                        aryDirs[0] = o.homeNode;
    10451102                                        for(var i = 1; i <= o.data.DIRECTORIES.length; i++) {
    10461103                                                aryDirs[i] = o.data.DIRECTORIES[i - 1];
    10471104                                        }
    1048                                        
     1105
    10491106                                        for (var i = 0; i < aryDirs.length; i++) {
    10501107                                                if (aryDirs[i].id == parentID) {
     
    10541111                                        }
    10551112                                }
    1056                                
     1113
    10571114                                this.deleteItem = function (item) {
    10581115
     
    11911248                                }
    11921249
    1193                                
     1250
    11941251                                this.getTreeCurrentNode = function () {
    11951252                                    return treeCurrentNode;
     
    13151372                                    $(statusbar).html(message);
    13161373                                }
    1317                                
     1374
    13181375                                this.refreshNavigator = function () {
    13191376                                        var navigatorBar = $('DIV#' + o.navigationbar + ' > UL.breadcrumb');
    13201377                                        $(navigatorBar).find('LI').remove();
    1321                                        
     1378
    13221379                                        var nodeID = self.getTreeCurrentNode();
    13231380                                        if (nodeID != 0) {
     
    13301387                                                aryPath.push(o.homeNode);
    13311388                                        }
    1332                                        
     1389
    13331390                                        for(var idx = 0; idx < aryPath.length; idx++) {
    13341391                                                var i = $('<i></i>',{'class':'ace-icon icon-folder-close home-icon'});
    13351392                                                var a = $('<a></a>',{text: aryPath[idx].name});
    13361393                                                var li = $('<li></li>');
    1337                                                 if (aryPath[idx].id == 0) 
     1394                                                if (aryPath[idx].id == 0)
    13381395                                                        $(li).append(i, a);
    1339                                                 else 
     1396                                                else
    13401397                                                        $(li).append(a);
    1341                                                
     1398
    13421399                                                $(navigatorBar).append(li);
    13431400                                        }
    1344                                        
     1401
    13451402                                        aryPath.splice(0,aryPath.length);
    13461403                                }
    1347                                
     1404
    13481405                                this.redirectPost = function (location, args) {
    13491406                                    var form = '';
    13501407                                    $.each(args, function (key, value) {
    1351                                        
     1408
    13521409                                        form += "<input type='hidden' name='"
    13531410                                                + key + "' value='" + value
     
    13861443                                    }
    13871444                                }
    1388                                
     1445
    13891446                                this.setHomeNode = function () {
    13901447                                        o.homeNode = {id:0, name:o.oTree.getRootName(), parentID:-1};
Note: See TracChangeset for help on using the changeset viewer.