databaseformalizer 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.project +18 -0
- data/README +256 -0
- data/README.md +2 -0
- data/Rakefile +21 -0
- data/app/controllers/databaseformalizer/attr_defs_controller.rb +98 -0
- data/app/controllers/databaseformalizer/attr_vals_controller.rb +85 -0
- data/app/controllers/databaseformalizer/dbformahome_controller.rb +7 -0
- data/app/controllers/databaseformalizer/entities_controller.rb +105 -0
- data/app/controllers/databaseformalizer/entity_defs_controller.rb +90 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/databaseformalizer/application_helper.rb +4 -0
- data/app/helpers/databaseformalizer/attr_defs_helper.rb +4 -0
- data/app/helpers/databaseformalizer/attr_vals_helper.rb +4 -0
- data/app/helpers/databaseformalizer/dbformahome_helper.rb +4 -0
- data/app/helpers/databaseformalizer/entities_helper.rb +160 -0
- data/app/helpers/databaseformalizer/entity_defs_helper.rb +68 -0
- data/app/models/databaseformalizer/attr_def.rb +48 -0
- data/app/models/databaseformalizer/attr_list_join_def.rb +17 -0
- data/app/models/databaseformalizer/attr_list_join_val.rb +18 -0
- data/app/models/databaseformalizer/attr_val.rb +36 -0
- data/app/models/databaseformalizer/attr_vals_entity.rb +18 -0
- data/app/models/databaseformalizer/entity.rb +27 -0
- data/app/models/databaseformalizer/entity_def.rb +24 -0
- data/app/models/databaseformalizer/entity_def_attr_def.rb +18 -0
- data/app/views/databaseformalizer/attr_defs/_form.html.erb +74 -0
- data/app/views/databaseformalizer/attr_defs/edit.html.erb +7 -0
- data/app/views/databaseformalizer/attr_defs/index.html.erb +38 -0
- data/app/views/databaseformalizer/attr_defs/new.html.erb +6 -0
- data/app/views/databaseformalizer/attr_defs/show.html.erb +50 -0
- data/app/views/databaseformalizer/attr_vals/_form.html.erb +29 -0
- data/app/views/databaseformalizer/attr_vals/edit.html.erb +7 -0
- data/app/views/databaseformalizer/attr_vals/index.html.erb +28 -0
- data/app/views/databaseformalizer/attr_vals/new.html.erb +6 -0
- data/app/views/databaseformalizer/attr_vals/show.html.erb +20 -0
- data/app/views/databaseformalizer/dbformahome/index.html.erb +19 -0
- data/app/views/databaseformalizer/entities/_attr_val_boolean_form.html.erb +7 -0
- data/app/views/databaseformalizer/entities/_attr_val_checkList_form.html.erb +22 -0
- data/app/views/databaseformalizer/entities/_attr_val_datetime_form.html.erb +15 -0
- data/app/views/databaseformalizer/entities/_attr_val_entityDef_form.html.erb +14 -0
- data/app/views/databaseformalizer/entities/_attr_val_form_all.html.erb +4 -0
- data/app/views/databaseformalizer/entities/_attr_val_form_one.html.erb +6 -0
- data/app/views/databaseformalizer/entities/_attr_val_integer_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_attr_val_openList_element_form.html.erb +16 -0
- data/app/views/databaseformalizer/entities/_attr_val_openList_form.html.erb +12 -0
- data/app/views/databaseformalizer/entities/_attr_val_selectOneInList_form.html.erb +20 -0
- data/app/views/databaseformalizer/entities/_attr_val_string_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_attr_val_text_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_form.html.erb +54 -0
- data/app/views/databaseformalizer/entities/edit.html.erb +8 -0
- data/app/views/databaseformalizer/entities/index.html.erb +45 -0
- data/app/views/databaseformalizer/entities/new.html.erb +10 -0
- data/app/views/databaseformalizer/entities/new.js.erb +1 -0
- data/app/views/databaseformalizer/entities/show.html.erb +50 -0
- data/app/views/databaseformalizer/entity_defs/_form.html.erb +51 -0
- data/app/views/databaseformalizer/entity_defs/edit.html.erb +7 -0
- data/app/views/databaseformalizer/entity_defs/index.html.erb +57 -0
- data/app/views/databaseformalizer/entity_defs/new.html.erb +6 -0
- data/app/views/databaseformalizer/entity_defs/show.html.erb +30 -0
- data/app/views/databaseformalizer/layouts/application.html.erb +134 -0
- data/databaseformalizer.gemspec +34 -0
- data/lib/acts_as_entity/base.rb +101 -0
- data/lib/application_controller.rb +21 -0
- data/lib/application_helper.rb +3 -0
- data/lib/databaseformalizer.rb +27 -0
- data/lib/engine.rb +23 -0
- data/lib/generators/entity_def/USAGE +8 -0
- data/lib/generators/entity_def/entity_def_generator.rb +39 -0
- data/lib/generators/entity_def/templates/controller.rb +98 -0
- data/lib/generators/entity_def/templates/helper.rb +2 -0
- data/lib/generators/entity_def/templates/model.rb +3 -0
- data/lib/generators/entity_def/templates/view/_form.html.erb +35 -0
- data/lib/generators/entity_def/templates/view/edit.html.erb +6 -0
- data/lib/generators/entity_def/templates/view/index.html.erb +27 -0
- data/lib/generators/entity_def/templates/view/new.html.erb +5 -0
- data/lib/generators/entity_def/templates/view/show.html.erb +3 -0
- data/lib/rails/generators/databaseformalizer/databaseformalizer_generator.rb +52 -0
- data/lib/rails/generators/databaseformalizer/templates/initializer.rb +8 -0
- data/lib/rails/generators/databaseformalizer/templates/migration.rb +9 -0
- data/lib/rails/generators/databaseformalizer/templates/migration.rb.bak +9 -0
- data/lib/rails/generators/databaseformalizer/templates/schema.rb +84 -0
- data/lib/rails/railties/tasks.rake +8 -0
- data/public/bootstrap/css/bootstrap-fixed-header.css +15 -0
- data/public/bootstrap/css/bootstrap-responsive.css +808 -0
- data/public/bootstrap/css/bootstrap-responsive.min.css +9 -0
- data/public/bootstrap/css/bootstrap-toggle.css +242 -0
- data/public/bootstrap/css/cerulean/bootstrap.min.css +740 -0
- data/public/bootstrap/css/img/glyphicons-halflings-white.png +0 -0
- data/public/bootstrap/css/img/glyphicons-halflings.png +0 -0
- data/public/bootstrap/js/bootstrap-alert.js +90 -0
- data/public/bootstrap/js/bootstrap-collapse.js +157 -0
- data/public/bootstrap/js/bootstrap-dropdown.js +100 -0
- data/public/bootstrap/js/bootstrap-fixed-header.js +54 -0
- data/public/bootstrap/js/bootstrap-modal.js +218 -0
- data/public/bootstrap/js/bootstrap-popover.js +98 -0
- data/public/bootstrap/js/bootstrap-tab.js +135 -0
- data/public/bootstrap/js/bootstrap-toggle.js +104 -0
- data/public/bootstrap/js/bootstrap-tooltip.js +275 -0
- data/public/bootstrap/js/bootstrap-transition.js +61 -0
- data/public/bootstrap/js/bootstrap.js +1824 -0
- data/public/bootstrap/js/bootstrap.min.js +6 -0
- data/public/images/Thumbs.db +0 -0
- data/public/images/bootstrap/Thumbs.db +0 -0
- data/public/images/bootstrap/glyphicons-halflings.png +0 -0
- data/public/images/databaseformalizer.jpg +0 -0
- data/public/images/metamodel.png +0 -0
- data/public/images/model.png +0 -0
- data/public/javascripts/databaseformalizer.js +13 -0
- data/public/javascripts/jquery.js +9252 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/jquery-ui-1.8.21.custom.css +565 -0
- data/public/jquery-ui/js/jquery-1.7.2.min.js +4 -0
- data/public/jquery-ui/js/jquery-ui-1.8.21.custom.min.js +125 -0
- data/public/jquery-validation/README.md +8 -0
- data/public/jquery-validation/additional-methods.js +300 -0
- data/public/jquery-validation/additional-methods.min.js +29 -0
- data/public/jquery-validation/changelog.txt +277 -0
- data/public/jquery-validation/jquery.validate.js +1188 -0
- data/public/jquery-validation/jquery.validate.min.js +51 -0
- data/public/jquery-validation/lib/jquery-1.3.2.js +4376 -0
- data/public/jquery-validation/lib/jquery-1.4.2.js +6240 -0
- data/public/jquery-validation/lib/jquery-1.4.4.js +7179 -0
- data/public/jquery-validation/lib/jquery-1.5.2.js +8374 -0
- data/public/jquery-validation/lib/jquery-1.6.1.js +8936 -0
- data/public/jquery-validation/lib/jquery.form.js +660 -0
- data/public/jquery-validation/lib/jquery.js +4376 -0
- data/public/jquery-validation/lib/jquery.metadata.js +122 -0
- data/public/jquery-validation/lib/jquery.mockjax.js +382 -0
- data/public/jquery-validation/localization/messages_ar.js +24 -0
- data/public/jquery-validation/localization/messages_bg.js +23 -0
- data/public/jquery-validation/localization/messages_ca.js +23 -0
- data/public/jquery-validation/localization/messages_cn.js +23 -0
- data/public/jquery-validation/localization/messages_cs.js +23 -0
- data/public/jquery-validation/localization/messages_da.js +20 -0
- data/public/jquery-validation/localization/messages_de.js +20 -0
- data/public/jquery-validation/localization/messages_el.js +24 -0
- data/public/jquery-validation/localization/messages_es.js +23 -0
- data/public/jquery-validation/localization/messages_eu.js +23 -0
- data/public/jquery-validation/localization/messages_fa.js +23 -0
- data/public/jquery-validation/localization/messages_fi.js +21 -0
- data/public/jquery-validation/localization/messages_fr.js +23 -0
- data/public/jquery-validation/localization/messages_ge.js +23 -0
- data/public/jquery-validation/localization/messages_he.js +23 -0
- data/public/jquery-validation/localization/messages_hu.js +20 -0
- data/public/jquery-validation/localization/messages_it.js +23 -0
- data/public/jquery-validation/localization/messages_ja.js +23 -0
- data/public/jquery-validation/localization/messages_kk.js +23 -0
- data/public/jquery-validation/localization/messages_lt.js +23 -0
- data/public/jquery-validation/localization/messages_lv.js +23 -0
- data/public/jquery-validation/localization/messages_nl.js +23 -0
- data/public/jquery-validation/localization/messages_no.js +23 -0
- data/public/jquery-validation/localization/messages_pl.js +23 -0
- data/public/jquery-validation/localization/messages_ptbr.js +23 -0
- data/public/jquery-validation/localization/messages_ptpt.js +23 -0
- data/public/jquery-validation/localization/messages_ro.js +23 -0
- data/public/jquery-validation/localization/messages_ru.js +23 -0
- data/public/jquery-validation/localization/messages_se.js +21 -0
- data/public/jquery-validation/localization/messages_si.js +23 -0
- data/public/jquery-validation/localization/messages_sk.js +20 -0
- data/public/jquery-validation/localization/messages_sl.js +23 -0
- data/public/jquery-validation/localization/messages_sr.js +23 -0
- data/public/jquery-validation/localization/messages_th.js +23 -0
- data/public/jquery-validation/localization/messages_tr.js +23 -0
- data/public/jquery-validation/localization/messages_tw.js +23 -0
- data/public/jquery-validation/localization/messages_ua.js +23 -0
- data/public/jquery-validation/localization/messages_vi.js +23 -0
- data/public/jquery-validation/localization/methods_de.js +12 -0
- data/public/jquery-validation/localization/methods_nl.js +9 -0
- data/public/jquery-validation/localization/methods_pt.js +9 -0
- data/public/jquery-validation/todo +172 -0
- data/public/jquery-validation/version.txt +1 -0
- data/public/stylesheets/databaseformalizer.css +64 -0
- data/public/stylesheets/scaffold.css +56 -0
- data/public/tablesorter/addons/.svn/all-wcprops +5 -0
- data/public/tablesorter/addons/.svn/entries +31 -0
- data/public/tablesorter/addons/pager/.svn/all-wcprops +17 -0
- data/public/tablesorter/addons/pager/.svn/entries +96 -0
- data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.css.svn-base +5 -0
- data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.js.svn-base +5 -0
- data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.css.svn-base +25 -0
- data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.js.svn-base +184 -0
- data/public/tablesorter/addons/pager/jquery.tablesorter.pager.css +25 -0
- data/public/tablesorter/addons/pager/jquery.tablesorter.pager.js +184 -0
- data/public/tablesorter/build/.svn/all-wcprops +47 -0
- data/public/tablesorter/build/.svn/entries +266 -0
- data/public/tablesorter/build/.svn/prop-base/ParseMaster.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/js.jar.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/jsmin.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/min.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/pack.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/packer.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/writeFile.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/ParseMaster.js.svn-base +106 -0
- data/public/tablesorter/build/.svn/text-base/js.jar.svn-base +0 -0
- data/public/tablesorter/build/.svn/text-base/jsmin.js.svn-base +316 -0
- data/public/tablesorter/build/.svn/text-base/min.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/pack.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/packer.js.svn-base +316 -0
- data/public/tablesorter/build/.svn/text-base/writeFile.js.svn-base +19 -0
- data/public/tablesorter/build/ParseMaster.js +106 -0
- data/public/tablesorter/build/js.jar +0 -0
- data/public/tablesorter/build/jsmin.js +316 -0
- data/public/tablesorter/build/min.js +5 -0
- data/public/tablesorter/build/pack.js +5 -0
- data/public/tablesorter/build/packer.js +316 -0
- data/public/tablesorter/build/writeFile.js +19 -0
- data/public/tablesorter/build.xml +26 -0
- data/public/tablesorter/changelog +41 -0
- data/public/tablesorter/jquery-latest.js +154 -0
- data/public/tablesorter/jquery.metadata.js +122 -0
- data/public/tablesorter/jquery.tablesorter.js +1031 -0
- data/public/tablesorter/jquery.tablesorter.min.js +4 -0
- data/public/tablesorter/jquery.tablesorter.widgets.js +433 -0
- data/public/tablesorter/jquery.ui.datepicker.js +1727 -0
- data/public/tablesorter/style.css +110 -0
- data/public/tablesorter/themes/.svn/all-wcprops +5 -0
- data/public/tablesorter/themes/.svn/entries +34 -0
- data/public/tablesorter/themes/blue/.svn/all-wcprops +35 -0
- data/public/tablesorter/themes/blue/.svn/entries +198 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/asc.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/bg.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/blue.zip.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/desc.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/style.css.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/text-base/asc.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/bg.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/blue.zip.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/desc.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/style.css.svn-base +39 -0
- data/public/tablesorter/themes/blue/asc.gif +0 -0
- data/public/tablesorter/themes/blue/bg.gif +0 -0
- data/public/tablesorter/themes/blue/blue.zip +0 -0
- data/public/tablesorter/themes/blue/desc.gif +0 -0
- data/public/tablesorter/themes/blue/style.css +39 -0
- data/public/tablesorter/themes/green/.svn/all-wcprops +35 -0
- data/public/tablesorter/themes/green/.svn/entries +198 -0
- data/public/tablesorter/themes/green/.svn/prop-base/asc.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/bg.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/desc.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/green.zip.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/style.css.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/text-base/asc.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/bg.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/desc.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/green.zip.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/style.css.svn-base +39 -0
- data/public/tablesorter/themes/green/asc.png +0 -0
- data/public/tablesorter/themes/green/bg.png +0 -0
- data/public/tablesorter/themes/green/desc.png +0 -0
- data/public/tablesorter/themes/green/green.zip +0 -0
- data/public/tablesorter/themes/green/style.css +39 -0
- data/test/database.yml +5 -0
- data/test/test_helper.rb +56 -0
- data/test/unit/databaseformalizer_test.rb +11 -0
- metadata +332 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
ParseMaster, version 1.0.2 (2005-08-19)
|
|
3
|
+
Copyright 2005, Dean Edwards
|
|
4
|
+
License: http://creativecommons.org/licenses/LGPL/2.1/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* a multi-pattern parser */
|
|
8
|
+
|
|
9
|
+
// KNOWN BUG: erroneous behavior when using escapeChar with a replacement value that is a function
|
|
10
|
+
|
|
11
|
+
function ParseMaster() {
|
|
12
|
+
// constants
|
|
13
|
+
var $EXPRESSION = 0, $REPLACEMENT = 1, $LENGTH = 2;
|
|
14
|
+
// used to determine nesting levels
|
|
15
|
+
var $GROUPS = /\(/g, $SUB_REPLACE = /\$\d/, $INDEXED = /^\$\d+$/,
|
|
16
|
+
$TRIM = /(['"])\1\+(.*)\+\1\1$/, $$ESCAPE = /\\./g, $QUOTE = /'/,
|
|
17
|
+
$$DELETED = /\x01[^\x01]*\x01/g;
|
|
18
|
+
var self = this;
|
|
19
|
+
// public
|
|
20
|
+
this.add = function($expression, $replacement) {
|
|
21
|
+
if (!$replacement) $replacement = "";
|
|
22
|
+
// count the number of sub-expressions
|
|
23
|
+
// - add one because each pattern is itself a sub-expression
|
|
24
|
+
var $length = (_internalEscape(String($expression)).match($GROUPS) || "").length + 1;
|
|
25
|
+
// does the pattern deal with sub-expressions?
|
|
26
|
+
if ($SUB_REPLACE.test($replacement)) {
|
|
27
|
+
// a simple lookup? (e.g. "$2")
|
|
28
|
+
if ($INDEXED.test($replacement)) {
|
|
29
|
+
// store the index (used for fast retrieval of matched strings)
|
|
30
|
+
$replacement = parseInt($replacement.slice(1)) - 1;
|
|
31
|
+
} else { // a complicated lookup (e.g. "Hello $2 $1")
|
|
32
|
+
// build a function to do the lookup
|
|
33
|
+
var i = $length;
|
|
34
|
+
var $quote = $QUOTE.test(_internalEscape($replacement)) ? '"' : "'";
|
|
35
|
+
while (i) $replacement = $replacement.split("$" + i--).join($quote + "+a[o+" + i + "]+" + $quote);
|
|
36
|
+
$replacement = new Function("a,o", "return" + $quote + $replacement.replace($TRIM, "$1") + $quote);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// pass the modified arguments
|
|
40
|
+
_add($expression || "/^$/", $replacement, $length);
|
|
41
|
+
};
|
|
42
|
+
// execute the global replacement
|
|
43
|
+
this.exec = function($string) {
|
|
44
|
+
_escaped.length = 0;
|
|
45
|
+
return _unescape(_escape($string, this.escapeChar).replace(
|
|
46
|
+
new RegExp(_patterns, this.ignoreCase ? "gi" : "g"), _replacement), this.escapeChar).replace($$DELETED, "");
|
|
47
|
+
};
|
|
48
|
+
// clear the patterns collection so that this object may be re-used
|
|
49
|
+
this.reset = function() {
|
|
50
|
+
_patterns.length = 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// private
|
|
54
|
+
var _escaped = []; // escaped characters
|
|
55
|
+
var _patterns = []; // patterns stored by index
|
|
56
|
+
var _toString = function(){return "(" + String(this[$EXPRESSION]).slice(1, -1) + ")"};
|
|
57
|
+
_patterns.toString = function(){return this.join("|")};
|
|
58
|
+
// create and add a new pattern to the patterns collection
|
|
59
|
+
function _add() {
|
|
60
|
+
arguments.toString = _toString;
|
|
61
|
+
// store the pattern - as an arguments object (i think this is quicker..?)
|
|
62
|
+
_patterns[_patterns.length] = arguments;
|
|
63
|
+
}
|
|
64
|
+
// this is the global replace function (it's quite complicated)
|
|
65
|
+
function _replacement() {
|
|
66
|
+
if (!arguments[0]) return "";
|
|
67
|
+
var i = 1, j = 0, $pattern;
|
|
68
|
+
// loop through the patterns
|
|
69
|
+
while ($pattern = _patterns[j++]) {
|
|
70
|
+
// do we have a result?
|
|
71
|
+
if (arguments[i]) {
|
|
72
|
+
var $replacement = $pattern[$REPLACEMENT];
|
|
73
|
+
switch (typeof $replacement) {
|
|
74
|
+
case "function": return $replacement(arguments, i);
|
|
75
|
+
case "number": return arguments[$replacement + i];
|
|
76
|
+
}
|
|
77
|
+
var $delete = (arguments[i].indexOf(self.escapeChar) == -1) ? "" :
|
|
78
|
+
"\x01" + arguments[i] + "\x01";
|
|
79
|
+
return $delete + $replacement;
|
|
80
|
+
// skip over references to sub-expressions
|
|
81
|
+
} else i += $pattern[$LENGTH];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// encode escaped characters
|
|
85
|
+
function _escape($string, $escapeChar) {
|
|
86
|
+
return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar + "(.)", "g"), function($match, $char) {
|
|
87
|
+
_escaped[_escaped.length] = $char;
|
|
88
|
+
return $escapeChar;
|
|
89
|
+
}) : $string;
|
|
90
|
+
};
|
|
91
|
+
// decode escaped characters
|
|
92
|
+
function _unescape($string, $escapeChar) {
|
|
93
|
+
var i = 0;
|
|
94
|
+
return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar, "g"), function() {
|
|
95
|
+
return $escapeChar + (_escaped[i++] || "");
|
|
96
|
+
}) : $string;
|
|
97
|
+
};
|
|
98
|
+
function _internalEscape($string) {
|
|
99
|
+
return $string.replace($$ESCAPE, "");
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
ParseMaster.prototype = {
|
|
103
|
+
constructor: ParseMaster,
|
|
104
|
+
ignoreCase: false,
|
|
105
|
+
escapeChar: ""
|
|
106
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/* jsmin.js - 2006-08-31
|
|
2
|
+
Author: Franck Marcia
|
|
3
|
+
This work is an adaptation of jsminc.c published by Douglas Crockford.
|
|
4
|
+
Permission is hereby granted to use the Javascript version under the same
|
|
5
|
+
conditions as the jsmin.c on which it is based.
|
|
6
|
+
|
|
7
|
+
jsmin.c
|
|
8
|
+
2006-05-04
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
13
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
14
|
+
the Software without restriction, including without limitation the rights to
|
|
15
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
16
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
17
|
+
so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
The Software shall be used for Good, not Evil.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
|
|
32
|
+
Update:
|
|
33
|
+
add level:
|
|
34
|
+
1: minimal, keep linefeeds if single
|
|
35
|
+
2: normal, the standard algorithm
|
|
36
|
+
3: agressive, remove any linefeed and doesn't take care of potential
|
|
37
|
+
missing semicolons (can be regressive)
|
|
38
|
+
store stats
|
|
39
|
+
jsmin.oldSize
|
|
40
|
+
jsmin.newSize
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
String.prototype.has = function(c) {
|
|
44
|
+
return this.indexOf(c) > -1;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function jsmin(comment, input, level) {
|
|
48
|
+
|
|
49
|
+
if (input === undefined) {
|
|
50
|
+
input = comment;
|
|
51
|
+
comment = '';
|
|
52
|
+
level = 2;
|
|
53
|
+
} else if (level === undefined || level < 1 || level > 3) {
|
|
54
|
+
level = 2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (comment.length > 0) {
|
|
58
|
+
comment += '\n';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var a = '',
|
|
62
|
+
b = '',
|
|
63
|
+
EOF = -1,
|
|
64
|
+
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
|
|
65
|
+
DIGITS = '0123456789',
|
|
66
|
+
ALNUM = LETTERS + DIGITS + '_$\\',
|
|
67
|
+
theLookahead = EOF;
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/* isAlphanum -- return true if the character is a letter, digit, underscore,
|
|
71
|
+
dollar sign, or non-ASCII character.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
function isAlphanum(c) {
|
|
75
|
+
return c != EOF && (ALNUM.has(c) || c.charCodeAt(0) > 126);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/* get -- return the next character. Watch out for lookahead. If the
|
|
80
|
+
character is a control character, translate it to a space or
|
|
81
|
+
linefeed.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
function get() {
|
|
85
|
+
|
|
86
|
+
var c = theLookahead;
|
|
87
|
+
if (get.i == get.l) {
|
|
88
|
+
return EOF;
|
|
89
|
+
}
|
|
90
|
+
theLookahead = EOF;
|
|
91
|
+
if (c == EOF) {
|
|
92
|
+
c = input.charAt(get.i);
|
|
93
|
+
++get.i;
|
|
94
|
+
}
|
|
95
|
+
if (c >= ' ' || c == '\n') {
|
|
96
|
+
return c;
|
|
97
|
+
}
|
|
98
|
+
if (c == '\r') {
|
|
99
|
+
return '\n';
|
|
100
|
+
}
|
|
101
|
+
return ' ';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get.i = 0;
|
|
105
|
+
get.l = input.length;
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/* peek -- get the next character without getting it.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
function peek() {
|
|
112
|
+
theLookahead = get();
|
|
113
|
+
return theLookahead;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
/* next -- get the next character, excluding comments. peek() is used to see
|
|
118
|
+
if a '/' is followed by a '/' or '*'.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
function next() {
|
|
122
|
+
|
|
123
|
+
var c = get();
|
|
124
|
+
if (c == '/') {
|
|
125
|
+
switch (peek()) {
|
|
126
|
+
case '/':
|
|
127
|
+
for (;;) {
|
|
128
|
+
c = get();
|
|
129
|
+
if (c <= '\n') {
|
|
130
|
+
return c;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
case '*':
|
|
135
|
+
get();
|
|
136
|
+
for (;;) {
|
|
137
|
+
switch (get()) {
|
|
138
|
+
case '*':
|
|
139
|
+
if (peek() == '/') {
|
|
140
|
+
get();
|
|
141
|
+
return ' ';
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case EOF:
|
|
145
|
+
throw 'Error: Unterminated comment.';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
return c;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return c;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/* action -- do something! What you do is determined by the argument:
|
|
158
|
+
1 Output A. Copy B to A. Get the next B.
|
|
159
|
+
2 Copy B to A. Get the next B. (Delete A).
|
|
160
|
+
3 Get the next B. (Delete B).
|
|
161
|
+
action treats a string as a single character. Wow!
|
|
162
|
+
action recognizes a regular expression if it is preceded by ( or , or =.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
function action(d) {
|
|
166
|
+
|
|
167
|
+
var r = [];
|
|
168
|
+
|
|
169
|
+
if (d == 1) {
|
|
170
|
+
r.push(a);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (d < 3) {
|
|
174
|
+
a = b;
|
|
175
|
+
if (a == '\'' || a == '"') {
|
|
176
|
+
for (;;) {
|
|
177
|
+
r.push(a);
|
|
178
|
+
a = get();
|
|
179
|
+
if (a == b) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (a <= '\n') {
|
|
183
|
+
throw 'Error: unterminated string literal: ' + a;
|
|
184
|
+
}
|
|
185
|
+
if (a == '\\') {
|
|
186
|
+
r.push(a);
|
|
187
|
+
a = get();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
b = next();
|
|
194
|
+
|
|
195
|
+
if (b == '/' && '(,=:[!&|'.has(a)) {
|
|
196
|
+
r.push(a);
|
|
197
|
+
r.push(b);
|
|
198
|
+
for (;;) {
|
|
199
|
+
a = get();
|
|
200
|
+
if (a == '/') {
|
|
201
|
+
break;
|
|
202
|
+
} else if (a =='\\') {
|
|
203
|
+
r.push(a);
|
|
204
|
+
a = get();
|
|
205
|
+
} else if (a <= '\n') {
|
|
206
|
+
throw 'Error: unterminated Regular Expression literal';
|
|
207
|
+
}
|
|
208
|
+
r.push(a);
|
|
209
|
+
}
|
|
210
|
+
b = next();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return r.join('');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
/* m -- Copy the input to the output, deleting the characters which are
|
|
218
|
+
insignificant to JavaScript. Comments will be removed. Tabs will be
|
|
219
|
+
replaced with spaces. Carriage returns will be replaced with
|
|
220
|
+
linefeeds.
|
|
221
|
+
Most spaces and linefeeds will be removed.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
function m() {
|
|
225
|
+
|
|
226
|
+
var r = [];
|
|
227
|
+
a = '\n';
|
|
228
|
+
|
|
229
|
+
r.push(action(3));
|
|
230
|
+
|
|
231
|
+
while (a != EOF) {
|
|
232
|
+
switch (a) {
|
|
233
|
+
case ' ':
|
|
234
|
+
if (isAlphanum(b)) {
|
|
235
|
+
r.push(action(1));
|
|
236
|
+
} else {
|
|
237
|
+
r.push(action(2));
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
case '\n':
|
|
241
|
+
switch (b) {
|
|
242
|
+
case '{':
|
|
243
|
+
case '[':
|
|
244
|
+
case '(':
|
|
245
|
+
case '+':
|
|
246
|
+
case '-':
|
|
247
|
+
r.push(action(1));
|
|
248
|
+
break;
|
|
249
|
+
case ' ':
|
|
250
|
+
r.push(action(3));
|
|
251
|
+
break;
|
|
252
|
+
default:
|
|
253
|
+
if (isAlphanum(b)) {
|
|
254
|
+
r.push(action(1));
|
|
255
|
+
} else {
|
|
256
|
+
if (level == 1 && b != '\n') {
|
|
257
|
+
r.push(action(1));
|
|
258
|
+
} else {
|
|
259
|
+
r.push(action(2));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
switch (b) {
|
|
266
|
+
case ' ':
|
|
267
|
+
if (isAlphanum(a)) {
|
|
268
|
+
r.push(action(1));
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
r.push(action(3));
|
|
272
|
+
break;
|
|
273
|
+
case '\n':
|
|
274
|
+
if (level == 1 && a != '\n') {
|
|
275
|
+
r.push(action(1));
|
|
276
|
+
} else {
|
|
277
|
+
switch (a) {
|
|
278
|
+
case '}':
|
|
279
|
+
case ']':
|
|
280
|
+
case ')':
|
|
281
|
+
case '+':
|
|
282
|
+
case '-':
|
|
283
|
+
case '"':
|
|
284
|
+
case '\'':
|
|
285
|
+
if (level == 3) {
|
|
286
|
+
r.push(action(3));
|
|
287
|
+
} else {
|
|
288
|
+
r.push(action(1));
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
if (isAlphanum(a)) {
|
|
293
|
+
r.push(action(1));
|
|
294
|
+
} else {
|
|
295
|
+
r.push(action(3));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
default:
|
|
301
|
+
r.push(action(1));
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return r.join('');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
jsmin.oldSize = input.length;
|
|
311
|
+
ret = m(input);
|
|
312
|
+
jsmin.newSize = ret.length;
|
|
313
|
+
|
|
314
|
+
return comment + ret;
|
|
315
|
+
|
|
316
|
+
}
|