//= require_directory ./rateable //= require jquery.min //= require jquery.infinitescroll /* Redmine - project management software Copyright (C) 2006-2013 Jean-Philippe Lang */ //动态高度控制 function description_show_hide(id){ showNormalImage('activity_description_'+id); if($("#intro_content_"+id).height() > 810) { $("#intro_content_show_"+id).show(); } $("#intro_content_show_"+id).click(function(){ $("#activity_description_"+id).toggleClass("maxh360"); $("#intro_content_show_"+id).hide(); $("#intro_content_hide_"+id).show(); }); $("#intro_content_hide_"+id).click(function(){ $("#activity_description_"+id).toggleClass("maxh360"); $("#intro_content_hide_"+id).hide(); $("#intro_content_show_"+id).show(); }); } //名片的显示 function user_card_show_hide() { // $(".homepagePostPortrait").mouseover(function(){ // $(".userCard").css("display","none"); // onImage = true; // $(this).children(".userCard").css("display","block"); // }); // $(".homepagePostPortrait").mouseout(function(){ // var cur = $(this); // onImage = false; // setTimeout(function(){ // if (onUserCard == false && onImage == false){ // $(cur).children(".userCard").css("display", "none"); // } // }, 500); // }); // $(".userCard").mouseover(function(){ // onUserCard = true; // $(this).css("display","block"); // }); // $(".userCard").mouseout(function(){ // onUserCard = false; // $(this).css("display","none"); // }); } function cleanArray (actual){ var newArray = new Array(); for (var i = 0; i< actual.length; i++){ if (actual[i]){ newArray.push(actual[i]); } } return newArray; } function checkAll(id, checked) { if (checked) { $('#'+id).find('input[type=checkbox]').attr('checked', true); } else { $('#'+id).find('input[type=checkbox]').removeAttr('checked'); } } function toggleCheckboxesBySelector(selector) { var all_checked = true; $(selector).each(function(index) { if (!$(this).is(':checked')) { all_checked = false; } }); $(selector).attr('checked', !all_checked); } function showAndScrollTo(id, focus) { $('#'+id).show(); if (focus !== null) { $('#'+focus).focus(); } $('html, body').animate({scrollTop: $('#'+id).offset().top}, 400); } function toggleRowGroup(el) { var tr = $(el).parents('tr').first(); var n = tr.next(); tr.toggleClass('open'); while (n.length && !n.hasClass('group')) { n.toggle(); n = n.next('tr'); } } function collapseAllRowGroups(el) { var tbody = $(el).parents('tbody').first(); tbody.children('tr').each(function(index) { if ($(this).hasClass('group')) { $(this).removeClass('open'); } else { $(this).hide(); } }); } function expandAllRowGroups(el) { var tbody = $(el).parents('tbody').first(); tbody.children('tr').each(function(index) { if ($(this).hasClass('group')) { $(this).addClass('open'); } else { $(this).show(); } }); } function toggleAllRowGroups(el) { var tr = $(el).parents('tr').first(); if (tr.hasClass('open')) { collapseAllRowGroups(el); } else { expandAllRowGroups(el); } } function toggleFieldset(el) { var fieldset = $(el).parents('fieldset').first(); fieldset.toggleClass('collapsed'); fieldset.children('div').toggle(); } function hideFieldset(el) { var fieldset = $(el).parents('fieldset').first(); fieldset.toggleClass('collapsed'); fieldset.children('div').hide(); } function initFilters(){ $('#add_filter_select').change(function(){ addFilter($(this).val(), '', []); }); $('#filters-table td.field input[type=checkbox]').each(function(){ toggleFilter($(this).val()); }); $('#filters-table td.field input[type=checkbox]').on('click',function(){ toggleFilter($(this).val()); }); $('#filters-table .toggle-multiselect').on('click',function(){ toggleMultiSelect($(this).siblings('select')); }); $('#filters-table input[type=text]').on('keypress', function(e){ if (e.keyCode == 13) submit_query_form("query_form"); }); } function addFilter(field, operator, values) { var fieldId = field.replace('.', '_'); var tr = $('#tr_'+fieldId); if (tr.length > 0) { tr.show(); } else { buildFilterRow(field, operator, values); } $('#cb_'+fieldId).attr('checked', true); toggleFilter(field); $('#add_filter_select').val('').children('option').each(function(){ if ($(this).attr('value') == field) { $(this).attr('disabled', true); } }); } function buildFilterRow(field, operator, values) { var fieldId = field.replace('.', '_'); var filterTable = $("#filters-table"); var filterOptions = availableFilters[field]; var operators = operatorByType[filterOptions['type']]; var filterValues = filterOptions['values']; var i, select; var tr = $('').attr('id', 'tr_'+fieldId).html( '' + '' + ' 复选/multi-select' ); select = tr.find('td.values select'); if (values.length > 1) { select.attr('multiple', true); } for (i=0;i'); if ($.isArray(filterValue)) { option.val(filterValue[1]).text(filterValue[0]); if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} } else { option.val(filterValue).text(filterValue); if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} } select.append(option); } break; case "date": case "date_past": tr.find('td.values').append( '' + ' ' + ' '+labelDayPlural+'' ); $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions); $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions); $('#values_'+fieldId).val(values[0]); break; case "string": case "text": tr.find('td.values').append( '' ); $('#values_'+fieldId).val(values[0]); break; case "relation": tr.find('td.values').append( '' + '' ); $('#values_'+fieldId).val(values[0]); select = tr.find('td.values select'); for (i=0;i'); option.val(filterValue[1]).text(filterValue[0]); if (values[0] == filterValue[1]) { option.attr('selected', true); } select.append(option); } case "integer": case "float": tr.find('td.values').append( '' + ' ' ); $('#values_'+fieldId+'_1').val(values[0]); $('#values_'+fieldId+'_2').val(values[1]); break; } } function toggleFilter(field) { var fieldId = field.replace('.', '_'); if ($('#cb_' + fieldId).is(':checked')) { $("#operators_" + fieldId).show().removeAttr('disabled'); toggleOperator(field); } else { $("#operators_" + fieldId).hide().attr('disabled', true); enableValues(field, []); } } function enableValues(field, indexes) { var fieldId = field.replace('.', '_'); $('#tr_'+fieldId+' td.values .value').each(function(index) { if ($.inArray(index, indexes) >= 0) { $(this).removeAttr('disabled'); $(this).parents('span').first().show(); } else { $(this).val(''); $(this).attr('disabled', true); $(this).parents('span').first().hide(); } if ($(this).hasClass('group')) { $(this).addClass('open'); } else { $(this).show(); } }); } function toggleOperator(field) { var fieldId = field.replace('.', '_'); var operator = $("#operators_" + fieldId); switch (operator.val()) { case "!*": case "*": case "t": case "ld": case "w": case "lw": case "l2w": case "m": case "lm": case "y": case "o": case "c": enableValues(field, []); break; case "><": enableValues(field, [0,1]); break; case "t+": case ">t-": case "0) { lis.eq(i-1).show(); } } function displayTabsButtons() { var lis; var tabsWidth = 0; var el; $('div.tabs').each(function() { el = $(this); lis = el.find('ul').children(); lis.each(function(){ if ($(this).is(':visible')) { tabsWidth += $(this).width() + 6; } }); if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) { el.find('div.tabs-buttons').hide(); } else { el.find('div.tabs-buttons').show(); } }); } function setPredecessorFieldsVisibility() { var relationType = $('#relation_relation_type'); if (relationType.val() == "precedes" || relationType.val() == "follows") { $('#predecessor_fields').show(); } else { $('#predecessor_fields').hide(); } } function showModal(id, width) { var el = $('#'+id).first(); if (el.length === 0 || el.is(':visible')) {return;} var title = el.find('h3.title').text(); el.dialog({ width: width, modal: true, resizable: false, dialogClass: 'modal', title: title }); el.find("input[type=text], input[type=submit]").first().focus(); } function hideModal(el) { if($("#popupWrap").length > 0){ $("#popupWrap").remove(); } else{ var modal; if (el) { modal = $(el).parents('.ui-dialog-content'); } else { modal = $('#ajax-modal'); } modal.dialog("close"); } } function submitPreview(url, form, target) { $.ajax({ url: url, type: 'post', data: $('#'+form).serialize(), success: function(data){ $('#'+target).html(data); } }); } function collapseScmEntry(id) { $('.'+id).each(function() { if ($(this).hasClass('open')) { collapseScmEntry($(this).attr('id')); } $(this).hide(); }); $('#'+id).removeClass('open'); } function expandScmEntry(id) { $('.'+id).each(function() { $(this).show(); if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) { expandScmEntry($(this).attr('id')); } }); $('#'+id).addClass('open'); } function scmEntryClick(id, url) { el = $('#'+id); if (el.hasClass('open')) { collapseScmEntry(id); el.addClass('collapsed'); return false; } else if (el.hasClass('loaded')) { expandScmEntry(id); el.removeClass('collapsed'); return false; } if (el.hasClass('loading')) { return false; } el.addClass('loading'); $.ajax({ url: url, success: function(data){ el.after(data); el.addClass('open').addClass('loaded').removeClass('loading'); } }); return true; } function randomKey(size) { var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); var key = ''; for (i = 0; i < size; i++) { key += chars[Math.floor(Math.random() * chars.length)]; } return key; } // Can't use Rails' remote select because we need the form data function updateIssueFrom(url) { $.ajax({ url: url, type: 'post', data: $('#issue-form').serialize() }); } function updateBulkEditFrom(url) { $.ajax({ url: url, type: 'post', data: $('#bulk_edit_form').serialize() }); } function clearMessage(id) { $('#'+id).val(""); } function observeAutocompleteField(fieldId, url, options) { $(document).ready(function() { $('#'+fieldId).autocomplete($.extend({ source: url, select: function(e,ui){self.location="/issues/"+ui.item.value;}, minLength: 1, search: function(){$('#'+fieldId).addClass('ajax-loading');}, response: function(){$('#'+fieldId).removeClass('ajax-loading'); } }, options)); $('#'+fieldId).addClass('autocomplete'); }); } function observeSearchfield(fieldId, targetId, url) { $('#'+fieldId).each(function() { var $this = $(this); $this.addClass('autocomplete'); $this.attr('data-value-was', $this.val()); var check = function() { var val = $this.val(); if ($this.attr('data-value-was') != val){ $this.attr('data-value-was', val); $.ajax({ url: url, type: 'get', dataType: 'jsonp', data: {q: $this.val()}, success: function(data){ if(targetId) $('#'+targetId).html(data); }, beforeSend: function(){ $this.addClass('ajax-loading'); }, // 添加成员加载完成前,显示载入中 complete: function(){ $this.removeClass('ajax-loading'); } // 完成后,移除 }); } }; var reset = function() { if (timer) { clearInterval(timer); timer = setInterval(check, 300); } }; var timer = setInterval(check, 300); $this.bind('keyup click mousemove', reset); }); } function observeProjectModules() { var f = function() { /* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */ if ($('#project_enabled_module_names_issue_tracking').attr('checked')) { $('#project_trackers').show(); }else{ $('#project_trackers').hide(); } }; $(window).load(f); $('#project_enabled_module_names_issue_tracking').change(f); } function initMyPageSortable(list, url) { $('#list-'+list).sortable({ connectWith: '.block-receiver', tolerance: 'pointer', update: function(){ $.ajax({ url: url, type: 'post', data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})} }); } }); $("#list-top, #list-left, #list-right").disableSelection(); } var warnLeavingUnsavedMessage; function warnLeavingUnsaved(message) { warnLeavingUnsavedMessage = message; $('form').submit(function(){ $('textarea').removeData('changed'); }); $('textarea').change(function(){ $(this).data('changed', 'changed'); }); window.onbeforeunload = function(){ var warn = false; $('textarea').blur().each(function(){ if ($(this).data('changed')) { warn = true; } }); if (warn) {return warnLeavingUnsavedMessage;} }; } function setupHeartBeat(){ var time = 60*1000*30; // 30 mins setInterval(function(){$.getJSON('/account/heartbeat');},time); } function setupAjaxIndicator() { $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){ return; } if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { $('#ajax-indicator').show(); } }); $('#ajax-indicator').bind('ajaxStop', function() { $('#ajax-indicator').hide(); if(MathJax && MathJax.Hub) MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话,手动执行MathJax的公式显示 try{ prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化 }catch (e){ } }); } function hideOnLoad() { $('.hol').hide(); } function addFormObserversForDoubleSubmit() { $('form[method=post]').each(function() { if (!$(this).hasClass('multiple-submit')) { $(this).submit(function(form_submission) { if ($(form_submission.target).attr('data-submitted')) { form_submission.preventDefault(); } else { $(form_submission.target).attr('data-submitted', true); } }); } }); } function blockEventPropagation(event) { event.stopPropagation(); event.preventDefault(); } function toggleAndSettingWordsVal(parent_widget, text_widget, value){ text_widget.val(value) parent_widget.slideToggle(400) } function transpotUrl (scope) { $(scope).each(function(){ var tmpContent = $(this).html(); tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,,]+)/gi,"$1$2$3<\/a>"); // tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,,]+)/gi,"$1$2"); $(this).html(tmpContent); }); } $(document).ready(setupAjaxIndicator); $(document).ready(setupHeartBeat); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); function img_thumbnails() { $('.thumbnails a').colorbox({rel:'nofollow'}); $('.attachments').find('a').each(function(index, element) { var href_value = $(element).attr('href'); if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { $(element).colorbox({rel:'nofollow'}); } }); $('.for_img_thumbnails').find('a').each(function(index, element) { var href_value = $(element).attr('href'); if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { $(element).colorbox({rel:'nofollow'}); } }); } $(document).ready(img_thumbnails); function TimeClose(dateText, inst) { if(inst.id=="issue_start_date"){ time=dateText; } } var time=new Date(); function TimeBeforeShow(input){ if(input.id=="issue_due_date"){ //var minDate = $(input).datepicker('option', 'minDate'); var tempdata=$("#issue_start_date").attr("value"); $(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/"))); //$('.selector').datepicker('option', 'minDate', '12/25/2012'); } } function SetMinValue(){ /// var tempdata=$("#issue_start_date").attr("value"); //$('.selector').datepicker('option', 'minDate', '12/25/2012'); //alert(tempdata); //$("#issue_due_date").datepicker({ // minDate: new Date(2014,08,23) //var datepickerOptions= //{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; //alert( $('.issue_due_date').length); //$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23)); //$("#issue_due_date").datepicker(datepickerOptions); //$("##{issue_due_date}").datepicker(datepickerOptions); //$("#issue_due_date").datepicker( // {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true} //) //}); } function PrecentChange(obj){ var _v= obj; if(_v==100) { //var select=$("select[id='issue_status_id']"); $("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected"); } else if(_v==0) { //alert(1); $("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected"); } else if(_v!=100&&_v!=0) { // alert(2); $("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected"); } } //added by lizanle 日期選擇js function HS_DateAdd(interval,number,date){ number = parseInt(number); if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])} if (typeof(date)=="object"){var date = date} switch(interval){ case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break; case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break; case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break; case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break; } } function checkDate(year,month,date){ var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"]; var returnDate = ""; if (year%4==0){enddate[1]="29"} if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date} return returnDate; } function WeekDay(date){ var theDate; if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);} if (typeof(date)=="object"){theDate = date} return theDate.getDay(); } function HS_calender(){ var lis = ""; var style = ""; /*可以把下面的css剪切出去独立一个css文件*/ style +=""; var now; if (typeof(arguments[0])=="string"){ selectDate = arguments[0].split("-"); var year = selectDate[0]; var month = parseInt(selectDate[1])-1+""; var date = selectDate[2]; now = new Date(year,month,date); }else if (typeof(arguments[0])=="object"){ now = arguments[0]; } var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate(); var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01"); var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01"); var thisMonthEndDate = thisMonthLastDate.getDate(); var thisMonthEndDay = thisMonthLastDate.getDay(); var todayObj = new Date(); today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate(); for (i=0; i" + lis; lastMonthEndDate--; } for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){ var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i; lis += "
  • "+i+"
  • "; }else{ lis += "
  • "+i+"
  • "; } } var j=1; for (i=thisMonthEndDay; i<6; i++){ // Next Month's Date lis += "
  • "+j+"
  • "; j++; } lis += style; var CalenderTitle = "»"; CalenderTitle += "«"; CalenderTitle += ""+now.getFullYear()+""+(parseInt(now.getMonth())+1).toString()+"月"; if (arguments.length>1){ arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis; arguments[1].parentNode.innerHTML = CalenderTitle; }else{ var CalenderBox = style+"
    "+CalenderTitle+"
      "+lis+"
    "; return CalenderBox; } } function _selectThisDay(d){ var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode; boxObj.targetObj.value = d.title; boxObj.parentNode.removeChild(boxObj); } function closeCalender(d){ var boxObj = d.parentNode.parentNode.parentNode; boxObj.parentNode.removeChild(boxObj); } function CalenderselectYear(obj){ var opt = ""; var thisYear = obj.innerHTML; for (i=1970; i<=2020; i++){ if (i==thisYear){ opt += ""; }else{ opt += ""; } } opt = ""; obj.parentNode.innerHTML = opt; } function selectThisYear(obj){ HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode); } function CalenderselectMonth(obj){ var opt = ""; var thisMonth = obj.innerHTML; for (i=1; i<=12; i++){ if (i==thisMonth){ opt += ""; }else{ opt += ""; } } opt = ""; obj.parentNode.innerHTML = opt; } function selectThisMonth(obj){ HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode); } function HS_setDate(inputObj){ var calenderObj = document.createElement("span"); calenderObj.innerHTML = HS_calender(new Date()); calenderObj.style.position = "absolute"; calenderObj.targetObj = inputObj; inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling); } //lizanle 刷新函数 function redo() { window.location.reload() } function encodeHomeworkUrl(url, is_base64){ if(typeof is_base64 === 'boolean' && is_base64){ return '/zipdown/download?base64file='+url; } var file = encodeURI(url).replace(/\+/g, '%2B'); return '/zipdown/download?file='+file; } //// 作业附件删除 $(function(){ $('.attachments a.delete-homework-icon').bind('ajax:complete', //this will work function(event, data, status, xhr) { //note parametes $(this).parent('p').remove(); console.log("delete complete."); }); $('a.tb_all').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ var res = JSON.parse(data.responseText); if(res.length<1){ return; } if(res.length==1){ if(res[0].base64file){ location.href = encodeHomeworkUrl(res[0].base64file, true);return; } location.href = encodeHomeworkUrl(res[0].file);return; } document.getElementById('light').style.display='block'; $container = $('#light .upload_box_ul'); $container.empty(); for(var i = 0; i 1){ des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; } else { des = '第'+res[i].index+'个学生的作品下载'; } if(res[i].base64file){ $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } else { $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } } } }); $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ var res = JSON.parse(data.responseText); if(res.length == null){ alert("该作业没有任何附件可下载"); } else if(res.length<1){ return; } else { if(res.length==1){ if(res[0].base64file){ location.href = encodeHomeworkUrl(res[0].base64file, true);return; } location.href = encodeHomeworkUrl(res[0].file);return; } document.getElementById('light').style.display='block'; $container = $('#light .upload_box_ul'); $container.empty(); for(var i = 0; i 1){ des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; } else { des = '第'+res[i].index+'个学生的作品下载'; } if(res[i].base64file){ $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } else { $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); } } } } }); }); //firefox的pre标签换行 $(document).ready(function () { var userAgent = navigator.userAgent.toLowerCase(); var browser = { version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1], safari: /webkit/.test(userAgent), opera: /opera/.test(userAgent), msie: /msie/.test(userAgent) && !/opera/.test(userAgent), mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) }; if (browser.mozilla || browser.opera){ $("pre").addClass("break_word_firefox"); } else{ $("pre").addClass("break_word"); } }); //点击发送资源弹出框中的组织,要更改选择栏目中的内容 //@dom 选中的radio,值为org_id function change_org_subfield(url){ $.ajax({ type:'get', url:url }) } //点击图片即显示大图 function showNormalImage(id) { var description_images=$('div#'+id).find("img"); if (description_images.length>0) { for (var i=0; i= 0 || tmpsrc.indexOf('.jpg') >= 0 || tmpsrc.indexOf('.jpeg') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.bmp') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.BMP') >= 0 || tmpsrc.indexOf('.JPEG') >= 0 || tmpsrc.indexOf('.JPG') >= 0 || tmpsrc.indexOf('.PNG') >= 0 || tmpsrc.indexOf('.GIF') >= 0) { var element = $("").attr("href", image.attr('src')); image.wrap(element); $(image).parent().colorbox({rel: 'nofollow', close: "关闭", returnFocus: false}); } } } //$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框 } } //文件、帖子、通知分享 function org_id_click(){ var sendText = $("input[name='org_id']:checked").next().text(); var orgDirection = "目标地址:"; $(".orgDirection").text(orgDirection + sendText); } function subfield_click(){ var sendText = $("input[name='org_id']:checked").next().text(); var orgDirection = "目标地址:"; var sendColumn = $("input[name='subfield']:checked").next().text(); $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn); } //send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 function observeSearchfieldOnInput(fieldId, url,send_id,send_ids, send_type) { $('#'+fieldId).each(function() { var $this = $(this); $this.addClass('autocomplete'); $this.attr('data-value-was', $this.val()); var check = function() { var val = $this.val(); if ($this.attr('data-value-was') != val){ $this.attr('data-value-was', val); $.ajax({ url: url, type: 'get', data: {search: $this.val(),send_id:send_id,send_ids:send_ids, send_type:send_type, is_observe:true}, success: function(data){ }, beforeSend: function(){ $this.addClass('ajax-loading'); }, complete: function(){ $this.removeClass('ajax-loading'); } }); } }; var reset = function() { if (timer) { clearInterval(timer); timer = setInterval(check, 500); } }; var timer = setInterval(check, 500); $this.bind('keyup click mousemove', reset); }); } function check_des(event){ if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){ event.preventDefault(); $(".orgDirection").text('目标地址组织不能为空'); return false; }else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){ event.preventDefault(); $(".orgDirection").text('目标地址栏目不能为空'); return false; }else{ return true; } } var sendType = '1'; var lastSendType ;//初始为发送到我的课程 function show_send(id, user_id, send_type){ if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project', data:{send_id:id, send_type:send_type} }); }else if(lastSendType == '1'){ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_course', data:{send_id:id, send_type:send_type} }); }else if( lastSendType == '3'){//组织 $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_org', data:{send_id:id, send_type:send_type} }); }else{ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_course', data:{send_id:id, send_type:send_type} }); } } //为了隐藏非项目功能 //var sendType = '1'; var lastSendType ;//初始为发送到我的项目 function show_send_hidden(id, user_id, send_type){ if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project', data:{send_id:id, send_type:send_type} }); }else if( lastSendType == '2'){//组织 $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_org', data:{send_id:id, send_type:send_type} }); }else{ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project', data:{send_id:id, send_type:send_type} }); } } //id 发送的id //发送的id数组 //send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 function chooseSendType(res_id,res_ids, user_id, send_type){ sendType = $(".resourcesSendType").val(); if (sendType === lastSendType) { return; } else if(lastSendType != null) { //不是第一次点击的时候 if (sendType == '1') { $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_course', data:{send_id:res_id, send_type:send_type} }); } else if(sendType == '2') { $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project', data:{send_id:res_id, send_type:send_type} }); }else if(sendType == '3'){ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_org', data:{send_id:res_id, send_type:send_type} }); } } lastSendType = sendType; } function chooseSendType2(res_id,res_ids, user_id, send_type, type){ console.log(res_ids); sendType = $(".resourcesSendType").val(); if (sendType === lastSendType) { return; } else if(lastSendType != null) { //不是第一次点击的时候 if (sendType == '1') { $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_course' + '?' + "&type=" + type, data:{send_id:res_id, send_ids:res_ids ,send_type:send_type} }); } else if(sendType == '2') { console.log(res_ids); $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project' + '?' + "&type=" + type, data:{send_id:res_id, send_ids:res_ids, send_type:send_type} }); }else if(sendType == '3'){ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_org' + '?' + "&type=" + type, data:{send_id:res_id, send_ids:res_ids, send_type:send_type} }); } } lastSendType = sendType; } //隐藏项目其它信息特用 function chooseSendType2hidden(res_id,res_ids, user_id, send_type, type){ console.log(res_ids); sendType = $(".resourcesSendType").val(); if (sendType === lastSendType) { return; } else if(lastSendType != null) { //不是第一次点击的时候 if (sendType == '1') { $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_project' + '?' + "&type=" + type, data:{send_id:res_id, send_ids:res_ids ,send_type:send_type} }); }else if(sendType == '2'){ $.ajax({ type: 'get', url: '/users/' + user_id + '/search_user_org' + '?' + "&type=" + type, data:{send_id:res_id, send_ids:res_ids, send_type:send_type} }); } } lastSendType = sendType; } //组织新建和配置中,选择组织为私有后,disbled掉允许游客下载选项 function disable_down(source, des, hint){ if (source.attr("checked")){ des.attr("disabled", false); hint.html(""); } else{ des.attr("checked", false); des.attr("disabled", true); hint.html("(私有组织不允许游客下载资源)"); } } function getRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName=window.document.location.pathname; var pos=curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8083 var localhostPaht=curWwwPath.substring(0,pos); //获取带"/"的项目名,如:/uimcardprj // var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); var projectName=""; return(localhostPaht+projectName); } //自动保存草稿 var editor2; function elocalStorage(editor,mdu,id){ if (window.sessionStorage){ editor2 = editor; var oc = window.sessionStorage.getItem('content'+mdu); if(oc !== null ){ if(arguments[2]){ var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; $("#e_tips_"+id).html(h); }else{ var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; $("#e_tips").html(h); } } setInterval(function() { d = new Date(); var h = d.getHours(); var m = d.getMinutes(); var s = d.getSeconds(); h = h < 10 ? '0' + h : h; m = m < 10 ? '0' + m : m; s = s < 10 ? '0' + s : s; editor.sync(); if(!editor.isEmpty()){ add_data("content",mdu,editor.html()); var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip"; var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips"; $(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); $(id2).html(""); } },10000); }else{ $('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); } } function add_data(k,mdu,d){ window.sessionStorage.setItem(k+mdu,d); } function rec_data(k,mdu,id){ if(window.sessionStorage.getItem(k+mdu) !== null){ editor2.html(window.sessionStorage.getItem(k+mdu)); clear_data(k,mdu,id); } } function clear_data(k,mdu,id){ window.sessionStorage.removeItem(k+mdu); var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip"; var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips"; if(k == 'content'){ $(id2).html(""); }else{ $(id1).html(""); } } function expand_reply(container,btnid){ var target = $(container).children(); var btn = $(btnid); if(btn.data('init')=='0'){ btn.data('init',1); btn.html('收起回复'); target.show(); }else{ btn.data('init',0); btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); target.eq(2).show(); } } function expand_all_reply(container, btnid, id, type, div_id) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { btn.data('init', 1); $.get( '/users/all_journals', { type: type, id: id, div_id: div_id }, function(data) { } ); btn.html('收起回复'); //target.show(); } else if(btn.data('init') == '1') { btn.data('init', 3); btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); target.eq(2).show(); } else { btn.data('init', 1); btn.html('收起回复'); target.show(); } } function expand_reply_homework(container, btnid, id, type, div_id, user_activity_id) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { btn.data('init', 1); $.get( '/users/all_journals', { type: type, id: id, div_id: div_id, user_activity_id: user_activity_id }, function(data) { } ); btn.html('收起回复'); //target.show(); } else if(btn.data('init') == '1') { btn.data('init', 3); btn.html('展开更多'); target.hide(); target.eq(0).show(); target.eq(1).show(); target.eq(2).show(); } else { btn.data('init', 1); btn.html('收起回复'); target.show(); } } //by yk 列表描述将文字和起来去掉空格多于100就显示省略号 function description_showwords_ellipsis(id,num){ var str = ""; $("#intro_content_"+id).each(function () { str = str + $(this).text(); }); //去掉空格 str = str.replace(/[\f\n\r\t\v]/gi,''); if(str.length > num){ str = str.substring(0,num)+"..."; } $("#intro_content_"+id).html(str); $("#intro_content_"+id).show(); } //by yk 弹框 value:html代码或跳转其他页面代码 tWidth = 580 tTop=30 tLeft=50 function pop_up_box(value,tWidth,tTop,tLeft){ if(!tWidth){ var tWidth = 580; } if(!tTop){ var tTop = 30; } if(!tLeft){ var tLeft = 50; } $("#ajax-modal").html(value); showModal('ajax-modal', tWidth + "px"); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); $('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed"); $('#ajax-modal').parent().addClass("resourceUploadPopup"); $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); function hideModal(){ $('#ajax-modal').hide(); } } // 公共弹框样式 // 建议左右栏的:Width:460,Height:190 // 建议宽屏对应值:Width:760,Height:500 function pop_box_new(value, Width, Height){ w = ($(window).width() - Width)/2; h = ($(window).height() - Height)/2; var container =$('
    '); container.attr('id','popupWrap'); $(document.body).append(container); $("#popupWrap").html(value); $("#popupWrap").show(); $('#popupWrap').css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed","z-index":"99999","background-color":"#fff","box-shadow": "0px 2px 8px rgba(146, 153, 169, 0.5)"}); $('#popupWrap').find("a[class*='close']").click(function(){ $("#popupWrap").hide(); }); // w = ($(window).width() - Width)/2; // h = ($(window).height() - Height)/2; // $("#ajax-modal").html(value); // showModal('ajax-modal', Width + 'px'); // $('#ajax-modal').siblings().remove(); // $('#ajax-modal').parent().css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed"}); // $('#ajax-modal').parent().removeClass("resourceUploadPopup popbox_polls popbox"); // $('#ajax-modal').css({"padding":"0","overflow":"hidden"}); // $('#ajax-modal').parent().attr("id","popupWrap"); //拖拽 function Drag(id) { this.div = document.getElementById(id); if (this.div) { this.div.style.cursor = "move"; this.div.style.position = "fixed"; } this.disX = 0; this.disY = 0; var _this = this; this.div.onmousedown = function (evt) { _this.getDistance(evt); document.onmousemove = function (evt) { _this.setPosition(evt); }; _this.div.onmouseup = function () { _this.clearEvent(); } } } Drag.prototype.getDistance = function (evt) { var oEvent = evt || event; this.disX = oEvent.clientX - this.div.offsetLeft; this.disY = oEvent.clientY - this.div.offsetTop; }; Drag.prototype.setPosition = function (evt) { var oEvent = evt || event; var l = oEvent.clientX - this.disX; var t = oEvent.clientY - this.disY; if (l <= 0) { l = 0; } else if (l >= document.documentElement.clientWidth - this.div.offsetWidth) { l = document.documentElement.clientWidth - this.div.offsetWidth; } if (t <= 0) { t = 0; } else if (t >= document.documentElement.clientHeight - this.div.offsetHeight) { t = document.documentElement.clientHeight - this.div.offsetHeight; } this.div.style.left = l + "px"; this.div.style.top = t + "px"; }; Drag.prototype.clearEvent = function () { this.div.onmouseup = null; document.onmousemove = null; }; new Drag("popupWrap"); $("#popupWrap input, #popupWrap textarea, #popupWrap ul").mousedown(function(event){ event.stopPropagation(); new Drag("popupWrap"); }); } function close_modal(){ $("#popupWrap").hide(); } // 公共提示弹框样式 //function pop_box_tip_new(value, Width, Top, Left){ // $("#ajax-modal").html(value); // showModal('ajax-modal', Width + 'px'); // $('#ajax-modal').siblings().remove(); // $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); // $('#ajax-modal').css({"padding":"0"}); //} //显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框 function autoMedia(id){ var rootPath = getRootPath(); function _mediaType(src) { if (/\.(rm|rmvb)(\?|$)/i.test(src)) { return 'audio/x-pn-realaudio-plugin'; } if (/\.(swf|flv)(\?|$)/i.test(src)) { return 'application/x-shockwave-flash'; } return 'video/x-ms-asf-plugin'; } if (rootPath.indexOf("https") < 0){ $("#"+id+" img").each(function(){ if ($(this).attr("class") == "mediaIco"){ var href = $(this).parent().attr("href"); //正则取地址 if (href){ var url = href.split("open('")[1].split("',")[0]; if (url != ""){ var type = _mediaType(url); //1.video/x-ms-asf-plugin 类型的视频播放不了,2.audio/x-pn-realaudio-plugin没试过3.application/x-shockwave-flash可以播放 if (type != "video/x-ms-asf-plugin"){ var width = 550; var height = 400; var html = ''; $(this).parent().replaceWith(html); } } } } }); } } //yk 自动识别URL 并加上链接 function autoUrl(id){ if ($("#"+id).children().length > 0 ){ $("#"+id+" p,#"+ id +" span,#"+id+" em,#"+id+" h1,#"+id+" h2,#"+id+" h3,#"+id+" h4,#"+id+" strong,#"+id+" b,#"+id+" font,#"+id+" i").each(function(){ if ($(this).children().length == 0){ var html = $(this).text(); html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|cn)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[A-Za-z0-9_\-\.~]+)*(\?[A-Za-z0-9+_\-\.%=&]*)?(\/([A-Za-z0-9_\-\.]*)(\?[A-Za-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) { //没有://的都加上http:// var reStr = full; if (full.length > 0){ if (full.indexOf("://") >= 0){ reStr = ""+full+""; } else{ reStr = ""+full+""; } } return reStr ; }); try{ $(this).html(html); } catch (e) { console.log(e.name + ": " + e.message); } } }); } else{ var html = $("#"+id).text(); html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|cn)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[A-Za-z0-9_\-\.~]+)*(\?[A-Za-z0-9+_\-\.%=&]*)?(\/([A-Za-z0-9_\-\.]*)(\?[A-Za-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) { //没有://的都加上http:// var reStr = full; if (full.length > 0){ if (full.indexOf("://") >= 0){ reStr = ""+full+""; } else{ reStr = ""+full+""; } } return reStr ; }); try{ $("#"+id).html(html); } catch (e) { console.log(e.name + ": " + e.message); } } if(!(!!window.ActiveXObject || "ActiveXObject" in window)){ autoMedia(id); } } //编辑资源描述 function show_edit_file_description(id) { $("#file_description_show_"+id).hide(); $("#file_description_edit_"+id).show(); $("#file_description_edit_"+id).focus(); } //编辑资源描述之后提交 function edit_file_description(url,id){ $.get( url, {id: id ,description: $("#file_description_edit_"+id).val() }, function (data) { } ); } //展开课程大纲列表中的班级 function expand_course_list(id, target, btnid, count) { var target = $(target); var btn = $(btnid); if(btn.data('init')=='0'){ btn.data('init',1); btn.html('点击收起'); target.show(); }else{ btn.data('init',0); btn.html('共'+count+ '个班级,点击全部展开'); target.hide(); target.eq(0).show(); target.eq(1).show(); target.eq(2).show(); btn.parent().show(); } } //点击删除时的确认弹框 function delete_confirm_box(url, str){ var htmlvalue = '

    提示

    '+ '

    ' + str + '

    确定'+ '取消
    '; pop_box_new(htmlvalue, 300, 140); } //删除组织成员 function ifDeleteOrgMember(id,name){ var htmlvalue = "
    您确定要删除"+name+"吗?

    " + ""; pop_up_box(htmlvalue,580,30,50); } //省市下拉框 function showcity(province, cityField) { switch (province) { case "北京" : var cityOptions = new Array( "东城", "西城", "朝阳", "丰台", "石景山", "海淀", "门头沟", "房山", "通州", "顺义", "昌平", "大兴", "平谷", "怀柔", "密云", "延庆"); break; case "上海" : var cityOptions = new Array( "崇明", "黄浦", "卢湾", "徐汇", "长宁", "静安", "普陀", "闸北", "虹口", "杨浦", "闵行", "宝山", "嘉定", "浦东", "金山", "松江", "青浦", "南汇", "奉贤"); break; case "广东" : var cityOptions = new Array( "广州", "深圳", "珠海", "东莞", "中山", "佛山", "惠州", "河源", "潮州", "江门", "揭阳", "茂名", "梅州", "清远", "汕头", "汕尾", "韶关", "顺德", "阳江", "云浮", "湛江", "肇庆"); break; case "江苏" : var cityOptions = new Array( "南京", "常熟", "常州", "海门", "淮安", "江都", "江阴", "昆山", "连云港", "南通", "启东", "沭阳", "宿迁", "苏州", "太仓", "泰州", "同里", "无锡", "徐州", "盐城", "扬州", "宜兴", "仪征", "张家港", "镇江", "周庄"); break; case "重庆" : var cityOptions = new Array( "万州", "涪陵", "渝中", "大渡口", "江北", "沙坪坝", "九龙坡", "南岸", "北碚", "万盛", "双挢", "渝北", "巴南", "黔江", "长寿", "綦江", "潼南", "铜梁", "大足", "荣昌", "壁山", "梁平", "城口", "丰都", "垫江", "武隆", "忠县", "开县", "云阳", "奉节", "巫山", "巫溪", "石柱", "秀山", "酉阳", "彭水", "江津", "合川", "永川", "南川"); break; case "安徽" : var cityOptions = new Array( "合肥", "安庆", "蚌埠", "亳州", "巢湖", "滁州", "阜阳", "贵池", "淮北", "淮化", "淮南", "黄山", "九华山", "六安", "马鞍山", "宿州", "铜陵", "屯溪", "芜湖", "宣城"); break; case "福建" : var cityOptions = new Array( "福州", "厦门", "泉州", "漳州", "龙岩", "南平", "宁德", "莆田", "三明"); break; case "甘肃" : var cityOptions = new Array( "兰州", "白银", "定西", "敦煌", "甘南", "金昌", "酒泉", "临夏", "平凉", "天水", "武都", "武威", "西峰", "张掖"); break; case "广西" : var cityOptions = new Array( "南宁", "百色", "北海", "桂林", "防城港", "贵港", "河池", "贺州", "柳州", "钦州", "梧州", "玉林"); break; case "贵州" : var cityOptions = new Array( "贵阳", "安顺", "毕节", "都匀", "凯里", "六盘水", "铜仁", "兴义", "玉屏", "遵义"); break; case "海南" : var cityOptions = new Array( "海口", "儋县", "陵水", "琼海", "三亚", "通什", "万宁"); break; case "河北" : var cityOptions = new Array( "石家庄", "保定", "北戴河", "沧州", "承德", "丰润", "邯郸", "衡水", "廊坊", "南戴河", "秦皇岛", "唐山", "新城", "邢台", "张家口"); break; case "黑龙江" : var cityOptions = new Array( "哈尔滨", "北安", "大庆", "大兴安岭", "鹤岗", "黑河", "佳木斯", "鸡西", "牡丹江", "齐齐哈尔", "七台河", "双鸭山", "绥化", "伊春"); break; case "河南" : var cityOptions = new Array( "郑州", "安阳", "鹤壁", "潢川", "焦作", "济源", "开封", "漯河", "洛阳", "南阳", "平顶山", "濮阳", "三门峡", "商丘", "新乡", "信阳", "许昌", "周口", "驻马店"); break; case "香港" : var cityOptions = new Array( "香港", "九龙", "新界"); break; case "湖北" : var cityOptions = new Array( "武汉", "恩施", "鄂州", "黄冈", "黄石", "荆门", "荆州", "潜江", "十堰", "随州", "武穴", "仙桃", "咸宁", "襄阳", "襄樊", "孝感", "宜昌"); break; case "湖南" : var cityOptions = new Array( "长沙", "常德", "郴州", "衡阳", "怀化", "吉首", "娄底", "邵阳", "湘潭", "益阳", "岳阳", "永州", "张家界", "株洲"); break; case "江西" : var cityOptions = new Array( "南昌", "抚州", "赣州", "吉安", "景德镇", "井冈山", "九江", "庐山", "萍乡", "上饶", "新余", "宜春", "鹰潭"); break; case "吉林" : var cityOptions = new Array( "长春", "吉林", "白城", "白山", "珲春", "辽源", "梅河", "四平", "松原", "通化", "延吉"); break; case "辽宁" : var cityOptions = new Array( "沈阳", "鞍山", "本溪", "朝阳", "大连", "丹东", "抚顺", "阜新", "葫芦岛", "锦州", "辽阳", "盘锦", "铁岭", "营口"); break; case "澳门" : var cityOptions = new Array("澳门"); break; case "内蒙古" : var cityOptions = new Array( "呼和浩特", "阿拉善盟", "包头", "赤峰", "东胜", "海拉尔", "集宁", "临河", "通辽", "乌海", "乌兰浩特", "锡林浩特"); break; case "宁夏" : var cityOptions = new Array( "银川", "固源", "石嘴山", "吴忠"); break; case "青海" : var cityOptions = new Array( "西宁", "德令哈", "格尔木", "共和", "海东", "海晏", "玛沁", "同仁", "玉树"); break; case "山东" : var cityOptions = new Array( "济南", "滨州", "兖州", "德州", "东营", "菏泽", "济宁", "莱芜", "聊城", "临沂", "蓬莱", "青岛", "曲阜", "日照", "泰安", "潍坊", "威海", "烟台", "枣庄", "淄博"); break; case "山西" : var cityOptions = new Array( "太原", "长治", "大同", "候马", "晋城", "离石", "临汾", "宁武", "朔州", "忻州", "阳泉", "榆次", "运城"); break; case "陕西" : var cityOptions = new Array( "西安", "安康", "宝鸡", "汉中", "渭南", "商州", "绥德", "铜川", "咸阳", "延安", "榆林"); break; case "四川" : var cityOptions = new Array( "成都", "巴中", "达川", "德阳", "都江堰", "峨眉山", "涪陵", "广安", "广元", "九寨沟", "康定", "乐山", "泸州", "马尔康", "绵阳", "眉山", "南充", "内江", "攀枝花", "遂宁", "汶川", "西昌", "雅安", "宜宾", "自贡", "资阳"); break; case "台湾" : var cityOptions = new Array( "台北", "基隆", "台南", "台中", "高雄", "屏东", "南投", "云林", "新竹", "彰化", "苗栗", "嘉义", "花莲", "桃园", "宜兰", "台东", "金门", "马祖", "澎湖"); break; case "天津" : var cityOptions = new Array( "天津", "和平", "东丽", "河东", "西青", "河西", "津南", "南开", "北辰", "河北", "武清", "红挢", "塘沽", "汉沽", "大港", "宁河", "静海", "宝坻", "蓟县"); break; case "新疆" : var cityOptions = new Array( "乌鲁木齐", "阿克苏", "阿勒泰", "阿图什", "博乐", "昌吉", "东山", "哈密", "和田", "喀什", "克拉玛依", "库车", "库尔勒", "奎屯", "石河子", "塔城", "吐鲁番", "伊宁"); break; case "西藏" : var cityOptions = new Array( "拉萨", "阿里", "昌都", "林芝", "那曲", "日喀则", "山南"); break; case "云南" : var cityOptions = new Array( "昆明", "大理", "保山", "楚雄", "大理", "东川", "个旧", "景洪", "开远", "临沧", "丽江", "六库", "潞西", "曲靖", "思茅", "文山", "西双版纳", "玉溪", "中甸", "昭通"); break; case "浙江" : var cityOptions = new Array( "杭州", "安吉", "慈溪", "定海", "奉化", "海盐", "黄岩", "湖州", "嘉兴", "金华", "临安", "临海", "丽水", "宁波", "瓯海", "平湖", "千岛湖", "衢州", "江山", "瑞安", "绍兴", "嵊州", "台州", "温岭", "温州", "余姚", "舟山"); break; case "海外" : var cityOptions = new Array( "美国", "日本", "英国", "法国", "德国", "其他"); break; default: var cityOptions = new Array(""); break; } cityField.options.length = 0; for (var i = 0; i < cityOptions.length; i++) { cityField.options[i] = new Option(cityOptions[i], cityOptions[i]); /* if (cityField.options[i].value==city) { //alert("here put City ok!"); document.oblogform["city"].selectedIndex = i; }*/ } } function regex_syllabus_name() { var name = $.trim($("#new_syllabus_name").val()); if(name.length < 2) { $("#new_syllabus_name_notice").show(); return false; } else { $("#new_syllabus_name_notice").hide(); return true; } } function alert_new_syllabus(course_id, flag){ htmlvalue = "

    新建课程

      " + "
    • " + "" + "
      " + "" + "
    • " + "
      " + "
    • " + "" + "" + "
    • " + "
      " + "
    • " + "提交" + "取消" + "
      " + "
    • " + "
    "; pop_up_box(htmlvalue,600,30,50); } function admin_new_syllabus(course_id, flag){ if(regex_syllabus_name()) { $.ajax({ type: "post", url: "/admin/create_syllabus", data: {course_id: course_id, title: $("#new_syllabus_name").val(), eng_name: $("#new_syllabus_eng_name").val(), flag: flag}, success: function (data) { } }); hideModal(); } } //执行修改courseName方法 function updateCourseName(){ if(isdb){ isdb = false; if($("#renameCourseName").val() == tagName){ //如果值一样,则恢复原来的状态 ele.parent().css("border",""); ele.parent().html(tagNameHtml); } else{ $.post( '<%= admin_update_course_name_path %>', {"course_id": tagId, "name": $("#renameCourseName").val().trim()} ); } } } function edit_school_name(url,id){ if($("#school_name_edit_"+id).val() == ""){ $("#apply_title_"+id).show(); $("#school_name_edit_"+id).hide(); return; } $.get( url, {id: id ,name: $("#school_name_edit_"+id).val() }, function (data) { $("#school_name_edit_"+id).val(""); if(data.status == 0){ $("#apply_title_"+data.id).show(); $("#school_name_edit_"+data.id).hide(); $("#apply_title_"+data.id).text(data.name); } else{ $("#apply_title_"+data.id).show(); $("#school_name_edit_"+data.id).hide(); } } ); } function show_edit_school_name(id){ $("#apply_title_"+id).hide(); $("#school_name_edit_"+id).val($("#apply_title_"+id).text()); $("#school_name_edit_"+id).show(); $("#school_name_edit_"+id).focus(); } function edit_school_address(url,id){ if($("#school_address_edit_"+id).val() == ""){ $("#apply_address_"+id).show(); $("#school_address_edit_"+id).hide(); return; } $.get( url, {id: id ,address: $("#school_address_edit_"+id).val() }, function (data) { $("#school_address_edit_"+data.id).val(""); if(data.status == 0){ $("#apply_address_"+data.id).show(); $("#school_address_edit_"+data.id).hide(); $("#apply_address_"+data.id).text(data.address); } else{ $("#apply_address_"+data.id).show(); $("#school_address_edit_"+data.id).hide(); } } ); } function show_edit_school_address(id){ $("#apply_address_"+id).hide(); $("#school_address_edit_"+id).val($("#apply_address_"+id).text()); $("#school_address_edit_"+id).show(); $("#school_address_edit_"+id).focus(); } function edit_school_province(url,id){ var province = $("#school_province_edit_"+id).val(); var city = $("#schoolCity_"+id).val(); if((province == "")||(city == "")){ $("#apply_province_"+id).show(); $("#school_province_edit_"+id).hide(); $("#schoolCity_"+id).hide(); return; } $.get( url, {id: id ,province: province,city:city }, function (data) { if(data.status == 0){ $("#apply_province_"+data.id).show(); $("#school_province_edit_"+data.id).hide(); $("#schoolCity_"+data.id).hide(); init_province_and_city(document.getElementById('school_province_edit_'+data.id), data.province, document.getElementById('schoolCity_'+data.id), data.city); $("#apply_province_"+data.id).text(data.province+data.city); } else{ $("#apply_province_"+data.id).show(); $("#school_province_edit_"+data.id).hide(); $("#schoolCity_"+data.id).hide(); } } ); } function init_province_and_city(pField, province, cField, city) { for (var i = 0; i < pField.options.length; i++) { if (pField.options[i].value == province) { pField.selectedIndex = i; } } showcity(province, cField); for (var i = 0; i < cField.options.length; i++) { if (cField.options[i].value == city) { cField.selectedIndex = i; } } } function show_edit_school_province(id){ $("#apply_province_"+id).hide(); $("#school_province_edit_"+id).show(); $("#schoolCity_"+id).show(); } //自动搜索 function throttle_search(e, condition, url) { if($(e.target).val().trim() == condition && condition != '') { return; } condition = $(e.target).val().trim(); $.ajax({ url: url, data:{search: e.target.value}, type:'get' }); } function throttle_me(method, context, e, condition, url){ clearTimeout(method.tId); method.tId=setTimeout(function(){ method.call(context, e, condition, url); },500); } //头像、logo编辑图标显隐 function edit_img(){ $(".homepageEditProfile").parent().mouseover(function(){ $(".homepageEditProfile").show(); }); $(".homepageEditProfile").parent().mouseout(function(){ $(".homepageEditProfile").hide(); }); } $(document).ready(edit_img); //自适应高度 function autoHeight(id, baseheight) { var obj = $(id); obj.height(baseheight); var scrollVal = obj[0].scrollHeight; obj.height(scrollVal); obj.on('input',function(){ obj.height(baseheight); var scrollVal = obj[0].scrollHeight; obj.height(scrollVal); }); }; function getIssueStatistics(url){ var tracker_id = $("#tracker_id").attr("value"); var subject = $("#v_subject").attr("value"); var assigned_to_id = $("#assigned_to_id").attr("value"); var fixed_version_id = $("#fixed_version_id").attr("value"); var status_id = $("#status_id").attr("value"); var done_ratio = $("#done_ratio").attr("value"); var test = $("#test").attr("value"); var author_id = $("#author_id").attr("value"); var priority_id = $("#priority_id").attr("value"); var issue_create_date_start = $("#issue_date_start_issue_export").attr("value"); var issue_create_date_end = $("#issue_date_end_issue_export").attr("value"); $.ajax({ url: url, type: 'get', data: {tracker_id: tracker_id,subject:subject,assigned_to_id:assigned_to_id, fixed_version_id:fixed_version_id, status_id:status_id,done_ratio:done_ratio,test:test,author_id:author_id,priority_id:priority_id,issue_create_date_start:issue_create_date_start,issue_create_date_end:issue_create_date_end}, success: function(data){ }, beforeSend: function(){ }, complete: function(){} }); } function archive_course(id, type, source){ if(type == 0){ var htmlvalue = '

    提示

    '+ '

    您是否确定归档此班级

    ' + '取  消' + '确  定
    '; pop_box_new(htmlvalue, 400, 132); } else{ var htmlvalue = '

    提示

    '+ '

    您和您的学生将可以重新在此班级中互动
    此班级的动态会在首页中显示

    ' + '您是否确定恢复此班级

    取  消' + '确  定
    '; pop_box_new(htmlvalue, 400, 200); } } //判断是不是IE浏览器 function is_IE(){ if(navigator.userAgent.toLowerCase().indexOf('msie') > -1){ return true; }else{ return false; } }