unageanu-jiji 1.1.4 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -1
- data/README +0 -0
- data/base/shared_lib/moving_average.rb +34 -33
- data/base/shared_lib/system/cross.rb +76 -0
- data/base/shared_lib/system/position_manager.rb +160 -0
- data/base/shared_lib/system/signal.rb +347 -0
- data/html/css/datatable.css +4 -4
- data/html/css/default.css +57 -5
- data/html/css/treeview.css +205 -0
- data/html/img/bin_closed.png +0 -0
- data/html/img/bin_empty.png +0 -0
- data/html/img/button_add_small.gif +0 -0
- data/html/img/button_add_small_gray.gif +0 -0
- data/html/img/button_add_small_over.gif +0 -0
- data/html/img/button_mkcol.gif +0 -0
- data/html/img/button_mkcol_gray.gif +0 -0
- data/html/img/button_mkcol_over.gif +0 -0
- data/html/img/button_remove_small.gif +0 -0
- data/html/img/button_remove_small_gray.gif +0 -0
- data/html/img/button_remove_small_over.gif +0 -0
- data/html/img/button_rename.gif +0 -0
- data/html/img/button_rename_gray.gif +0 -0
- data/html/img/button_rename_over.gif +0 -0
- data/html/img/control_play.png +0 -0
- data/html/img/control_play_blue.png +0 -0
- data/html/img/folder.png +0 -0
- data/html/img/folder_brick.png +0 -0
- data/html/img/folder_user.png +0 -0
- data/html/{js/codepress/images → img}/line-numbers.png +0 -0
- data/html/img/page_white_ruby.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/yui/treeview-sprite.gif +0 -0
- data/html/index.html +34 -18
- data/html/js/agent-editor/agent-editor-page.js +324 -0
- data/html/js/agent-editor/agent-editor.js +363 -0
- data/html/js/agent-editor/agent-list-tree.js +251 -0
- data/html/js/agent-selector.js +23 -28
- data/html/js/app.js +63 -91
- data/html/js/bt-create-page.js +25 -19
- data/html/js/container-min.js +1 -1
- data/html/js/container.js +944 -0
- data/html/js/edit_area/autocompletion.js +11 -13
- data/html/js/edit_area/edit_area.css +79 -40
- data/html/js/edit_area/edit_area.js +255 -226
- data/html/js/edit_area/edit_area_compressor.php +4 -4
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +31 -31
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +31 -31
- data/html/js/edit_area/edit_area_functions.js +448 -341
- data/html/js/edit_area/edit_area_loader.js +409 -397
- data/html/js/edit_area/elements_functions.js +120 -123
- data/html/js/edit_area/highlight.js +305 -197
- data/html/js/edit_area/images/goto.png +0 -0
- data/html/js/edit_area/images/help.png +0 -0
- data/html/js/edit_area/images/redo.png +0 -0
- data/html/js/edit_area/images/save.png +0 -0
- data/html/js/edit_area/images/search.png +0 -0
- data/html/js/edit_area/images/undo.png +0 -0
- data/html/js/edit_area/images/word_wrap.gif +0 -0
- data/html/js/edit_area/keyboard.js +5 -5
- data/html/js/edit_area/langs/bg.js +73 -0
- data/html/js/edit_area/langs/cs.js +2 -0
- data/html/js/edit_area/langs/de.js +2 -0
- data/html/js/edit_area/langs/dk.js +2 -0
- data/html/js/edit_area/langs/en.js +2 -0
- data/html/js/edit_area/langs/eo.js +2 -0
- data/html/js/edit_area/langs/es.js +2 -0
- data/html/js/edit_area/langs/fi.js +67 -0
- data/html/js/edit_area/langs/fr.js +2 -0
- data/html/js/edit_area/langs/hr.js +2 -0
- data/html/js/edit_area/langs/it.js +2 -0
- data/html/js/edit_area/langs/ja.js +2 -0
- data/html/js/edit_area/langs/mk.js +2 -0
- data/html/js/edit_area/langs/nl.js +2 -0
- data/html/js/edit_area/langs/pl.js +2 -0
- data/html/js/edit_area/langs/pt.js +2 -0
- data/html/js/edit_area/langs/ru.js +2 -0
- data/html/js/edit_area/langs/sk.js +2 -0
- data/html/js/edit_area/langs/zh.js +67 -0
- data/html/js/edit_area/manage_area.js +362 -205
- data/html/js/edit_area/plugins/charmap/langs/bg.js +12 -0
- data/html/js/edit_area/plugins/charmap/langs/zh.js +6 -0
- data/html/js/edit_area/plugins/test/langs/bg.js +10 -0
- data/html/js/edit_area/plugins/test/langs/zh.js +4 -0
- data/html/js/edit_area/reg_syntax/java.js +56 -0
- data/html/js/edit_area/reg_syntax/ruby.js +9 -9
- data/html/js/edit_area/reg_syntax.js +15 -13
- data/html/js/edit_area/regexp.js +36 -32
- data/html/js/edit_area/resize_area.js +43 -47
- data/html/js/edit_area/search_replace.js +29 -29
- data/html/js/edit_area/template.html +6 -4
- data/html/js/json-broker-client.js +23 -17
- data/html/js/result-page.js +107 -57
- data/html/js/rt-setting-page.js +38 -15
- data/html/js/sidebar.js +41 -27
- data/html/js/templates.js +167 -32
- data/html/js/utils.js +143 -7
- data/html/js/yui/treeview.js +3671 -0
- data/html/swf/chart.swf +0 -0
- data/html/test/agent_editor_spec.js +815 -0
- data/html/test/index.html +40 -0
- data/html/test/jsspec/JSSpec.css +224 -0
- data/html/test/jsspec/JSSpec.js +1549 -0
- data/html/test/jsspec/diff_match_patch.js +1 -0
- data/html/test/utils_spec.js +111 -0
- data/lib/jiji/agent/agent.rb +69 -12
- data/lib/jiji/agent/agent_manager.rb +18 -12
- data/lib/jiji/agent/agent_registry.rb +35 -121
- data/lib/jiji/collector.rb +16 -6
- data/lib/jiji/command.rb +46 -5
- data/lib/jiji/dao/file_system_dao.rb +158 -0
- data/lib/jiji/dao/timed_data_dao.rb +2 -0
- data/lib/jiji/dao/trade_result_dao.rb +1 -1
- data/lib/jiji/error.rb +24 -8
- data/lib/jiji/migration/migrator1_2_0.rb +67 -0
- data/lib/jiji/models.rb +82 -24
- data/lib/jiji/operator.rb +55 -51
- data/lib/jiji/output.rb +85 -29
- data/lib/jiji/output_manager.rb +84 -0
- data/lib/jiji/plugin/embedded/single_click_client.rb +2 -2
- data/lib/jiji/plugin/securities_plugin.rb +0 -1
- data/lib/jiji/process.rb +229 -208
- data/lib/jiji/process_manager.rb +190 -96
- data/lib/jiji/registry.rb +87 -19
- data/lib/jiji/server.rb +1 -0
- data/lib/jiji/service/agent_service.rb +147 -48
- data/lib/jiji/service/output_service.rb +37 -17
- data/lib/jiji/service/process_service.rb +3 -5
- data/lib/jiji/service/trade_result_service.rb +4 -5
- data/lib/jiji/util/file_lock.rb +4 -4
- data/lib/jiji/util/include_proxy.rb +17 -0
- data/lib/jiji/util/json_broker.rb +6 -4
- data/lib/jiji/util/util.rb +1 -1
- data/swf/chart/fx/chart/Chart.as +7 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +15 -2
- data/test/ProcessTest/agents/foo.rb +10 -0
- data/test/ProcessTest/conf/configuration.yaml +3 -0
- data/test/agent/agent_tests.rb +10 -0
- data/test/agent/test_AgentManager.rb +28 -12
- data/test/agent/test_AgentRegistry.rb +194 -99
- data/test/agent/test_PeriodicallyAgent.rb +1 -2
- data/test/agent/test_Permitter.rb +1 -2
- data/test/all_tests.rb +7 -19
- data/test/dao/dao_tests.rb +9 -0
- data/test/dao/test_FileSystemDao.rb +431 -0
- data/test/dao/test_RateDao.rb +5 -7
- data/test/dao/test_TradeResultDao.rb +1 -2
- data/test/migration/migration_tests.rb +10 -0
- data/test/migration/migrator1_2_0test_data/basic/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/basic/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/basic/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/migrator1_2_0test_data/illegal_props/props.yaml +1 -0
- data/test/migration/migrator1_2_0test_data/no_outs/props.yaml +85 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/M2NlOTA2ODEtZDdlNi00NWU1LWIwNDQtMjBmODY2ZGNkNzBj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MDVhYzcxMjYtMGFlMS00Mzk0LWEyNmUtYjVjZjgwNDA0ZmE2/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/MzA1YTk0NDgtNzhjNi00NDk3LTk2NTktYzE1ZjBhNzdiYjNj/56e75YuV5bmz5Z2H57ea/meta.yaml +8 -0
- data/test/migration/migrator1_2_0test_data/no_props/out/YjRkOTI1MzEtZTM4MS00YjQwLTg1ZTQtMWFmZDRlNDUwMzBm/56e75YuV5bmz5Z2H57ea/meta.yaml +9 -0
- data/test/migration/test_Migrator.rb +1 -1
- data/test/migration/test_Migrator1_0_3.rb +1 -1
- data/test/migration/test_Migrator1_1_0.rb +1 -1
- data/test/migration/test_Migrator1_2_0.rb +94 -0
- data/test/plugin/embedded/test_SingleClickClient.rb +1 -2
- data/test/plugin/plugin_tests.rb +8 -0
- data/test/plugin/test_Loader.rb +1 -1
- data/test/shared/rate.csv +144 -0
- data/test/shared/shared_tests.rb +9 -0
- data/test/shared/test_Cross.rb +144 -0
- data/test/shared/test_PositionManager.rb +285 -0
- data/test/shared/test_Signal.rb +65 -0
- data/test/test_Output.rb +28 -21
- data/test/test_OutputManager.rb +162 -0
- data/test/test_Output_registry.rb +6 -17
- data/test/test_Process.rb +434 -222
- data/test/test_ProcessManager.rb +458 -101
- data/test/test_utils.rb +71 -8
- data/test/util/test_BlockToSession.rb +1 -2
- data/test/util/test_CSV.rb +1 -2
- data/test/util/test_SynchronizeInterceptor.rb +1 -2
- data/test/util/util_tests.rb +9 -0
- metadata +127 -47
- data/html/js/agent-editor-page.js +0 -440
- data/html/js/codepress/codepress.css +0 -21
- data/html/js/codepress/codepress.html +0 -35
- data/html/js/codepress/codepress.js +0 -138
- data/html/js/codepress/engines/gecko.js +0 -293
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +0 -304
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +0 -260
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/index.html +0 -443
- data/html/js/codepress/languages/asp.css +0 -71
- data/html/js/codepress/languages/asp.js +0 -117
- data/html/js/codepress/languages/autoit.css +0 -13
- data/html/js/codepress/languages/autoit.js +0 -32
- data/html/js/codepress/languages/csharp.css +0 -9
- data/html/js/codepress/languages/csharp.js +0 -25
- data/html/js/codepress/languages/css.css +0 -10
- data/html/js/codepress/languages/css.js +0 -23
- data/html/js/codepress/languages/generic.css +0 -9
- data/html/js/codepress/languages/generic.js +0 -25
- data/html/js/codepress/languages/html.css +0 -13
- data/html/js/codepress/languages/html.js +0 -59
- data/html/js/codepress/languages/java.css +0 -7
- data/html/js/codepress/languages/java.js +0 -24
- data/html/js/codepress/languages/javascript.css +0 -8
- data/html/js/codepress/languages/javascript.js +0 -30
- data/html/js/codepress/languages/perl.css +0 -11
- data/html/js/codepress/languages/perl.js +0 -27
- data/html/js/codepress/languages/php.css +0 -12
- data/html/js/codepress/languages/php.js +0 -61
- data/html/js/codepress/languages/ruby.css +0 -10
- data/html/js/codepress/languages/ruby.js +0 -26
- data/html/js/codepress/languages/sql.css +0 -10
- data/html/js/codepress/languages/sql.js +0 -30
- data/html/js/codepress/languages/text.css +0 -5
- data/html/js/codepress/languages/text.js +0 -9
- data/html/js/codepress/languages/vbscript.css +0 -71
- data/html/js/codepress/languages/vbscript.js +0 -117
- data/html/js/codepress/languages/xsl.css +0 -15
- data/html/js/codepress/languages/xsl.js +0 -103
- data/html/js/codepress/license.txt +0 -458
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/test/plugin/test_gem/a/lib/jiji_plugin_test.rb +0 -6
@@ -1,8 +1,8 @@
|
|
1
1
|
// change_to: "on" or "off"
|
2
2
|
EditArea.prototype.change_highlight= function(change_to){
|
3
3
|
if(this.settings["syntax"].length==0 && change_to==false){
|
4
|
-
this.switchClassSticky($("highlight"), 'editAreaButtonDisabled', true);
|
5
|
-
this.switchClassSticky($("reset_highlight"), 'editAreaButtonDisabled', true);
|
4
|
+
this.switchClassSticky(_$("highlight"), 'editAreaButtonDisabled', true);
|
5
|
+
this.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
|
6
6
|
return false;
|
7
7
|
}
|
8
8
|
|
@@ -10,8 +10,7 @@
|
|
10
10
|
return false;
|
11
11
|
|
12
12
|
|
13
|
-
|
14
|
-
this.getIESelection();
|
13
|
+
this.getIESelection();
|
15
14
|
var pos_start= this.textarea.selectionStart;
|
16
15
|
var pos_end= this.textarea.selectionEnd;
|
17
16
|
|
@@ -22,261 +21,370 @@
|
|
22
21
|
this.textarea.focus();
|
23
22
|
this.textarea.selectionStart = pos_start;
|
24
23
|
this.textarea.selectionEnd = pos_end;
|
25
|
-
|
26
|
-
this.setIESelection();
|
24
|
+
this.setIESelection();
|
27
25
|
|
28
26
|
};
|
29
27
|
|
30
|
-
EditArea.prototype.disable_highlight= function(displayOnly){
|
31
|
-
this.
|
32
|
-
|
28
|
+
EditArea.prototype.disable_highlight= function(displayOnly){
|
29
|
+
var t= this, a=t.textarea, new_Obj, old_class, new_class;
|
30
|
+
|
31
|
+
t.selection_field.innerHTML="";
|
32
|
+
t.selection_field_text.innerHTML="";
|
33
|
+
t.content_highlight.style.visibility="hidden";
|
33
34
|
// replacing the node is far more faster than deleting it's content in firefox
|
34
|
-
|
35
|
+
new_Obj= t.content_highlight.cloneNode(false);
|
35
36
|
new_Obj.innerHTML= "";
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
t.content_highlight.parentNode.insertBefore(new_Obj, t.content_highlight);
|
38
|
+
t.content_highlight.parentNode.removeChild(t.content_highlight);
|
39
|
+
t.content_highlight= new_Obj;
|
40
|
+
old_class= parent.getAttribute( a,"class" );
|
40
41
|
if(old_class){
|
41
|
-
|
42
|
-
parent.setAttribute(
|
42
|
+
new_class= old_class.replace( "hidden","" );
|
43
|
+
parent.setAttribute( a, "class", new_class );
|
43
44
|
}
|
44
45
|
|
45
|
-
|
46
|
+
a.style.backgroundColor="transparent"; // needed in order to see the bracket finders
|
46
47
|
|
47
48
|
//var icon= document.getElementById("highlight");
|
48
49
|
//setAttribute(icon, "class", getAttribute(icon, "class").replace(/ selected/g, "") );
|
49
|
-
//
|
50
|
-
//
|
51
|
-
|
52
|
-
|
50
|
+
//t.restoreClass(icon);
|
51
|
+
//t.switchClass(icon,'editAreaButtonNormal');
|
52
|
+
t.switchClassSticky(_$("highlight"), 'editAreaButtonNormal', true);
|
53
|
+
t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
|
53
54
|
|
54
|
-
|
55
|
+
t.do_highlight=false;
|
55
56
|
|
56
|
-
|
57
|
-
if(typeof(
|
58
|
-
|
57
|
+
t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonSelected', true);
|
58
|
+
if(typeof(t.smooth_selection_before_highlight)!="undefined" && t.smooth_selection_before_highlight===false){
|
59
|
+
t.change_smooth_selection_mode(false);
|
59
60
|
}
|
60
61
|
|
61
62
|
// this.textarea.style.backgroundColor="#FFFFFF";
|
62
63
|
};
|
63
64
|
|
64
65
|
EditArea.prototype.enable_highlight= function(){
|
65
|
-
this.
|
66
|
+
var t=this, a=t.textarea, new_class;
|
67
|
+
t.show_waiting_screen();
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
parent.setAttribute(
|
69
|
+
t.content_highlight.style.visibility="visible";
|
70
|
+
new_class =parent.getAttribute(a,"class")+" hidden";
|
71
|
+
parent.setAttribute( a, "class", new_class );
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
+
// IE can't manage mouse click outside text range without this
|
74
|
+
if( t.isIE )
|
75
|
+
a.style.backgroundColor="#FFFFFF";
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
//this.switchClass(icon,'editAreaButtonSelected');
|
77
|
-
//this.switchClassSticky($("highlight"), 'editAreaButtonNormal', false);
|
78
|
-
this.switchClassSticky($("highlight"), 'editAreaButtonSelected', false);
|
79
|
-
this.switchClassSticky($("reset_highlight"), 'editAreaButtonNormal', false);
|
77
|
+
t.switchClassSticky(_$("highlight"), 'editAreaButtonSelected', false);
|
78
|
+
t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonNormal', false);
|
80
79
|
|
81
|
-
|
82
|
-
if(!
|
83
|
-
|
84
|
-
|
80
|
+
t.smooth_selection_before_highlight=t.smooth_selection;
|
81
|
+
if(!t.smooth_selection)
|
82
|
+
t.change_smooth_selection_mode(true);
|
83
|
+
t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonDisabled', true);
|
85
84
|
|
86
85
|
|
87
|
-
|
88
|
-
|
86
|
+
t.do_highlight=true;
|
87
|
+
t.resync_highlight();
|
89
88
|
|
90
|
-
|
91
|
-
//area.onkeyup="";
|
92
|
-
/*if(!displayOnly){
|
93
|
-
this.do_highlight=true;
|
94
|
-
this.reSync();
|
95
|
-
if(this.state=="loaded")
|
96
|
-
this.textarea.focus();
|
97
|
-
}*/
|
98
|
-
|
89
|
+
t.hide_waiting_screen();
|
99
90
|
};
|
100
91
|
|
101
|
-
|
92
|
+
/**
|
93
|
+
* Ask to update highlighted text
|
94
|
+
* @param Array infos - Array of datas returned by EditArea.get_selection_infos()
|
95
|
+
*/
|
102
96
|
EditArea.prototype.maj_highlight= function(infos){
|
103
|
-
if(this.last_highlight_base_text==infos["full_text"] && this.resync_highlight!==true)
|
104
|
-
return;
|
105
|
-
|
106
|
-
//var infos= this.getSelectionInfos();
|
107
|
-
if(infos["full_text"].indexOf("\r")!=-1)
|
108
|
-
text_to_highlight= infos["full_text"].replace(/\r/g, "");
|
109
|
-
else
|
110
|
-
text_to_highlight= infos["full_text"];
|
111
|
-
|
112
|
-
// for optimisation process
|
113
|
-
var start_line_pb=-1;
|
114
|
-
var end_line_pb=-1;
|
115
|
-
|
116
|
-
var stay_begin="";
|
117
|
-
var stay_end="";
|
118
|
-
|
119
|
-
|
120
|
-
var debug_opti="";
|
121
|
-
|
122
97
|
// for speed mesure
|
123
|
-
var
|
124
|
-
var
|
125
|
-
var
|
98
|
+
var debug_opti="",tps_start= new Date().getTime(), tps_middle_opti=new Date().getTime();
|
99
|
+
var t=this, hightlighted_text, updated_highlight;
|
100
|
+
var textToHighlight=infos["full_text"], doSyntaxOpti = false, doHtmlOpti = false, stay_begin="", stay_end="", trace_new , trace_last;
|
126
101
|
|
102
|
+
if(t.last_text_to_highlight==infos["full_text"] && t.resync_highlight!==true)
|
103
|
+
return;
|
127
104
|
|
128
105
|
// OPTIMISATION: will search to update only changed lines
|
129
|
-
if(
|
130
|
-
|
131
|
-
}else if(
|
132
|
-
|
133
|
-
}else{
|
134
|
-
|
106
|
+
if(t.reload_highlight===true){
|
107
|
+
t.reload_highlight=false;
|
108
|
+
}else if(textToHighlight.length==0){
|
109
|
+
textToHighlight="\n ";
|
110
|
+
}else{
|
111
|
+
// get text change datas
|
112
|
+
changes = t.checkTextEvolution(t.last_text_to_highlight,textToHighlight);
|
135
113
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
while(cpt<end && step>=1){
|
141
|
-
if(this.last_text_to_highlight.substr(cpt, step) == text_to_highlight.substr(cpt, step)){
|
142
|
-
cpt+= step;
|
143
|
-
}else{
|
144
|
-
step= Math.floor(step/2);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
var pos_start_change=cpt;
|
148
|
-
var line_start_change= text_to_highlight.substr(0, pos_start_change).split("\n").length -1;
|
114
|
+
// check if it can only reparse the changed text
|
115
|
+
trace_new = t.get_syntax_trace(changes.newTextLine).replace(/\r/g, '');
|
116
|
+
trace_last = t.get_syntax_trace(changes.lastTextLine).replace(/\r/g, '');
|
117
|
+
doSyntaxOpti = ( trace_new == trace_last );
|
149
118
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
if(this.last_text_to_highlight.substr(cpt_last-step, step) == text_to_highlight.substr(cpt-step, step)){
|
156
|
-
cpt-= step;
|
157
|
-
cpt_last-= step;
|
158
|
-
}else{
|
159
|
-
step= Math.floor(step/2);
|
160
|
-
}
|
119
|
+
// check if the difference comes only from a new line created
|
120
|
+
// => we have to remember that the editor can automaticaly add tabulation or space after the new line)
|
121
|
+
if( !doSyntaxOpti && trace_new == "\n"+trace_last && /^[ \t\s]*\n[ \t\s]*$/.test( changes.newText.replace(/\r/g, '') ) && changes.lastText =="" )
|
122
|
+
{
|
123
|
+
doSyntaxOpti = true;
|
161
124
|
}
|
162
|
-
//cpt_last=Math.max(0, cpt_last);
|
163
|
-
var pos_new_end_change= cpt;
|
164
|
-
var pos_last_end_change= cpt_last;
|
165
|
-
if(pos_new_end_change<=pos_start_change){
|
166
|
-
if(this.last_text_to_highlight.length < text_to_highlight.length){
|
167
|
-
pos_new_end_change= pos_start_change + text_to_highlight.length - this.last_text_to_highlight.length;
|
168
|
-
pos_last_end_change= pos_start_change;
|
169
|
-
}else{
|
170
|
-
pos_last_end_change= pos_start_change + this.last_text_to_highlight.length - text_to_highlight.length;
|
171
|
-
pos_new_end_change= pos_start_change;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
var change_new_text= text_to_highlight.substring(pos_start_change, pos_new_end_change);
|
175
|
-
var change_last_text= this.last_text_to_highlight.substring(pos_start_change, pos_last_end_change);
|
176
|
-
|
177
|
-
var line_new_end_change= text_to_highlight.substr(0, pos_new_end_change).split("\n").length -1;
|
178
|
-
var line_last_end_change= this.last_text_to_highlight.substr(0, pos_last_end_change).split("\n").length -1;
|
179
125
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
// check if it can only reparse the changed text
|
184
|
-
var trace_new= this.get_syntax_trace(change_new_text_line);
|
185
|
-
var trace_last= this.get_syntax_trace(change_last_text_line);
|
186
|
-
if(trace_new == trace_last){
|
126
|
+
// we do the syntax optimisation
|
127
|
+
if( doSyntaxOpti ){
|
187
128
|
|
129
|
+
tps_middle_opti=new Date().getTime();
|
188
130
|
|
189
|
-
|
190
|
-
|
191
|
-
tps_middle_opti=date.getTime();
|
192
|
-
|
193
|
-
stay_begin= this.last_hightlighted_text.split("\n").slice(0, line_start_change).join("\n");
|
194
|
-
if(line_start_change>0)
|
131
|
+
stay_begin= t.last_hightlighted_text.split("\n").slice(0, changes.lineStart).join("\n");
|
132
|
+
if(changes.lineStart>0)
|
195
133
|
stay_begin+= "\n";
|
196
|
-
stay_end=
|
134
|
+
stay_end= t.last_hightlighted_text.split("\n").slice(changes.lineLastEnd+1).join("\n");
|
197
135
|
if(stay_end.length>0)
|
198
136
|
stay_end= "\n"+stay_end;
|
199
|
-
|
200
|
-
|
201
|
-
if(stay_begin.length
|
202
|
-
|
203
|
-
|
204
|
-
|
137
|
+
|
138
|
+
// Final check to see that we're not in the middle of span tags
|
139
|
+
if( stay_begin.split('<span').length != stay_begin.split('</span').length
|
140
|
+
|| stay_end.split('<span').length != stay_end.split('</span').length )
|
141
|
+
{
|
142
|
+
doSyntaxOpti = false;
|
143
|
+
stay_end = '';
|
144
|
+
stay_begin = '';
|
145
|
+
}
|
146
|
+
else
|
147
|
+
{
|
148
|
+
if(stay_begin.length==0 && changes.posLastEnd==-1)
|
149
|
+
changes.newTextLine+="\n";
|
150
|
+
textToHighlight=changes.newTextLine;
|
151
|
+
}
|
205
152
|
}
|
206
|
-
if(
|
207
|
-
|
208
|
-
debug_opti
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
153
|
+
if(t.settings["debug"]){
|
154
|
+
var ch =changes;
|
155
|
+
debug_opti= ( doSyntaxOpti?"Optimisation": "No optimisation" )
|
156
|
+
+" start: "+ch.posStart +"("+ch.lineStart+")"
|
157
|
+
+" end_new: "+ ch.posNewEnd+"("+ch.lineNewEnd+")"
|
158
|
+
+" end_last: "+ ch.posLastEnd+"("+ch.lineLastEnd+")"
|
159
|
+
+"\nchanged_text: "+ch.newText+" => trace: "+trace_new
|
160
|
+
+"\nchanged_last_text: "+ch.lastText+" => trace: "+trace_last
|
161
|
+
//debug_opti+= "\nchanged: "+ infos["full_text"].substring(ch.posStart, ch.posNewEnd);
|
162
|
+
+ "\nchanged_line: "+ch.newTextLine
|
163
|
+
+ "\nlast_changed_line: "+ch.lastTextLine
|
164
|
+
+"\nstay_begin: "+ stay_begin.slice(-100)
|
165
|
+
+"\nstay_end: "+ stay_end.substr( 0, 100 );
|
166
|
+
//debug_opti="start: "+stay_begin_len+ "("+nb_line_start_unchanged+") end: "+ (stay_end_len)+ "("+(splited.length-nb_line_end_unchanged)+") ";
|
167
|
+
//debug_opti+="changed: "+ textToHighlight.substring(stay_begin_len, textToHighlight.length-stay_end_len)+" \n";
|
168
|
+
|
169
|
+
//debug_opti+="changed: "+ stay_begin.substr(stay_begin.length-200)+ "----------"+ textToHighlight+"------------------"+ stay_end.substr(0,200) +"\n";
|
170
|
+
+"\n";
|
223
171
|
}
|
224
172
|
|
225
173
|
|
226
174
|
// END OPTIMISATION
|
227
175
|
}
|
228
|
-
|
229
|
-
tps_end_opti=
|
176
|
+
|
177
|
+
tps_end_opti = new Date().getTime();
|
230
178
|
|
231
179
|
// apply highlight
|
232
|
-
|
180
|
+
updated_highlight = t.colorize_text(textToHighlight);
|
181
|
+
tpsAfterReg = new Date().getTime();
|
233
182
|
|
234
|
-
|
183
|
+
/***
|
184
|
+
* see if we can optimize for updating only the required part of the HTML code
|
185
|
+
*
|
186
|
+
* The goal here will be to find the text node concerned by the modification and to update it
|
187
|
+
*/
|
188
|
+
//-------------------------------------------
|
189
|
+
//
|
190
|
+
if( doSyntaxOpti )
|
191
|
+
{
|
192
|
+
try
|
193
|
+
{
|
194
|
+
var replacedBloc, i, nbStart = '', nbEnd = '', newHtml, lengthOld, lengthNew;
|
195
|
+
replacedBloc = t.last_hightlighted_text.substring( stay_begin.length, t.last_hightlighted_text.length - stay_end.length );
|
196
|
+
|
197
|
+
lengthOld = replacedBloc.length;
|
198
|
+
lengthNew = updated_highlight.length;
|
199
|
+
|
200
|
+
// find the identical caracters at the beginning
|
201
|
+
for( i=0; i < lengthOld && i < lengthNew && replacedBloc.charAt(i) == updated_highlight.charAt(i) ; i++ )
|
202
|
+
{
|
203
|
+
}
|
204
|
+
nbStart = i;
|
205
|
+
// find the identical caracters at the end
|
206
|
+
for( i=0; i + nbStart < lengthOld && i + nbStart < lengthNew && replacedBloc.charAt(lengthOld-i-1) == updated_highlight.charAt(lengthNew-i-1) ; i++ )
|
207
|
+
{
|
208
|
+
}
|
209
|
+
nbEnd = i;
|
210
|
+
|
211
|
+
// get the changes
|
212
|
+
lastHtml = replacedBloc.substring( nbStart, lengthOld - nbEnd );
|
213
|
+
newHtml = updated_highlight.substring( nbStart, lengthNew - nbEnd );
|
214
|
+
|
215
|
+
|
216
|
+
// We can do the optimisation only if we havn't touch to span elements
|
217
|
+
if( newHtml.indexOf('<span') == -1 && newHtml.indexOf('</span') == -1
|
218
|
+
&& lastHtml.indexOf('<span') == -1 && lastHtml.indexOf('</span') == -1 )
|
219
|
+
{
|
220
|
+
var beginStr, nbOpendedSpan, nbClosedSpan, nbUnchangedChars, span, textNode;
|
221
|
+
doHtmlOpti = true;
|
222
|
+
beginStr = t.last_hightlighted_text.substr( 0, stay_begin.length + nbStart );
|
235
223
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
224
|
+
nbOpendedSpan = beginStr.split('<span').length - 1;
|
225
|
+
nbClosedSpan = beginStr.split('</span').length - 1;
|
226
|
+
// retrieve the previously opened span (Add 1 for the first level span?)
|
227
|
+
span = t.content_highlight.getElementsByTagName('span')[ nbOpendedSpan ];
|
228
|
+
|
229
|
+
//--------[
|
230
|
+
// get the textNode to update
|
231
|
+
|
232
|
+
// if we're inside a span, we'll take the one that is opened (can be a parent of the current span)
|
233
|
+
parentSpan = span;
|
234
|
+
maxStartOffset = maxEndOffset = 0;
|
235
|
+
|
236
|
+
// it will be in the child of the root node
|
237
|
+
if( nbOpendedSpan == nbClosedSpan )
|
238
|
+
{
|
239
|
+
while( parentSpan.parentNode != t.content_highlight && parentSpan.parentNode.tagName != 'PRE' )
|
240
|
+
{
|
241
|
+
parentSpan = parentSpan.parentNode;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
// get the last opened span
|
245
|
+
else
|
246
|
+
{
|
247
|
+
maxStartOffset = maxEndOffset = beginStr.length + 1;
|
248
|
+
// move to parent node for each closed span found after the lastest open span
|
249
|
+
nbClosed = beginStr.substr( Math.max( 0, beginStr.lastIndexOf( '<span', maxStartOffset - 1 ) ) ).split('</span').length - 1;
|
250
|
+
while( nbClosed > 0 )
|
251
|
+
{
|
252
|
+
nbClosed--;
|
253
|
+
parentSpan = parentSpan.parentNode;
|
254
|
+
}
|
255
|
+
|
256
|
+
// find the position of the last opended tag
|
257
|
+
while( parentSpan.parentNode != t.content_highlight && parentSpan.parentNode.tagName != 'PRE' && ( tmpMaxStartOffset = Math.max( 0, beginStr.lastIndexOf( '<span', maxStartOffset - 1 ) ) ) < ( tmpMaxEndOffset = Math.max( 0, beginStr.lastIndexOf( '</span', maxEndOffset - 1 ) ) ) )
|
258
|
+
{
|
259
|
+
maxStartOffset = tmpMaxStartOffset;
|
260
|
+
maxEndOffset = tmpMaxEndOffset;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
// Note: maxEndOffset is no more used but maxStartOffset will be used
|
264
|
+
|
265
|
+
if( parentSpan.parentNode == t.content_highlight || parentSpan.parentNode.tagName == 'PRE' )
|
266
|
+
{
|
267
|
+
maxStartOffset = Math.max( 0, beginStr.indexOf( '<span' ) );
|
268
|
+
}
|
269
|
+
|
270
|
+
// find the matching text node (this will be one that will be at the end of the beginStr
|
271
|
+
if( maxStartOffset == beginStr.length )
|
272
|
+
{
|
273
|
+
nbSubSpanBefore = 0;
|
274
|
+
}
|
275
|
+
else
|
276
|
+
{
|
277
|
+
lastEndPos = Math.max( 0, beginStr.lastIndexOf( '>', maxStartOffset ) );
|
241
278
|
|
242
|
-
|
243
|
-
|
279
|
+
// count the number of sub spans
|
280
|
+
nbSubSpanBefore = beginStr.substr( lastEndPos ).split('<span').length-1;
|
281
|
+
}
|
244
282
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
283
|
+
// there is no sub-span before
|
284
|
+
if( nbSubSpanBefore == 0 )
|
285
|
+
{
|
286
|
+
textNode = parentSpan.firstChild;
|
287
|
+
}
|
288
|
+
// we need to find where is the text node modified
|
289
|
+
else
|
290
|
+
{
|
291
|
+
// take the last direct child (no sub-child)
|
292
|
+
lastSubSpan = parentSpan.getElementsByTagName('span')[ nbSubSpanBefore - 1 ];
|
293
|
+
while( lastSubSpan.parentNode != parentSpan )
|
294
|
+
{
|
295
|
+
lastSubSpan = lastSubSpan.parentNode;
|
296
|
+
}
|
297
|
+
|
298
|
+
// associate to next text node following the last sub span
|
299
|
+
if( lastSubSpan.nextSibling == null || lastSubSpan.nextSibling.nodeType != 3 )
|
300
|
+
{
|
301
|
+
textNode = document.createTextNode('');
|
302
|
+
lastSubSpan.parentNode.insertBefore( textNode, lastSubSpan.nextSibling );
|
303
|
+
}
|
304
|
+
else
|
305
|
+
{
|
306
|
+
textNode = lastSubSpan.nextSibling;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
//--------]
|
310
|
+
|
311
|
+
|
312
|
+
//--------[
|
313
|
+
// update the textNode content
|
314
|
+
|
315
|
+
// number of caracters after the last opened of closed span
|
316
|
+
nbUnchangedChars = beginStr.length - Math.max( 0, beginStr.lastIndexOf( '>' ) + 1 );
|
317
|
+
|
318
|
+
// console.log( span, textNode, nbOpendedSpan,nbClosedSpan, span.nextSibling, textNode.length, nbUnchangedChars, lastHtml, lastHtml.length, newHtml, newHtml.length );
|
319
|
+
// alert( textNode.parentNode.className +'-'+ textNode.parentNode.tagName+"\n"+ textNode.data +"\n"+ nbUnchangedChars +"\n"+ lastHtml.length +"\n"+ newHtml +"\n"+ newHtml.length );
|
320
|
+
|
321
|
+
// IE only manage \r for cariage return in textNode and not \n or \r\n
|
322
|
+
if( t.isIE )
|
323
|
+
{
|
324
|
+
nbUnchangedChars -= ( beginStr.substr( beginStr.length - nbUnchangedChars ).split("\n").length - 1 );
|
325
|
+
//alert( textNode.data.replace(/\r/g, '_r').replace(/\n/g, '_n'));
|
326
|
+
textNode.replaceData( nbUnchangedChars, lastHtml.replace(/\n/g, '').length, newHtml.replace(/\n/g, '') );
|
327
|
+
}
|
328
|
+
else
|
329
|
+
{
|
330
|
+
textNode.replaceData( nbUnchangedChars, lastHtml.length, newHtml );
|
331
|
+
}
|
332
|
+
//--------]
|
333
|
+
}
|
334
|
+
}
|
335
|
+
// an exception shouldn't occured but if replaceData failed at least it won't break everything
|
336
|
+
catch( e )
|
337
|
+
{
|
338
|
+
// throw e;
|
339
|
+
// console.log( e );
|
340
|
+
doHtmlOpti = false;
|
341
|
+
}
|
342
|
+
|
343
|
+
}
|
344
|
+
/*** END HTML update's optimisation ***/
|
345
|
+
// end test
|
346
|
+
|
347
|
+
// console.log( (TPS6-TPS5), (TPS5-TPS4), (TPS4-TPS3), (TPS3-TPS2), (TPS2-TPS1), _CPT );
|
348
|
+
// get the new highlight content
|
349
|
+
tpsAfterOpti2 = new Date().getTime();
|
350
|
+
hightlighted_text = stay_begin + updated_highlight + stay_end;
|
351
|
+
if( !doHtmlOpti )
|
352
|
+
{
|
353
|
+
// update the content of the highlight div by first updating a clone node (as there is no display in the same time for t node it's quite faster (5*))
|
354
|
+
var new_Obj= t.content_highlight.cloneNode(false);
|
355
|
+
if( ( t.isIE && t.isIE < 8 ) || ( t.isOpera && t.isOpera < 9.6 ) )
|
356
|
+
new_Obj.innerHTML= "<pre><span class='"+ t.settings["syntax"] +"'>" + hightlighted_text + "</span></pre>";
|
357
|
+
else
|
358
|
+
new_Obj.innerHTML= "<span class='"+ t.settings["syntax"] +"'>"+ hightlighted_text +"</span>";
|
359
|
+
|
360
|
+
t.content_highlight.parentNode.replaceChild(new_Obj, t.content_highlight);
|
361
|
+
|
362
|
+
t.content_highlight= new_Obj;
|
363
|
+
}
|
364
|
+
|
365
|
+
t.last_text_to_highlight= infos["full_text"];
|
366
|
+
t.last_hightlighted_text= hightlighted_text;
|
367
|
+
|
368
|
+
tps3=new Date().getTime();
|
260
369
|
|
261
|
-
if(
|
262
|
-
tot1=tps_end_opti-tps_start;
|
263
|
-
tot_middle=tps_end_opti- tps_middle_opti;
|
264
|
-
tot2=tps2-tps_end_opti;
|
265
|
-
tps_join=inner1-tps2;
|
266
|
-
tps_td2=tps3-inner1;
|
370
|
+
if(t.settings["debug"]){
|
267
371
|
//lineNumber=tab_text.length;
|
268
|
-
//
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
372
|
+
//t.debug.value+=" \nNB char: "+_$("src").value.length+" Nb line: "+ lineNumber;
|
373
|
+
|
374
|
+
t.debug.value= "Tps optimisation "+(tps_end_opti-tps_start)
|
375
|
+
+" | tps reg exp: "+ (tpsAfterReg-tps_end_opti)
|
376
|
+
+" | tps opti HTML : "+ (tpsAfterOpti2-tpsAfterReg) + ' '+ ( doHtmlOpti ? 'yes' : 'no' )
|
377
|
+
+" | tps update highlight content: "+ (tps3-tpsAfterOpti2)
|
378
|
+
+" | tpsTotal: "+ (tps3-tps_start)
|
379
|
+
+ "("+tps3+")\n"+ debug_opti;
|
380
|
+
// t.debug.value+= "highlight\n"+hightlighted_text;*/
|
273
381
|
}
|
274
382
|
|
275
383
|
};
|
276
384
|
|
277
385
|
EditArea.prototype.resync_highlight= function(reload_now){
|
278
386
|
this.reload_highlight=true;
|
279
|
-
this.
|
387
|
+
this.last_text_to_highlight="";
|
280
388
|
this.focus();
|
281
389
|
if(reload_now)
|
282
390
|
this.check_line_selection(false);
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -11,7 +11,7 @@ function keyDown(e){
|
|
11
11
|
for(var i in editArea.plugins){
|
12
12
|
if(typeof(editArea.plugins[i].onkeydown)=="function"){
|
13
13
|
if(editArea.plugins[i].onkeydown(e)===false){ // stop propaging
|
14
|
-
if(editArea.
|
14
|
+
if(editArea.isIE)
|
15
15
|
e.keyCode=0;
|
16
16
|
return false;
|
17
17
|
}
|
@@ -27,10 +27,10 @@ function keyDown(e){
|
|
27
27
|
|
28
28
|
var low_letter= letter.toLowerCase();
|
29
29
|
|
30
|
-
if(letter=="Page up" && !editArea.
|
30
|
+
if(letter=="Page up" && !editArea.isOpera){
|
31
31
|
editArea.execCommand("scroll_page", {"dir": "up", "shift": ShiftPressed(e)});
|
32
32
|
use=true;
|
33
|
-
}else if(letter=="Page down" && !editArea.
|
33
|
+
}else if(letter=="Page down" && !editArea.isOpera){
|
34
34
|
editArea.execCommand("scroll_page", {"dir": "down", "shift": ShiftPressed(e)});
|
35
35
|
use=true;
|
36
36
|
}else if(editArea.is_editable==false){
|
@@ -43,7 +43,7 @@ function keyDown(e){
|
|
43
43
|
editArea.execCommand("tab_selection");
|
44
44
|
|
45
45
|
use=true;
|
46
|
-
if(editArea.
|
46
|
+
if(editArea.isOpera || (editArea.isFirefox && editArea.isMac) ) // opera && firefox mac can't cancel tabulation events...
|
47
47
|
setTimeout("editArea.execCommand('focus');", 1);
|
48
48
|
}else if(letter=="Entrer" && target_id=="textarea"){
|
49
49
|
if(editArea.press_enter())
|
@@ -103,7 +103,7 @@ function keyDown(e){
|
|
103
103
|
|
104
104
|
if(use){
|
105
105
|
// in case of a control that sould'nt be used by IE but that is used => THROW a javascript error that will stop key action
|
106
|
-
if(editArea.
|
106
|
+
if(editArea.isIE)
|
107
107
|
e.keyCode=0;
|
108
108
|
return false;
|
109
109
|
}
|