rjack-solr 3.6.2.0-java → 4.0.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. data/History.rdoc +5 -0
  2. data/Manifest.txt +268 -33
  3. data/NOTICE.txt +1 -1
  4. data/README.rdoc +6 -6
  5. data/assembly.xml +2 -2
  6. data/bin/rjack-solr-fg +1 -1
  7. data/init/rjack-solr +2 -2
  8. data/lib/rjack-solr.rb +7 -2
  9. data/lib/rjack-solr/base.rb +2 -2
  10. data/lib/rjack-solr/commons-cli-1.2.jar +0 -0
  11. data/lib/rjack-solr/config.rb +1 -1
  12. data/lib/rjack-solr/server.rb +1 -1
  13. data/lib/rjack-solr/solr-core-4.0.0.jar +0 -0
  14. data/lib/rjack-solr/solr-solrj-4.0.0.jar +0 -0
  15. data/pom.xml +19 -6
  16. data/test/test_solr.rb +7 -5
  17. data/webapp/META-INF/LICENSE.txt +0 -940
  18. data/webapp/META-INF/MANIFEST.MF +5 -5
  19. data/webapp/META-INF/NOTICE.txt +160 -93
  20. data/webapp/WEB-INF/web.xml +57 -43
  21. data/webapp/admin.html +140 -0
  22. data/webapp/css/chosen.css +392 -0
  23. data/webapp/css/styles/analysis.css +293 -0
  24. data/webapp/css/styles/cloud.css +331 -0
  25. data/webapp/css/styles/common.css +593 -0
  26. data/webapp/css/styles/cores.css +203 -0
  27. data/webapp/css/styles/dashboard.css +127 -0
  28. data/webapp/css/styles/dataimport.css +222 -0
  29. data/webapp/css/styles/index.css +195 -0
  30. data/webapp/css/styles/java-properties.css +33 -0
  31. data/webapp/css/styles/logging.css +323 -0
  32. data/webapp/css/styles/menu.css +272 -0
  33. data/webapp/css/styles/plugins.css +175 -0
  34. data/webapp/css/styles/query.css +137 -0
  35. data/webapp/css/styles/replication.css +494 -0
  36. data/webapp/css/styles/schema-browser.css +476 -0
  37. data/webapp/css/styles/threads.css +153 -0
  38. data/webapp/img/ZeroClipboard.swf +0 -0
  39. data/webapp/img/chosen-sprite.png +0 -0
  40. data/webapp/img/div.gif +0 -0
  41. data/webapp/{admin → img}/favicon.ico +0 -0
  42. data/webapp/img/filetypes/7z.png +0 -0
  43. data/webapp/img/filetypes/README +27 -0
  44. data/webapp/img/filetypes/ai.png +0 -0
  45. data/webapp/img/filetypes/aiff.png +0 -0
  46. data/webapp/img/filetypes/asc.png +0 -0
  47. data/webapp/img/filetypes/audio.png +0 -0
  48. data/webapp/img/filetypes/bin.png +0 -0
  49. data/webapp/img/filetypes/bz2.png +0 -0
  50. data/webapp/img/filetypes/c.png +0 -0
  51. data/webapp/img/filetypes/cfc.png +0 -0
  52. data/webapp/img/filetypes/cfm.png +0 -0
  53. data/webapp/img/filetypes/chm.png +0 -0
  54. data/webapp/img/filetypes/class.png +0 -0
  55. data/webapp/img/filetypes/conf.png +0 -0
  56. data/webapp/img/filetypes/cpp.png +0 -0
  57. data/webapp/img/filetypes/cs.png +0 -0
  58. data/webapp/img/filetypes/css.png +0 -0
  59. data/webapp/img/filetypes/csv.png +0 -0
  60. data/webapp/img/filetypes/deb.png +0 -0
  61. data/webapp/img/filetypes/divx.png +0 -0
  62. data/webapp/img/filetypes/doc.png +0 -0
  63. data/webapp/img/filetypes/dot.png +0 -0
  64. data/webapp/img/filetypes/eml.png +0 -0
  65. data/webapp/img/filetypes/enc.png +0 -0
  66. data/webapp/img/filetypes/file.png +0 -0
  67. data/webapp/img/filetypes/gif.png +0 -0
  68. data/webapp/img/filetypes/gz.png +0 -0
  69. data/webapp/img/filetypes/hlp.png +0 -0
  70. data/webapp/img/filetypes/htm.png +0 -0
  71. data/webapp/img/filetypes/html.png +0 -0
  72. data/webapp/img/filetypes/image.png +0 -0
  73. data/webapp/img/filetypes/iso.png +0 -0
  74. data/webapp/img/filetypes/jar.png +0 -0
  75. data/webapp/img/filetypes/java.png +0 -0
  76. data/webapp/img/filetypes/jpeg.png +0 -0
  77. data/webapp/img/filetypes/jpg.png +0 -0
  78. data/webapp/img/filetypes/js.png +0 -0
  79. data/webapp/img/filetypes/lua.png +0 -0
  80. data/webapp/img/filetypes/m.png +0 -0
  81. data/webapp/img/filetypes/mm.png +0 -0
  82. data/webapp/img/filetypes/mov.png +0 -0
  83. data/webapp/img/filetypes/mp3.png +0 -0
  84. data/webapp/img/filetypes/mpg.png +0 -0
  85. data/webapp/img/filetypes/odc.png +0 -0
  86. data/webapp/img/filetypes/odf.png +0 -0
  87. data/webapp/img/filetypes/odg.png +0 -0
  88. data/webapp/img/filetypes/odi.png +0 -0
  89. data/webapp/img/filetypes/odp.png +0 -0
  90. data/webapp/img/filetypes/ods.png +0 -0
  91. data/webapp/img/filetypes/odt.png +0 -0
  92. data/webapp/img/filetypes/ogg.png +0 -0
  93. data/webapp/img/filetypes/pdf.png +0 -0
  94. data/webapp/img/filetypes/pgp.png +0 -0
  95. data/webapp/img/filetypes/php.png +0 -0
  96. data/webapp/img/filetypes/pl.png +0 -0
  97. data/webapp/img/filetypes/png.png +0 -0
  98. data/webapp/img/filetypes/ppt.png +0 -0
  99. data/webapp/img/filetypes/ps.png +0 -0
  100. data/webapp/img/filetypes/py.png +0 -0
  101. data/webapp/img/filetypes/ram.png +0 -0
  102. data/webapp/img/filetypes/rar.png +0 -0
  103. data/webapp/img/filetypes/rb.png +0 -0
  104. data/webapp/img/filetypes/rm.png +0 -0
  105. data/webapp/img/filetypes/rpm.png +0 -0
  106. data/webapp/img/filetypes/rtf.png +0 -0
  107. data/webapp/img/filetypes/sig.png +0 -0
  108. data/webapp/img/filetypes/sql.png +0 -0
  109. data/webapp/img/filetypes/swf.png +0 -0
  110. data/webapp/img/filetypes/sxc.png +0 -0
  111. data/webapp/img/filetypes/sxd.png +0 -0
  112. data/webapp/img/filetypes/sxi.png +0 -0
  113. data/webapp/img/filetypes/sxw.png +0 -0
  114. data/webapp/img/filetypes/tar.png +0 -0
  115. data/webapp/img/filetypes/tex.png +0 -0
  116. data/webapp/img/filetypes/tgz.png +0 -0
  117. data/webapp/img/filetypes/txt.png +0 -0
  118. data/webapp/img/filetypes/vcf.png +0 -0
  119. data/webapp/img/filetypes/video.png +0 -0
  120. data/webapp/img/filetypes/vsd.png +0 -0
  121. data/webapp/img/filetypes/wav.png +0 -0
  122. data/webapp/img/filetypes/wma.png +0 -0
  123. data/webapp/img/filetypes/wmv.png +0 -0
  124. data/webapp/img/filetypes/xls.png +0 -0
  125. data/webapp/img/filetypes/xml.png +0 -0
  126. data/webapp/img/filetypes/xpi.png +0 -0
  127. data/webapp/img/filetypes/xvid.png +0 -0
  128. data/webapp/img/filetypes/zip.png +0 -0
  129. data/webapp/img/ico/arrow-000-small.png +0 -0
  130. data/webapp/img/ico/arrow-circle.png +0 -0
  131. data/webapp/img/ico/arrow-switch.png +0 -0
  132. data/webapp/img/ico/asterisk.png +0 -0
  133. data/webapp/img/ico/battery.png +0 -0
  134. data/webapp/img/ico/block-small.png +0 -0
  135. data/webapp/img/ico/block.png +0 -0
  136. data/webapp/img/ico/book-open-text.png +0 -0
  137. data/webapp/img/ico/box.png +0 -0
  138. data/webapp/img/ico/bug.png +0 -0
  139. data/webapp/img/ico/chart.png +0 -0
  140. data/webapp/img/ico/chevron-small-expand.png +0 -0
  141. data/webapp/img/ico/chevron-small.png +0 -0
  142. data/webapp/img/ico/clipboard-list.png +0 -0
  143. data/webapp/img/ico/clipboard-paste-document-text.png +0 -0
  144. data/webapp/img/ico/clipboard-paste.png +0 -0
  145. data/webapp/img/ico/clock-select-remain.png +0 -0
  146. data/webapp/img/ico/clock-select.png +0 -0
  147. data/webapp/img/ico/construction.png +0 -0
  148. data/webapp/img/ico/cross-0.png +0 -0
  149. data/webapp/img/ico/cross-1.png +0 -0
  150. data/webapp/img/ico/cross.png +0 -0
  151. data/webapp/img/ico/dashboard.png +0 -0
  152. data/webapp/img/ico/database.png +0 -0
  153. data/webapp/img/ico/databases.png +0 -0
  154. data/webapp/img/ico/disk-black.png +0 -0
  155. data/webapp/img/ico/document-convert.png +0 -0
  156. data/webapp/img/ico/document-import.png +0 -0
  157. data/webapp/img/ico/document-list.png +0 -0
  158. data/webapp/img/ico/document-text.png +0 -0
  159. data/webapp/img/ico/download-cloud.png +0 -0
  160. data/webapp/img/ico/exclamation-button.png +0 -0
  161. data/webapp/img/ico/eye.png +0 -0
  162. data/webapp/img/ico/folder-export.png +0 -0
  163. data/webapp/img/ico/folder-tree.png +0 -0
  164. data/webapp/img/ico/folder.png +0 -0
  165. data/webapp/img/ico/funnel-small.png +0 -0
  166. data/webapp/img/ico/funnel.png +0 -0
  167. data/webapp/img/ico/gear.png +0 -0
  168. data/webapp/img/ico/globe-network.png +0 -0
  169. data/webapp/img/ico/globe.png +0 -0
  170. data/webapp/img/ico/hammer-screwdriver.png +0 -0
  171. data/webapp/img/ico/hand.png +0 -0
  172. data/webapp/img/ico/highlighter-text.png +0 -0
  173. data/webapp/img/ico/hourglass--exclamation.png +0 -0
  174. data/webapp/img/ico/hourglass.png +0 -0
  175. data/webapp/img/ico/inbox-document-text.png +0 -0
  176. data/webapp/img/ico/information-button.png +0 -0
  177. data/webapp/img/ico/information-small.png +0 -0
  178. data/webapp/img/ico/information-white.png +0 -0
  179. data/webapp/img/ico/information.png +0 -0
  180. data/webapp/img/ico/jar.png +0 -0
  181. data/webapp/img/ico/magnifier.png +0 -0
  182. data/webapp/img/ico/mail.png +0 -0
  183. data/webapp/img/ico/memory.png +0 -0
  184. data/webapp/img/ico/molecule.png +0 -0
  185. data/webapp/img/ico/network-cloud.png +0 -0
  186. data/webapp/img/ico/network-status-away.png +0 -0
  187. data/webapp/img/ico/network-status-busy.png +0 -0
  188. data/webapp/img/ico/network-status-offline.png +0 -0
  189. data/webapp/img/ico/network-status.png +0 -0
  190. data/webapp/img/ico/network.png +0 -0
  191. data/webapp/img/ico/node-design.png +0 -0
  192. data/webapp/img/ico/node-master.png +0 -0
  193. data/webapp/img/ico/node-select.png +0 -0
  194. data/webapp/img/ico/node-slave.png +0 -0
  195. data/webapp/img/ico/node.png +0 -0
  196. data/webapp/img/ico/pencil-small.png +0 -0
  197. data/webapp/img/ico/plus-button.png +0 -0
  198. data/webapp/img/ico/processor.png +0 -0
  199. data/webapp/img/ico/prohibition.png +0 -0
  200. data/webapp/img/ico/property.png +0 -0
  201. data/webapp/img/ico/question-small-white.png +0 -0
  202. data/webapp/img/ico/question-white.png +0 -0
  203. data/webapp/img/ico/question.png +0 -0
  204. data/webapp/img/ico/receipt-invoice.png +0 -0
  205. data/webapp/img/ico/receipt.png +0 -0
  206. data/webapp/img/ico/script-code.png +0 -0
  207. data/webapp/img/ico/server-cast.png +0 -0
  208. data/webapp/img/ico/server.png +0 -0
  209. data/webapp/img/ico/sitemap.png +0 -0
  210. data/webapp/img/ico/slash.png +0 -0
  211. data/webapp/img/ico/status-away.png +0 -0
  212. data/webapp/img/ico/status-busy.png +0 -0
  213. data/webapp/img/ico/status-offline.png +0 -0
  214. data/webapp/img/ico/status.png +0 -0
  215. data/webapp/img/ico/system-monitor--exclamation.png +0 -0
  216. data/webapp/img/ico/system-monitor.png +0 -0
  217. data/webapp/img/ico/table.png +0 -0
  218. data/webapp/img/ico/terminal.png +0 -0
  219. data/webapp/img/ico/tick-circle.png +0 -0
  220. data/webapp/img/ico/tick-red.png +0 -0
  221. data/webapp/img/ico/tick.png +0 -0
  222. data/webapp/img/ico/toggle-small-expand.png +0 -0
  223. data/webapp/img/ico/toggle-small.png +0 -0
  224. data/webapp/img/ico/toolbox.png +0 -0
  225. data/webapp/img/ico/ui-accordion.png +0 -0
  226. data/webapp/img/ico/ui-address-bar.png +0 -0
  227. data/webapp/img/ico/ui-check-box-uncheck.png +0 -0
  228. data/webapp/img/ico/ui-check-box.png +0 -0
  229. data/webapp/img/ico/ui-radio-button-uncheck.png +0 -0
  230. data/webapp/img/ico/ui-radio-button.png +0 -0
  231. data/webapp/img/ico/ui-text-field-select.png +0 -0
  232. data/webapp/img/ico/users.png +0 -0
  233. data/webapp/img/ico/wooden-box.png +0 -0
  234. data/webapp/img/ico/zone.png +0 -0
  235. data/webapp/img/loader-light.gif +0 -0
  236. data/webapp/img/loader.gif +0 -0
  237. data/webapp/img/lucene-ico.png +0 -0
  238. data/webapp/img/solr-ico.png +0 -0
  239. data/webapp/{admin/solr_small.png → img/solr.png} +0 -0
  240. data/webapp/img/tree.png +0 -0
  241. data/webapp/js/lib/ZeroClipboard.js +317 -0
  242. data/webapp/js/lib/chosen.js +953 -0
  243. data/webapp/{admin/get-properties.jsp → js/lib/console.js} +13 -10
  244. data/webapp/js/lib/d3.js +9342 -0
  245. data/webapp/js/lib/highlight.js +1 -0
  246. data/webapp/{admin/jquery-1.4.3.min.js → js/lib/jquery-1.7.2.min.js} +0 -0
  247. data/webapp/js/lib/jquery.blockUI.js +499 -0
  248. data/webapp/js/lib/jquery.cookie.js +47 -0
  249. data/webapp/js/lib/jquery.form.js +782 -0
  250. data/webapp/js/lib/jquery.jstree.js +3510 -0
  251. data/webapp/js/lib/jquery.sammy.js +1856 -0
  252. data/webapp/js/lib/jquery.sparkline.js +1271 -0
  253. data/webapp/js/lib/jquery.timeago.js +165 -0
  254. data/webapp/js/lib/linker.js +48 -0
  255. data/webapp/js/lib/order.js +189 -0
  256. data/webapp/js/main.js +57 -0
  257. data/webapp/js/require.js +11319 -0
  258. data/webapp/js/scripts/analysis.js +549 -0
  259. data/webapp/js/scripts/app.js +368 -0
  260. data/webapp/js/scripts/cloud.js +719 -0
  261. data/webapp/js/scripts/cores.js +540 -0
  262. data/webapp/js/scripts/dashboard.js +540 -0
  263. data/webapp/js/scripts/dataimport.js +567 -0
  264. data/webapp/js/scripts/file.js +56 -0
  265. data/webapp/js/scripts/index.js +344 -0
  266. data/webapp/js/scripts/java-properties.js +107 -0
  267. data/webapp/js/scripts/logging.js +519 -0
  268. data/webapp/js/scripts/ping.js +72 -0
  269. data/webapp/js/scripts/plugins.js +426 -0
  270. data/webapp/js/scripts/query.js +170 -0
  271. data/webapp/js/scripts/replication.js +557 -0
  272. data/webapp/js/scripts/schema-browser.js +1206 -0
  273. data/webapp/js/scripts/threads.js +159 -0
  274. data/webapp/tpl/analysis.html +83 -0
  275. data/webapp/tpl/cloud.html +54 -0
  276. data/webapp/tpl/cores.html +215 -0
  277. data/webapp/tpl/dashboard.html +164 -0
  278. data/webapp/tpl/dataimport.html +123 -0
  279. data/webapp/tpl/index.html +250 -0
  280. data/webapp/tpl/logging.html +23 -0
  281. data/webapp/tpl/plugins.html +39 -0
  282. data/webapp/tpl/query.html +318 -0
  283. data/webapp/tpl/replication.html +207 -0
  284. data/webapp/tpl/schema-browser.html +178 -0
  285. data/webapp/tpl/threads.html +56 -0
  286. metadata +307 -40
  287. data/lib/rjack-solr/solr-core-3.6.2.jar +0 -0
  288. data/lib/rjack-solr/solr-solrj-3.6.2.jar +0 -0
  289. data/webapp/admin/_info.jsp +0 -120
  290. data/webapp/admin/action.jsp +0 -94
  291. data/webapp/admin/analysis.jsp +0 -496
  292. data/webapp/admin/analysis.xsl +0 -179
  293. data/webapp/admin/dataimport.jsp +0 -53
  294. data/webapp/admin/debug.jsp +0 -103
  295. data/webapp/admin/distributiondump.jsp +0 -160
  296. data/webapp/admin/form.jsp +0 -152
  297. data/webapp/admin/get-file.jsp +0 -72
  298. data/webapp/admin/header.jsp +0 -44
  299. data/webapp/admin/index.jsp +0 -162
  300. data/webapp/admin/meta.xsl +0 -34
  301. data/webapp/admin/ping.jsp +0 -52
  302. data/webapp/admin/ping.xsl +0 -71
  303. data/webapp/admin/raw-schema.jsp +0 -38
  304. data/webapp/admin/registry.jsp +0 -107
  305. data/webapp/admin/registry.xsl +0 -321
  306. data/webapp/admin/replication/header.jsp +0 -89
  307. data/webapp/admin/replication/index.jsp +0 -378
  308. data/webapp/admin/schema.jsp +0 -690
  309. data/webapp/admin/solr-admin.css +0 -215
  310. data/webapp/admin/stats.jsp +0 -92
  311. data/webapp/admin/stats.xsl +0 -220
  312. data/webapp/admin/tabular.xsl +0 -141
  313. data/webapp/admin/threaddump.jsp +0 -110
  314. data/webapp/admin/threaddump.xsl +0 -103
  315. data/webapp/index.jsp +0 -49
@@ -0,0 +1,1206 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one or more
3
+ contributor license agreements. See the NOTICE file distributed with
4
+ this work for additional information regarding copyright ownership.
5
+ The ASF licenses this file to You under the Apache License, Version 2.0
6
+ (the "License"); you may not use this file except in compliance with
7
+ the License. You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ var current_core = null;
19
+ var cookie_schema_browser_autoload = 'schema-browser_autoload';
20
+
21
+ var luke_array_to_struct = function( array )
22
+ {
23
+ var struct = {
24
+ keys : [],
25
+ values : []
26
+ };
27
+ for( var i = 0; i < array.length; i += 2 )
28
+ {
29
+ struct.keys.push( array[i] );
30
+ struct.values.push( array[i+1] );
31
+ }
32
+ return struct;
33
+ }
34
+
35
+ var luke_array_to_hash = function( array )
36
+ {
37
+ var hash = {};
38
+ for( var i = 0; i < array.length; i += 2 )
39
+ {
40
+ hash[ array[i] ] = array[i+1];
41
+ }
42
+ return hash;
43
+ }
44
+
45
+ var load_terminfo = function( trigger_element, core_basepath, field, data_element, terminfo_element )
46
+ {
47
+ var luke_url = core_basepath + '/admin/luke?wt=json&fl=' + field;
48
+ var topterms_count_element = $( '.topterms-holder .head input', terminfo_element );
49
+
50
+ var term_load_count = parseInt( topterms_count_element.val(), 10 );
51
+ if( term_load_count )
52
+ {
53
+ luke_url += '&numTerms=' + term_load_count;
54
+ }
55
+
56
+ $.ajax
57
+ (
58
+ {
59
+ url : luke_url,
60
+ dataType : 'json',
61
+ context : terminfo_element,
62
+ beforeSend : function( xhr, settings )
63
+ {
64
+ $( 'span', trigger_element )
65
+ .addClass( 'loader' );
66
+ },
67
+ success : function( response, text_status, xhr )
68
+ {
69
+ $( 'span', trigger_element )
70
+ .removeClass( 'loader' );
71
+
72
+ var field_data = response.fields[field];
73
+
74
+ if( !field_data || !( field_data.topTerms && field_data.histogram ) )
75
+ {
76
+ terminfo_element
77
+ .addClass( 'disabled' );
78
+
79
+ return false;
80
+ }
81
+
82
+ var topterms_holder_element = $( '.topterms-holder', data_element );
83
+ var histogram_holder_element = $( '.histogram-holder', data_element );
84
+
85
+ if( !field_data.topTerms )
86
+ {
87
+ topterms_holder_element
88
+ .hide();
89
+ }
90
+ else
91
+ {
92
+ topterms_holder_element
93
+ .show();
94
+
95
+ var topterms_table_element = $( 'ul', topterms_holder_element );
96
+
97
+ var topterms = field_data.topTerms;
98
+ var topterms_count = topterms.length;
99
+
100
+ var topterms_content = '';
101
+ var topterms_frq_last = null;
102
+
103
+ for( var i = 0; i < topterms_count; i += 2 )
104
+ {
105
+ if( topterms_frq_last !== topterms[i+1] )
106
+ {
107
+ if( topterms_frq_last )
108
+ {
109
+ topterms_content += '</ul></li>' + "\n";
110
+ }
111
+
112
+ topterms_frq_last = topterms[i+1];
113
+ topterms_content += '<li class="clearfix">'
114
+ + '<p><span>' + topterms_frq_last.esc() + '</span></p>' + "\n"
115
+ + '<ul>' + "\n";
116
+ }
117
+
118
+ var target = '#/' + current_core + '/query?q=' + field.esc() + ':' + encodeURIComponent( topterms[i] );
119
+ topterms_content += '<li><a href="' + target + '">' + topterms[i].esc() + '</a></li>' + "\n";
120
+ }
121
+
122
+ topterms_content += '</li>';
123
+
124
+ topterms_count = topterms_count / 2;
125
+
126
+ $( 'input', trigger_element )
127
+ .val( topterms_count );
128
+
129
+ topterms_table_element
130
+ .html( topterms_content );
131
+
132
+ topterms_count_element
133
+ .val( topterms_count );
134
+
135
+ $( 'p.head .max', topterms_holder_element )
136
+ .html( field_data.distinct );
137
+
138
+ $( 'p.head #query_link', topterms_holder_element )
139
+ .attr( 'href', '#/' + current_core + '/query?q=' + field.esc() + ':[* TO *]' );
140
+
141
+ $( 'ul li:even', topterms_table_element )
142
+ .addClass( 'odd' );
143
+ }
144
+
145
+ if( !field_data.histogram )
146
+ {
147
+ histogram_holder_element
148
+ .hide();
149
+ }
150
+ else
151
+ {
152
+ histogram_holder_element
153
+ .show();
154
+
155
+ var histogram_element = $( '.histogram', histogram_holder_element );
156
+
157
+ var histogram_values = luke_array_to_hash( field_data.histogram );
158
+ var histogram_legend = '';
159
+
160
+ histogram_holder_element
161
+ .show();
162
+
163
+ for( var key in histogram_values )
164
+ {
165
+ histogram_legend += '<dt><span>' + key + '</span></dt>' + "\n" +
166
+ '<dd title="' + key + '">' +
167
+ '<span>' + histogram_values[key] + '</span>' +
168
+ '</dd>' + "\n";
169
+ }
170
+
171
+ $( 'dl', histogram_holder_element )
172
+ .html( histogram_legend );
173
+
174
+ var histogram_values = luke_array_to_struct( field_data.histogram ).values;
175
+
176
+ histogram_element
177
+ .sparkline
178
+ (
179
+ histogram_values,
180
+ {
181
+ type : 'bar',
182
+ barColor : '#c0c0c0',
183
+ zeroColor : '#000000',
184
+ height : histogram_element.height(),
185
+ barWidth : 46,
186
+ barSpacing : 3
187
+ }
188
+ );
189
+
190
+ 1 === histogram_values.length
191
+ ? histogram_element.addClass( 'single' )
192
+ : histogram_element.removeClass( 'single' );
193
+ }
194
+
195
+ },
196
+ error : function( xhr, text_status, error_thrown)
197
+ {
198
+ },
199
+ complete : function( xhr, text_status )
200
+ {
201
+ }
202
+ }
203
+ );
204
+ }
205
+
206
+ sammy.bind
207
+ (
208
+ 'schema_browser_navi',
209
+ function( event, params )
210
+ {
211
+ var related_navigation_element = $( '#related dl#f-df-t', params.schema_browser_element );
212
+ var related_navigation_meta = $( '#related dl.ukf-dsf', params.schema_browser_element );
213
+ var related_select_element = $( '#related select', params.schema_browser_element )
214
+ var type = 'index';
215
+
216
+ var sammy_basepath = '#/' + $( 'p a', params.active_core ).html() + '/schema-browser';
217
+
218
+ if( !related_navigation_meta.hasClass( 'done' ) )
219
+ {
220
+ if( app.schema_browser_data.unique_key_field )
221
+ {
222
+ $( '.unique-key-field', related_navigation_meta )
223
+ .show()
224
+ .after
225
+ (
226
+ '<dd class="unique-key-field"><a href="' + sammy_basepath + '?field=' +
227
+ app.schema_browser_data.unique_key_field + '">' +
228
+ app.schema_browser_data.unique_key_field + '</a></dd>'
229
+ );
230
+ }
231
+
232
+ if( app.schema_browser_data.default_search_field )
233
+ {
234
+ $( '.default-search-field', related_navigation_meta )
235
+ .show()
236
+ .after
237
+ (
238
+ '<dd class="default-search-field"><a href="' + sammy_basepath + '?field=' +
239
+ app.schema_browser_data.default_search_field + '">' +
240
+ app.schema_browser_data.default_search_field + '</a></dd>'
241
+ );
242
+ }
243
+
244
+ related_navigation_meta
245
+ .addClass( 'done' );
246
+ }
247
+
248
+ if( params.route_params )
249
+ {
250
+ var type = params.route_params.type;
251
+ var value = params.route_params.value;
252
+
253
+ var navigation_data = {
254
+ 'fields' : [],
255
+ 'copyfield_source' : [],
256
+ 'copyfield_dest' : [],
257
+ 'dynamic_fields' : [],
258
+ 'types' : []
259
+ }
260
+
261
+ $( 'option[value="' + params.route_params.path + '"]', related_select_element )
262
+ .attr( 'selected', 'selected' );
263
+
264
+ related_select_element
265
+ .trigger( 'liszt:updated' );
266
+
267
+ if( 'field' === type )
268
+ {
269
+ navigation_data.fields.push( value );
270
+ navigation_data.types.push( app.schema_browser_data.relations.f_t[value] );
271
+
272
+ if( app.schema_browser_data.relations.f_df[value] )
273
+ {
274
+ navigation_data.dynamic_fields.push( app.schema_browser_data.relations.f_df[value] );
275
+ }
276
+
277
+ if( 0 !== app.schema_browser_data.fields[value].copySources.length )
278
+ {
279
+ navigation_data.copyfield_source = app.schema_browser_data.fields[value].copySources;
280
+ }
281
+
282
+ if( 0 !== app.schema_browser_data.fields[value].copyDests.length )
283
+ {
284
+ navigation_data.copyfield_dest = app.schema_browser_data.fields[value].copyDests;
285
+ }
286
+ }
287
+ else if( 'dynamic-field' === type )
288
+ {
289
+ navigation_data.dynamic_fields.push( value );
290
+ navigation_data.types.push( app.schema_browser_data.relations.df_t[value] );
291
+
292
+ if( app.schema_browser_data.relations.df_f[value] )
293
+ {
294
+ navigation_data.fields = app.schema_browser_data.relations.df_f[value];
295
+ }
296
+ }
297
+ else if( 'type' === type )
298
+ {
299
+ navigation_data.types.push( value );
300
+
301
+ if( app.schema_browser_data.relations.t_f[value] )
302
+ {
303
+ navigation_data.fields = app.schema_browser_data.relations.t_f[value];
304
+ }
305
+
306
+ if( app.schema_browser_data.relations.t_df[value] )
307
+ {
308
+ navigation_data.dynamic_fields = app.schema_browser_data.relations.t_df[value];
309
+ }
310
+ }
311
+
312
+ var navigation_content = '';
313
+
314
+ if( 0 !== navigation_data.fields.length )
315
+ {
316
+ navigation_data.fields.sort();
317
+ navigation_content += '<dt class="field">Field</dt>' + "\n";
318
+ for( var i in navigation_data.fields )
319
+ {
320
+ var href = sammy_basepath + '?field=' + navigation_data.fields[i];
321
+ navigation_content += '<dd class="field"><a href="' + href + '">' + navigation_data.fields[i] + '</a></dd>' + "\n";
322
+ }
323
+ }
324
+
325
+ if( 0 !== navigation_data.copyfield_source.length )
326
+ {
327
+ navigation_data.copyfield_source.sort();
328
+ navigation_content += '<dt class="copyfield">Copied from</dt>' + "\n";
329
+ for( var i in navigation_data.copyfield_source )
330
+ {
331
+ var href = sammy_basepath + '?field=' + navigation_data.copyfield_source[i];
332
+ navigation_content += '<dd class="copyfield"><a href="' + href + '">' + navigation_data.copyfield_source[i] + '</a></dd>' + "\n";
333
+ }
334
+ }
335
+
336
+ if( 0 !== navigation_data.copyfield_dest.length )
337
+ {
338
+ navigation_data.copyfield_dest.sort();
339
+ navigation_content += '<dt class="copyfield">Copied to</dt>' + "\n";
340
+ for( var i in navigation_data.copyfield_dest )
341
+ {
342
+ var href = sammy_basepath + '?field=' + navigation_data.copyfield_dest[i];
343
+ navigation_content += '<dd class="copyfield"><a href="' + href + '">' + navigation_data.copyfield_dest[i] + '</a></dd>' + "\n";
344
+ }
345
+ }
346
+
347
+ if( 0 !== navigation_data.dynamic_fields.length )
348
+ {
349
+ navigation_data.dynamic_fields.sort();
350
+ navigation_content += '<dt class="dynamic-field">Dynamic Field</dt>' + "\n";
351
+ for( var i in navigation_data.dynamic_fields )
352
+ {
353
+ var href = sammy_basepath + '?dynamic-field=' + navigation_data.dynamic_fields[i];
354
+ navigation_content += '<dd class="dynamic-field"><a href="' + href + '">' + navigation_data.dynamic_fields[i] + '</a></dd>' + "\n";
355
+ }
356
+ }
357
+
358
+ if( 0 !== navigation_data.types.length )
359
+ {
360
+ navigation_data.types.sort();
361
+ navigation_content += '<dt class="type">Type</dt>' + "\n";
362
+ for( var i in navigation_data.types )
363
+ {
364
+ var href = sammy_basepath + '?type=' + navigation_data.types[i];
365
+ navigation_content += '<dd class="type"><a href="' + href + '">' + navigation_data.types[i] + '</a></dd>' + "\n";
366
+ }
367
+ }
368
+
369
+ related_navigation_element
370
+ .show()
371
+ .attr( 'class', type )
372
+ .html( navigation_content );
373
+ }
374
+ else
375
+ {
376
+ related_navigation_element
377
+ .hide();
378
+
379
+ $( 'option:selected', related_select_element )
380
+ .removeAttr( 'selected' );
381
+ }
382
+
383
+ if( 'field' === type && value === app.schema_browser_data.unique_key_field )
384
+ {
385
+ $( '.unique-key-field', related_navigation_meta )
386
+ .addClass( 'active' );
387
+ }
388
+ else
389
+ {
390
+ $( '.unique-key-field', related_navigation_meta )
391
+ .removeClass( 'active' );
392
+ }
393
+
394
+ if( 'field' === type && value === app.schema_browser_data.default_search_field )
395
+ {
396
+ $( '.default-search-field', related_navigation_meta )
397
+ .addClass( 'active' );
398
+ }
399
+ else
400
+ {
401
+ $( '.default-search-field', related_navigation_meta )
402
+ .removeClass( 'active' );
403
+ }
404
+
405
+ if( params.callback )
406
+ {
407
+ params.callback( app.schema_browser_data, $( '#data', params.schema_browser_element ) );
408
+ }
409
+ }
410
+ );
411
+
412
+ sammy.bind
413
+ (
414
+ 'schema_browser_load',
415
+ function( event, params )
416
+ {
417
+ var core_basepath = params.active_core.attr( 'data-basepath' );
418
+ var content_element = $( '#content' );
419
+
420
+ if( app.schema_browser_data )
421
+ {
422
+ params.schema_browser_element = $( '#schema-browser', content_element );
423
+
424
+ sammy.trigger
425
+ (
426
+ 'schema_browser_navi',
427
+ params
428
+ );
429
+ }
430
+ else
431
+ {
432
+ content_element
433
+ .html( '<div id="schema-browser"><div class="loader">Loading ...</div></div>' );
434
+
435
+ $.ajax
436
+ (
437
+ {
438
+ url : core_basepath + '/admin/luke?numTerms=0&wt=json',
439
+ dataType : 'json',
440
+ beforeSend : function( xhr, settings )
441
+ {
442
+ },
443
+ success : function( response, text_status, xhr )
444
+ {
445
+ app.schema_browser_data = {
446
+ default_search_field : null,
447
+ unique_key_field : null,
448
+ key : {},
449
+ fields : {},
450
+ dynamic_fields : {},
451
+ types : {},
452
+ relations : {
453
+ f_df : {},
454
+ f_t : {},
455
+ df_f : {},
456
+ df_t : {},
457
+ t_f : {},
458
+ t_df : {}
459
+ }
460
+ };
461
+
462
+ app.schema_browser_data.fields = response.fields;
463
+ app.schema_browser_data.key = response.info.key;
464
+
465
+ $.ajax
466
+ (
467
+ {
468
+ url : core_basepath + '/admin/luke?show=schema&wt=json',
469
+ dataType : 'json',
470
+ beforeSend : function( xhr, settings )
471
+ {
472
+ },
473
+ success : function( response, text_status, xhr )
474
+ {
475
+ app.schema_browser_data.default_search_field = response.schema.defaultSearchField;
476
+ app.schema_browser_data.unique_key_field = response.schema.uniqueKeyField;
477
+
478
+ app.schema_browser_data.dynamic_fields = response.schema.dynamicFields;
479
+ app.schema_browser_data.types = response.schema.types;
480
+
481
+ for( var field in response.schema.fields )
482
+ {
483
+ app.schema_browser_data.fields[field] = $.extend
484
+ (
485
+ {},
486
+ app.schema_browser_data.fields[field],
487
+ response.schema.fields[field]
488
+ );
489
+ }
490
+
491
+ for( var field in app.schema_browser_data.fields )
492
+ {
493
+ app.schema_browser_data.fields[field].copySourcesRaw = null;
494
+
495
+ if( app.schema_browser_data.fields[field].copySources &&
496
+ 0 !== app.schema_browser_data.fields[field].copySources.length )
497
+ {
498
+ app.schema_browser_data.fields[field].copySourcesRaw =
499
+ app.schema_browser_data.fields[field].copySources;
500
+ }
501
+
502
+ app.schema_browser_data.fields[field].copyDests = [];
503
+ app.schema_browser_data.fields[field].copySources = [];
504
+ }
505
+
506
+ for( var field in app.schema_browser_data.fields )
507
+ {
508
+ if( app.schema_browser_data.fields[field].copySourcesRaw )
509
+ {
510
+ var copy_sources = app.schema_browser_data.fields[field].copySourcesRaw;
511
+ for( var i in copy_sources )
512
+ {
513
+ var target = copy_sources[i].replace( /^.+:(.+)\{.+$/, '$1' );
514
+
515
+ app.schema_browser_data.fields[field].copySources.push( target );
516
+ app.schema_browser_data.fields[target].copyDests.push( field );
517
+ }
518
+ }
519
+
520
+ app.schema_browser_data.relations.f_t[field] = app.schema_browser_data.fields[field].type;
521
+
522
+ if( !app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] )
523
+ {
524
+ app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type] = [];
525
+ }
526
+ app.schema_browser_data.relations.t_f[app.schema_browser_data.fields[field].type].push( field );
527
+
528
+ if( app.schema_browser_data.fields[field].dynamicBase )
529
+ {
530
+ app.schema_browser_data.relations.f_df[field] = app.schema_browser_data.fields[field].dynamicBase;
531
+
532
+ if( !app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] )
533
+ {
534
+ app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase] = [];
535
+ }
536
+ app.schema_browser_data.relations.df_f[app.schema_browser_data.fields[field].dynamicBase].push( field );
537
+ }
538
+ }
539
+
540
+ for( var dynamic_field in app.schema_browser_data.dynamic_fields )
541
+ {
542
+ app.schema_browser_data.relations.df_t[dynamic_field] = app.schema_browser_data.dynamic_fields[dynamic_field].type;
543
+
544
+ if( !app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] )
545
+ {
546
+ app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type] = [];
547
+ }
548
+ app.schema_browser_data.relations.t_df[app.schema_browser_data.dynamic_fields[dynamic_field].type].push( dynamic_field );
549
+ }
550
+
551
+ $.get
552
+ (
553
+ 'tpl/schema-browser.html',
554
+ function( template )
555
+ {
556
+ content_element
557
+ .html( template );
558
+
559
+ var schema_browser_element = $( '#schema-browser', content_element );
560
+ var related_element = $( '#related', schema_browser_element );
561
+ var related_select_element = $( 'select', related_element );
562
+ var data_element = $( '#data', schema_browser_element );
563
+
564
+ var related_options = '';
565
+
566
+ var fields = [];
567
+ for( var field_name in app.schema_browser_data.fields )
568
+ {
569
+ fields.push
570
+ (
571
+ '<option value="?field=' + field_name + '">' + field_name + '</option>'
572
+ );
573
+ }
574
+ if( 0 !== fields.length )
575
+ {
576
+ fields.sort();
577
+ related_options += '<optgroup label="Fields">' + "\n";
578
+ related_options += fields.sort().join( "\n" ) + "\n";
579
+ related_options += '</optgroup>' + "\n";
580
+ }
581
+
582
+ var dynamic_fields = [];
583
+ for( var type_name in app.schema_browser_data.dynamic_fields )
584
+ {
585
+ dynamic_fields.push
586
+ (
587
+ '<option value="?dynamic-field=' + type_name + '">' + type_name + '</option>'
588
+ );
589
+ }
590
+ if( 0 !== dynamic_fields.length )
591
+ {
592
+ dynamic_fields.sort();
593
+ related_options += '<optgroup label="DynamicFields">' + "\n";
594
+ related_options += dynamic_fields.sort().join( "\n" ) + "\n";
595
+ related_options += '</optgroup>' + "\n";
596
+ }
597
+
598
+ var types = [];
599
+ for( var type_name in app.schema_browser_data.types )
600
+ {
601
+ types.push
602
+ (
603
+ '<option value="?type=' + type_name + '">' + type_name + '</option>'
604
+ );
605
+ }
606
+ if( 0 !== types.length )
607
+ {
608
+ types.sort();
609
+ related_options += '<optgroup label="Types">' + "\n";
610
+ related_options += types.sort().join( "\n" ) + "\n";
611
+ related_options += '</optgroup>' + "\n";
612
+ }
613
+
614
+ related_select_element
615
+ .attr( 'rel', '#/' + $( 'p a', params.active_core ).html() + '/schema-browser' )
616
+ .append( related_options )
617
+ .chosen();
618
+
619
+ related_select_element
620
+ .die( 'change' )
621
+ .live
622
+ (
623
+ 'change',
624
+ function( event )
625
+ {
626
+ var select_element = $( this );
627
+ var option_element = $( 'option:selected', select_element );
628
+
629
+ location.href = select_element.attr( 'rel' ) + option_element.val();
630
+ return false;
631
+ }
632
+ );
633
+
634
+ params.schema_browser_element = schema_browser_element;
635
+ sammy.trigger
636
+ (
637
+ 'schema_browser_navi',
638
+ params
639
+ );
640
+ }
641
+ );
642
+ },
643
+ error : function( xhr, text_status, error_thrown)
644
+ {
645
+ },
646
+ complete : function( xhr, text_status )
647
+ {
648
+ }
649
+ }
650
+ );
651
+
652
+ },
653
+ error : function( xhr, text_status, error_thrown)
654
+ {
655
+ },
656
+ complete : function( xhr, text_status )
657
+ {
658
+ }
659
+ }
660
+ );
661
+ }
662
+ }
663
+ );
664
+
665
+ // #/:core/schema-browser
666
+ sammy.get
667
+ (
668
+ /^#\/([\w\d-]+)\/(schema-browser)$/,
669
+ function( context )
670
+ {
671
+ var core_basepath = this.active_core.attr( 'data-basepath' );
672
+ current_core = context.params.splat[0];
673
+
674
+ var trigger_params = {
675
+ active_core : this.active_core
676
+ };
677
+
678
+ var path = context.path.split( '?' );
679
+ if( path && path[1] )
680
+ {
681
+ var param = path[1].split( '=' );
682
+ trigger_params.route_params = {
683
+ path : '?' + path[1],
684
+ type : param[0],
685
+ value : param[1]
686
+ }
687
+
688
+ trigger_params.callback = function( schema_browser_data, data_element )
689
+ {
690
+ var field = trigger_params.route_params.value;
691
+
692
+ var type = trigger_params.route_params.type;
693
+ var is_f = 'field' === type;
694
+ var is_df = 'dynamic-field' === type;
695
+ var is_t = 'type' === type;
696
+
697
+ var options_element = $( '.options', data_element );
698
+ var sammy_basepath = context.path.indexOf( '/', context.path.indexOf( '/', 2 ) + 1 );
699
+
700
+ data_element
701
+ .show();
702
+
703
+ var keystring_to_list = function( keystring, element_class )
704
+ {
705
+ var key_list = keystring.replace( /-/g, '' ).split( '' );
706
+ var list = [];
707
+
708
+ for( var i in key_list )
709
+ {
710
+ var option_key = schema_browser_data.key[key_list[i]];
711
+
712
+ if( !option_key )
713
+ {
714
+ option_key = schema_browser_data.key[key_list[i].toLowerCase()];
715
+ }
716
+
717
+ if( !option_key )
718
+ {
719
+ option_key = schema_browser_data.key[key_list[i].toUpperCase()];
720
+ }
721
+
722
+ if( option_key )
723
+ {
724
+ list.push
725
+ (
726
+ '<dd ' + ( element_class ? ' class="' + element_class + '"' : '' ) + '>' +
727
+ option_key +
728
+ ',</dd>'
729
+ );
730
+ }
731
+ }
732
+
733
+ list[list.length-1] = list[key_list.length-1].replace( /,/, '' );
734
+
735
+ return list;
736
+ }
737
+
738
+ var flags = null;
739
+
740
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].flags )
741
+ {
742
+ flags = schema_browser_data.fields[field].flags;
743
+ }
744
+ else if( is_df && schema_browser_data.dynamic_fields[field] && schema_browser_data.dynamic_fields[field].flags )
745
+ {
746
+ flags = schema_browser_data.dynamic_fields[field].flags;
747
+ }
748
+
749
+ // -- head
750
+
751
+ var head_element = $( '.head', data_element );
752
+ if( is_f )
753
+ {
754
+ $( '.type', head_element ).html( 'Field' );
755
+ }
756
+ else if( is_df )
757
+ {
758
+ $( '.type', head_element ).html( 'Dynamic Field' );
759
+ }
760
+ else if( is_t )
761
+ {
762
+ $( '.type', head_element ).html( 'Type' );
763
+ }
764
+ $( '.name', head_element ).html( field.esc() );
765
+
766
+ // -- properties
767
+ var properties_element = $( 'dt.properties', options_element );
768
+ if( flags )
769
+ {
770
+ var properties_keys = keystring_to_list( flags, 'properties' );
771
+
772
+ $( 'dd.properties', options_element )
773
+ .remove();
774
+
775
+ properties_element
776
+ .show()
777
+ .after( properties_keys.join( "\n" ) );
778
+ }
779
+ else
780
+ {
781
+ $( '.properties', options_element )
782
+ .hide();
783
+ }
784
+
785
+ // -- schema
786
+ var schema_element = $( 'dt.schema', options_element );
787
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].schema )
788
+ {
789
+ var schema_keys = keystring_to_list( schema_browser_data.fields[field].schema, 'schema' );
790
+
791
+ $( 'dd.schema', options_element )
792
+ .remove();
793
+
794
+ schema_element
795
+ .show()
796
+ .after( schema_keys.join( "\n" ) );
797
+ }
798
+ else
799
+ {
800
+ $( '.schema', options_element )
801
+ .hide();
802
+ }
803
+
804
+ // -- index
805
+ var index_element = $( 'dt.index', options_element );
806
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].index )
807
+ {
808
+ var index_keys = [];
809
+
810
+ if( 0 === schema_browser_data.fields[field].index.indexOf( '(' ) )
811
+ {
812
+ index_keys.push( '<dd class="index">' + schema_browser_data.fields[field].index + '</dd>' );
813
+ }
814
+ else
815
+ {
816
+ index_keys = keystring_to_list( schema_browser_data.fields[field].index, 'index' );
817
+ }
818
+
819
+ $( 'dd.index', options_element )
820
+ .remove();
821
+
822
+ index_element
823
+ .show()
824
+ .after( index_keys.join( "\n" ) );
825
+ }
826
+ else
827
+ {
828
+ $( '.index', options_element )
829
+ .hide();
830
+ }
831
+
832
+ // -- docs
833
+ var docs_element = $( 'dt.docs', options_element );
834
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].docs )
835
+ {
836
+ $( 'dd.docs', options_element )
837
+ .remove();
838
+
839
+ var target = '#/' + current_core + '/query?q=' + field.esc() + ':[* TO *]';
840
+ docs_element
841
+ .show()
842
+ .after(
843
+ '<dd class="docs">'+
844
+ '<a href="'+target+'">' + schema_browser_data.fields[field].docs + '</a>' +
845
+ '</dd>' );
846
+ }
847
+ else
848
+ {
849
+ $( '.docs', options_element )
850
+ .hide();
851
+ }
852
+
853
+ // -- distinct
854
+ var distinct_element = $( 'dt.distinct', options_element );
855
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].distinct )
856
+ {
857
+ $( 'dd.distinct', options_element )
858
+ .remove();
859
+
860
+ distinct_element
861
+ .show()
862
+ .after( '<dd class="distinct">' + schema_browser_data.fields[field].distinct + '</dd>' );
863
+ }
864
+ else
865
+ {
866
+ $( '.distinct', options_element )
867
+ .hide();
868
+ }
869
+
870
+ // -- position-increment-gap
871
+ var pig_element = $( 'dt.position-increment-gap', options_element );
872
+ if( is_f && schema_browser_data.fields[field] && schema_browser_data.fields[field].positionIncrementGap )
873
+ {
874
+ $( 'dd.position-increment-gap', options_element )
875
+ .remove();
876
+
877
+ pig_element
878
+ .show()
879
+ .after( '<dd class="position-increment-gap">' + schema_browser_data.fields[field].positionIncrementGap + '</dd>' );
880
+ }
881
+ else
882
+ {
883
+ $( '.position-increment-gap', options_element )
884
+ .hide();
885
+ }
886
+
887
+ var similarity_element = $( 'dt.similarity', options_element );
888
+ if ( is_t && schema_browser_data.types[field] && schema_browser_data.types[field].similarity ) {
889
+ var similarity = schema_browser_data.types[field].similarity
890
+ if (similarity.details && similarity.className) {
891
+ $( 'dd.similarity', options_element ).remove();
892
+ similarity_element
893
+ .show()
894
+ .after(['<dd class="similarity">', similarity.details.esc(), ' (', similarity.className.esc(), ') </dd>'].join(""));
895
+ }
896
+ } else {
897
+ $( '.similarity', options_element ).hide();
898
+ }
899
+
900
+ var analyzer_element = $( '.analyzer', data_element );
901
+ var analyzer_data = null;
902
+
903
+ var analysis_link = false;
904
+ var analysis_link_elements = $( 'p a', analyzer_element );
905
+ var analysis_target = '#/' + current_core + '/analysis?';
906
+
907
+ if( is_f )
908
+ {
909
+ analyzer_data = schema_browser_data.types[schema_browser_data.relations.f_t[field]];
910
+
911
+ analysis_link = true;
912
+ analysis_target += 'analysis.fieldname=' + field;
913
+ }
914
+ else if( is_df )
915
+ {
916
+ analyzer_data = schema_browser_data.types[schema_browser_data.relations.df_t[field]];
917
+ }
918
+ else if( is_t )
919
+ {
920
+ analyzer_data = schema_browser_data.types[field];
921
+
922
+ analysis_link = true;
923
+ analysis_target += 'analysis.fieldtype=' + field;
924
+ }
925
+
926
+ if( analysis_link )
927
+ {
928
+ analysis_link_elements
929
+ .addClass( 'analysis' )
930
+ .attr( 'href', analysis_target );
931
+ }
932
+ else
933
+ {
934
+ analysis_link_elements
935
+ .removeClass( 'analysis' )
936
+ .removeAttr( 'href' );
937
+ }
938
+
939
+
940
+ if( analyzer_data )
941
+ {
942
+ var transform_analyzer_data_into_list = function( analyzer_data )
943
+ {
944
+ var args = [];
945
+ for( var key in analyzer_data.args )
946
+ {
947
+ var arg_class = '';
948
+ var arg_content = '';
949
+
950
+ if( 'true' === analyzer_data.args[key] || '1' === analyzer_data.args[key] )
951
+ {
952
+ arg_class = 'ico-1';
953
+ arg_content = key;
954
+ }
955
+ else if( 'false' === analyzer_data.args[key] || '0' === analyzer_data.args[key] )
956
+ {
957
+ arg_class = 'ico-0';
958
+ arg_content = key;
959
+ }
960
+ else
961
+ {
962
+ arg_content = key + ': ';
963
+
964
+ if( 'synonyms' === key || 'words' === key )
965
+ {
966
+ // @TODO: set link target for file
967
+ arg_content += '<a>' + analyzer_data.args[key] + '</a>';
968
+ }
969
+ else
970
+ {
971
+ arg_content += analyzer_data.args[key];
972
+ }
973
+ }
974
+
975
+ args.push( '<dd class="' + arg_class + '">' + arg_content + '</dd>' );
976
+ }
977
+
978
+ var list_content = '<dt>' + analyzer_data.className + '</dt>';
979
+ if( 0 !== args.length )
980
+ {
981
+ args.sort();
982
+ list_content += args.join( "\n" );
983
+ }
984
+
985
+ return list_content;
986
+ }
987
+
988
+ // -- field-type
989
+ var field_type_element = $( 'dt.field-type', options_element );
990
+
991
+ $( 'dd.field-type', options_element )
992
+ .remove();
993
+
994
+ field_type_element
995
+ .show()
996
+ .after( '<dd class="field-type">' + analyzer_data.className + '</dd>' );
997
+
998
+ $( '.toggle', analyzer_element )
999
+ .die( 'click' )
1000
+ .live
1001
+ (
1002
+ 'click',
1003
+ function( event )
1004
+ {
1005
+ $( this ).closest( 'li' )
1006
+ .toggleClass( 'open' );
1007
+
1008
+ return false;
1009
+ }
1010
+ );
1011
+
1012
+ for( var key in analyzer_data )
1013
+ {
1014
+ var key_match = key.match( /^(.+)Analyzer$/ );
1015
+ if( !key_match )
1016
+ {
1017
+ continue;
1018
+ }
1019
+
1020
+ var analyzer_key_element = $( '.' + key_match[1], analyzer_element );
1021
+ var analyzer_key_data = analyzer_data[key];
1022
+
1023
+ analyzer_element.show();
1024
+ analyzer_key_element.show();
1025
+
1026
+ $( 'ul li', analyzer_key_element )
1027
+ .removeClass( 'data' )
1028
+ .hide();
1029
+
1030
+ for( var type in analyzer_key_data )
1031
+ {
1032
+ if( 'object' !== typeof analyzer_key_data[type] )
1033
+ {
1034
+ continue;
1035
+ }
1036
+
1037
+ var type_element = $( '.' + type, analyzer_key_element );
1038
+ var type_content = [];
1039
+
1040
+ type_element
1041
+ .addClass( 'data' )
1042
+ .show();
1043
+
1044
+ if( analyzer_key_data[type].className )
1045
+ {
1046
+ type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type] ) );
1047
+ }
1048
+ else
1049
+ {
1050
+ for( var entry in analyzer_key_data[type] )
1051
+ {
1052
+ type_content.push( transform_analyzer_data_into_list( analyzer_key_data[type][entry] ) );
1053
+ }
1054
+ }
1055
+
1056
+ $( 'dl', type_element )
1057
+ .empty()
1058
+ .append( type_content.join( "\n" ) );
1059
+ }
1060
+
1061
+ var name_element = $( 'dl:first dt a', analyzer_key_element );
1062
+ if( analyzer_key_data.className )
1063
+ {
1064
+ name_element
1065
+ .html( analyzer_key_data.className );
1066
+ }
1067
+
1068
+ 0 === $( 'ul li.data', analyzer_key_element ).size()
1069
+ ? name_element.removeClass( 'toggle' )
1070
+ : name_element.addClass( 'toggle' );
1071
+ }
1072
+ }
1073
+
1074
+ var terminfo_element = $( '.terminfo-holder', data_element );
1075
+
1076
+ terminfo_element
1077
+ .removeClass( 'disabled' )
1078
+ .removeClass( 'loaded' );
1079
+
1080
+ var trigger_element = $( '.trigger button', terminfo_element );
1081
+ var form_element = $( 'form', terminfo_element );
1082
+
1083
+ trigger_element
1084
+ .die( 'click' )
1085
+ .live
1086
+ (
1087
+ 'click',
1088
+ function( event )
1089
+ {
1090
+ form_element
1091
+ .trigger( 'submit' );
1092
+
1093
+ return false;
1094
+ }
1095
+ );
1096
+
1097
+ form_element
1098
+ .clearForm()
1099
+ .die( 'submit' )
1100
+ .live
1101
+ (
1102
+ 'submit',
1103
+ function( event )
1104
+ {
1105
+ load_terminfo( trigger_element, core_basepath, field, data_element, terminfo_element );
1106
+
1107
+ terminfo_element
1108
+ .addClass( 'loaded' );
1109
+
1110
+ return false;
1111
+ }
1112
+ );
1113
+
1114
+ $( '.max-holder', terminfo_element )
1115
+ .die( 'click' )
1116
+ .live
1117
+ (
1118
+ 'click',
1119
+ function( event )
1120
+ {
1121
+ var element = $( this );
1122
+
1123
+ $( 'input', element.closest( 'form' ) )
1124
+ .val( $( '.max', element ).text() );
1125
+
1126
+ form_element
1127
+ .trigger( 'submit' );
1128
+
1129
+ return false;
1130
+ }
1131
+ );
1132
+
1133
+ $( '.trigger .autoload', terminfo_element )
1134
+ .die( 'click' )
1135
+ .live
1136
+ (
1137
+ 'click',
1138
+ function( event )
1139
+ {
1140
+ $.cookie( cookie_schema_browser_autoload, $.cookie( cookie_schema_browser_autoload ) ? null : true );
1141
+ $( this ).trigger( 'state' );
1142
+
1143
+ return false;
1144
+ }
1145
+ )
1146
+ .die( 'state' )
1147
+ .live
1148
+ (
1149
+ 'state',
1150
+ function( event )
1151
+ {
1152
+ $.cookie( cookie_schema_browser_autoload )
1153
+ ? $( this ).addClass( 'on' )
1154
+ : $( this ).removeClass( 'on' );
1155
+ }
1156
+ )
1157
+ .die( 'init' )
1158
+ .live
1159
+ (
1160
+ 'init',
1161
+ function( event )
1162
+ {
1163
+ if( !$.cookie( cookie_schema_browser_autoload ) )
1164
+ {
1165
+ return false;
1166
+ }
1167
+
1168
+ $( this ).trigger( 'state' );
1169
+ trigger_element.trigger( 'click' );
1170
+ }
1171
+ )
1172
+ .trigger( 'init' );
1173
+
1174
+ $( 'div[class$="-holder"]', terminfo_element )
1175
+ .hide();
1176
+
1177
+ if( !is_f )
1178
+ {
1179
+ terminfo_element
1180
+ .hide();
1181
+ }
1182
+ else
1183
+ {
1184
+ terminfo_element
1185
+ .show();
1186
+ }
1187
+ }
1188
+ }
1189
+ else
1190
+ {
1191
+ trigger_params.callback = function( schema_browser_data, data_element )
1192
+ {
1193
+ data_element
1194
+ .hide();
1195
+ };
1196
+ }
1197
+
1198
+ delete app.schema_browser_data;
1199
+
1200
+ sammy.trigger
1201
+ (
1202
+ 'schema_browser_load',
1203
+ trigger_params
1204
+ );
1205
+ }
1206
+ );