html.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. App.HTML.setTplKeys = function(tpl, o, empty)
  2. {
  3. var empty = empty || '';
  4. fb.log(empty);
  5. tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'"))
  6. $(o).each(function(i, object)
  7. {
  8. $.each(o, function(key)
  9. {
  10. var val = o[key];
  11. if (empty == true) {
  12. tpl.set(':' + key, val || '');
  13. }
  14. else {
  15. tpl.set(':' + key, val || '');
  16. }
  17. });
  18. });
  19. return tpl;
  20. }
  21. App.HTML.makeDatabases = function(databases)
  22. {
  23. var acc = [];
  24. $(databases).each(function(i, o)
  25. {
  26. var tpl = App.Templates.get('database', 'database');
  27. tpl.set(':name', o.Database);
  28. tpl.set(':db_name', o.Database);
  29. acc[acc.length++] = tpl.finalize();
  30. });
  31. return acc.done();
  32. }
  33. App.HTML.makeDbTableList = function(data)
  34. {
  35. var acc = [];
  36. $(data).each(function(i, o)
  37. {
  38. var name = App.Helpers.getFirstValue(o);
  39. var tpl = App.Templates.get('database_table', 'database');
  40. tpl.set(':name', name);
  41. tpl.set(':table_name', name);
  42. acc[acc.length++] = tpl.finalize();
  43. });
  44. return acc.done();
  45. }
  46. App.HTML.makeDbFieldsList = function(data)
  47. {
  48. var acc = [];
  49. $(data).each(function(i, o)
  50. {
  51. var details = [o['Type'], o['Null'], o['Key'], o['Default'], o['Extra']].join(' ');
  52. var tpl = App.Templates.get('database_field', 'database');
  53. tpl.set(':name', o.Field);
  54. tpl.set(':details', details);
  55. acc[acc.length++] = tpl.finalize();
  56. });
  57. return acc.done();
  58. }
  59. App.HTML.Build.dns_form = function(options, id)
  60. {
  61. if('undefined' == typeof App.Env.initialParams) {
  62. return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
  63. }
  64. var tpl = App.Templates.get('FORM', 'dns');
  65. tpl.set(':source', options);
  66. options = App.Helpers.evalJSON(options) || {};
  67. if (App.Helpers.isEmpty(options)) {
  68. tpl.set(':title', 'New dns record');
  69. tpl.set(':save_button', 'ADD');
  70. }
  71. else {
  72. tpl.set(':title', 'Edit dns record');
  73. tpl.set(':save_button', 'SAVE');
  74. }
  75. tpl.set(':id', id || '');
  76. tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || '');
  77. tpl.set(':IP', options.IP || '');
  78. tpl.set(':TTL', options.TTL || '');
  79. tpl.set(':SOA', options.SOA || '');
  80. tpl.set(':DATE', options.DATE || '');
  81. tpl = App.HTML.Build.dns_selects(tpl, options);
  82. return tpl.finalize();
  83. }
  84. App.HTML.Build.ip_form = function(options, id)
  85. {
  86. if('undefined' == typeof App.Env.initialParams) {
  87. return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
  88. }
  89. var tpl = App.Templates.get('FORM', 'ip');
  90. tpl.set(':source', options);
  91. options = App.Helpers.evalJSON(options) || {};
  92. if (App.Helpers.isEmpty(options)) {
  93. tpl.set(':title', 'New ip address');
  94. tpl.set(':save_button', 'ADD');
  95. }
  96. else {
  97. tpl.set(':title', 'Edit ip address');
  98. tpl.set(':save_button', 'SAVE');
  99. }
  100. tpl.set(':id', id || '');
  101. tpl.set(':IP_ADDRESS', options.IP_ADDRESS || '');
  102. tpl.set(':NETMASK', options.NETMASK || '');
  103. tpl.set(':NAME', options.NAME || '');
  104. tpl = App.HTML.Build.ip_selects(tpl, options);
  105. return tpl.finalize();
  106. }
  107. App.HTML.Build.options = function(initial, default_value)
  108. {
  109. var opts = [];
  110. $.each(initial, function(key){
  111. var selected = key == default_value ? 'selected="selected"' : '';
  112. opts[opts.length++] = '<option value="'+key+'" '+selected+'>'+initial[key]+'</options>';
  113. });
  114. return opts.join('');
  115. }
  116. App.HTML.Build.ip_entry = function(o)
  117. {
  118. var tpl = App.Templates.get('ENTRY', 'ip');
  119. tpl = App.HTML.setTplKeys(tpl, o);
  120. /*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
  121. var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip');
  122. }
  123. else {
  124. var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip');
  125. }*/
  126. tpl.set(':SUSPENDED_TPL', '');
  127. return tpl.finalize();
  128. }
  129. App.HTML.Build.dns_entry = function(o, is_new)
  130. {
  131. var tpl = App.Templates.get('ENTRY', 'dns');
  132. tpl = App.HTML.setTplKeys(tpl, o);
  133. var ip = o.IP.split('.');
  134. tpl.set(':IP', ip.join('<span class="dot">.</span>'));
  135. tpl.set(':CHECKED', '');
  136. if (is_new) {
  137. var now = new Date();
  138. tpl.set(':DATE', now.format("d.mm.yyyy"));
  139. }
  140. tpl.set(':TPL_VAL', o.TPL);
  141. /*if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
  142. var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
  143. }
  144. else {
  145. var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
  146. }*/
  147. tpl.set(':SUSPENDED_TPL', '');
  148. return tpl.finalize();
  149. }
  150. App.HTML.Build.user_entry = function(o, key)
  151. {
  152. var processed_data = {
  153. 'NICKNAME' : key,
  154. 'U_DISK_PERCENTAGE' : o.U_DISK > 0 ? o.U_DISK / o.DISK_QUOTA * 100 : 1,
  155. 'U_BANDWIDTH_PERCENTAGE': o.U_BANDWIDTH > 0 ? o.U_BANDWIDTH / o.BANDWIDTH * 100 : 1,
  156. 'U_DISK' : o.U_DISK == 0 ? 1 : App.Helpers.formatNumber(o.U_DISK),
  157. 'U_BANDWIDTH' : o.U_BANDWIDTH == 0 ? 1 : App.Helpers.formatNumber(o.U_BANDWIDTH),
  158. 'DISK_QUOTA_MEASURE' : App.Helpers.getMbHumanMeasure(o.DISK_QUOTA),
  159. 'BANDWIDTH_MEASURE' : App.Helpers.getMbHumanMeasure(o.BANDWIDTH),
  160. 'BANDWIDTH' : App.Helpers.getMbHuman(o.BANDWIDTH),
  161. 'DISK_QUOTA' : App.Helpers.getMbHuman(o.DISK_QUOTA)
  162. };
  163. var o = $.extend(o, processed_data);
  164. o.U_DISK_PERCENTAGE_2 = o.U_DISK_PERCENTAGE;
  165. o.U_DISK_PERCENTAGE_3 = o.U_DISK_PERCENTAGE;
  166. o.BANDWIDTH_MEASURE_2 = o.BANDWIDTH_MEASURE;
  167. o.DISK_QUOTA_MEASURE_2 = o.DISK_QUOTA_MEASURE;
  168. o.U_BANDWIDTH_PERCENTAGE_2 = o.U_BANDWIDTH_PERCENTAGE;
  169. o.U_BANDWIDTH_PERCENTAGE_3 = o.U_BANDWIDTH_PERCENTAGE;
  170. var tpl = App.Templates.get('ENTRY', 'user');
  171. tpl = App.HTML.setTplKeys(tpl, o);
  172. tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
  173. var ns = [];
  174. var ns_full = [];
  175. $([1,2,3,4,5,6,7,8]).each(function(i, index)
  176. {
  177. var key = 'NS'+index;
  178. if ('undefined' != typeof o[key]) {
  179. if (o[key].trim() != '') {
  180. var tpl_ns = App.Templates.get('NS_RECORD', 'user');
  181. tpl_ns.set(':NAME', o[key]);
  182. var tpl_finalized = tpl_ns.finalize();
  183. ns_full[ns_full.length++] = tpl_finalized;
  184. if (i < App.Settings.USER_VISIBLE_NS) {
  185. ns[ns.length++] = tpl_finalized;
  186. }
  187. }
  188. }
  189. });
  190. if (ns_full.length <= App.Settings.USER_VISIBLE_NS) {
  191. tpl.set(':NS', ns.done());
  192. }
  193. else {
  194. var ns_custom = App.Templates.get('NS_MINIMIZED', 'user');
  195. ns_custom.set(':NS_MINI', ns.done());
  196. ns_custom.set(':NS_FULL', ns_full.done());
  197. ns_custom.set(':MORE_NUMBER', Math.abs(App.Settings.USER_VISIBLE_NS - ns_full.length));
  198. tpl.set(':NS', ns_custom.finalize());
  199. }
  200. tpl = App.HTML.Build.user_web_tpl(tpl, o);
  201. tpl.set(':REPORTS_ENABLED', o.REPORTS_ENABLED == 'yes' ? 'enabled' : 'DISABLED');
  202. if (o.U_DISK_PERCENTAGE > 100) {
  203. var tpl_over = App.Templates.get('over_bar', 'general');
  204. var difference = parseInt(o.U_DISK_PERCENTAGE, 10) - 100;
  205. tpl_over.set(':OVER_PERCENTS', difference);
  206. tpl_over.set(':OVER_PERCENTS_2', difference);
  207. tpl.set(':OVER_BAR', tpl_over.finalize());
  208. tpl.set(':U_DISK_PERCENTAGE_3', 100);
  209. tpl.set(':OVER_DRAFT_VALUE', 'overdraft');
  210. }
  211. else {
  212. tpl.set(':OVER_BAR', '');
  213. tpl.set(':OVER_DRAFT_VALUE', '');
  214. }
  215. // OVER BANDWIDTH
  216. if (o.U_BANDWIDTH_PERCENTAGE > 100) {
  217. var tpl_over = App.Templates.get('over_bar', 'general');
  218. var difference = parseInt(o.U_BANDWIDTH_PERCENTAGE, 10) - 100;
  219. tpl_over.set(':OVER_PERCENTS', difference);
  220. tpl_over.set(':OVER_PERCENTS_2', difference);
  221. tpl.set(':OVER_BAR_2', tpl_over.finalize());
  222. tpl.set(':U_BANDWIDTH_PERCENTAGE_3', 100);
  223. tpl.set(':OVER_DRAFT_VALUE_2', 'overdraft');
  224. }
  225. else {
  226. tpl.set(':OVER_BAR_2', '');
  227. tpl.set(':OVER_DRAFT_VALUE_2', '');
  228. }
  229. return tpl.finalize();
  230. }
  231. App.HTML.Build.user_form = function(options, id)
  232. {
  233. var in_edit = false;
  234. if (!App.Helpers.isEmpty(options)) {
  235. in_edit = true;
  236. }
  237. if('undefined' == typeof App.Env.initialParams) {
  238. return alert('Please wait a bit. Some background processes are not yet executed. Thank you for patience.');
  239. }
  240. var tpl = App.Templates.get('FORM', 'user');
  241. tpl.set(':source', options);
  242. tpl.set(':id', id || '');
  243. options = App.Helpers.evalJSON(options) || {};
  244. if (App.Helpers.isEmpty(options)) {
  245. tpl.set(':title', 'New user');
  246. tpl.set(':save_button', 'ADD');
  247. }
  248. else {
  249. tpl.set(':title', 'Edit user');
  250. tpl.set(':save_button', 'SAVE');
  251. }
  252. options = !App.Helpers.isEmpty(options) ? options : App.Empty.USER;
  253. if (in_edit == true) {
  254. options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
  255. // NS
  256. var ns = [];
  257. $([3,4,5,6,7,8]).each(function(i, index)
  258. {
  259. if (options['NS'+index].trim() != '') {
  260. var tpl_ns = App.Templates.get('NS_INPUT', 'user');
  261. tpl_ns.set(':NS_LABEL', 'NS #' + (index));
  262. tpl_ns.set(':NAME', options['NS'+index]);
  263. ns[ns.length++] = tpl_ns.finalize();
  264. }
  265. });
  266. ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
  267. tpl.set(':NS', ns.done());
  268. }
  269. else {
  270. tpl.set(':NS', '');
  271. }
  272. tpl = App.HTML.setTplKeys(tpl, options, true);
  273. tpl = App.HTML.Build.user_selects(tpl, options);
  274. if (options.REPORTS_ENABLED == 'yes') {
  275. tpl.set(':CHECKED', 'checked="checked"');
  276. }
  277. else {
  278. tpl.set(':CHECKED', '');
  279. }
  280. if (!in_edit) {
  281. tpl.set(':REPORTS_ENABLED_EDITABLE', 'hidden');
  282. }
  283. return tpl.finalize();
  284. }
  285. App.HTML.Build.web_domain_entry = function(o, key)
  286. {
  287. var processed_data = {
  288. DOMAIN: key
  289. };
  290. var o = $.extend(o, processed_data);
  291. var tpl = App.Templates.get('ENTRY', 'web_domain');
  292. tpl = App.HTML.setTplKeys(tpl, o);
  293. if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
  294. var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
  295. }
  296. else {
  297. var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
  298. }
  299. tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
  300. if (o.STATS_LOGIN.trim() != '') {
  301. tpl.set(':STATS_AUTH', '+auth');
  302. }
  303. else {
  304. tpl.set(':STATS_AUTH', '');
  305. }
  306. tpl.set(':DISK', App.Env.initialParams.PROFILE.BANDWIDTH);
  307. tpl.set(':BANDWIDTH', App.Env.initialParams.PROFILE.DISK);
  308. return tpl.finalize();
  309. }
  310. App.HTML.Build.web_domain_form = function(options, id)
  311. {
  312. if('undefined' == typeof App.Env.initialParams) {
  313. return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
  314. }
  315. var in_edit = false;
  316. if (!App.Helpers.isEmpty(options)) {
  317. in_edit = true;
  318. }
  319. var tpl = App.Templates.get('FORM', 'web_domain');
  320. tpl.set(':source', options);
  321. tpl.set(':id', id || '');
  322. options = App.Helpers.evalJSON(options) || {};
  323. if (App.Helpers.isEmpty(options)) {
  324. tpl.set(':title', 'New WEB domain');
  325. tpl.set(':save_button', 'ADD');
  326. }
  327. else {
  328. tpl.set(':title', 'Edit WEB domain');
  329. tpl.set(':save_button', 'SAVE');
  330. }
  331. options = !App.Helpers.isEmpty(options) ? options : App.Empty.WEB_DOMAIN;
  332. if (in_edit == true) {
  333. options.STATS_PASSWORD = options.STATS_LOGIN.trim() != '' ? App.Settings.PASSWORD_IMMUTE : '';
  334. }
  335. tpl = App.HTML.setTplKeys(tpl, options, true);
  336. tpl = App.HTML.Build.web_domain_selects(tpl, options);
  337. if (options.CGI == 'yes') {
  338. tpl.set(':CHECKED_CGI', 'checked="checked"');
  339. }
  340. if (options.ELOG == 'yes') {
  341. tpl.set(':CHECKED_ELOG', 'checked="checked"');
  342. }
  343. if (options.STATS_LOGIN.trim() != '') {
  344. tpl.set(':STAT_AUTH', 'checked="checked"');
  345. tpl.set(':ACTIVE_LOGIN', '');
  346. tpl.set(':ACTIVE_PASSWORD', '');
  347. tpl.set(':stats_auth_checked', 'checked="checked"');
  348. }
  349. else {
  350. tpl.set(':ACTIVE_LOGIN', 'hidden');
  351. tpl.set(':ACTIVE_PASSWORD', 'hidden');
  352. tpl.set(':stats_auth_checked', '');
  353. }
  354. return tpl.finalize();
  355. }
  356. App.HTML.Build.mail_entry = function(o, key)
  357. {
  358. var processed_data = {
  359. DOMAIN: key
  360. };
  361. var o = $.extend(o, processed_data);
  362. var tpl = App.Templates.get('ENTRY', 'mail');
  363. tpl = App.HTML.setTplKeys(tpl, o);
  364. return tpl.finalize();
  365. }
  366. App.HTML.Build.db_entry = function(o, key)
  367. {
  368. var user_list_html = [];
  369. $(o['USERS']).each(function(i, o)
  370. {
  371. var tpl = App.Templates.get('USER_ITEM', 'db');
  372. tpl.set(':NAME', o);
  373. user_list_html.push(tpl.finalize());
  374. });
  375. var wrapper = App.Templates.get('USER_ITEMS_WRAPPER', 'db');
  376. wrapper.set(':CONTENT', user_list_html.done());
  377. var processed_data = {
  378. 'USER_LIST': wrapper.finalize(),
  379. 'USERS': o['USERS'].length || 0,
  380. 'U_DISK_PERCENTAGE' : o.U_DISK > 0 ? o.U_DISK / o.DISK * 100 : 0.01,
  381. 'DISK_MEASURE': App.Helpers.getMbHumanMeasure(o.DISK),
  382. 'DISK': App.Helpers.getMbHuman(o.DISK)
  383. };
  384. var o = $.extend(o, processed_data);
  385. var tpl = App.Templates.get('ENTRY', 'db');
  386. tpl = App.HTML.setTplKeys(tpl, o);
  387. return tpl.finalize();
  388. }
  389. App.HTML.Build.db_form = function(options, id)
  390. {
  391. var in_edit = false;
  392. if (!App.Helpers.isEmpty(options)) {
  393. in_edit = true;
  394. }
  395. if('undefined' == typeof App.Env.initialParams) {
  396. return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
  397. }
  398. var tpl = App.Templates.get('FORM', 'db');
  399. tpl.set(':source', options);
  400. tpl.set(':id', id || '');
  401. options = App.Helpers.evalJSON(options) || {};
  402. if (App.Helpers.isEmpty(options)) {
  403. tpl.set(':title', 'New database');
  404. tpl.set(':save_button', 'ADD');
  405. }
  406. else {
  407. tpl.set(':title', 'Edit database "'+options.DB+'"');
  408. tpl.set(':save_button', 'SAVE');
  409. }
  410. options = !App.Helpers.isEmpty(options) ? options : App.Empty.DB;
  411. if (in_edit == true) {
  412. options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
  413. }
  414. tpl = App.HTML.setTplKeys(tpl, options, true);
  415. tpl = App.HTML.Build.db_selects(tpl, options);
  416. return tpl.finalize();
  417. }
  418. App.HTML.Build.cron_entry = function(o, key)
  419. {
  420. var processed_data = {
  421. DOMAIN: key
  422. };
  423. var o = $.extend(o, processed_data);
  424. var tpl = App.Templates.get('ENTRY', 'cron');
  425. tpl = App.HTML.setTplKeys(tpl, o);
  426. if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
  427. var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
  428. }
  429. else {
  430. var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
  431. }
  432. tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
  433. return tpl.finalize();
  434. }
  435. App.HTML.Build.cron_form = function(options, id)
  436. {
  437. if('undefined' == typeof App.Env.initialParams) {
  438. return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
  439. }
  440. var tpl = App.Templates.get('FORM', 'cron');
  441. tpl.set(':source', options);
  442. tpl.set(':id', id || '');
  443. options = App.Helpers.evalJSON(options) || {};
  444. if (App.Helpers.isEmpty(options)) {
  445. tpl.set(':title', 'New cron entry');
  446. tpl.set(':save_button', 'ADD');
  447. }
  448. else {
  449. tpl.set(':title', 'Edit cron entry');
  450. tpl.set(':save_button', 'SAVE');
  451. }
  452. options = !App.Helpers.isEmpty(options) ? options : {DAY:'', MONTH: '', WDAY:'',HOUR:'',CMD:'',MIN:''};
  453. tpl = App.HTML.setTplKeys(tpl, options);
  454. return tpl.finalize();
  455. }
  456. App.HTML.Build.dns_records = function(records)
  457. {
  458. var acc = [];
  459. $.each(records, function(i, record)
  460. {
  461. var record = records[i];
  462. var tpl = App.HTML.Build.dns_subrecord(record);
  463. acc[acc.length++] = tpl.finalize();
  464. });
  465. return acc.done();
  466. }
  467. App.HTML.Build.dns_subrecord = function(record)
  468. {
  469. var tpl = App.Templates.get('SUBENTRY', 'dns');
  470. tpl.set(':RECORD', record.RECORD || '');
  471. tpl.set(':RECORD_VALUE', record.RECORD_VALUE || '');
  472. tpl.set(':RECORD_ID', record.RECORD_ID || '');
  473. tpl.set(':RECORD_TYPE', App.HTML.Build.options(App.Env.initialParams.DNS.record.RECORD_TYPE, (record.RECORD_TYPE || -1)));
  474. return tpl;
  475. }
  476. App.HTML.Build.ssl_key_file = function()
  477. {
  478. return '<iframe src="'+App.Helpers.getUploadUrl()+'?action=show&type=key" width="500px;" height="53px;" framevorder="0" scroll="no">..</iframe>';
  479. }
  480. App.HTML.Build.ssl_cert_file = function()
  481. {
  482. return '<iframe src="'+App.Helpers.getUploadUrl()+'?action=show&type=cert" width="500px;" height="53px;" framevorder="0" scroll="no">..</iframe>';
  483. }
  484. App.HTML.Build.user_selects = function(tpl, options)
  485. {
  486. var acc = [];
  487. // PACKAGE
  488. var pkg = App.Env.initialParams.USERS.PACKAGE;
  489. $.each(pkg, function(val)
  490. {
  491. var tpl = App.Templates.get('select_option', 'general');
  492. tpl.set(':VALUE', val);
  493. tpl.set(':TEXT', pkg[val]);
  494. tpl.set(':SELECTED', val == options.PACKAGE ? 'selected="selected"' : '');
  495. acc[acc.length++] = tpl.finalize();
  496. });
  497. tpl.set(':PACKAGE_OPTIONS', acc.done());
  498. // ROLE
  499. acc = [];
  500. var roles = App.Env.initialParams.USERS.ROLE;
  501. $.each(roles, function(val)
  502. {
  503. var tpl = App.Templates.get('select_option', 'general');
  504. tpl.set(':VALUE', val);
  505. tpl.set(':TEXT', roles[val]);
  506. tpl.set(':SELECTED', val == options.ROLE ? 'selected="selected"' : '');
  507. acc[acc.length++] = tpl.finalize();
  508. });
  509. tpl.set(':ROLE_OPTIONS', acc.done());
  510. // SHELL
  511. acc = [];
  512. var shell = App.Env.initialParams.USERS.SHELL;
  513. $.each(shell, function(val)
  514. {
  515. var tpl = App.Templates.get('select_option', 'general');
  516. tpl.set(':VALUE', val);
  517. tpl.set(':TEXT', shell[val]);
  518. tpl.set(':SELECTED', val == options.SHELL ? 'selected="selected"' : '');
  519. acc[acc.length++] = tpl.finalize();
  520. });
  521. tpl.set(':SHELL_OPTIONS', acc.done());
  522. return tpl;
  523. }
  524. App.HTML.Build.db_selects = function(tpl, options)
  525. {
  526. var acc = [];
  527. // PACKAGE
  528. var items = App.Env.initialParams.DB.TYPE;
  529. $.each(items, function(val)
  530. {
  531. var tpl = App.Templates.get('select_option', 'general');
  532. tpl.set(':VALUE', val);
  533. tpl.set(':TEXT', items[val]);
  534. tpl.set(':SELECTED', val == options.TYPE ? 'selected="selected"' : '');
  535. acc[acc.length++] = tpl.finalize();
  536. });
  537. tpl.set(':TYPE_OPTIONS', acc.done());
  538. // ROLE
  539. acc = [];
  540. var items = App.Env.initialParams.DB.HOST;
  541. $.each(items, function(val)
  542. {
  543. var tpl = App.Templates.get('select_option', 'general');
  544. tpl.set(':VALUE', val);
  545. tpl.set(':TEXT', items[val]);
  546. tpl.set(':SELECTED', val == options.HOST ? 'selected="selected"' : '');
  547. acc[acc.length++] = tpl.finalize();
  548. });
  549. tpl.set(':HOST_OPTIONS', acc.done());
  550. return tpl;
  551. }
  552. App.HTML.Build.ip_selects = function(tpl, options)
  553. {
  554. // OWNER
  555. var users = App.Env.initialParams.IP.OWNER;
  556. var opts = App.HTML.Build.options(users, options.OWNER);
  557. tpl.set(':owner_options', opts);
  558. // STATUS
  559. var opts = App.HTML.Build.options(App.Env.initialParams.IP.STATUSES, options.STATUS);
  560. tpl.set(':status_options', opts);
  561. // INTERFACE
  562. var opts = App.HTML.Build.options(App.Env.initialParams.IP.INTERFACES, options.INTERFACE);
  563. tpl.set(':interface_options', opts);
  564. return tpl;
  565. }
  566. App.HTML.Build.dns_selects = function(tpl, options)
  567. {
  568. try {
  569. // TPL
  570. var obj = {};
  571. $.each(App.Env.initialParams.DNS.TPL, function(key) {
  572. obj[key] = key;
  573. });
  574. var opts = App.HTML.Build.options(obj, options.PACKAGE);
  575. tpl.set(':TPL', opts);
  576. tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
  577. }
  578. catch (e) {
  579. return tpl;
  580. }
  581. return tpl;
  582. }
  583. App.HTML.Build.web_domain_selects = function(tpl, options)
  584. {
  585. try {
  586. // IP
  587. var obj = App.Env.initialParams.WEB_DOMAIN.IP;
  588. var opts = App.HTML.Build.options(obj, options.IP);
  589. tpl.set(':IP_OPTIONS', opts);
  590. // TPL
  591. var obj = {};
  592. $.each(App.Env.initialParams.WEB_DOMAIN.TPL, function(key) {
  593. obj[key] = key;
  594. });
  595. //var obj = App.Env.initialParams.WEB_DOMAIN.TPL;
  596. var opts = App.HTML.Build.options(obj, options.TPL);
  597. tpl.set(':TPL_OPTIONS', opts);
  598. // STAT
  599. var obj = App.Env.initialParams.WEB_DOMAIN.STAT;
  600. var opts = App.HTML.Build.options(obj, options.STAT);
  601. tpl.set(':STAT_OPTIONS', opts);
  602. }
  603. catch (e) {
  604. return tpl;
  605. }
  606. return tpl;
  607. }
  608. App.HTML.Build.user_web_tpl = function(tpl, o)
  609. {
  610. var wt = [];
  611. var wt_full = [];
  612. var templates = o.WEB_TPL;
  613. templates = templates.split(',');
  614. if (templates.length == 0) {
  615. templates = templates.split(' ');
  616. }
  617. $(templates).each(function(i, web_tpl) {
  618. var tpl_wt = App.Templates.get('WEB_TPL', 'user');
  619. tpl_wt.set(':NAME', web_tpl);
  620. var tpl_finalized = tpl_wt.finalize();
  621. wt_full[wt_full.length++] = tpl_finalized;
  622. if (i < App.Settings.USER_VISIBLE_WEB_TPL) {
  623. wt[wt.length++] = tpl_finalized;
  624. }
  625. });
  626. if (templates.length <= App.Settings.USER_VISIBLE_NS) {
  627. tpl.set(':WEB_TPL', wt.done());
  628. }
  629. else {
  630. var wt_custom = App.Templates.get('WEB_TPL_MINIMIZED', 'user');
  631. wt_custom.set(':WEB_TPL_MINI', wt.done());
  632. wt_custom.set(':WEB_TPL_FULL', wt_full.done());
  633. wt_custom.set(':MORE_NUMBER', Math.abs(App.Settings.USER_VISIBLE_NS - wt_full.length));
  634. tpl.set(':WEB_TPL', wt_custom.finalize());
  635. }
  636. return tpl;
  637. }