You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.2 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var fnRenderList = function (handle, list) {
  4. var sHtmlList = $('#temp_list').render(list);
  5. handle.html(sHtmlList).find('.download-button').on('click', function () {
  6. var sName = $(this).attr('filename'),
  7. sPath = $(this).attr('filepath');
  8. DownLoadFile(sPath, sName);
  9. });
  10. },
  11. fnGetFileList = function (handle, parentid) {
  12. return g_api.ConnectLite(Service.apiappcom, ComFn.GetFileList, {
  13. ParentID: parentid
  14. }, function (res) {
  15. if (res.RESULT) {
  16. var saRes = res.DATA.rel;
  17. fnRenderList(handle, saRes);
  18. }
  19. });
  20. },
  21. init = function () {
  22. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  23. myHelpers = {
  24. setFileName: function (val) {
  25. return val.split('.')[0];
  26. },
  27. setDescription: function (val) {
  28. return !val ? '-' : val;
  29. },
  30. setFilePath: function (val) {
  31. return gServerUrl + '/' + val.replace(/\\/g, "\/");
  32. },
  33. checkSubFileName: function (val) {
  34. return val.toLowerCase() === 'pdf';
  35. }
  36. },
  37. oTempl = {
  38. 'zh-TW': ['FileList1', 'FileList2'],
  39. 'zh': ['FileList3', 'FileList4'],
  40. 'en': ['FileList5']
  41. };
  42. $.views.helpers(myHelpers);
  43. $.each(oTempl[sLang], function (idx, item) {
  44. return g_api.ConnectLite(Service.apiwebcom, ComFn.GetFileInfo, {
  45. Id: item
  46. }, function (res) {
  47. if (res.RESULT) {
  48. var oRes = res.DATA.rel;
  49. if (oRes && oRes.FileID) {
  50. fnGetFileList($('#' + item), oRes.FileID);
  51. }
  52. }
  53. });
  54. });
  55. };
  56. init();
  57. });