@@ -2,14 +2,14 @@ var myName;
22var  otI ; 
33var  state ; 
44      function  createFileUploader ( element ,  tree ,  editor )  { 
5-         function  addButton ( name , fn ) { 
6-           $ ( element ) . append ( $ ( '<button>' ) . addClass ( 'btn btn-sm m-1' ) . text ( name ) . on ( 'click' , fn ) ) ; 
5+         function  addButton ( name ,   fn ,   title )   { 
6+           $ ( element ) . append ( $ ( '<button>' ) . addClass ( 'btn btn-sm m-1' ) . text ( name ) . on ( 'click' ,   fn ) . attr ( 'title' ,   title ) ) ; 
77        } 
88//        addButton('<<',function(e){ $('.jstree').toggle(); }); 
99//        addButton('A',function(e){ toggleFullScreen(); }); 
1010//        addButton('Save',function(e){ editor.execCommand("saveCommand") }); 
11-         addButton ( 'next' , function ( e ) {  editor . execCommand ( "nextDiff" )  } ) ; 
12-         addButton ( 'prev' , function ( e ) {  editor . execCommand ( "prevDiff" )  } ) ; 
11+         addButton ( 'next' , function ( e ) {  editor . execCommand ( "nextDiff" )  } ,   'seek for next diff' ) ; 
12+         addButton ( 'prev' , function ( e ) {  editor . execCommand ( "prevDiff" )  } ,   'seek for previous diff' ) ; 
1313        addButton ( '{}' ,  function ( e )  { 
1414          if  ( ! editor . getSelectedText ( ) )  return ; 
1515          var  beautify  =  ace . require ( "ace/ext/beautify" ) ;  // get reference to extension 
@@ -22,10 +22,29 @@ var state;
2222          session . setValue ( val ) ; 
2323          beautify . beautify ( session ) ; 
2424          var  b  =  session . getValue ( ) ; 
25+           var  space  =  val . match ( / ^ \s + / ) ; 
26+           if  ( space ) 
27+             b  =  b . split ( / \r \n ? | \n / ) . map ( function ( line ) {  return  space [ 0 ]  +  line ; } ) . join ( '\n' ) ; 
2528          editor . session . doc . replace ( range ,  b ) ; 
2629          editor . _signal ( "change" ,  { } ) ; 
27-         } ) ; 
28-         addButton ( 'NAME' , function ( e ) {  myName  =  prompt ( 'Tell Ur Name!!!' ) ;  otI . setName ( myName ) ;  } ) ; 
30+         } ,  'beauitify JS code' ) ; 
31+         addButton ( 'NAME' , function ( e ) { 
32+           if ( isElectron ( ) )  { 
33+             var  d  =  vex . dialog . prompt ( { 
34+               message : 'Tell Ur Name!!!' , 
35+               placeholder : 'name' , 
36+               callback : function  ( value )  { 
37+                 if ( value ) 
38+                   otI . setName ( myName  =  value ) ; 
39+               } 
40+             } ) 
41+             $ ( d . contentEl ) . find ( 'input' ) . val ( myName ) ; 
42+           }  else  { 
43+             var  value  =  prompt ( 'Tell Ur Name!!!' ,  myName ) ; 
44+             if ( value ) 
45+               otI . setName ( myName  =  value ) ; 
46+           } 
47+         } ,  'set Your name for collaborative editing' ) ; 
2948        addButton ( 'undo' , function ( e ) {  editor . getSession ( ) . getUndoManager ( ) . undo ( false ) ;  } ) ; 
3049        $ ( element ) . append ( state  =  $ ( '<span class="m-1">Loading...</span>' ) ) ; 
3150      } 
@@ -180,7 +199,7 @@ if(0)
180199      } 
181200
182201$ ( function ( ) { 
183-         $ ( window ) . on ( 'beforeunload' , function ( )  {  return  "Realy?" ;  } ) ; 
202+ //         $(window).on('beforeunload',function() { return "Realy?"; });
184203        var  vars  =  { } ; 
185204        var  parts  =  window . location . href . replace ( / [ ? & ] + ( [ ^ = & ] + ) = ( [ ^ & ] * ) / gi,  function ( m , key , value )  {  vars [ key ]  =  value ;  } ) ; 
186205        var  editor  =  createEditor ( "editor" ,  vars . file ,  vars . lang ,  vars . theme ) ; 
0 commit comments