softwareFolder.js 24.1 KB
Newer Older
Marco Mariani's avatar
Marco Mariani committed
1
/*jslint undef: true */
2
/*global $, document, $SCRIPT_ROOT, ace, window */
Marco Mariani's avatar
Marco Mariani committed
3 4
/*global path: true */
/* vim: set et sts=4: */
5

Marco Mariani's avatar
Marco Mariani committed
6
$(document).ready(function () {
7
  "use strict";
8

9 10 11
    var viewer,
        editor,
        modelist,
12
        config,
Marco Mariani's avatar
Marco Mariani committed
13 14 15
        softwareDisplay = true,
        projectDir = $("input#project").val(),
        workdir = $("input#workdir").val(),
16
        currentProject = "workspace/" + projectDir.replace(workdir, "").split('/')[1],
Marco Mariani's avatar
Marco Mariani committed
17
        send = false,
18
        edit = false,
19
        ajaxResult = false,
20 21
        clipboardNode = null,
        pasteMode = null,
22
        selection = "",
Marco Mariani's avatar
Marco Mariani committed
23
        edit_status = "",
24 25
        current_file = null,
        favourite_list = new Array(),
26
        beforeunload_warning_set = false,
Marco Mariani's avatar
Marco Mariani committed
27
        base_path = function () {
28
            return softwareDisplay ? currentProject : 'runner_workdir/';
Marco Mariani's avatar
Marco Mariani committed
29
        };
30

31 32 33 34 35
    function openFile(file) {
        if (send) {
            return;
        }
        send = true;
Marco Mariani's avatar
Marco Mariani committed
36 37
        edit = false;
        if (file.substr(-1) !== "/") {
38
          var info = $("#edit_info").html();
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
          $("#edit_info").empty();
          $("#edit_info").append("LOADING FILE... <img src='"+$SCRIPT_ROOT+"/static/images/loading.gif' />");
          $.ajax({
            type: "POST",
            url: $SCRIPT_ROOT + '/getFileContent',
            data: {file: file},
            success: function (data) {
                var name, start, path = file;
                if (data.code === 1) {
                    $("#edit_info").empty();
                    name = file.split('/');
                    if (file.length > 75) {
                        //substring title.
                        start = file.length - 75;
                        path = "..." + file.substring(file.indexOf("/", (start + 1)));
Marco Mariani's avatar
Marco Mariani committed
54
                    }
55 56
                    $("#edit_info").append(" " + path);
                    editor.getSession().setValue(data.result);
57 58 59
                    var mode = modelist.getModeForPath(file);
                    editor.getSession().modeName = mode.name;
                    editor.getSession().setMode(mode.mode);
60 61
                    beforeunload_warning_set = false;
                    window.onbeforeunload = function() { return; };
62 63 64 65 66 67 68
                    edit = true;
                    current_file = file;
                    $("span#edit_status").html("");
                    edit_status = "";
                    setCookie("EDIT_CURRENT_FILE", file);
                } else {
                    $("#error").Popup(data.result, {type: 'error', duration: 5000});
69
                    $("#edit_info").html(info);
Marco Mariani's avatar
Marco Mariani committed
70
                }
71 72 73
                send = false;
            }
          });
Marco Mariani's avatar
Marco Mariani committed
74 75 76
        }
        return;
    }
77

Marco Mariani's avatar
Marco Mariani committed
78 79
    function switchContent() {
        if (!softwareDisplay) {
80
            $("span.swith_btn").empty();
81
            $("span.swith_btn").append("Working dir");
82 83
            $('#fileTreeFull').show();
            $('#fileTree').hide();
Marco Mariani's avatar
Marco Mariani committed
84
        } else {
85
            $("span.swith_btn").empty();
86
            $("span.swith_btn").append("This project");
87 88
            $('#fileTree').show();
            $('#fileTreeFull').hide();
Marco Mariani's avatar
Marco Mariani committed
89 90
        }
        $("#info").empty();
91
        $("#info").append("Current work tree: " + base_path());
92
        selection = "";
93 94
        clipboardNode = null;
        pasteMode = null;
Marco Mariani's avatar
Marco Mariani committed
95
    }
96

97
    function getmd5sum(path) {
Marco Mariani's avatar
Marco Mariani committed
98 99 100 101
        if (send) {
            return;
        }
        send = true;
102
        var filename;
103

Marco Mariani's avatar
Marco Mariani committed
104 105 106
        $.ajax({
            type: "POST",
            url: $SCRIPT_ROOT + '/getmd5sum',
107
            data: {file: path},
Marco Mariani's avatar
Marco Mariani committed
108 109
            success: function (data) {
                if (data.code === 1) {
110
                    filename = path.replace(/^.*(\\|\/|\:)/, '');
111
                    $("#info").empty();
112
                    $("#info").html("Md5sum for file [" + filename + "]: " + data.result);
Marco Mariani's avatar
Marco Mariani committed
113 114 115 116 117 118 119
                } else {
                    $("#error").Popup(data.result, {type: 'error', duration: 5000});
                }
                send = false;
            }
        });
    }
120

Marco Mariani's avatar
Marco Mariani committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    function setDevelop(developList) {
        if (developList === null || developList.length <= 0) {
            return;
        }
        editor.navigateFileStart();
        editor.find('buildout', {caseSensitive: true, wholeWord: true});
        if (!editor.getSelectionRange().isEmpty()) {
            //editor.find("",{caseSensitive: true,wholeWord: true,regExp: true});
            //if (!editor.getSelectionRange().isEmpty()) {
                    //alert("found");
            //}
            //else{alert("no found");
            //}
        } else {
            $("#error").Popup("Can not found part [buildout]! Please make sure that you have a cfg file", {type: 'alert', duration: 3000});
            return;
        }
        editor.navigateLineEnd();
        $.post($SCRIPT_ROOT + "/getPath", {file: developList.join("#")}, function (data) {
            var result, i;
            if (data.code === 1) {
                result = data.result.split('#');
                editor.insert("\ndevelop =\n\t" + result[0] + "\n");
                for (i = 1; i < result.length; i += 1) {
                    editor.insert("\t" + result[i] + "\n");
                }
            }
        })
            .error(function () {})
            .complete(function () {});
        editor.insert("\n");
152 153
        //Close popup
        $("#option").click();
Marco Mariani's avatar
Marco Mariani committed
154
    }
155

156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
    // --- Implement Cut/Copy/Paste --------------------------------------------

    function copyPaste(action, node) {
      switch( action ) {
        case "cut":
        case "copy":
          clipboardNode = node;
          pasteMode = action;
          break;
        case "paste":
          if( !clipboardNode ) {
            $("#error").Popup("Clipoard is empty. Make a copy first!", {type: 'alert', duration: 5000});
            break;
          }
          var dataForSend = {
            opt: 5,
            files: clipboardNode.data.path,
            dir: node.data.path
          };
          if( pasteMode == "cut" ) {
            // Cut mode: check for recursion and remove source
            dataForSend.opt = 7;
            var cb = clipboardNode.toDict(true);
179 180
            if( node.isDescendantOf(clipboardNode) ) {
              $("#error").Popup("ERROR: Cannot move a node to it's sub node.", {type: 'error', duration: 5000});
181 182
              return;
            }
183 184 185 186 187 188 189 190 191 192 193 194 195
            request = fileBrowserOp(dataForSend);
            request.always(function() {
              if (ajaxResult){
                if (node.isExpanded()){
                  node.addChildren(cb);
                  node.render();
                }
                else{
                  node.lazyLoad()
                }
                clipboardNode.remove();
              }
            });
196 197 198 199 200 201 202
          } else {
            if (node.key === clipboardNode.getParent().key){
              dataForSend = {opt: 14, filename: clipboardNode.title,
                              dir: node.data.path,
                              newfilename: clipboardNode.title
                            };
            }
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
            request = fileBrowserOp(dataForSend);
            request.always(function() {
              if (ajaxResult){
                // Copy mode: prevent duplicate keys:
                var cb = clipboardNode.toDict(true, function(dict){
                  delete dict.key; // Remove key, so a new one will be created
                });
                if (dataForSend.opt === 14){
                  node.lazyLoad(true);
                  node.toggleExpanded();
                }
                else if (node.isExpanded()){
                  node.addChildren(cb);
                  node.render();
                }
              }
219 220 221 222 223 224 225 226
            });
          }
          clipboardNode = pasteMode = null;
          break;
      }
    };

    function manageMenu (srcElement, menu){
227 228 229 230 231 232 233
      /*if (!srcElement.hasClass('fancytree-node')){
        menu.disableContextMenuItems("#edit,#editfull,#view,#md5sum,#refresh,#paste");
        return;
      }*/
      var node = $.ui.fancytree.getNode(srcElement);
      node.setFocus();
      node.setActive();
234
      if (srcElement.hasClass('fancytree-folder')){
235
        menu.disableContextMenuItems("#edit,#editfull,#view,#md5sum,#favorite");
236 237 238 239 240 241 242 243
      }
      else{
        menu.disableContextMenuItems("#nfile,#nfolder,#refresh,#paste");
      }
      return true;
    }

    function fileBrowserOp(data){
244 245 246 247 248 249 250 251 252 253

      ajaxResult = false;
      var jqxhr = $.ajax({
          type: "POST",
          url: $SCRIPT_ROOT + '/fileBrowser',
          data: data})
        .done(function(data) {
          if (data.indexOf("{result: '1'}") === -1) {
            var msg = (data === "{result: '0'}") ? "ERROR: Please check your file or folder location!" : data;
            $("#error").Popup("Error: " + msg, {type: 'error', duration: 5000});
254
          } else {
255
            $("#error").Popup("Operation complete!", {type: 'confirm', duration: 5000});
256
            ajaxResult = true;
257
          }
258 259
        })
        .fail(function(jqXHR, exception) {
260 261 262 263 264 265 266
          if (jqXHR.status == 404) {
              $("#error").Popup("Requested page not found. [404]", {type: 'error'});
          } else if (jqXHR.status == 500) {
              $("#error").Popup("Internal Error. Cannot respond to your request, please check your parameters", {type: 'error'});
          } else {
              $("#error").Popup("An Error occured: \n" + jqXHR.responseText, {type: 'error'});
          }
267 268 269 270 271
        })
        .always(function() {
          //return result;
        });
        return jqxhr;
272 273 274
    }

    // --- Contextmenu helper --------------------------------------------------
275
    function bindContextMenu(span) {
276
      // Add context menu to this node:
277
      var item = $(span).contextMenu({menu: "fileTreeMenu"}, function(action, el, pos) {
278 279 280 281
        // The event was bound to the <span> tag, but the node object
        // is stored in the parent <li> tag
        var node = $.ui.fancytree.getNode(el);
        var directory = encodeURIComponent(node.data.path.substring(0, node.data.path.lastIndexOf('/')) +"/");
282
        var request;
283 284 285 286 287 288 289 290 291 292
        switch( action ) {
        case "cut":
        case "copy":
        case "paste":
          copyPaste(action, node);
          break;
        case "edit": openFile(node.data.path); break;
        case "view":
          $.colorbox.remove();
          $.ajax({
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
            type: "POST",
            url: $SCRIPT_ROOT + '/fileBrowser',
            data: {opt: 9, filename: node.title, dir: directory},
            success: function (data) {
              $("#inline_content").empty();
        			$("#inline_content").append('<div class="main_content"><pre id="editorViewer"></pre></div>');
              viewer = ace.edit("editorViewer");
              viewer.setTheme("ace/theme/crimson_editor");

              var mode = modelist.getModeForPath(node.data.path);
              viewer.getSession().modeName = mode.name;
              viewer.getSession().setMode(mode.mode);
              viewer.getSession().setTabSize(2);
              viewer.getSession().setUseSoftTabs(true);
              viewer.renderer.setHScrollBarAlwaysVisible(false);
              viewer.setReadOnly(true);
        			$("#inlineViewer").colorbox({inline:true, width: "847px", onComplete:function(){
        				viewer.getSession().setValue(data);
        			}, title: "Content of file: " + node.title});
  			      $("#inlineViewer").click();
            }
          });
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
          break;
        case "editfull":
          var url = $SCRIPT_ROOT+"/editFile?profile="+encodeURIComponent(node.data.path)+"&filename="+encodeURIComponent(node.title);
          window.open(url, '_blank');
          window.focus();
          break;
        case "md5sum":
          getmd5sum(node.data.path);
          break;
        case "refresh":
          node.lazyLoad(true);
          node.toggleExpanded();
          break;
        case "nfolder":
          var newName = window.prompt('Please Enter the folder name: ');
          if (newName == null || newName.length < 1) {
              return;
          }
          var dataForSend = {
              opt: 3,
              filename: newName,
              dir: node.data.path
          };
338 339 340 341 342 343 344
          request = fileBrowserOp(dataForSend)
          request.always(function() {
            if (ajaxResult){
              node.lazyLoad(true);
              node.toggleExpanded();
            }
          });
345 346 347 348 349 350 351 352 353 354 355
          break;
        case "nfile":
          var newName = window.prompt('Please Enter the file name: ');
          if (newName == null || newName.length < 1) {
              return;
          }
          var dataForSend = {
              opt: 2,
              filename: newName,
              dir: node.data.path
          };
356 357 358 359 360 361 362
          request = fileBrowserOp(dataForSend)
          request.always(function() {
            if (ajaxResult){
              node.lazyLoad(true);
              node.toggleExpanded();
            }
          });
363 364 365 366 367 368 369 370 371 372
          break;
        case "delete":
          if(!window.confirm("Are you sure that you want to delete this item?")){
            return;
          }
          var dataForSend = {
              opt: 4,
              files: encodeURIComponent(node.title),
              dir: directory
          };
373 374 375 376 377 378
          request = fileBrowserOp(dataForSend)
          request.always(function() {
            if (ajaxResult){
              node.remove();
            }
          });
379 380 381 382 383 384 385 386 387 388 389 390
          break;
        case "rename":
          var newName = window.prompt('Please enter the new name: ', node.title);
          if (newName == null) {
              return;
          }
          dataForSend = {
              opt: 6,
              filename: node.data.path,
              dir: directory,
              newfilename: newName
          };
391 392 393 394 395 396 397 398
          request = fileBrowserOp(dataForSend);
          request.always(function() {
            if (ajaxResult){
              var copy = node.toDict(true, function(dict){
                dict.title = newName;
              });
              node.applyPatch(copy);
            }
399
          });
400 401 402 403

          break;
        case "favorite":
          addToFavourite(node.data.path);
404 405 406 407 408 409 410 411
          break;
        default:
          return;
        }
      }, manageMenu);
    };

    // --- Init fancytree during startup ----------------------------------------
412 413 414 415 416
    function initTree(tree, path, key){
      if (!key){
        key = '0';
      }
      $(tree).fancytree({
417 418 419 420 421 422 423 424 425 426
        activate: function(event, data) {
          var node = data.node;
        },
        click: function(event, data) {
          // Close menu on click
          if( $(".contextMenu:visible").length > 0 ){
            $(".contextMenu").hide();
  //          return false;
          }
        },
427 428 429 430 431
        dblclick: function(event, data) {
          if (!data.node.isFolder()){
            openFile(data.node.data.path);
          }
        },
432 433
        source: {
          url: $SCRIPT_ROOT + "/fileBrowser",
434
          data:{opt: 20, dir: path, key: key, listfiles: 'yes'},
435 436 437 438 439 440
          cache: false
        },
        lazyload: function(event, data) {
          var node = data.node;
          data.result = {
            url: $SCRIPT_ROOT + "/fileBrowser",
441
            data: {opt: 20, dir: node.data.path , key: node.key, listfiles: 'yes'}
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
          }
        },
        keydown: function(event, data) {
          var node = data.node;
          // Eat keyboard events, when a menu is open
          if( $(".contextMenu:visible").length > 0 )
            return false;

          switch( event.which ) {

          // Open context menu on [Space] key (simulate right click)
          case 32: // [Space]
            $(node.span).trigger("mousedown", {
              preventDefault: true,
              button: 2
              })
            .trigger("mouseup", {
              preventDefault: true,
              pageX: node.span.offsetLeft,
              pageY: node.span.offsetTop,
              button: 2
              });
            return false;

          // Handle Ctrl-C, -X and -V
          case 67:
            if( event.ctrlKey ) { // Ctrl-C
              copyPaste("copy", node);
              return false;
            }
            break;
          case 86:
            if( event.ctrlKey ) { // Ctrl-V
              copyPaste("paste", node);
              return false;
            }
            break;
          case 88:
            if( event.ctrlKey ) { // Ctrl-X
              copyPaste("cut", node);
              return false;
            }
            break;
          }
        },
        createNode: function(event, data){
488
          bindContextMenu(data.node.span);
489 490
        }
      });
491
    }
492

493 494 495 496
    function openOnFavourite($elt){
      var index = parseInt($elt.attr('rel')),
          file = favourite_list[index];
      openFile(file);
497
      $("#filelist").click();
498 499 500 501 502 503 504 505 506 507
    }

    function removeFavourite($elt){
      var index = parseInt($elt.attr('rel'));
      favourite_list.splice(index, 1);
      $elt.parent().remove();
      $('#tooltip-filelist ul li[rel="'+index+'"]').remove();
      if (favourite_list.length === 0){
        $("#tooltip-filelist ul").append("<li>Your favourites files list is <br/>empty for the moment!</li>");
      }
508 509 510 511 512 513 514 515 516 517 518
      else{
        var i = 0;
        $("#tooltip-filelist ul li").each(function(){
          $(this).attr('rel', i);
          //Change attribute rel of all children!!
          $(this).children().each(function(){
            $(this).attr('rel', i);
          });
          i++;
        });
      }
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
      deleteCookie("FAV_FILE_LIST");
      setCookie("FAV_FILE_LIST", favourite_list.join('#'));
    }

    function initEditor(){
      var tmp, filename;
      current_file = getCookie("EDIT_CURRENT_FILE");
      if (current_file) {
          openFile(current_file);
      }
      tmp = getCookie("FAV_FILE_LIST");
      if(tmp){
        favourite_list = tmp.split('#');
        if (favourite_list.length !== 0){
          $("#tooltip-filelist ul").empty();
        }
        for (var i=0; i<favourite_list.length; i++){
          filename = favourite_list[i].replace(/^.*(\\|\/|\:)/, '');
          $("#tooltip-filelist ul").append('<li rel="'+i+
                    '"><span class="bt_close" title="Remove this element!" rel="'+i+
539 540
                    '">×</span><a href="#" rel="'+i+'" title="' + favourite_list[i]
                    + '">'+ filename +'</a></li>');
541 542 543 544 545 546 547 548 549 550 551 552 553 554
        }
      }
      //Click on favorite file in list to open it!
      $("#tooltip-filelist ul li a").click(function(){
        openOnFavourite($(this));
        return false;
      });
      //Remove favorite file in list
      $("#tooltip-filelist ul li span").click(function(){
        removeFavourite($(this));
        return false;
      });
    }

555
    function addToFavourite(filepath){
556 557 558
      if (! filepath ) {
        return;
      }
559
      var i = favourite_list.length,
560
          filename = filepath.replace(/^.*(\\|\/|\:)/, '');
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
      if (i === 0){
        $("#tooltip-filelist ul").empty();
      }
      if (favourite_list.indexOf(filepath) !== -1){
        $("#error").Popup("<b>Duplicate item!</b><br/>This files already exist in your favourite list", {type: 'alert', duration: 5000});
      }
      else{
        favourite_list.push(filepath);
        $("#tooltip-filelist ul").append('<li rel="'+i+
                    '"><span class="bt_close" title="Remove this element!" rel="'+i+
                    '">×</span><a href="#" rel="'+i+'" title="' + filepath
                    + '">'+ filename +'</a></li>');
        deleteCookie("FAV_FILE_LIST");
        setCookie("FAV_FILE_LIST", favourite_list.join('#'));
        $("#tooltip-filelist ul li a[rel='"+i+"']").bind('click', function() {
          openOnFavourite($(this));
          return false;
        });
        $("#tooltip-filelist ul li span[rel='"+i+"']").click(function(){
          removeFavourite($(this));
          return false;
        });
        $("#error").Popup("<b>Item added!</b><br/>"+filename+" has been added to your favourite list.", {type: 'confirm', duration: 3000});
      }
    }

Marco Mariani's avatar
Marco Mariani committed
587 588


589 590
    editor = ace.edit("editor");
    modelist = require("ace/ext/modelist");
591
    ace.require("ace/ext/language_tools");
592
    config = require("ace/config");
593

594 595
    editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true });

596 597
    editor.setTheme("ace/theme/crimson_editor");
    editor.getSession().setMode("ace/mode/text");
Marco Mariani's avatar
Marco Mariani committed
598 599 600 601
    editor.getSession().setTabSize(2);
    editor.getSession().setUseSoftTabs(true);
    editor.renderer.setHScrollBarAlwaysVisible(false);

602
    initTree('#fileTree', currentProject, 'pfolder');
603
    initTree('#fileTreeFull', 'runner_workdir');
604
    //bindContextMenu('#fileTree');
605
    $("#info").append("Current work tree: " + base_path());
606

607
    initEditor();
608

609 610 611
    $("#option").Tooltip();
    $("#filelist").Tooltip();

612 613 614 615
    editor.on("change", function (e) {
        if (edit_status === "" && edit) {
            $("span#edit_status").html("*");
        }
616 617 618 619 620 621
        if (!beforeunload_warning_set) {
            window.onbeforeunload = function() { return "You have unsaved changes"; };
            beforeunload_warning_set = true;
        }
    });

622 623 624 625 626 627 628 629
    editor.commands.addCommand({
      name: 'myCommand',
      bindKey: {win: 'Ctrl-S',  mac: 'Command-S'},
      exec: function(editor) {
        $("#save").click();
      },
      readOnly: false // false if this command should not apply in readOnly mode
    });
630

631 632 633 634
    editor.commands.addCommand({
      name: 'Fullscreen',
      bindKey: {win: 'Ctrl-E',  mac: 'Command-E'},
      exec: function(editor) {
635
          $("#fullscreen").click();
636 637 638
      }
    });

Marco Mariani's avatar
Marco Mariani committed
639
    $("#save").click(function () {
640 641
        beforeunload_warning_set = false;
        window.onbeforeunload = function() { return; };
Marco Mariani's avatar
Marco Mariani committed
642 643 644 645 646 647 648 649 650 651 652 653
        if (!edit) {
            $("#error").Popup("Please select the file to edit", {type: 'alert', duration: 3000});
            return false;
        }
        if (send) {
            return false;
        }
        send = true;
        $.ajax({
            type: "POST",
            url: $SCRIPT_ROOT + '/saveFileContent',
            data: {
654
                file: current_file,
Marco Mariani's avatar
Marco Mariani committed
655 656 657 658 659
                content: editor.getSession().getValue()
            },
            success: function (data) {
                if (data.code === 1) {
                    $("#error").Popup("File saved succefuly!", {type: 'confirm', duration: 3000});
660
                    $("span#edit_status").html("");
Marco Mariani's avatar
Marco Mariani committed
661 662 663 664 665 666 667 668 669
                } else {
                    $("#error").Popup(data.result, {type: 'error', duration: 5000});
                }
                send = false;
            }
        });
        return false;
    });

670
    /*$("#details_head").click(function () {
Marco Mariani's avatar
Marco Mariani committed
671
        setDetailBox();
672
    });*/
Marco Mariani's avatar
Marco Mariani committed
673 674 675 676 677 678 679

    $("#switch").click(function () {
        softwareDisplay = !softwareDisplay;
        switchContent();
        return false;
    });
    $("#getmd5").click(function () {
680
        getmd5sum(current_file);
681
        $("#option").click();
Marco Mariani's avatar
Marco Mariani committed
682 683 684 685
        return false;
    });

    $("#clearselect").click(function () {
686
        edit = false;
Marco Mariani's avatar
Marco Mariani committed
687
        $("#info").empty();
688
        $("#info").append("Current work tree: " + base_path());
Marco Mariani's avatar
Marco Mariani committed
689
        $("#edit_info").empty();
690
        $("#edit_info").append("No file in editor");
Marco Mariani's avatar
Marco Mariani committed
691 692
        editor.getSession().setValue("");
        $("a#option").hide();
693
        selection = "";
Marco Mariani's avatar
Marco Mariani committed
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
        return false;
    });
    $("#adddevelop").click(function () {
        var developList = [],
            i = 0;
        $("#plist li").each(function (index) {
            var elt = $(this).find("input:checkbox");
            if (elt.is(":checked")) {
                developList[i] = workdir + "/" + elt.val();
                i += 1;
                elt.attr("checked", false);
            }
        });
        if (developList.length > 0) {
            setDevelop(developList);
        }
        return false;
    });
712
    $("a#addflist").click(function(){
713 714
      addToFavourite(current_file);
      $("#option").click();
715 716
      return false;
    });
Marco Mariani's avatar
Marco Mariani committed
717

718 719 720 721 722 723 724 725 726 727 728 729
    $("a#find").click(function(){
      config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
      $("#option").click();
      return false;
    });

    $("a#replace").click(function(){
      config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
      $("#option").click();
      return false;
    });

730 731 732 733 734
    $("#fullscreen").click(function(){                                                                   
          $("body").toggleClass("fullScreen");
          $("#editor").toggleClass("fullScreen-editor");                                                 
          editor.resize();
    });
Marco Mariani's avatar
Marco Mariani committed
735 736

});