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 48 kB

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

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