- Timestamp:
- Aug 24, 2019 10:26:26 PM (6 years ago)
- Location:
- branches/testa
- Files:
-
- 5 edited
-
index.php (modified) (4 diffs)
-
js/main.js (modified) (4 diffs)
-
js/tab.js (modified) (1 diff)
-
js/topmenu.js (modified) (1 diff)
-
php/content.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa/index.php
r25 r27 18 18 <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> 19 19 <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js"></script> 20 <script src="js/storage.js?0"></script> 21 <script src="js/remote.js?9"></script> 22 <script src="js/menux.js?9"></script> 20 <!-- <script src="js/storage.js?0"></script> --> 21 <script src="js/storagex.js?1"></script> 22 <!-- <script src="js/remote.js?9"></script> --> 23 <!-- <script src="js/menux.js?0"></script> --> 24 <script src="js/sidemenu.js?1"></script> 23 25 <script src="js/bookmark.js?0>"></script> 24 26 <script src="js/bookmarkmgr.js?9"></script> 27 <script src="js/bookmarkmenu.js?1"></script> 25 28 <script src="js/tab.js?9"></script> 26 29 <script src="js/topmenu.js?2"></script> 27 <script src="js/main.js?9"></script> 30 31 <script src="js/remotex.js?2"></script> 32 <script src="js/main.js?1"></script> 28 33 29 34 <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.ui-contextmenu/1.18.1/jquery.ui-contextmenu.min.js" integrity="sha256-cI6Q7epHX696CtqUt0dJouTIkNh0w67o5YOhUZygI/s=" crossorigin="anonymous"></script> --> … … 77 82 <li><a href="#">config</a> 78 83 <ul> 79 <li><a href="#" onclick=" save_info_from_globalx()">Save info</a></li>80 <li><a href="#" onclick=" reset_info()">Reset Info</a></li>81 <li><a href="#" onclick=" clear_localstorage()">Clear local</a></li>84 <li><a href="#" onclick="Globalx.storagex.save_info_from_globalx()">Save info</a></li> 85 <li><a href="#" onclick="Globalx.storagex.reset_info()">Reset Info</a></li> 86 <li><a href="#" onclick="Globalx.storagex.clear_localstorage()">Clear local</a></li> 82 87 </ul> 83 88 </li> … … 105 110 <div id="area-output" class="panel"> 106 111 <div id="output-menubar"></div> 112 <ul class="nav"> 113 <li><a href="#">File</a> 114 <ul> 115 <li><a onclick="upload_to_host('data')">Save on host</a></li> 116 <li><a onclick="download_cmd('part')">Download</a></li> 117 <li><a class="disabled" >-Rename</a></li> 118 <li><a class="disabled" >-Move</a></li> 119 <li><a class="disabled" >-Delete</a></li> 120 <li><a class="disabled" >-Duplicate</a></li> 121 </ul> 122 </li> 123 </ul> 107 124 <div id="output-bar"> 108 125 <textarea id="output-editor" name="output-editor"></textarea> 109 126 </div> 110 <div id="output-side"> output</div>127 <div id="output-side"></div> 111 128 <div id="output-work"> 112 129 <div id="output-editor"></div> … … 118 135 <textarea id="setting-editor" name="setting-editor"></textarea> 119 136 </div> 120 <div id="setting-side"> setting</div>137 <div id="setting-side"></div> 121 138 <div id="setting-work"> 122 139 <div id="setting-editor"></div> -
branches/testa/js/main.js
r25 r27 6 6 }; 7 7 8 function main() { 9 restore_info_to_globalx() 8 function init_globalx_storagex() { 9 Globalx.storagex = new Storagex(); 10 } 10 11 11 editor_func("data"); 12 make_ul_for_menu('data' , '#data-side') 13 menux( "data" ) 14 15 editor_func("setting"); 16 make_ul_for_menu("setting" , '#setting-side') 17 18 editor_func("output"); 19 make_ul_for_menu("output" , '#output-side') 12 function init_globalx() { 13 Globalx.num = 0; 14 Globalx.index = 0; 15 Globalx.parts = ["data", "output", "setting"] 16 Globalx.bookmark_displayname_max_length = 18 20 17 21 18 tab_init() 22 19 topmenu_init() 20 Globalx.remotex = new Remotex('php/content.php') 21 } 23 22 24 rebuild_bookmark_menu("data") 23 function menu_action(part, item_name , up_flag = false) { 24 //console.log("menu_action 1") 25 Globalx[part].sidemenu.menu_action(item_name , up_flag) 26 //console.log("menu_action 2") 27 } 25 28 26 // LocalStorageにまだ保存していない場合を想定して、ここで保存しておく 27 console.log("call save_info_from_globalx()") 28 save_info_from_globalx() 29 function main() { 30 init_globalx_storagex() 29 31 30 part = "data" 31 $('#down-download').on('click', {part: part}, handleDownload) 32 $( Globalx['data'].textarea_sel ).val(""); 33 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx[part].bookmark_displayname_max_length) 32 let need_to_save = Globalx.storagex.restore_globalx_from_info() 33 init_globalx() 34 35 Globalx.parts.map( ( part ) => { 36 set_globalx_editor(part) 37 Globalx[ part ].bookmarkmenu = new BookmarkMenu( Globalx.num, part ) 38 Globalx[ part ].sidemenu = new SideMenu( Globalx.num, part ) 39 Globalx[ part ].sidemenu.setup(`#${part}-side`) 40 Globalx[ part ].bookmarkmenu.set_click_handler() 41 Globalx[ part ].bookmarkmenu.rebuild_bookmark_menu(part) 42 43 $( Globalx[ part ].download_sel ).on('click', {num: Globalx.num, part: part}, handleDownload) 44 $( Globalx[ part ].textarea_sel ).val(""); 45 } ) 46 /* 47 Globalx.parts.map( (part) => { 48 Globalx[ part ].sidemenu.setup(`#${part}-side`) 49 Globalx[ part ].bookmarkmenu.rebuild_bookmark_menu(part) 50 51 $( Globalx[part].download_sel ).on('click', {num: Globalx.num, part: part}, handleDownload) 52 $( Globalx[part].textarea_sel ).val(""); 53 } 54 */ 55 if( need_to_save ){ 56 // LocalStorageにまだ保存していない場合、ここで保存しておく 57 //console.log("call save_as_info_from_globalx()") 58 Globalx.storagex.save_as_info_from_globalx( (data) => { console.log( "data=" + data ) } ) 59 } 60 61 let part = "data" 62 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx.bookmark_displayname_max_length) 34 63 $('#bookmarkDlg').dialog({ 35 64 autoOpen: false, … … 50 79 } 51 80 52 function init_globalx() {53 Globalx.num = 0;54 Globalx.index = 0;55 Globalx.parts = ["data", "output", "setting"]56 57 Globalx.parts.map( function( part ){58 console.log("init_globalx part=" + part )59 set_globalx_editor(part)60 } )61 }62 81 63 82 function set_globalx_editor(part) { … … 73 92 /**/ 74 93 bookmarks: [], 75 bookmark_displayname_max_length: 18,76 94 key_indicate_file: false, 77 95 key: '/', 78 96 key_sel: `#${part}-filelist_key`, 79 download_sel: `#${part}-down load_sel`97 download_sel: `#${part}-down-download` 80 98 } 99 editor_config(part); 100 81 101 Globalx[part].menu_sel = `#${Globalx[part].menu_id}` 82 102 Globalx[part].bookmark_sel = `#${Globalx[part].bookmark_id}` 83 103 Globalx[part].bookmark_op_sel = `#${Globalx[part].bookmark_op_id}` 84 Globalx[part].bookmark_mgr = new BookmarkMgr( Globalx[part].bookmark_displayname_max_length ) 85 104 Globalx[part].bookmark_mgr = new BookmarkMgr( Globalx.bookmark_displayname_max_length ) 86 105 } 87 106 88 function editor_ func(part) {107 function editor_config(part) { 89 108 let editor = ace.edit( Globalx[part].editor_id ) 90 109 editor.setTheme("ace/theme/monokai"); … … 100 119 }); 101 120 } 102 -
branches/testa/js/tab.js
r25 r27 10 10 // クリックしたタブと同じインデックス番号をもつコンテンツを表示 11 11 $('.panel').eq(index).addClass('is-show'); 12 console.log("tab index="+index ) 12 13 }) 13 14 } -
branches/testa/js/topmenu.js
r25 r27 1 function topmenu_init0() {2 const nav = $('.nav');3 $('li', nav)4 .mouseover(function(e) {5 $('ul', this).stop().slideDown('fast');6 })7 .mouseout(function(e) {8 $('ul', this).stop().slideUp('fast');9 })10 }11 1 function topmenu_init() { 12 2 const nav = $('.nav'); -
branches/testa/php/content.php
r25 r27 12 12 function get_url_data_array() 13 13 { 14 $yaml= spyc_load_file( dirname(__FILE__) . "/../settings.yml");// ☆の部分にはyamlファイルがあるパスを入れます15 return $yaml;14 $yaml= spyc_load_file( dirname(__FILE__) . "/../settings.yml");// ☆の部分にはyamlファイルがあるパスを入れます 15 return $yaml; 16 16 } 17 17 … … 33 33 } 34 34 35 function get_path_from_url_data( $num ){ 36 return get_url_data( $num )['path']; 37 } 38 39 function get_path_list_by_url( $num ){ 40 $pattern = "*.md"; 41 $top_path = get_path_from_url_data($num); 42 $cmd_line_items = array("find" , $top_path , "-name", $pattern); 35 function get_path_from_url_data( $num , $part){ 36 switch($part){ 37 case 'data': 38 $ret = get_url_data( $num )['path']; 39 break; 40 case 'setting': 41 $ret = get_url_data( $num )['setting_path']; 42 break; 43 case 'output': 44 $ret = get_url_data( $num )['output_path']; 45 break; 46 default: 47 //exit(200); 48 echo "get_path_from_url_data " . $part . "<br>"; 49 } 50 51 return $ret; 52 } 53 54 function get_path_list_by_url( $num , $part){ 55 $top_path = get_path_from_url_data($num, $part); 56 57 switch($part){ 58 case 'data': 59 $pattern = "*.md"; 60 $cmd_line_items = array("find" , $top_path , "-name", $pattern); 61 break; 62 case 'setting': 63 $cmd_line_items = array("find" , $top_path , "-type", "f"); 64 break; 65 default: 66 echo "get_path_list_by_url=" . $part . "<br>"; 67 exit(100); 68 } 43 69 $cmd_line = implode(" " , $cmd_line_items); 44 70 … … 67 93 } 68 94 echo $v . "||(" . strlen($v) . ")\n"; 69 }95 } 70 96 } 71 97 … … 81 107 } 82 108 83 function get_path_info( $num ){84 $path_info = get_path_list_by_url( $num );109 function get_path_info( $num , $part){ 110 $path_info = get_path_list_by_url( $num , $part); 85 111 $pathinfo = new ns\PathInfo($path_info["top_path"]); 86 # $pathinfo = new PathInfo($path_info["top_path"]);87 112 foreach($path_info["file_list"] as $path){ 88 113 $pathinfo->register($path); 89 114 } 90 115 return $pathinfo->pathinfo_list_in_json(); 91 # $pathinfo->dump(); 92 # $pathinfo->dump_root(); 93 # dump_hier_list($pathinfo); 94 } 95 96 function print_get_path_info( $num ){ 97 echo get_path_info( $num ); 116 } 117 118 function get_setting_path_info( $num ){ 119 $path_info = get_setting_path_list_by_url( $num ); 120 $pathinfo = new ns\PathInfo($path_info["top_path"]); 121 foreach($path_info["file_list"] as $path){ 122 $pathinfo->register($path); 123 } 124 return $pathinfo->pathinfo_list_in_json(); 125 } 126 127 function print_get_path_info( $num ,$part){ 128 echo get_path_info( $num , $part); 129 } 130 131 function print_get_setting_path_info( $num ){ 132 echo get_setting_path_info( $num ); 98 133 } 99 134 … … 113 148 } 114 149 115 function get_content( $num , $path ) {116 $top_dir = get_path_from_url_data( $num );150 function get_content( $num , $path , $part) { 151 $top_dir = get_path_from_url_data( $num , $part); 117 152 $full_path = implode( '/', [$top_dir, $path]); 118 153 $result = input_file( $full_path ); … … 121 156 122 157 function cmdx(){ 123 $filelist_filename = "filelist.json"; 124 $setting_filelist_filename = "setting-filelist.json"; 158 $filelist_filename = array("data"=> "filelist.json", "setting"=> "setting-filelist.json"); 125 159 $storage_dir = dirname(__FILE__) . '/../storage'; 126 160 … … 130 164 if (isset($_GET['num'])) { 131 165 $num = $_GET['num']; 132 133 switch ($cmd) { 134 case 'get_setting_filelist': 135 $path = ensure_storage_dir( $storage_dir , $num, $setting_filelist_filename ); 136 if( file_exists($path) ){ 137 $content = input_file( $path ); 166 if (isset($_GET['part'])) { 167 $part = $_GET['part']; 168 169 switch ($cmd) { 170 case 'update_setting_filelist': 171 $path = ensure_storage_dir( $storage_dir , $num, $setting_filelist_filename ); 172 $content = get_setting_path_info( $num ); 173 output_file( $path , $content ); 174 break; 175 case 'get_setting_filelist': 176 $path = ensure_storage_dir( $storage_dir , $num, $setting_filelist_filename ); 177 if( file_exists($path) ){ 178 $content = input_file( $path ); 179 } 180 else { 181 $content = get_setting_path_info( $num ); 182 output_file( $path , $content ); 183 } 184 break; 185 case 'get_setting_content': 186 if (isset($_GET['path'])) { 187 $path = $_GET['path']; 188 $content = get_setting_content( $num , $path ); 189 } 190 break; 191 case 'build': 192 break; 193 case 'get_content': 194 if (isset($_GET['path'])) { 195 $path = $_GET['path']; 196 $content = get_content( $num , $path , $part ); 197 } 198 break; 199 case 'update_filelistx': 200 $path = ensure_storage_dir( $storage_dir , $num, $filelist_filename[$part] ); 201 $content = get_path_info( $num , $part); 202 output_file( $path , $content ); 203 break; 204 case 'get_filelistx': 205 $path = ensure_storage_dir( $storage_dir , $num, $filelist_filename[$part] ); 206 if( file_exists($path) ){ 207 $content = input_file( $path ); 208 } 209 else { 210 $content = get_path_info( $num , $part); 211 output_file( $path , $content ); 212 } 213 break; 214 default: 215 break; 138 216 } 139 else {140 $content = get_path_info( $num );141 output_file( $path , $content );142 }143 break;144 case 'build':145 break;146 case 'get_content':147 if (isset($_GET['path'])) {148 $path = $_GET['path'];149 $content = get_content( $num , $path );150 }151 break;152 case 'update_filelist':153 $path = ensure_storage_dir( $storage_dir , $num, $filelist_filename );154 $content = get_path_info( $num );155 output_file( $path , $content );156 break;157 case 'get_filelist':158 $path = ensure_storage_dir( $storage_dir , $num, $filelist_filename );159 if( file_exists($path) ){160 $content = input_file( $path );161 }162 else {163 $content = get_path_info( $num );164 output_file( $path , $content );165 }166 break;167 default:168 break;169 217 } 170 218 } 171 219 } 220 172 221 elseif (isset($_POST['cmd'])) { 173 222 $cmd = $_POST['cmd']; 174 223 if (isset($_POST['num'])) { 175 224 $num = $_POST['num']; 176 177 switch ($cmd) { 178 case 'upload_content': 179 $array = get_lines_from_formdata( "mytext" ); 180 $upload_content = implode( "\n" , $array ); 181 if (isset($_POST['path'])) { 182 $path = $_POST['path']; 183 $top_path = get_path_from_url_data( $num ); 184 $filename_abs_path = $top_path . DIRECTORY_SEPARATOR . $path; 185 186 output_file( $filename_abs_path , $upload_content ); 187 $content = "P-UPLOAD_CONTENT-OK=" . $filename_abs_path; 225 if (isset($_POST['part'])) { 226 $part = $_POST['part']; 227 228 229 switch ($cmd) { 230 case 'upload_content': 231 $array = get_lines_from_formdata( "mytext" ); 232 $upload_content = implode( "\n" , $array ); 233 if (isset($_POST['path'])) { 234 $path = $_POST['path']; 235 $top_path = get_path_from_url_data( $num , $part); 236 $filename_abs_path = $top_path . DIRECTORY_SEPARATOR . $path; 237 238 output_file( $filename_abs_path , $upload_content ); 239 $content = "P-UPLOAD_CONTENT-OK=" . $filename_abs_path; 240 } 241 else{ 242 $content = "P-UPLOAD_CONTENT-NO-PATH"; 243 } 244 245 default: 246 debug_x("P-DEFAULT"); 247 /* $content = "P-DEFAULT";*/ 248 break; 188 249 } 189 else{190 $content = "P-UPLOAD_CONTENT-NO-PATH";191 }192 193 default:194 debug_x("P-DEFAULT");195 /* $content = "P-DEFAULT";*/196 break;197 250 } 198 251 } … … 221 274 #print_get_path_info( 0 ); 222 275 #print_get_path_info( 1 ); 276 #dump_url_data( 0 ); 277 #echo( get_setting_path_from_url_data( 0 ) ); 278 #var_dump( get_setting_path_list_by_url( 0 ) ); 279 #echo( get_setting_path_info( 0 ) ); 280 #print_get_setting_path_info( 0 ); 281 223 282 cmdx(); 224 283
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)