utils.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. // Some general purpose JS functions for the iTop application
  2. //IE 8 compatibility, copied from: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/IndexOf
  3. if (!Array.prototype.indexOf) {
  4. if (false) // deactivated since it causes troubles: for(k in aData) => returns the indexOf function as first element on empty arrays !
  5. {
  6. Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
  7. "use strict";
  8. if (this == null) {
  9. throw new TypeError();
  10. }
  11. var t = Object(this);
  12. var len = t.length >>> 0;
  13. if (len === 0) {
  14. return -1;
  15. }
  16. var n = 0;
  17. if (arguments.length > 1) {
  18. n = Number(arguments[1]);
  19. if (n != n) { // shortcut for verifying if it's NaN
  20. n = 0;
  21. } else if (n != 0 && n != Infinity && n != -Infinity) {
  22. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  23. }
  24. }
  25. if (n >= len) {
  26. return -1;
  27. }
  28. var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
  29. for (; k < len; k++) {
  30. if (k in t && t[k] === searchElement) {
  31. return k;
  32. }
  33. }
  34. return -1;
  35. }
  36. }
  37. }
  38. /**
  39. * Reload a truncated list
  40. */
  41. aTruncatedLists = {}; // To keep track of the list being loaded, each member is an ajaxRequest object
  42. function ReloadTruncatedList(divId, sSerializedFilter, sExtraParams)
  43. {
  44. $('#'+divId).block();
  45. //$('#'+divId).blockUI();
  46. if (aTruncatedLists[divId] != undefined)
  47. {
  48. try
  49. {
  50. aAjaxRequest = aTruncatedLists[divId];
  51. aAjaxRequest.abort();
  52. }
  53. catch(e)
  54. {
  55. // Do nothing special, just continue
  56. console.log('Uh,uh, exception !');
  57. }
  58. }
  59. aTruncatedLists[divId] = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style=list',
  60. { operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
  61. function(data)
  62. {
  63. aTruncatedLists[divId] = undefined;
  64. if (data.length > 0)
  65. {
  66. $('#'+divId).html(data);
  67. $('#'+divId+' .listResults').tableHover(); // hover tables
  68. $('#'+divId+' .listResults').each( function()
  69. {
  70. var table = $(this);
  71. var id = $(this).parent();
  72. aTruncatedLists[divId] = undefined;
  73. var checkbox = (table.find('th:first :checkbox').length > 0);
  74. if (checkbox)
  75. {
  76. // There is a checkbox in the first column, don't make it sortable
  77. table.tablesorter( { headers: { 0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ).tablesorterPager({container: $("#pager")}); // sortable and zebra tables
  78. }
  79. else
  80. {
  81. // There is NO checkbox in the first column, all columns are considered sortable
  82. table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ).tablesorterPager({container: $("#pager"), totalRows:97, filter: sSerializedFilter, extra_params: sExtraParams }); // sortable and zebra tables
  83. }
  84. });
  85. $('#'+divId).unblock();
  86. }
  87. }
  88. );
  89. }
  90. /**
  91. * Truncate a previously expanded list !
  92. */
  93. function TruncateList(divId, iLimit, sNewLabel, sLinkLabel)
  94. {
  95. $('#'+divId).block();
  96. var iCount = 0;
  97. $('#'+divId+' table.listResults tr:gt('+iLimit+')').each( function(){
  98. $(this).remove();
  99. });
  100. $('#lbl_'+divId).html(sNewLabel);
  101. $('#'+divId+' table.listResults tr:last td').addClass('truncated');
  102. $('#'+divId+' table.listResults').addClass('truncated');
  103. $('#trc_'+divId).html(sLinkLabel);
  104. $('#'+divId+' .listResults').trigger("update"); // Reset the cache
  105. $('#'+divId).unblock();
  106. }
  107. /**
  108. * Reload any block -- used for periodic auto-reload
  109. */
  110. function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
  111. {
  112. // Check if the user is not editing the list properties right now
  113. var bDialogOpen = false;
  114. var oDataTable = $('#'+divId+' :itop-datatable');
  115. var bIsDataTable = false;
  116. if (oDataTable.length > 0)
  117. {
  118. bDialogOpen = oDataTable.datatable('IsDialogOpen');
  119. bIsDataTable = true;
  120. }
  121. if (!bDialogOpen)
  122. {
  123. if (bIsDataTable)
  124. {
  125. oDataTable.datatable('DoRefresh');
  126. }
  127. else
  128. {
  129. $('#'+divId).block();
  130. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style='+sStyle,
  131. { operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
  132. function(data){
  133. $('#'+divId).empty();
  134. $('#'+divId).append(data);
  135. $('#'+divId).removeClass('loading');
  136. }
  137. );
  138. }
  139. }
  140. }
  141. function SaveGroupBySortOrder(sTableId, aValues)
  142. {
  143. var sDashboardId = $('#'+sTableId).closest('.dashboard_contents').attr('id');
  144. var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
  145. if (aValues.length != 0)
  146. {
  147. $sValue = JSON.stringify(aValues);
  148. if (GetUserPreference(sPrefKey, null) != $sValue)
  149. {
  150. SetUserPreference(sPrefKey, $sValue, true);
  151. }
  152. }
  153. }
  154. function LoadGroupBySortOrder(sTableId)
  155. {
  156. var sDashboardId = $('#'+sTableId).closest('.dashboard_contents').attr('id');
  157. var sPrefKey = 'GroupBy_'+sDashboardId+'_'+sTableId;
  158. var sValues = GetUserPreference(sPrefKey, null);
  159. if (sValues != null)
  160. {
  161. aValues = JSON.parse(sValues);
  162. window.setTimeout(function () { $('#'+sTableId+' table.listResults').trigger('sorton', [aValues]); }, 50);
  163. }
  164. }
  165. /**
  166. * Update the display and value of a file input widget when the user picks a new file
  167. */
  168. function UpdateFileName(id, sNewFileName)
  169. {
  170. var aPath = sNewFileName.split('\\');
  171. var sNewFileName = aPath[aPath.length-1];
  172. $('#'+id).val(sNewFileName);
  173. $('#'+id).trigger('validate');
  174. $('#name_'+id).text(sNewFileName);
  175. return true;
  176. }
  177. /**
  178. * Reload a search form for the specified class
  179. */
  180. function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
  181. {
  182. var oDiv = $('#ds_'+divId);
  183. oDiv.block();
  184. // deprecated in jQuery 1.8
  185. //var oFormEvents = $('#ds_'+divId+' form').data('events');
  186. var oForm = $('#ds_'+divId+' form');
  187. var oFormEvents = $._data(oForm[0], "events");
  188. // Save the submit handlers
  189. aSubmit = new Array();
  190. if ( (oFormEvents != null) && (oFormEvents.submit != undefined))
  191. {
  192. for(var index = 0; index < oFormEvents.submit.length; index++)
  193. {
  194. aSubmit [index ] = { data:oFormEvents.submit[index].data, namespace:oFormEvents.submit[index].namespace, handler: oFormEvents.submit[index].handler};
  195. }
  196. }
  197. sAction = $('#ds_'+divId+' form').attr('action');
  198. // Save the current values in the form
  199. var oMap = {};
  200. $('#ds_'+divId+" form :input[name!='']").each(function() {
  201. oMap[this.name] = this.value;
  202. });
  203. oMap.operation = 'search_form';
  204. oMap.className = sClassName;
  205. oMap.baseClass = sBaseClass;
  206. oMap.currentId = divId;
  207. oMap.action = sAction;
  208. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, oMap,
  209. function(data) {
  210. oDiv.empty();
  211. oDiv.append(data);
  212. if (aSubmit.length > 0)
  213. {
  214. var oForm = $('#ds_'+divId+' form'); // Form was reloaded, recompute it
  215. for(var index = 0; index < aSubmit.length; index++)
  216. {
  217. // Restore the previously bound submit handlers
  218. var sEventName = 'submit';
  219. if ((aSubmit[index].namespace != undefined) && (aSubmit[index].namespace != ''))
  220. {
  221. sEventName += '.'+aSubmit[index].namespace;
  222. }
  223. if (aSubmit[index].data != undefined)
  224. {
  225. oForm.bind(sEventName, aSubmit[index].data, aSubmit[index].handler)
  226. }
  227. else
  228. {
  229. oForm.bind(sEventName, aSubmit[index].handler)
  230. }
  231. }
  232. }
  233. FixSearchFormsDisposition();
  234. oDiv.unblock();
  235. oDiv.parent().resize(); // Inform the parent that the form has just been (potentially) resized
  236. }
  237. );
  238. }
  239. function FixSearchFormsDisposition()
  240. {
  241. // Fix search forms
  242. $('.SearchDrawer').each(function() {
  243. var colWidth = 0;
  244. var labelWidth = 0;
  245. $('label:visible', $(this)).each( function() {
  246. var l = $(this).parent().width() - $(this).width();
  247. colWidth = Math.max(l, colWidth);
  248. labelWidth = Math.max($(this).width(), labelWidth);
  249. });
  250. $('label:visible', $(this)).each( function() {
  251. if($(this).data('resized') != true)
  252. {
  253. $(this).parent().width(colWidth + labelWidth);
  254. $(this).width(labelWidth).css({display: 'inline-block'}).data('resized', true);
  255. }
  256. });
  257. });
  258. }
  259. /**
  260. * Stores - in a persistent way - user specific preferences
  261. * depends on a global variable oUserPreferences created/filled by the iTopWebPage
  262. * that acts as a local -write through- cache
  263. */
  264. function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent)
  265. {
  266. sPreviousValue = undefined;
  267. try
  268. {
  269. sPreviousValue = oUserPreferences[sPreferenceCode];
  270. }
  271. catch(err)
  272. {
  273. sPreviousValue = undefined;
  274. }
  275. oUserPreferences[sPreferenceCode] = sPrefValue;
  276. if (bPersistent && (sPrefValue != sPreviousValue))
  277. {
  278. ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
  279. { operation: 'set_pref', code: sPreferenceCode, value: sPrefValue} ); // Make it persistent
  280. }
  281. }
  282. /**
  283. * Get user specific preferences
  284. * depends on a global variable oUserPreferences created/filled by the iTopWebPage
  285. * that acts as a local -write through- cache
  286. */
  287. function GetUserPreference(sPreferenceCode, sDefaultValue)
  288. {
  289. var value = sDefaultValue;
  290. if ( oUserPreferences[sPreferenceCode] != undefined)
  291. {
  292. value = oUserPreferences[sPreferenceCode];
  293. }
  294. return value;
  295. }
  296. /**
  297. * Check/uncheck a whole list of checkboxes
  298. */
  299. function CheckAll(sSelector, bValue)
  300. {
  301. var value = bValue;
  302. $(sSelector).each( function() {
  303. if (this.checked != value)
  304. {
  305. this.checked = value;
  306. $(this).trigger('change');
  307. }
  308. });
  309. }
  310. /**
  311. * Toggle (enabled/disabled) the specified field of a form
  312. */
  313. function ToogleField(value, field_id)
  314. {
  315. if (value)
  316. {
  317. $('#'+field_id).removeAttr('disabled');
  318. // In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
  319. $('#'+field_id+' :input').removeAttr('disabled');
  320. }
  321. else
  322. {
  323. $('#'+field_id).attr('disabled', 'disabled');
  324. // In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
  325. $('#'+field_id+' :input').attr('disabled', 'disabled');
  326. }
  327. $('#'+field_id).trigger('update');
  328. $('#'+field_id).trigger('validate');
  329. }
  330. /**
  331. * For the fields that cannot be visually disabled, they can be blocked
  332. * @return
  333. */
  334. function BlockField(field_id, bBlocked)
  335. {
  336. if (bBlocked)
  337. {
  338. $('#'+field_id).block({ message: ' ** disabled ** '});
  339. }
  340. else
  341. {
  342. $('#'+field_id).unblock();
  343. }
  344. }
  345. /**
  346. * Updates (enables/disables) a "duration" field
  347. */
  348. function ToggleDurationField(field_id)
  349. {
  350. // Toggle all the subfields that compose the "duration" input
  351. aSubFields = new Array('d', 'h', 'm', 's');
  352. if ($('#'+field_id).attr('disabled'))
  353. {
  354. for(var i=0; i<aSubFields.length; i++)
  355. {
  356. $('#'+field_id+'_'+aSubFields[i]).attr('disabled', 'disabled');
  357. }
  358. }
  359. else
  360. {
  361. for(var i=0; i<aSubFields.length; i++)
  362. {
  363. $('#'+field_id+'_'+aSubFields[i]).removeAttr('disabled');
  364. }
  365. }
  366. }
  367. /**
  368. * PropagateCheckBox
  369. */
  370. function PropagateCheckBox(bCurrValue, aFieldsList, bCheck)
  371. {
  372. if (bCurrValue == bCheck)
  373. {
  374. for(var i=0;i<aFieldsList.length;i++)
  375. {
  376. $('#enable_'+aFieldsList[i]).attr('checked', bCheck);
  377. ToogleField(bCheck, aFieldsList[i]);
  378. }
  379. }
  380. }
  381. function FixTableSorter(table)
  382. {
  383. if (table[0].config == undefined)
  384. {
  385. // Table is not sort-able, let's fix it
  386. var checkbox = (table.find('th:first :checkbox').length > 0);
  387. if (checkbox)
  388. {
  389. // There is a checkbox in the first column, don't make it sort-able
  390. table.tablesorter( { headers: { 0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
  391. }
  392. else
  393. {
  394. // There is NO checkbox in the first column, all columns are considered sort-able
  395. table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sort-able and zebra tables
  396. }
  397. }
  398. }
  399. function DashletCreationDlg(sOQL)
  400. {
  401. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'dashlet_creation_dlg', oql: sOQL}, function(data){
  402. $('body').append(data);
  403. });
  404. return false;
  405. }
  406. function ShortcutListDlg(sOQL, sDataTableId, sContext)
  407. {
  408. var sDataTableName = 'datatable_'+sDataTableId;
  409. var oTableSettings = {
  410. oColumns: $('#'+sDataTableName).datatable('option', 'oColumns'),
  411. iPageSize: $('#'+sDataTableName).datatable('option', 'iPageSize')
  412. };
  413. var sTableSettings = JSON.stringify(oTableSettings);
  414. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'shortcut_list_dlg', oql: sOQL, table_settings: sTableSettings}, function(data){
  415. $('body').append(data);
  416. });
  417. return false;
  418. }
  419. function ExportListDlg(sOQL, sDataTableId, sFormat, sDlgTitle)
  420. {
  421. var aFields = [];
  422. if (sDataTableId != '')
  423. {
  424. var sDataTableName = 'datatable_'+sDataTableId;
  425. var oColumns = $('#'+sDataTableName).datatable('option', 'oColumns');
  426. for(var j in oColumns)
  427. {
  428. for(var k in oColumns[j])
  429. {
  430. if (oColumns[j][k].checked)
  431. {
  432. var sCode = oColumns[j][k].code;
  433. if (sCode == '_key_')
  434. {
  435. sCode = 'id';
  436. }
  437. aFields.push(j+'.'+sCode);
  438. }
  439. }
  440. }
  441. }
  442. var oParams = {
  443. interactive: 1,
  444. mode: 'dialog',
  445. expression: sOQL,
  446. suggested_fields: aFields.join(','),
  447. dialog_title: sDlgTitle
  448. };
  449. if (sFormat !== null)
  450. {
  451. oParams.format = sFormat;
  452. }
  453. $.post(GetAbsoluteUrlAppRoot()+'webservices/export-v2.php', oParams, function(data) {
  454. $('body').append(data);
  455. });
  456. return false;
  457. }
  458. function ExportToggleFormat(sFormat)
  459. {
  460. $('.form_part').hide();
  461. for(k in window.aFormParts[sFormat])
  462. {
  463. $('#form_part_'+window.aFormParts[sFormat][k]).show().trigger('form-part-activate');
  464. }
  465. }
  466. function ExportStartExport()
  467. {
  468. var oParams = {};
  469. $('.form_part:visible :input').each(function() {
  470. if (this.name != '')
  471. {
  472. if ((this.type == 'radio') || (this.type == 'checkbox'))
  473. {
  474. if (this.checked)
  475. {
  476. oParams[this.name] = $(this).val();
  477. }
  478. }
  479. else
  480. {
  481. oParams[this.name] = $(this).val();
  482. }
  483. }
  484. });
  485. $(':itop-tabularfieldsselector:visible').tabularfieldsselector('close_all_tooltips');
  486. $('#export-form').hide();
  487. $('#export-feedback').show();
  488. oParams.operation = 'export_build';
  489. oParams.format = $('#export-form :input[name=format]').val();
  490. var sQueryMode = $(':input[name=query_mode]:checked').val();
  491. if($(':input[name=query_mode]:checked').length > 0)
  492. {
  493. if (sQueryMode == 'oql')
  494. {
  495. oParams.expression = $('#export-form :input[name=expression]').val();
  496. }
  497. else
  498. {
  499. oParams.query = $('#export-form :input[name=query]').val();
  500. }
  501. }
  502. else
  503. {
  504. oParams.expression = $('#export-form :input[name=expression]').val();
  505. oParams.query = $('#export-form :input[name=query]').val();
  506. }
  507. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
  508. if (data == null)
  509. {
  510. ExportError('Export failed (no data provided), please contact your administrator');
  511. }
  512. else
  513. {
  514. ExportRun(data);
  515. }
  516. }, 'json')
  517. .fail(function() {
  518. ExportError('Export failed, please contact your administrator');
  519. });
  520. }
  521. function ExportError(sMessage)
  522. {
  523. $('.export-message').html(sMessage);
  524. $('.export-progress-bar').hide();
  525. $('#export-btn').hide();
  526. }
  527. function ExportRun(data)
  528. {
  529. switch(data.code)
  530. {
  531. case 'run':
  532. // Continue
  533. $('.export-progress-bar').progressbar({value: data.percentage });
  534. $('.export-message').html(data.message);
  535. oParams = {};
  536. oParams.token = data.token;
  537. var sDataState = $('#export-form').attr('data-state');
  538. if (sDataState == 'cancelled')
  539. {
  540. oParams.operation = 'export_cancel';
  541. }
  542. else
  543. {
  544. oParams.operation = 'export_build';
  545. }
  546. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
  547. ExportRun(data);
  548. },
  549. 'json');
  550. break;
  551. case 'done':
  552. $('#export-btn').hide();
  553. sMessage = '<a href="'+GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?operation=export_download&token='+data.token+'" target="_blank">'+data.message+'</a>';
  554. $('.export-message').html(sMessage);
  555. $('.export-progress-bar').hide();
  556. $('#export-btn').hide();
  557. $('#export-form').attr('data-state', 'done');
  558. if(data.text_result != undefined)
  559. {
  560. if (data.mime_type == 'text/html')
  561. {
  562. $('#export_content').parent().html(data.text_result);
  563. $('#export_text_result').show();
  564. $('#export_text_result .listResults').tableHover();
  565. $('#export_text_result .listResults').tablesorter( { widgets: ['myZebra']} );
  566. }
  567. else
  568. {
  569. if ($('#export_text_result').closest('ui-dialog').length == 0)
  570. {
  571. // not inside a dialog box, adjust the height... approximately
  572. var jPane = $('#export_text_result').closest('.ui-layout-content');
  573. var iTotalHeight = jPane.height();
  574. jPane.children(':visible').each(function() {
  575. if ($(this).attr('id') != '')
  576. {
  577. iTotalHeight -= $(this).height();
  578. }
  579. });
  580. $('#export_content').height(iTotalHeight - 80);
  581. }
  582. $('#export_content').val(data.text_result);
  583. $('#export_text_result').show();
  584. }
  585. }
  586. $('#export-dlg-submit').button('option', 'label', Dict.S('UI:Button:Done')).button('enable');
  587. break;
  588. case 'error':
  589. $('#export-form').attr('data-state', 'error');
  590. $('.export-progress-bar').progressbar({value: data.percentage });
  591. $('.export-message').html(data.message);
  592. $('#export-dlg-submit').button('option', 'label', Dict.S('UI:Button:Done')).button('enable');
  593. $('#export-btn').hide();
  594. default:
  595. }
  596. }
  597. function ExportInitButton(sSelector)
  598. {
  599. $(sSelector).on('click', function() {
  600. var sDataState = $('#export-form').attr('data-state');
  601. switch(sDataState)
  602. {
  603. case 'not-yet-started':
  604. $('.form_part:visible').each(function() {
  605. $('#export-form').data('validation_messages', []);
  606. var ret = $(this).trigger('validate');
  607. });
  608. var aMessages = $('#export-form').data('validation_messages');
  609. if(aMessages.length > 0)
  610. {
  611. alert(aMessages.join(''));
  612. return;
  613. }
  614. if ($(this).hasClass('ui-button'))
  615. {
  616. $(this).button('option', 'label', Dict.S('UI:Button:Cancel'));
  617. }
  618. else
  619. {
  620. $(this).html(Dict.S('UI:Button:Cancel'));
  621. }
  622. $('#export-form').attr('data-state', 'running');
  623. ExportStartExport();
  624. break;
  625. case 'running':
  626. if ($(this).hasClass('ui-button'))
  627. {
  628. $(this).button('disable');
  629. }
  630. else
  631. {
  632. $(this).attr('disabled', 'disabled');
  633. }
  634. $('#export-form').attr('data-state', 'cancelled');
  635. break;
  636. case 'done':
  637. case 'error':
  638. $('#interactive_export_dlg').dialog('close');
  639. break;
  640. default:
  641. // Do nothing
  642. }
  643. });
  644. }
  645. function DisplayHistory(sSelector, sFilter, iCount, iStart)
  646. {
  647. $(sSelector).block();
  648. var oParams = { operation: 'history_from_filter', filter: sFilter, start: iStart, count: iCount };
  649. $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
  650. $(sSelector).html(data).unblock();
  651. }
  652. );
  653. }