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.js 57 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
10 years ago
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
9 years ago
​
​
​
9 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770
  1. //配置课程信息
  2. function course_setting(id)
  3. {
  4. //alert(id);
  5. //$('#tb_'+id).removeClass().addClass("hwork_hovertab");
  6. //$('#tbc_0'+id).removeClass().addClass("dis");
  7. //$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab");
  8. //$('#tbc_0'+(3-id)).removeClass().addClass("undis");
  9. for (var i = 1; i < 5; i++) {
  10. if (i == id) {
  11. $("#tb_" + i).removeClass().addClass("hwork_hovertab");
  12. $("#tbc_0" + i).removeClass().addClass("dis");
  13. }
  14. else {
  15. $("#tb_" + i).removeClass().addClass("hwork_normaltab");
  16. $("#tbc_0" + i).removeClass().addClass("undis");
  17. }
  18. }
  19. }
  20. $(function(){
  21. $("img").removeAttr("align");
  22. });
  23. ///////////////////////////////////////////////////////////////
  24. //添加分班
  25. function add_group(url,course_id) {
  26. var group_name = $('#group_name').val();
  27. $.get(
  28. url,
  29. { valid: "name",
  30. value: group_name,
  31. course_id: course_id },
  32. function (data) {
  33. if (data.valid) {
  34. $("#add_group_name").submit();
  35. }
  36. else
  37. {
  38. alert(data.message);
  39. }
  40. }
  41. );
  42. }
  43. //修改分班:修改分班时得考虑什么都不改但是点击确定的情况
  44. function edit_group(id,url,course_id,group_id)
  45. {
  46. var group_name = $('#'+id).val();
  47. var group_id = $('#'+group_id).val();
  48. $.get(
  49. url,
  50. {
  51. valid: "name",
  52. value: group_name,
  53. course_id: course_id,
  54. group_id: group_id
  55. },
  56. function (data) {
  57. if (data.valid) {
  58. $("#update_group_form").submit();
  59. }
  60. else
  61. {
  62. alert(data.message);
  63. }
  64. }
  65. );
  66. }
  67. function hidden_homework_score_form()
  68. {
  69. hideModal($("#user_score"));
  70. }
  71. ///////////////////////////////////////////////////////////////
  72. ///////////////////////////////////////////////////////////////新建课程相关
  73. //验证班级名称
  74. function regex_course_name(str)
  75. {
  76. var name = $.trim($("#"+str+"_course_name").val());
  77. var syl_title = "";
  78. if($("#new_syllabus_id").length > 0){
  79. syl_title = $("#new_syllabus_id").find("option:selected").text();
  80. } else{
  81. if(str == "edit"){
  82. syl_title = $("#edit_syllabus_id").html();
  83. } else{
  84. syl_title = $("#course_syllabus_title").html();
  85. }
  86. }
  87. if(name.length < 2)
  88. {
  89. $("#"+str+"_course_name_notice").show();
  90. $("#"+str+"_course_name").css('border', "2px solid red");
  91. return false;
  92. }
  93. else if(name.indexOf(syl_title) != 0){
  94. $("#"+str+"_course_name_notice").html("请参照正确示例规范,应该以课程名称开头命名");
  95. $("#"+str+"_course_name_notice").show();
  96. $("#"+str+"_course_name").focus();
  97. $("#"+str+"_course_name").css('border', "2px solid red");
  98. return false;
  99. }
  100. else
  101. {
  102. $("#"+str+"_course_name_notice").hide();
  103. $("#"+str+"_course_name").css('border', "1px solid #ddd");
  104. return true;
  105. }
  106. }
  107. //验证课程学时
  108. function regex_course_class_period(str)
  109. {
  110. var class_period = $.trim($("#"+str+"_class_period").val());
  111. var regex = /^\d*$/;
  112. if(class_period.length == 0)
  113. {
  114. $("#"+str+"_course_class_period_notice").html("学时总数不能为空");
  115. $("#"+str+"_course_class_period_notice").show();
  116. return false;
  117. }
  118. else if (regex.test(class_period)) {
  119. if(parseInt(class_period) > 0)
  120. {
  121. $("#"+str+"_course_class_period_notice").html("");
  122. $("#"+str+"_course_class_period_notice").hide();
  123. return true;
  124. }
  125. else
  126. {
  127. $("#"+str+"_course_class_period_notice").html("学时总数必须大于0");
  128. $("#"+str+"_course_class_period_notice").show();
  129. return false;
  130. }
  131. }
  132. else
  133. {
  134. $("#"+str+"_course_class_period_notice").html("学时总数必须为正整数");
  135. $("#"+str+"_course_class_period_notice").show();
  136. return false;
  137. }
  138. }
  139. //验证开始学期和结束学期
  140. function regex_time_term(str){
  141. var obj_time = document.getElementById(str+"_time");
  142. var obj_end_time = document.getElementById(str+"_end_time");
  143. var obj_term = document.getElementById(str+"_term");
  144. var obj_end_term = document.getElementById(str+"_end_term");
  145. var time = obj_time.options[obj_time.selectedIndex];
  146. var end_time = obj_end_time.options[obj_end_time.selectedIndex];
  147. var term = obj_term.options[obj_term.selectedIndex];
  148. var end_term = obj_end_term.options[obj_end_term.selectedIndex];
  149. if(time.value == end_time.value) {
  150. if(set_term_val(term.value) > set_term_val(end_term.value)) {
  151. $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期");
  152. $("#"+str+"_course_time_term_notice").show();
  153. return false;
  154. } else {
  155. $("#"+str+"_course_time_term_notice").html("");
  156. $("#"+str+"_course_time_term_notice").hide();
  157. return true;
  158. }
  159. } else if(time.value < end_time.value) {
  160. $("#"+str+"_course_time_term_notice").html("");
  161. $("#"+str+"_course_time_term_notice").hide();
  162. return true;
  163. } else {
  164. $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期");
  165. $("#"+str+"_course_time_term_notice").show();
  166. return false;
  167. }
  168. }
  169. //学期转换为数字
  170. function set_term_val(val) {
  171. if(val == "春季学期"){
  172. return 1;
  173. } else if(val == "夏季学期"){
  174. return 2;
  175. } else if(val == "秋季学期"){
  176. return 3;
  177. }
  178. }
  179. //验证密码
  180. function regex_course_password(str)
  181. {
  182. var class_period = $.trim($("#"+str+"_course_course_password").val());
  183. var regex = /^\w+$/;
  184. if(class_period.length == 0)
  185. {
  186. $("#"+str+"_course_course_password_notice").html("课程密码不能为空");
  187. $("#"+str+"_course_course_password_notice").show();
  188. return false;
  189. }
  190. else if (regex.test(class_period)) {
  191. $("#"+str+"_course_course_password_notice").html("");
  192. $("#"+str+"_course_course_password_notice").hide();
  193. return true;
  194. }
  195. else
  196. {
  197. $("#"+str+"_course_course_password_notice").html("课程密码有非法字符");
  198. $("#"+str+"_course_course_password_notice").show();
  199. return false;
  200. }
  201. }
  202. //验证课程大纲
  203. function regex_syllabus_option(str) {
  204. if(str == "new" && document.getElementById(str + "_syllabus_id")) {
  205. var obj = document.getElementById(str + "_syllabus_id");
  206. var syllabus = obj.options[obj.selectedIndex];
  207. if(parseInt(syllabus.value) == 0) {
  208. $("#"+str+"_course_syllabus_notice").show();
  209. return false;
  210. } else{
  211. $("#"+str+"_course_syllabus_notice").hide();
  212. return true;
  213. }
  214. } else {
  215. $("#"+str+"_course_syllabus_notice").hide();
  216. return true;
  217. }
  218. }
  219. //提交新建课程
  220. function submit_new_course()
  221. {
  222. if(regex_syllabus_option('new')&&regex_course_name('new')&&regex_course_class_period('new')&&regex_time_term('new'))
  223. {
  224. $("#new_course").submit();
  225. }
  226. }
  227. function submit_edit_course(id)
  228. {
  229. if(regex_syllabus_option('edit')&&regex_course_name('edit')&&regex_course_class_period('edit')&&regex_time_term('edit'))
  230. {
  231. $("#edit_course_"+id).submit();
  232. }
  233. }
  234. //新建课程大纲
  235. function submit_new_syllabus()
  236. {
  237. if(regex_syllabus_name())
  238. {
  239. $("#new_syllabus").submit();
  240. }
  241. }
  242. //课程讨论区
  243. function regexTopicSubject() {
  244. var name = $("#message_subject").val();
  245. if(name.length ==0)
  246. {
  247. $("#subjectmsg").text("标题不能为空");
  248. $("#subjectmsg").css('color','#ff0000');
  249. $("#message_subject").focus();
  250. return false;
  251. }
  252. else if(name.length <= 255)
  253. {
  254. $("#subjectmsg").text("填写正确");
  255. $("#subjectmsg").css('color','#008000');
  256. return true;
  257. }
  258. else
  259. {
  260. $("#subjectmsg").text("标题超过255个字符");
  261. $("#subjectmsg").css('color','#ff0000');
  262. $("#message_subject").focus();
  263. return false;
  264. }
  265. }
  266. function regexTopicDescription()
  267. {
  268. var name = message_content_editor.html();
  269. if(message_content_editor.isEmpty())
  270. {
  271. $("#message_content_span").text("描述不能为空");
  272. $("#message_content_span").css('color','#ff0000');
  273. return false;
  274. }
  275. else if(name.length >=6000){
  276. $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
  277. $("#message_content_span").css('color','#ff0000');
  278. return false;
  279. }
  280. else
  281. {
  282. $("#message_content_span").text("填写正确");
  283. $("#message_content_span").css('color','#008000');
  284. return true;
  285. }
  286. }
  287. function submit_topic()
  288. {
  289. // if(regexTopicSubject() && regexTopicDescription())
  290. // {
  291. message_content_editor.sync();
  292. $("#message-form").submit();
  293. // }
  294. }
  295. function reset_topic(){
  296. }
  297. ///////////////////////////////////////////////////////////////
  298. //////////////////////////////////////////////////////////////课程讨论区
  299. function regexSubject(id) {
  300. var subjectid = "#message_subject" + id ;
  301. var content = $.trim($(subjectid).val());
  302. var message = "#subject_span" + id;
  303. if (content.length == 0) {
  304. $(message).text("主题不能为空");
  305. $(message).css('color', '#ff0000');
  306. return false;
  307. }
  308. else {
  309. $(message).text("填写正确");
  310. $(message).css('color', '#008000');
  311. return true;
  312. }
  313. return false;
  314. }
  315. function regexContent(id) {
  316. var contentid = "#message_content" + id;
  317. var message = "#message_content_span"+ id;
  318. var content = $.trim($(contentid).val());
  319. if (content.length == 0) {
  320. $(message).text("描述不能为空");
  321. $(message).css('color', '#ff0000');
  322. return false;
  323. }
  324. else {
  325. $(message).text("填写正确");
  326. $(message).css('color', '#008000');
  327. return true;
  328. }
  329. return false;
  330. }
  331. // 项目讨论区编辑和提交
  332. function submitProjectsBoard(id) {
  333. var formid = "#message-form" + id;
  334. if (regexSubject(id) && regexContent(id)) {
  335. $(formid).submit();
  336. }
  337. }
  338. ///////////////////////////////////////////////////////////////
  339. /////////////////////////////////////////////////////////////// 课程通知
  340. function regexTitle()
  341. {
  342. var name = $("#news_title").val();
  343. if(name.length ==0)
  344. {
  345. $("#title_notice_span").text("标题不能为空");
  346. $("#title_notice_span").css('color','#ff0000');
  347. $("#news_title").focus();
  348. return false;
  349. }
  350. else if(name.length <= 60)
  351. {
  352. $("#title_notice_span").text("填写正确");
  353. $("#title_notice_span").css('color','#008000');
  354. return true;
  355. }
  356. else
  357. {
  358. $("#title_notice_span").text("标题超过60个字符");
  359. $("#title_notice_span").css('color','#ff0000');
  360. $("#news_title").focus();
  361. return false;
  362. }
  363. }
  364. function regexDescription()
  365. {
  366. var name = news_description_editor.html();
  367. if(news_description_editor.isEmpty())
  368. {
  369. $("#description_notice_span").text("描述不能为空");
  370. $("#description_notice_span").css('color','#ff0000');
  371. $("#description_notice_span").focus();
  372. return false;
  373. }
  374. /*else if(name.length >=6000){
  375. $("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)");
  376. $("#description_notice_span").css('color','#ff0000');
  377. $("#description_notice_span").focus();
  378. return false;
  379. }*/
  380. else
  381. {
  382. $("#description_notice_span").text("填写正确");
  383. $("#description_notice_span").css('color','#008000');
  384. return true;
  385. }
  386. }
  387. function submitNews()
  388. {
  389. if(regexTitle() && regexDescription())
  390. {
  391. news_description_editor.sync();
  392. $("#news-form").submit();
  393. }
  394. }
  395. function submitFocus(obj)
  396. {
  397. $(obj).focus();
  398. }
  399. function submitComment()
  400. {
  401. if (newsReplyVerify()) {
  402. comment_editor.sync();
  403. $("#add_comment_form").submit();
  404. }
  405. }
  406. function newsReplyVerify() {
  407. var content = comment_editor.html();
  408. if(comment_editor.isEmpty()) {
  409. $("#add_reply_news").text("评论不能为空");
  410. $("#add_reply_news").css('color', '#ff0000');
  411. $("#news_submit_comment").one('click',function(){
  412. submitComment();
  413. });
  414. return false;
  415. } else {
  416. $("#add_reply_news").text("填写正确");
  417. $("#add_reply_news").css('color', '#008000');
  418. return true;
  419. }
  420. }
  421. /////////////////////////////////////////////////课程讨论区
  422. function course_board_submit_message_replay()
  423. {
  424. if(MessageReplayVevify())
  425. {
  426. message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
  427. $("#message_form").submit();
  428. }
  429. }
  430. function course_board_canel_message_replay()
  431. {
  432. $("#reply").hide(200);
  433. $("#message_quote").html("");
  434. }
  435. function MessageReplayVevify() {
  436. var content = message_content_editor.html();//$.trim($("#message_content").val());
  437. if (message_content_editor.isEmpty()) {
  438. $("#message_content_span").text("回复不能为空");
  439. $("#message_content_span").css('color', '#ff0000');
  440. return false;
  441. }
  442. else {
  443. $("#message_content_span").text("填写正确");
  444. $("#message_content_span").css('color', '#008000');
  445. return true;
  446. }
  447. }
  448. //////////////////////////////////////////////////
  449. ///////////////////////////////////////////////////////////////
  450. ///////////////////////////////////////////////////////////////
  451. //验证搜索时输入名字
  452. function regexName(content)
  453. {
  454. var name = $.trim($("#name").val());
  455. if(name.length == 0)
  456. {
  457. $("#project_name_span").text(content);
  458. $("#project_name_span").css('color','#ff0000');
  459. $("#project_name_span").focus();
  460. return false;
  461. }
  462. else
  463. {
  464. $("#project_name_span").text("");
  465. return true;
  466. }
  467. }
  468. //提交搜索
  469. function submitSerch(content)
  470. {
  471. if(regexName(content)){$("#course_search_form").submit();}
  472. }
  473. //验证搜索时输入名字
  474. function regexQ(content)
  475. {
  476. var name = $.trim($("#q").val());
  477. if(name.length == 0)
  478. {
  479. $("#course_member_name_span").text(content);
  480. $("#course_member_name_span").css('color','#ff0000');
  481. $("#course_member_name_span").focus();
  482. return false;
  483. }
  484. else
  485. {
  486. $("#course_member_name_span").text("");
  487. return true;
  488. }
  489. }
  490. //提交课程成员搜索
  491. function submitMemberSerch(content)
  492. {
  493. //if(regexQ(content)){$("#course_member_search_form").submit();}
  494. $("#course_member_search_form").submit();
  495. }
  496. //课程描述显示更多信息
  497. function show_more_msg()
  498. {
  499. $("#course_description").toggleClass("course_description_none");
  500. var information = $("#expend_more_information");
  501. var arrow = $("#arrow");
  502. var val = information.attr("value");
  503. if (val == "show_more") {
  504. $("#expend_more_information").text("收起描述信息");
  505. information.attr("value", "hide_more");
  506. arrow.attr("src", "/images/jiantouup.jpg")
  507. }
  508. else {
  509. $("#expend_more_information").text("展开更多信息");
  510. information.attr("value", "show_more");
  511. arrow.attr("src", "/images/jiantou.jpg")
  512. }
  513. }
  514. //作业描述显示更多信息
  515. function news_show_more_des(id)
  516. {
  517. $('#news_description_' + id).toggleClass("news_description_none");
  518. if($("#news_description_" + id).hasClass("news_description_none"))
  519. {
  520. $("#news_foot_" + id).html("[收起]");
  521. }
  522. else
  523. {
  524. $("#news_foot_" + id).html("[展开]");
  525. }
  526. }
  527. function bid_show_more_des(id)
  528. {
  529. $("#bid_description_" + id).toggleClass("news_description_none");
  530. if($("#bid_description_" + id).hasClass("news_description_none"))
  531. {
  532. $("#bid_show_more_des_button" + id).html("[收起]");
  533. }
  534. else
  535. {
  536. $("#bid_show_more_des_button" + id).html("[展开]");
  537. }
  538. }
  539. //课程作业结束时间倒计时
  540. function show_bid_dead_line(year,month,day,divname)
  541. {
  542. var now = new Date();
  543. var endDate = new Date(year, month-1, day);
  544. var leftTime=endDate.getTime()-now.getTime();
  545. var leftsecond = parseInt(leftTime/1000);
  546. var day1=Math.floor(leftsecond/(60*60*24));
  547. var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
  548. var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
  549. var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
  550. $("#"+divname).html("<form name='formnow' class='fr'>"
  551. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+day1+"' > 天"
  552. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+hour+"' > 小时"
  553. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+minute+"' > 分"
  554. + "<input class='c_orange' type='text' style='border:0;' size='1' value='"+second+"' > 秒"
  555. + "</form>"
  556. + "<p class='fr'>作品提交还剩:</p>");
  557. }
  558. //处理迟交、缺评扣分
  559. function check_late_penalty(id)
  560. {
  561. var obj = $("#" + id);
  562. var regex = /^\d+$/;
  563. if(regex.test(obj.val()))
  564. {
  565. if(obj.val() > 50)
  566. {
  567. obj.val("50");
  568. }
  569. }
  570. else
  571. {
  572. obj.val("");
  573. }
  574. }
  575. //验证匿评数量
  576. //function regex_evaluation_num()
  577. //{
  578. // if($("#evaluation_num").length == 0){ return true;}
  579. // var evaluation_num = $.trim($("#evaluation_num").val());
  580. // var regex = /^\d+$/;
  581. // if(evaluation_num=="")
  582. // {
  583. // $("#evaluation_num_notice").html("匿评分配数量不能为空");
  584. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  585. // return false;
  586. // }
  587. // else if(regex.test(evaluation_num))
  588. // {
  589. // if(evaluation_num > 0)
  590. // {
  591. // $("#evaluation_num_notice").html("每个学生将收到<span class='c_red'>&nbsp;"+ parseInt(evaluation_num) + "&nbsp;</span>份待匿评作品");
  592. // $("#evaluation_num_notice").removeClass("c_red");
  593. // return true;
  594. // }
  595. // else
  596. // {
  597. // $("#evaluation_num_notice").html("匿评分配数量必须为大于0");
  598. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  599. // return false;
  600. // }
  601. // }
  602. // else
  603. // {
  604. // $("#evaluation_num_notice").html("匿评分配数量只能为数字");
  605. // $("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
  606. // return false;
  607. // }
  608. //}
  609. //点击是否开启匿评单选框效果
  610. $(function(){
  611. $("#absence_penalty").change(function(){
  612. $("#absence_penalty_notice").html("&nbsp;"+ $("#absence_penalty").val() +"&nbsp;");
  613. });
  614. });
  615. //生成select
  616. function build_selector(max_num){
  617. var html = "<select class='w61 fl ml15' id='ta_proportion' name='ta_proportion'>";
  618. for(var i = 0; i <= max_num; i += 10){
  619. if( i == max_num){
  620. html += "<option value='" + parseFloat(i)/100 + "' selected='selected'>" + i + "%</option>";
  621. }else{
  622. html += "<option value='" + parseFloat(i)/100 + "'>" + i + "%</option>";
  623. }
  624. }
  625. html += "</select>";
  626. return html;
  627. }
  628. function build_selector_sy(max_num){
  629. var html = "<select class='w61 fl ml15' id='sy_proportion' name='sy_proportion'>";
  630. for(var i = 0; i <= max_num; i += 10){
  631. if( i == max_num){
  632. html += "<option value='" + parseFloat(i)/100 + "' selected='selected'>" + i + "%</option>";
  633. }else{
  634. html += "<option value='" + parseFloat(i)/100 + "'>" + i + "%</option>";
  635. }
  636. }
  637. html += "</select>";
  638. return html;
  639. }
  640. //提交匿评参数设置
  641. function submit_set_evaluation_attr(end_time){
  642. if(!regex_evaluation_start(end_time)){
  643. $("#evaluation_start_time").focus();
  644. }
  645. else if(!regex_evaluation_end()){
  646. $("#evaluation_end_time").focus();
  647. }
  648. else if(!regex_evaluation_num()){
  649. $("#evaluation_num").focus();
  650. }
  651. else{
  652. $('#muban_popup_box form').submit();
  653. hideModal();
  654. }
  655. }
  656. //验证匿评开启时间:大于截止时间,或者为空
  657. function regex_evaluation_start(end_time){
  658. var evaluation_start = $.trim($("#evaluation_start_time").val());
  659. if(evaluation_start == ""){
  660. $("#homework_evaluation_start_time").text("开启匿评日期不能为空");
  661. return false;
  662. }
  663. var end_time = new Date(end_time);
  664. var evaluation_start_time = new Date(evaluation_start);
  665. if(evaluation_start_time > end_time){
  666. $("#homework_evaluation_start_time").text("");
  667. return true;
  668. }else{
  669. $("#homework_evaluation_start_time").text("开启匿评日期必须大于截止日期");
  670. return false;
  671. }
  672. }
  673. //验证匿评结束时间:大于匿评开启时间,或者为空。当匿评开启时间为空时,匿评结束时间必须为空
  674. function regex_evaluation_end(){
  675. var evaluation_start = $.trim($("#evaluation_start_time").val());
  676. var evaluation_end = $.trim($("#evaluation_end_time").val());
  677. if(evaluation_end == ""){
  678. $("#homework_evaluation_end_time").text("关闭匿评日期不能为空");
  679. return true;
  680. }
  681. var evaluation_start_time = new Date(evaluation_start);
  682. var evaluation_end_time = new Date(evaluation_end);
  683. if(evaluation_end_time >= evaluation_start_time){
  684. $("#homework_evaluation_end_time").text("");
  685. return true;
  686. }else{
  687. $("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
  688. return false;
  689. }
  690. }
  691. //验证匿评数量
  692. function regex_evaluation_num(){
  693. var evaluation_num = $.trim($("#evaluation_num").val());
  694. var regex = /^\d+$/;
  695. if(evaluation_num==""){
  696. $("#evaluation_num_notice").text("匿评人数不能为空");
  697. return false;
  698. }
  699. else if(regex.test(evaluation_num)){
  700. if(evaluation_num > 0){
  701. $("#evaluation_num_notice").html("");
  702. return true;
  703. }
  704. else{
  705. $("#evaluation_num_notice").text("匿评人数必须为大于0");
  706. return false;
  707. }
  708. }
  709. else{
  710. $("#evaluation_num_notice").text("匿评人数只能为数字");
  711. return false;
  712. }
  713. }
  714. //老师提交 新建/修改 作业
  715. function submit_homework(id){
  716. if(!regex_homework_name()){
  717. $("#homework_name").focus();
  718. }
  719. else if(!regex_homework_end_time()){
  720. $("#homework_end_time").focus();
  721. }
  722. else if(!regex_homework_end_publish_time()){
  723. $("#homework_end_time").focus();
  724. }
  725. else if(!regex_course_id()){
  726. $("#course_id").focus();
  727. }
  728. else{
  729. homework_description_editor.sync();
  730. $("#"+id).submit();
  731. }
  732. }
  733. //验证新建作业的名字
  734. function regex_homework_name()
  735. {
  736. var type = $("#homework_type_option").children('option:selected').val();
  737. if(type == "0"){
  738. $('#select_type_nitice').show();
  739. return false;
  740. }
  741. var name = $.trim($("#homework_name").val());
  742. if(name=="")
  743. {
  744. $("#homework_name_span").text("名称不能为空");
  745. return false;
  746. }
  747. else
  748. {
  749. $("#homework_name_span").text("");
  750. return true;
  751. }
  752. }
  753. //验证发布时间不能大于截止时间
  754. function regex_homework_end_publish_time()
  755. {
  756. if($.trim($("#homework_end_time").val()) != ""){
  757. var myDate = new Date();
  758. if($.trim($("#homework_publish_time").val()) == "")
  759. {
  760. $("#homework_publish_time").val(formate_time(myDate));
  761. }
  762. var publish_time = Date.parse($("#homework_publish_time").val());
  763. var end_time = Date.parse($("#homework_end_time").val());
  764. if(end_time < publish_time)
  765. {
  766. $("#homework_end_time_span").text("截止时间应晚于发布时间");
  767. return false;
  768. }
  769. else
  770. {
  771. $("#homework_end_time_span").text("");
  772. return true;
  773. }
  774. } else{
  775. return true;
  776. }
  777. }
  778. //验证截止时间
  779. function regex_homework_end_time()
  780. {
  781. var name = $.trim($("#homework_end_time").val());
  782. if(name=="")
  783. {
  784. $("#homework_end_time_span").text("截止时间不能为空");
  785. return false;
  786. }
  787. else
  788. {
  789. $("#homework_end_time_span").text("");
  790. return true;
  791. }
  792. }
  793. function regex_work_end_publish_time()
  794. {
  795. var myDate = new Date();
  796. if($.trim($("#homework_publish_time").val()) == "")
  797. {
  798. $("#homework_publish_time").val(formate_date(myDate));
  799. }
  800. var publish_time = Date.parse($("#homework_publish_time").val());
  801. var end_time = Date.parse($("#homework_end_time").val());
  802. if(end_time < publish_time)
  803. {
  804. $("#homework_end_time_span").text("截止日期不能小于发布日期");
  805. return false;
  806. }
  807. else
  808. {
  809. $("#homework_end_time_span").text("");
  810. return true;
  811. }
  812. }
  813. function formate_date(date){
  814. var str = "";
  815. var year = date.getFullYear();
  816. var month = date.getMonth() + 1;
  817. var day = date.getDate();
  818. if(month < 10) {
  819. month = '0' + month;
  820. }
  821. if(day < 10) {
  822. day = '0' + day;
  823. }
  824. str = year + '-' + month + '-' + day;
  825. return str;
  826. }
  827. function formate_time(time){
  828. var str = "";
  829. var year = time.getFullYear();
  830. var month = time.getMonth() + 1;
  831. var day = time.getDate();
  832. var hour = time.getHours();
  833. var min = time.getMinutes();
  834. if(month < 10) {
  835. month = '0' + month;
  836. }
  837. if(day < 10) {
  838. day = '0' + day;
  839. }
  840. if(hour < 10) {
  841. hour = '0' + hour;
  842. }
  843. if(min < 10) {
  844. min = '0' + min;
  845. }
  846. str = year + '-' + month + '-' + day + ' ' + hour + ':' + min;
  847. return str;
  848. }
  849. //验证发送到课程
  850. function regex_course_id(){
  851. var course_id = $("#course_id").val();
  852. if(course_id == -1)
  853. {
  854. $("#homework_course_id_span").text("发布课程不能为空");
  855. return false;
  856. }
  857. else
  858. {
  859. $("#homework_course_id_span").text("");
  860. return true;
  861. }
  862. }
  863. //验证分组作业的参数
  864. function regex_group_attr(){
  865. var min = $.trim($("#min_num").val());
  866. var max = $.trim($("#max_num").val());
  867. var regex = /^\d+$/;
  868. if(!regex.test(min) || parseInt(min) <= 0) {
  869. $("#min_max_num_notice").html("人数为正整数");
  870. $("#min_max_num_notice").show();
  871. $("#min_num").focus();
  872. return false;
  873. } else {
  874. $("#min_max_num_notice").html("");
  875. $("#min_max_num_notice").hide();
  876. }
  877. if(!regex.test(max) || parseInt(max) <= 0) {
  878. $("#min_max_num_notice").html("人数为正整数");
  879. $("#min_max_num_notice").show();
  880. $("#max_num").focus();
  881. return false;
  882. } else {
  883. $("#min_max_num_notice").html("");
  884. $("#min_max_num_notice").hide();
  885. }
  886. if(parseInt(min) > parseInt(max)) {
  887. $("#min_max_num_notice").html("最小人数不得大于最大人数");
  888. $("#min_max_num_notice").show();
  889. $("#max_num").focus();
  890. return false;
  891. } else {
  892. $("#min_max_num_notice").html("");
  893. $("#min_max_num_notice").hide();
  894. }
  895. if ($("#base_on_project").is(":checked")) {
  896. $("#base_on_project").val(1);
  897. } else {
  898. $("#base_on_project").val(0);
  899. }
  900. return true;
  901. }
  902. //验证编程作业的参数
  903. function regex_program_attr() {
  904. var result = true;
  905. $.each($("#programHomework textarea[name='sample[output][]']"), function(i, val){
  906. if (result && $(val).val().length<=0) {
  907. $(val)[0].focus();
  908. result = false;
  909. }
  910. });
  911. $.each($("#programHomework textarea[name='program[output][]']"), function(i, val){
  912. if (result && $(val).val().length<=0) {
  913. $(val)[0].focus();
  914. result = false;
  915. }
  916. });
  917. return result;
  918. }
  919. function regexHomeworkCommonName()
  920. {
  921. var name = $.trim($("#homework_attach_name").val());
  922. if(name=="")
  923. {
  924. $("#homework_attach_name_span").text("作品名称不能为空");
  925. $("#homework_attach_name_span").css('color','#ff0000');
  926. return false;
  927. }
  928. else
  929. {
  930. $("#homework_attach_name_span").text("填写正确");
  931. $("#homework_attach_name_span").css('color','#008000');
  932. return true;
  933. }
  934. }
  935. function regexHomeworkCommonDescription()
  936. {
  937. var name = $.trim($("#homework_attach_description").val());
  938. if(name=="")
  939. {
  940. $("#homework_attach_description_span").text("作品描述不能为空");
  941. $("#homework_attach_description_span").css('color','#ff0000');
  942. return false;
  943. }
  944. else
  945. {
  946. $("#homework_attach_description_span").text("填写正确");
  947. $("#homework_attach_description_span").css('color','#008000');
  948. return true;
  949. }
  950. }
  951. function submit_homework_form(){if(regexHomeworkCommonName()&&regexHomeworkCommonDescription()){$('#new_homework_attach').submit();}}
  952. //增加测试结果
  953. function add_programing_test(obj) {
  954. var now = new Date().getTime();
  955. obj.after("<div><li><label class='label02'>&nbsp;测试输入:&nbsp;</label><input type='text' class='fl h26 w190 mb10' name='input[" + now +"]'' />" +
  956. "</li><li ><label class='fl f14 ml10'>&nbsp;输出:&nbsp;</label><input type='text' class='fl h26 w190 mb10' name='output[" + now +"]' />" +
  957. "</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
  958. "<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
  959. "<a class='blue_btn fl ml5 mt1 programing_test' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
  960. "<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]'/>" +
  961. "</li><div class='cl'></div></div>");
  962. }
  963. //删除测试结果
  964. function remove_programing_test(obj) {
  965. if(obj.siblings("div").length == 0){
  966. alert("至少需要一组测试");
  967. }
  968. else{
  969. obj.remove();
  970. }
  971. }
  972. function show_window (id1,id2,top,left) {
  973. $('#'+ id1).css('top',top);
  974. $('#'+ id1).css('left',left);
  975. $('#'+ id1).css('display','block');
  976. $('#' + id2).css('display','block');
  977. }
  978. function close_window(id1,id2){
  979. $('#' + id1).css('display','none');
  980. $('#' + id2).css('display','none');
  981. }
  982. //隐藏提示狂
  983. function hidden_atert_form(cur_page,cur_type)
  984. {
  985. hideModal($("#popbox"));
  986. }
  987. //当课程描述长度小于112px时,不显示更多按钮
  988. $(function(){
  989. if($("#course_description_content").height()>400)
  990. {
  991. $("#lg-foot").show();
  992. }
  993. });
  994. //将右侧的最小高度设置成左侧高度,美化界面
  995. // firefox pre标签换行
  996. $(document).ready(function () {
  997. $("#RSide").css("min-height",$("#LSide").height()-30);
  998. var userAgent = navigator.userAgent.toLowerCase();
  999. var browser = {
  1000. version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1],
  1001. safari: /webkit/.test(userAgent),
  1002. opera: /opera/.test(userAgent),
  1003. msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
  1004. mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
  1005. };
  1006. if (browser.mozilla || browser.opera){
  1007. $("pre").addClass("break_word_firefox");
  1008. }
  1009. else{
  1010. $("pre").addClass("break_word");
  1011. }
  1012. });
  1013. // 日历选择日期后关闭
  1014. function regexDeadLine()
  1015. {
  1016. ('#ui-datepicker-div').hide();
  1017. }
  1018. //新建、修改课程明码显示
  1019. $(function(){
  1020. $("#psw_btn").click(function() {
  1021. if($("#new_course_course_password").length > 0) {
  1022. alert("密码: "+$("#new_course_course_password").val());
  1023. } else if($("#edit_course_course_password").length > 0){
  1024. alert("密码: "+$("#edit_course_course_password").val());
  1025. }
  1026. });
  1027. });
  1028. //查找TAG资源
  1029. var clickFunction = null; //单击事件函数
  1030. var isdb = false; //是否双击
  1031. function search_tag_attachment(url,tag_name,q,course_id,sort)
  1032. {
  1033. //alert("111");
  1034. //clearTimeout(clickFunction);
  1035. clickFunction = setTimeout(function() {
  1036. search_func()
  1037. }, 500);
  1038. function search_func(){
  1039. if(isdb!= false ) return;
  1040. $.get(
  1041. url,
  1042. {
  1043. tag_name: tag_name,
  1044. q: q,
  1045. course_id:course_id
  1046. },
  1047. function (data) {
  1048. }
  1049. );
  1050. }
  1051. }
  1052. // 课程讨论区
  1053. function showhelpAndScrollToMessage(id, id1, count) {
  1054. $('#' + id).toggle();
  1055. if(cookieget("repositories_visiable") == "true")
  1056. {
  1057. cookiesave("repositories_visiable", false,'','','');
  1058. }
  1059. else
  1060. {
  1061. cookiesave("repositories_visiable", true,'','','');
  1062. }
  1063. var information = $(id1);
  1064. var val = information.attr("value");
  1065. if(val=="show_help")
  1066. {
  1067. $(id1).text("收起回复(" + count + ")" );
  1068. information.attr("value", "hide_help");
  1069. }
  1070. else
  1071. {
  1072. $(id1).text("展开回复(" + count + ")");
  1073. information.attr("value", "show_help");
  1074. }
  1075. }
  1076. function show_more_reply(contentid, id2, id3) {
  1077. $(contentid).toggleClass("course_description_none");
  1078. var information = $(id2);
  1079. var arrow = $(id3);
  1080. var val = information.attr("value");
  1081. if (val == "show_more") {
  1082. $(id2).text("[收起]");
  1083. information.attr("value", "hide_more");
  1084. arrow.attr("src", "/images/jiantouup.jpg")
  1085. }
  1086. else {
  1087. $(id2).text("[展开]");
  1088. information.attr("value", "show_more");
  1089. arrow.attr("src", "/images/jiantou.jpg")
  1090. }
  1091. }
  1092. ///////////////////////////////////////////////
  1093. //学生作品
  1094. function show_project()
  1095. {
  1096. $("#about_project").slideToggle();
  1097. }
  1098. //验证作品名称
  1099. function regexStudentWorkName()
  1100. {
  1101. var name = $.trim($("#student_work_name").val());
  1102. if(name=="")
  1103. {
  1104. $("#student_work_name_span").text("作品名称不能为空");
  1105. return false;
  1106. }
  1107. else
  1108. {
  1109. $("#student_work_name_span").text("");
  1110. return true;
  1111. }
  1112. }
  1113. function regexStudentWorkDescription()
  1114. {
  1115. var name = $.trim($("#student_work_description").val());
  1116. if(name=="")
  1117. {
  1118. $("#student_work_description_textarea").text("作品描述不能为空");
  1119. return false;
  1120. }
  1121. else
  1122. {
  1123. $("#student_work_description_textarea").text("");
  1124. return true;
  1125. }
  1126. }
  1127. function regexStudentWorkMember(min, max) {
  1128. var members = $.trim($("#group_member_ids").val()).split(',');
  1129. if ( min <= members.length && members.length <= max ){
  1130. $("#student_work_group_textarea").text("");
  1131. return true;
  1132. } else {
  1133. $("#student_work_group_textarea").text("合作成员人数应为:"+min+"-"+max+"人");
  1134. return false;
  1135. }
  1136. }
  1137. //提交新建作品
  1138. function new_student_work()
  1139. {
  1140. if(regexStudentWorkName()&&regexStudentWorkDescription())
  1141. {
  1142. if($("#group_member_ids").length > 0) {
  1143. if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
  1144. $("#new_student_work").submit();
  1145. $("#ajax-indicator").hide();
  1146. }
  1147. } else {
  1148. $("#new_student_work").submit();
  1149. $("#ajax-indicator").hide();
  1150. }
  1151. }
  1152. }
  1153. function edit_student_work(id)
  1154. {
  1155. if(regexStudentWorkName()&&regexStudentWorkDescription())
  1156. {
  1157. $("#edit_student_work_" + id).submit();
  1158. $("#ajax-indicator").hide();
  1159. }
  1160. }
  1161. //
  1162. //滑动打分
  1163. $.fn.peSlider = function(settings){
  1164. //configurable options (none so far)
  1165. var o = $.extend({},settings);
  1166. if( !$('body').is('[role]') ){ $('body').attr('role','application'); }
  1167. return $(this).each(function(){
  1168. var thisLabel = $('label[for=' + $(this).attr('id') + ']').attr('id', $(this).attr('id') + '-label').attr('id');
  1169. var thisUnits = $(this).attr('data-units') || '';
  1170. var slider = $('<div></div>');
  1171. if( $(this).is('input') ){
  1172. var input = $(this);
  1173. var thisUnits = input.attr('data-units');
  1174. var friendlyVal = input.val() + ' ' + thisUnits;
  1175. var sliderOptions = $.extend(o,{
  1176. min: parseFloat(input.attr('min')),
  1177. max: parseFloat(input.attr('max')),
  1178. value: parseFloat(input.val())
  1179. });
  1180. if(parseFloat(input.val()) == -1){
  1181. input.css("color", "#fff");
  1182. input.next().next().html("未评分");
  1183. input.next().next().show();
  1184. } else{
  1185. input.css("color", "#000");
  1186. input.next().next().hide();
  1187. }
  1188. slider
  1189. .insertBefore(input)
  1190. .slider(sliderOptions)
  1191. .bind('slide', function(e, ui){
  1192. if(ui.value == -1){
  1193. input.css("color", "#fff");
  1194. input.next().next().html("未评分");
  1195. input.next().next().show();
  1196. } else {
  1197. input.css("color", "#000");
  1198. input.next().next().hide();
  1199. }
  1200. input.val(ui.value);
  1201. friendlyVal = input.val() + ' ' + thisUnits;
  1202. slider.find('a').attr({
  1203. 'aria-valuenow': ui.value,
  1204. 'aria-valuetext': friendlyVal
  1205. });
  1206. })
  1207. .find('a')
  1208. .attr({
  1209. 'role': 'slider',
  1210. 'aria-valuemin': input.attr('min'),
  1211. 'aria-valuemax': input.attr('max'),
  1212. 'aria-valuenow': input.val(),
  1213. 'aria-valuetext': friendlyVal,
  1214. 'aria-labelledby': thisLabel
  1215. });
  1216. input
  1217. .keyup(function(){
  1218. var inVal = parseFloat(input.val());
  1219. if( !isNaN(inVal) ){
  1220. if(inVal == -1){
  1221. input.css("color", "#fff");
  1222. input.next().next().html("未评分");
  1223. input.next().next().show();
  1224. } else {
  1225. input.css("color", "#000");
  1226. input.next().next().hide();
  1227. }
  1228. slider.slider('value', inVal);
  1229. input.val(slider.slider('value'));
  1230. }
  1231. })
  1232. .change(function(){
  1233. var inVal = parseFloat(input.val());
  1234. if( !isNaN(inVal) ){
  1235. if(inVal == -1){
  1236. input.css("color", "#fff");
  1237. input.next().next().html("未评分");
  1238. input.next().next().show();
  1239. } else {
  1240. input.css("color", "#000");
  1241. input.next().next().hide();
  1242. }
  1243. slider.slider('value', inVal);
  1244. input.val(slider.slider('value'));
  1245. }
  1246. })
  1247. .blur(function(){
  1248. var inVal = parseFloat(input.val());
  1249. if( isNaN(inVal) ){
  1250. input.val(-1);
  1251. }
  1252. if(input.val() == -1){
  1253. input.css("color", "#fff");
  1254. input.next().next().html("未评分");
  1255. input.next().next().show();
  1256. } else {
  1257. input.css("color", "#000");
  1258. input.next().next().hide();
  1259. }
  1260. });
  1261. if( !settings.step ){
  1262. var step = Math.round( parseFloat(input.attr('max')) / slider.width());
  1263. if(step > 1){ slider.slider('option','step',step); }
  1264. }
  1265. }
  1266. });
  1267. };
  1268. //返回顶部
  1269. $(function(){goTopEx();});
  1270. var Sys = {};
  1271. var ua = navigator.userAgent.toLowerCase();
  1272. var s;
  1273. (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
  1274. (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
  1275. (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
  1276. (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
  1277. (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
  1278. function goTopEx() {
  1279. var obj = document.getElementById("goTopBtn");
  1280. if(obj != null)
  1281. {
  1282. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  1283. function getScrollTop() {
  1284. var xsun = document.documentElement.scrollTop;
  1285. if (Sys.chrome) {
  1286. xsun=document.body.scrollTop;
  1287. }
  1288. return xsun;
  1289. }
  1290. function setScrollTop(value) {
  1291. if (Sys.chrome) {
  1292. document.body.scrollTop = value;
  1293. }
  1294. else {
  1295. document.documentElement.scrollTop = value;
  1296. }
  1297. }
  1298. window.onscroll = function () { getScrollTop() > 0 ? obj.style.display = "" : obj.style.display = "none"; };
  1299. obj.onclick = function () {
  1300. var goTop = setInterval(scrollMove, 10);
  1301. function scrollMove() {
  1302. setScrollTop(getScrollTop() / 1.1);
  1303. if (getScrollTop() < 1) clearInterval(goTop);
  1304. }
  1305. }
  1306. }
  1307. }
  1308. $(function(){
  1309. //匿评评分提示
  1310. $(".student_score_info").live("mouseover",function(){
  1311. $(this).find("div").show();
  1312. });
  1313. $(".student_score_info").live("mouseout",function(){
  1314. $(this).find("div").hide();
  1315. });
  1316. //最终成绩提示
  1317. $(".student_final_scor_info").live("mouseover",function(){
  1318. $(this).find("div").show();
  1319. });
  1320. $(".student_final_scor_info").live("mouseout",function(){
  1321. $(this).find("div").hide();
  1322. });
  1323. $("#about_project label").eq(1).remove();
  1324. ////附件下载提示
  1325. //$(".zip_download_alert").bind("mouseover",function(){
  1326. // $(this).next("div").show();
  1327. //});
  1328. //$(".zip_download_alert").bind("mouseout",function(){
  1329. // $(this).next("div").hide();
  1330. //});
  1331. });
  1332. //匿评弹框取消按钮
  1333. function clickCanel(){hideModal("#popbox02");}
  1334. //匿评弹框确定按钮
  1335. function clickOK(path)
  1336. {
  1337. clickCanel();
  1338. $.ajax({
  1339. type: "GET",
  1340. url: path,
  1341. data: 'text',
  1342. success: function (data) {
  1343. }
  1344. });
  1345. }
  1346. //关闭引入资源弹框
  1347. function hideResource(){
  1348. $('#ajax-modal').parent().removeClass("popbox").removeClass("referenceResourcesPopup");
  1349. hideModal();
  1350. }
  1351. //查询
  1352. function SearchByName(url,event)
  1353. {
  1354. var keycode = (event.keyCode ? event.keyCode : event.which);
  1355. if(keycode == '13'){
  1356. $.get(
  1357. url,
  1358. {
  1359. name : $("#course_student_name").val(),
  1360. group : $("#student_work_in_group").val()
  1361. },
  1362. function (data) {
  1363. }
  1364. );
  1365. }
  1366. }
  1367. function SearchByName_1(url)
  1368. {
  1369. //alert($("#student_work_in_group").val());
  1370. $.get(
  1371. url,
  1372. {
  1373. name : $("#course_student_name").val(),
  1374. group : $("#student_work_in_group").val(),
  1375. appeal: $("#anonymous_appeal_check").is(":checked") ? 1 : 0
  1376. },
  1377. function (data) {
  1378. }
  1379. );
  1380. }
  1381. $(function(){
  1382. $("#student_work_in_group").live("change",function(){
  1383. $("#search_in_student_work").click();
  1384. });
  1385. $("#anonymous_appeal_check").live("change",function(){
  1386. $("#search_in_student_work").click();
  1387. });
  1388. });
  1389. //新建作业临时弹框
  1390. function new_homework_alert(){
  1391. alert("您好!课程内直接发布作业的功能正在改进中,请直接点击\n顶部导航栏的“作业”向本课程发送作业。谢谢!如有问\n题,可参见帮助中心。");
  1392. }
  1393. function show_student_work(url){
  1394. $.get(
  1395. url,
  1396. {
  1397. },
  1398. function (data) {
  1399. }
  1400. );
  1401. }
  1402. //textarea自适应高度 纯js写的 有浏览器判断
  1403. /**
  1404. * 文本框根据输入内容自适应高度
  1405. * @param {HTMLElement} 输入框元素
  1406. * @param {Number} 设置光标与输入框保持的距离(默认0)
  1407. * @param {Number} 设置最大高度(可选)
  1408. */
  1409. var autoTextarea = function (elem, extra, maxHeight) {
  1410. extra = extra || 0;
  1411. var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
  1412. isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
  1413. addEvent = function (type, callback) {
  1414. elem.addEventListener ?
  1415. elem.addEventListener(type, callback, false) :
  1416. elem.attachEvent('on' + type, callback);
  1417. },
  1418. getStyle = elem.currentStyle ? function (name) {
  1419. var val = elem.currentStyle[name];
  1420. if (name === 'height' && val.search(/px/i) !== 1) {
  1421. var rect = elem.getBoundingClientRect();
  1422. return rect.bottom - rect.top -
  1423. parseFloat(getStyle('paddingTop')) -
  1424. parseFloat(getStyle('paddingBottom')) + 'px';
  1425. };
  1426. return val;
  1427. } : function (name) {
  1428. return getComputedStyle(elem, null)[name];
  1429. },
  1430. minHeight = parseFloat(getStyle('height'));
  1431. elem.style.resize = 'none';
  1432. var change = function () {
  1433. var scrollTop, height,
  1434. padding = 0,
  1435. style = elem.style;
  1436. if (elem._length === elem.value.length) return;
  1437. elem._length = elem.value.length;
  1438. if (!isFirefox && !isOpera) {
  1439. padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
  1440. };
  1441. scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
  1442. elem.style.height = minHeight + 'px';
  1443. if (elem.scrollHeight > minHeight) {
  1444. if (maxHeight && elem.scrollHeight > maxHeight) {
  1445. height = maxHeight - padding;
  1446. style.overflowY = 'auto';
  1447. } else {
  1448. height = elem.scrollHeight - padding;
  1449. style.overflowY = 'hidden';
  1450. };
  1451. style.height = height + extra + 'px';
  1452. scrollTop += parseInt(style.height) - elem.currHeight;
  1453. document.body.scrollTop = scrollTop;
  1454. document.documentElement.scrollTop = scrollTop;
  1455. elem.currHeight = parseInt(style.height);
  1456. };
  1457. };
  1458. addEvent('propertychange', change);
  1459. addEvent('input', change);
  1460. addEvent('focus', change);
  1461. change();
  1462. };
  1463. /////////////////////////////////////////////////////////////////////////////////////////
  1464. var autoTextarea2 = function (elem,elem2, extra, maxHeight) {
  1465. extra = extra || 0;
  1466. var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
  1467. isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
  1468. addEvent = function (element, type, callback) {
  1469. element.addEventListener ?
  1470. element.addEventListener(type, callback, false) :
  1471. element.attachEvent('on' + type, callback);
  1472. },
  1473. getFirstStyle = elem.currentStyle ? function (name) {
  1474. var val = elem.currentStyle[name];
  1475. if (name === 'height' && val.search(/px/i) !== 1) {
  1476. var rect = elem.getBoundingClientRect();
  1477. return rect.bottom - rect.top -
  1478. parseFloat(getFirstStyle('paddingTop')) -
  1479. parseFloat(getFirstStyle('paddingBottom')) + 'px';
  1480. };
  1481. return val;
  1482. } : function (name) {
  1483. return getComputedStyle(elem, null)[name];
  1484. },
  1485. minHeight = parseFloat(getFirstStyle('height'));
  1486. elem.style.resize = 'none';
  1487. elem2.style.resize = 'none';
  1488. var change = function () {
  1489. var scrollTop, height,
  1490. padding = 0,
  1491. style = elem.style,
  1492. style2 = elem2.style;
  1493. if (elem._length === elem.value.length) return;
  1494. elem._length = elem.value.length;
  1495. elem2._length = elem._length;
  1496. if (!isFirefox && !isOpera) {
  1497. padding = parseInt(getFirstStyle('paddingTop')) + parseInt(getFirstStyle('paddingBottom'));
  1498. };
  1499. scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
  1500. elem.style.height = minHeight + 'px';
  1501. elem2.style.height = minHeight + 'px';
  1502. if (elem.scrollHeight > minHeight) {
  1503. if (maxHeight && elem.scrollHeight > maxHeight) {
  1504. height = maxHeight - padding;
  1505. style.overflowY = 'auto';
  1506. style2.overflowY = 'auto';
  1507. } else {
  1508. height = elem.scrollHeight - padding;
  1509. };
  1510. style.height = height + extra + 'px';
  1511. style2.height = height + extra + 'px';
  1512. scrollTop += parseInt(style.height) - elem.currHeight;
  1513. document.body.scrollTop = scrollTop;
  1514. document.documentElement.scrollTop = scrollTop;
  1515. elem.currHeight = parseInt(style.height);
  1516. };
  1517. if (elem2.scrollHeight > minHeight) {
  1518. if (maxHeight && elem2.scrollHeight > maxHeight) {
  1519. height = maxHeight - padding;
  1520. style.overflowY = 'auto';
  1521. style2.overflowY = 'auto';
  1522. } else {
  1523. height = elem2.scrollHeight - padding;
  1524. };
  1525. style.height = height + extra + 'px';
  1526. style2.height = height + extra + 'px';
  1527. scrollTop += parseInt(style2.height) - elem2.currHeight;
  1528. document.body.scrollTop = scrollTop;
  1529. document.documentElement.scrollTop = scrollTop;
  1530. elem2.currHeight = parseInt(style2.height);
  1531. };
  1532. };
  1533. addEvent(elem, 'propertychange', change);
  1534. addEvent(elem, 'input', change);
  1535. addEvent(elem, 'focus', change);
  1536. addEvent(elem2, 'propertychange', change);
  1537. addEvent(elem2, 'input', change);
  1538. addEvent(elem2, 'focus', change);
  1539. change();
  1540. };
  1541. //课程大纲选择请求,第二个参数是可选的,判断当前页面是大纲显示页面还是 课程首页
  1542. function course_outline(id){
  1543. $.get(
  1544. ' /courses/'+id+'/course_outline'+"?is_in_show_outline_page="+(arguments[1] ? arguments[1] : 'N')
  1545. )
  1546. }
  1547. //取消课程组织关联
  1548. function cancel_org_course_relation(id, courseId){
  1549. if(confirm("确定取消关联吗?") == false) return;
  1550. $.ajax({
  1551. url:"/org_courses/" + id + "?course_id=" + courseId,
  1552. type: "delete",
  1553. success:function(data){
  1554. $.ajax({
  1555. url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true",
  1556. type:'get'
  1557. });
  1558. }
  1559. });
  1560. }
  1561. //$(function(){
  1562. // $('#course_outline_search').on('input',function(){
  1563. // alert('<%= @course.id%>')
  1564. // })
  1565. //})
  1566. //项目点击展开
  1567. function expand_tools_expand(content) {
  1568. if (content == "invit") {
  1569. $("#expand_tools_expand_invit").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
  1570. $("#expand_tools_expand_invit").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
  1571. $("#expand_tools_expand_invit").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
  1572. }
  1573. else {
  1574. // $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
  1575. // $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
  1576. // $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
  1577. $("#navContent").toggle(500);
  1578. }
  1579. // 修改数字控制速度, slideUp(500)控制卷起速度
  1580. }
  1581. //通过cookie存储伸开形式
  1582. $(function(){
  1583. var personalized_expand_key = "personalized_expand";
  1584. function personalized_init(){
  1585. var personalized_map = cookieget(personalized_expand_key);
  1586. if(personalized_map!=false){
  1587. personalized_map = JSON.parse(personalized_map);
  1588. $("*[nhtype='toggle4cookiecourse']").each(function(){
  1589. var personalized_id=$(this).data('id');
  1590. var val = personalized_map[personalized_id];
  1591. if(val!=undefined && val!=$(this).data('val')){
  1592. personalized_click($(this),0);
  1593. }
  1594. });
  1595. }
  1596. }
  1597. function personalized_click(obj,timeout){
  1598. var target = $(obj.data('target'));
  1599. var oldval = obj.data('val');
  1600. var val='';
  1601. if(oldval=='expand'){val='retract';}else{val='expand';}
  1602. obj.data('val',val);
  1603. var personalized_map = cookieget(personalized_expand_key);
  1604. if(personalized_map == false){
  1605. personalized_map={};
  1606. }else{
  1607. personalized_map = JSON.parse(personalized_map);
  1608. }
  1609. var personalized_id=obj.data('id');
  1610. personalized_map[personalized_id]=val;
  1611. cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
  1612. target.toggle(timeout);
  1613. }
  1614. $("*[nhtype='toggle4cookiecourse']").on('click',function(){
  1615. personalized_click($(this),500);
  1616. });
  1617. personalized_init();
  1618. });
  1619. function submit_course_feedback() {
  1620. var flag = false;
  1621. if(flag == false){
  1622. $("#course_feedback_new").submit();
  1623. var flag = true
  1624. }
  1625. }
  1626. function show_more_tool(){
  1627. $('#navContentCourse').css('display', 'block');
  1628. }
  1629. //留言
  1630. function course_jour_submit(){
  1631. if(jourReplyVerify()){
  1632. jour_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
  1633. $("#course_feedback_new").submit();
  1634. }
  1635. }
  1636. function jourReplyVerify() {
  1637. var content = jour_content_editor.html();//$.trim($("#message_content").val());
  1638. if (jour_content_editor.isEmpty()) {
  1639. $("#jour_content_span").text("留言不能为空");
  1640. $("#jour_content_span").show();
  1641. $("#jour_content_span").css('color', '#ff0000');
  1642. $("#submit_feedback_user").one('click',function() {
  1643. course_jour_submit();
  1644. });
  1645. return false;
  1646. }
  1647. else {
  1648. $("#jour_content_span").text("填写正确");
  1649. $("#jour_content_span").css('color', '#008000');
  1650. return true;
  1651. }
  1652. }
  1653. function cancel_jour_submit(){
  1654. jour_content_editor.html("");
  1655. $("#jour_content_span").text("");
  1656. $("#jour_content_span").hide();
  1657. }

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...