Common.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. window.MWFForum = MWF.xApplication.Forum;
  3. MWFForum.getDateDiff = function (publishTime, justNowStr) {
  4. if(!publishTime)return "";
  5. var dateTimeStamp = Date.parse(publishTime.replace(/-/gi, "/"));
  6. var minute = 1000 * 60;
  7. var hour = minute * 60;
  8. var day = hour * 24;
  9. var halfamonth = day * 15;
  10. var month = day * 30;
  11. var year = month * 12;
  12. var now = new Date().getTime();
  13. var diffValue = now - dateTimeStamp;
  14. if (diffValue < 0) {
  15. //若日期不符则弹出窗口告之
  16. //alert("结束日期不能小于开始日期!");
  17. }
  18. var yesterday = new Date().decrement('day', 1);
  19. var beforYesterday = new Date().decrement('day', 2);
  20. var yearC = diffValue / year;
  21. var monthC = diffValue / month;
  22. var weekC = diffValue / (7 * day);
  23. var dayC = diffValue / day;
  24. var hourC = diffValue / hour;
  25. var minC = diffValue / minute;
  26. if (yesterday.getFullYear() == dateTimeStamp.getFullYear() && yesterday.getMonth() == dateTimeStamp.getMonth() && yesterday.getDate() == dateTimeStamp.getDate()) {
  27. result = MWF.xApplication.Forum.LP.yesterday + " " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  28. } else if (beforYesterday.getFullYear() == dateTimeStamp.getFullYear() && beforYesterday.getMonth() == dateTimeStamp.getMonth() && beforYesterday.getDate() == dateTimeStamp.getDate()) {
  29. result = MWF.xApplication.Forum.LP.twoDaysAgo + " " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  30. } else if (yearC > 1) {
  31. result = dateTimeStamp.getFullYear() + "-" + (dateTimeStamp.getMonth() + 1) + "-" + dateTimeStamp.getDate();
  32. } else if (monthC >= 1) {
  33. //result= parseInt(monthC) + "个月前";
  34. // s.getFullYear()+"年";
  35. result = dateTimeStamp.getFullYear() + "-" + (dateTimeStamp.getMonth() + 1) + "-" + dateTimeStamp.getDate();
  36. } else if (weekC >= 1) {
  37. result = parseInt(weekC) + MWF.xApplication.Forum.LP.weekAgo;
  38. } else if (dayC >= 1) {
  39. result = parseInt(dayC) + MWF.xApplication.Forum.LP.dayAgo;
  40. } else if (hourC >= 1) {
  41. result = parseInt(hourC) + MWF.xApplication.Forum.LP.hourAgo;
  42. } else if (minC >= 1) {
  43. result = parseInt(minC) + MWF.xApplication.Forum.LP.minuteAgo;
  44. } else
  45. result = justNowStr || MWF.xApplication.Forum.LP.publishJustNow;
  46. return result;
  47. };
  48. MWFForum.getDateDiff2 = function (publishTime) {
  49. return MWFForum.getDateDiff( publishTime, MWF.xApplication.Forum.LP.justNow );
  50. };
  51. MWFForum.BBS_LOGO_NAME = "BBS_LOGO_NAME";
  52. MWFForum.BBS_SUBJECT_TYPECATAGORY = "BBS_SUBJECT_TYPECATAGORY";
  53. MWFForum.BBS_TITLE_TAIL = "BBS_TITLE_TAIL";
  54. MWFForum.BBS_USE_NICKNAME = "BBS_USE_NICKNAME";
  55. MWFForum.BBS_ANONYMOUS_PERMISSION = "BBS_ANONYMOUS_PERMISSION";
  56. MWFForum.enableAnonymousSubject = function(){
  57. return MWFForum.getSystemConfigValue( MWFForum.BBS_ANONYMOUS_PERMISSION ) === "YES";
  58. }
  59. MWFForum.isSubjectMuted = function( usecache ){
  60. if( usecache && o2.typeOf( MWFForum.isMuted ) === "boolean" ){
  61. return MWFForum.isMuted;
  62. }
  63. o2.Actions.load("x_bbs_assemble_control").ShutupAction.getShutup(function(json){
  64. debugger;
  65. // json.data = {
  66. // "id": "a13843ac-0700-4a94-b7d9-a85e6fca131b",
  67. // "operator": "蔡祥熠@cxy@P",
  68. // "person": "龚新民@91eed25b-8891-4ba6-b234-a70ed97c42ae@P",
  69. // "unmuteDate": "2022-05-25",
  70. // "reason": "888",
  71. // "createTime": "2022-05-24 16:09:48",
  72. // "updateTime": "2022-05-24 16:09:48"
  73. // };
  74. var d = json.data || {};
  75. MWFForum.muteData = d;
  76. if( d.unmuteDate && (new Date(d.unmuteDate + " 00:00:00") > new Date())){
  77. MWFForum.isMuted = true;
  78. }else{
  79. MWFForum.isMuted = false;
  80. }
  81. }, null, false);
  82. if( o2.typeOf( MWFForum.isMuted ) !== "boolean" ){
  83. MWFForum.isMuted = false;
  84. }
  85. return MWFForum.isMuted;
  86. }
  87. MWFForum.isReplyMuted = function(){
  88. return MWFForum.isSubjectMuted( true );
  89. }
  90. MWFForum.isUseNickName = function(){
  91. if( layout.desktop.session.user.name === "anonymous" )return false;
  92. return MWFForum.getSystemConfigValue( MWFForum.BBS_USE_NICKNAME ) === "YES";
  93. };
  94. MWFForum.Nick_Name_Map = {};
  95. MWFForum.getDisplayName = function( dn ){
  96. if( layout.desktop.session.user.name === "anonymous" )return "";
  97. if( !dn || dn === layout.desktop.session.user.distinguishedName){
  98. dn = layout.desktop.session.user.distinguishedName;
  99. if( !dn )return "";
  100. if( MWFForum.isUseNickName() ){
  101. return layout.desktop.session.user.nickName || (dn||"").split("@")[0];
  102. }else{
  103. return (dn||"").split("@")[0];
  104. }
  105. }else{
  106. if( MWFForum.isUseNickName() ){
  107. if( MWFForum.Nick_Name_Map[dn] )return MWFForum.Nick_Name_Map[dn];
  108. return o2.Actions.load("x_organization_assemble_express").PersonAction.getNickName( dn ).then(function (json) {
  109. MWFForum.Nick_Name_Map[dn] = json.data.value;
  110. return MWF.name.cn(json.data.value);
  111. }).catch(function () {
  112. return "";
  113. })
  114. }else{
  115. return (dn||"").split("@")[0];
  116. }
  117. }
  118. };
  119. MWFForum.getSubjectCreatorName = function(d){
  120. return o2.name.cn( MWFForum.isUseNickName() ? (d.nickName || d.creatorName): d.creatorName );
  121. };
  122. MWFForum.getLastReplyUserName = function(d){
  123. return o2.name.cn( MWFForum.isUseNickName() ? (d.latestReplyUserNickName || d.latestReplyUser): d.latestReplyUser );
  124. };
  125. MWFForum.isSubjectEditor = function(d){
  126. var dn = layout.desktop.session.user.distinguishedName;
  127. return d.creatorName === dn || (d.editorList || []).contains(dn);
  128. };
  129. MWFForum.getReplyCreatorName = function(d){
  130. return o2.name.cn( MWFForum.isUseNickName() ? (d.nickName || d.creatorName): d.creatorName );
  131. };
  132. MWFForum.openPersonCenter = function( userName, data ){
  133. if( data && ( data.anonymousSubject || data.anonymousReply ) ){
  134. return;
  135. }
  136. if( MWFForum.isUseNickName() && userName!=="xadmin" ){
  137. o2.Actions.load("x_organization_assemble_express").PersonAction.listObject(
  138. { personList : [userName]}
  139. ).then(function(json){
  140. if( !json.data || !json.data.length )return;
  141. var flag = json.data[0].id;
  142. var appId = "ForumPerson"+flag;
  143. if (layout.desktop.apps[appId]){
  144. layout.desktop.apps[appId].setCurrent();
  145. }else {
  146. layout.desktop.openApplication(null, "ForumPerson", {
  147. "p" : flag,
  148. "appId": appId
  149. });
  150. }
  151. })
  152. }else{
  153. var appId = "ForumPerson"+userName;
  154. if (layout.desktop.apps[appId]){
  155. layout.desktop.apps[appId].setCurrent();
  156. }else {
  157. layout.desktop.openApplication(null, "ForumPerson", {
  158. "personName" : userName,
  159. "appId": appId
  160. });
  161. }
  162. }
  163. };
  164. MWFForum.getSystemConfig = function( code ){
  165. if( !MWFForum.SystemSetting )MWFForum.SystemSetting = {};
  166. if( typeOf( MWFForum.SystemSetting[code] ) !== "null" )return MWFForum.SystemSetting[code];
  167. o2.Actions.load("x_bbs_assemble_control").BBSConfigSettingAction.getByCode( {configCode : code }, function(json) {
  168. MWFForum.SystemSetting[code] = json.data;
  169. }.bind(this), function(){
  170. MWFForum.SystemSetting[code] = "";
  171. return true;
  172. }, false );
  173. return MWFForum.SystemSetting[code];
  174. };
  175. MWFForum.getSystemConfigValue = function( code ){
  176. var config = MWFForum.getSystemConfig(code);
  177. if( config && config.configValue ){
  178. return config.configValue;
  179. }else{
  180. return "";
  181. }
  182. };
  183. MWFForum.getBBSName = function(){
  184. if( typeOf( MWFForum.BBSName ) !== "null" )return MWFForum.BBSName;
  185. o2.Actions.load("x_bbs_assemble_control").BBSConfigSettingAnonymousAction.getBBSName( function(json) {
  186. MWFForum.BBSName = (json.data || {}).configValue;
  187. }.bind(this), function(){
  188. MWFForum.BBSName = "";
  189. }, false );
  190. return MWFForum.BBSName;
  191. };