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

course_list.tmpl 9.9 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <style>
  2. .text-right{
  3. float:right !important;
  4. }
  5. .header{
  6. font-weight:bold;
  7. font-size: 18px;
  8. font-family: SourceHanSansSC-medium;
  9. }
  10. .cor{
  11. color:#0366D6 !important;
  12. }
  13. .header_card{
  14. /* color:#003A8C !important; */
  15. color:#101010 !important;
  16. margin: 10px 0 0px 0;
  17. height: 25px;
  18. font-size: 18px;
  19. }
  20. .marg{
  21. margin: 0 5px !important;
  22. }
  23. .content_list{
  24. max-height: 130px;
  25. overflow: auto;
  26. }
  27. .Relist{
  28. color:#0366D6 !important;
  29. }
  30. .descript_height{
  31. color: #999999 !important;
  32. margin: 10px 0;
  33. height: 40px !important;
  34. word-break:break-all;
  35. line-height: 20px;
  36. overflow: hidden;
  37. /* overflow: hidden!important;
  38. word-wrap:break-word!important; */
  39. }
  40. .tags_height{
  41. height: 30px !important;
  42. }
  43. .full_height{
  44. height: 100%;
  45. }
  46. .omit{
  47. overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  48. }
  49. /deep/ ui.checkbox input[type=checkbox]::after{
  50. border: 1px solid #0366D6 !important;
  51. }
  52. .nowrap-2 {
  53. /* height: 2.837em; */
  54. /* line-height: 1.4285em; */
  55. overflow: hidden;
  56. overflow: hidden;
  57. display: -webkit-box;
  58. -webkit-line-clamp: 2;
  59. -webkit-box-orient: vertical;
  60. }
  61. .ui.label{
  62. color:#0366D6 !important;
  63. background-color: #B3DBDB !important;
  64. font-weight:normal !important
  65. }
  66. .tag_text{
  67. /* margin-top: 2px; */
  68. /* margin-left: 0.5em; */
  69. font-size: 14px;
  70. }
  71. .card{
  72. box-shadow: 0px 4px 4px 0px rgba(232, 232, 232, 60) !important;
  73. border-radius: 5px;
  74. border: 1px solid rgba(232, 232, 232, 100)
  75. }
  76. </style>
  77. <div style="width: 100%;">
  78. <div class="ui three cards" style="margin-bottom: 10px;">
  79. {{range .Repos}}
  80. <div class="card " >
  81. <div class="extra full_height cor" >
  82. <div class="content " >
  83. {{if .Topics }}
  84. <div class=" tags " style="position: relative;">
  85. {{range .Topics}}
  86. {{if ne . "" }}<a style="max-width:100%;margin: 5px 0;display:inline-flex;" href="{{AppSubUrl}}/explore/repos?q={{.}}&topic={{$.Topic}}" ><span class="ui small label topic omit" >{{.}}</span></a>{{end}}
  87. {{end}}
  88. </div>
  89. {{end}}
  90. </div>
  91. <div class=" header header_card omit" >
  92. <a class="header_card image poping up " href="{{.Link}}" data-content="{{.Alias}}" data-position="top left" data-variation="tiny inverted"> {{.Alias}}</a>
  93. </div>
  94. <div class='content descript_height nowrap-2'>
  95. {{.Description}}
  96. </div>
  97. </div>
  98. <div class=" extra content" style="color:#888888;border-top: none !important;padding-top: 0px;margin-bottom: 15px;">
  99. <div class="left aligned author">
  100. <!-- <span > -->
  101. {{if .Creator }}
  102. <img class="ui avatar image" style="width: 22px;height:22px;margin-top:-5px" src="{{.Creator.RelAvatarLink}}">
  103. {{else}}
  104. <img class="ui avatar image" style="width: 22px;height:22px;margin-top:-5px" src="{{.Owner.RelAvatarLink}}">
  105. {{end}}
  106. {{$.i18n.Tr "org.repo_updated"}}&nbsp;: &nbsp; {{TimeSinceUnixShort .UpdatedUnix}}
  107. <!-- </span> -->
  108. </div>
  109. </div>
  110. </div>
  111. {{end}}
  112. </div>
  113. </div>
  114. <script>
  115. var data;
  116. var filterData=[];
  117. var num=0;
  118. function showcreate(obj){
  119. document.getElementById("search_selectPro").value=''
  120. $('.ui.modal')
  121. .modal({
  122. centered: false,
  123. onShow:function(){
  124. $("#org_list").empty()
  125. getPro(1)
  126. },
  127. onHide:function(){
  128. }
  129. })
  130. .modal('show')
  131. }
  132. function getPro(typeTag){
  133. $.ajax({
  134. type:"GET",
  135. url:"/org/{{.Org.Name}}/org_tag/repo_list?tagId="+typeTag,
  136. dataType:"json",
  137. async:false,
  138. success:function(json){
  139. data = json.data;
  140. var n_length = data.length
  141. pro_html = getHTML(data)
  142. $("#org_list").append(pro_html)
  143. // console.log('原始',data)
  144. checkedNum(0)
  145. }
  146. });
  147. }
  148. function getHTML(data){
  149. let pro_html=''
  150. for (let i=0;i<data.length;i++){
  151. if (data[i].Selected==true){
  152. console.log("data[i]:",data[i])
  153. pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = " ${i}" checked="" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName}</label></div>`
  154. pro_html += '</div>'
  155. }
  156. else{
  157. pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = "${i}" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label class='omit image poping up' data-content=${data[i].RepoName}  data-position="top left " data-variation="mini"> ${data[i].RepoName} </label></div>`
  158. pro_html += '</div>'
  159. }
  160. }
  161. return pro_html
  162. }
  163. function saveSeletedPro(typeTag){
  164. var saveData=[];
  165. $('input[name="select_pro_name"]:checked').each(function(){
  166. // console.log('值',this.dataset.repoid)
  167. saveData.push(parseInt(this.dataset.repoid));
  168. })
  169. if(saveData.length>9){
  170. alert("最多可选9个,保存失败")
  171. return
  172. }
  173. // saveData = getSelecteDataID();
  174. // console.log("数据:",saveData)
  175. $.ajax({
  176. type:"POST",
  177. url:"/org/{{.Org.Name}}/org_tag/repo_submit?tagId="+typeTag,
  178. contentType:'application/json',
  179. dataType:"json",
  180. async:false,
  181. data:JSON.stringify({'repoList':saveData
  182. }),
  183. success:function(res){
  184. console.log('保存成功');
  185. location.reload()
  186. }
  187. });
  188. }
  189. function getSelecteData(){
  190. var selectedData=[];
  191. $('input[name="select_pro_name"]:checked').each(function(){
  192. // console.log(this)
  193. // console.log('值',this.dataset.selected)
  194. selectedData.push({"RepoID":parseInt(this.dataset.repoid),"RepoName":this.dataset.reponame,"Selected":JSON.parse(this.dataset.selected)});
  195. })
  196. return selectedData
  197. }
  198. function search(){
  199. var selectedData = getSelecteData();
  200. var searchValue = document.getElementById("search_selectPro").value;
  201. filterData=[];
  202. console.log("searchValue:",searchValue)
  203. for (let i=0;i<data.length;i++){
  204. var isInclude=false;
  205. if(data[i].RepoName.toLowerCase().includes(searchValue.toLowerCase())){
  206. filterData.push(data[i])
  207. }
  208. }
  209. console.log("选中的值:",selectedData)
  210. console.log("筛选包括选中的值:",filterData)
  211. var showData=[];
  212. for(i=0;i<selectedData.length;i++){
  213. filterData =filterData.filter((item)=>{
  214. return item.RepoID!=selectedData[i].RepoID
  215. });
  216. }
  217. console.log("筛选后不包括选中的值:",filterData)
  218. $("#org_list").empty()
  219. if(searchValue!=""){
  220. if (filterData.length!=0){
  221. var pro_html = getHTML(selectedData);
  222. console.log("selectedData_pro_html:",pro_html)
  223. $("#org_list").append(pro_html)
  224. pro_html= getHTML(filterData);
  225. $("#org_list").append(pro_html)
  226. }else{
  227. var pro_html = getHTML(selectedData);
  228. $("#org_list").append(pro_html)
  229. }
  230. }else{
  231. var pro_html = getHTML(data);
  232. $("#org_list").append(pro_html)
  233. }
  234. }
  235. function checkedNum(id){
  236. num=0;
  237. var inputs = document.getElementsByName("select_pro_name")
  238. for (var i=0;i<inputs.length;i++){
  239. if(inputs[i].checked){
  240. num++
  241. if(num>9){
  242. document.getElementById(id).checked=false
  243. alert("选择超过9个,请重新选择!")
  244. return
  245. }
  246. }
  247. }
  248. var show_num = 9-num;
  249. document.getElementById("recommend").innerHTML="还能推荐"+show_num+"个"
  250. }
  251. </script>