Showing
1 changed file
with
158 additions
and
0 deletions
文章分类/栏目.js
0 → 100644
| 1 | +// ==UserScript== | |
| 2 | +// @name 栏目 | |
| 3 | +// @namespace http://tampermonkey.net/ | |
| 4 | +// @version 0.1 | |
| 5 | +// @description try to take over the world! | |
| 6 | +// @author You | |
| 7 | +// @match http://dpcms8.sysu.edu.cn/*/manage/article/add?destination=manage/article | |
| 8 | +// @match http://dpcms8.sysu.edu.cn/sph-dev/manage/article?title=&department_target_id=*&category_target_id=All&promote=All&sticky=All&access_permission_value=All&status=All | |
| 9 | +// @grant none | |
| 10 | +// ==/UserScript== | |
| 11 | +(function($) { | |
| 12 | + 'use strict'; | |
| 13 | + | |
| 14 | + // Your code here... | |
| 15 | + var ARTICLE_DATA = { | |
| 16 | + "Sheet1": [{ | |
| 17 | + "title": "中山大学公共卫生学院2018年寒假期间值班安排表" | |
| 18 | + }, | |
| 19 | + { | |
| 20 | + "title": "关于预报2018年举办国际学术会议计划的第二轮通知" | |
| 21 | + }, | |
| 22 | + { | |
| 23 | + "title": "关于预报2018年举办国际学术会议计划的通知" | |
| 24 | + }, | |
| 25 | + { | |
| 26 | + "title": "转国际合作与交流处关于申报2017年“珠江人才计划”海外来粤短期工作专家认定的通知" | |
| 27 | + }, | |
| 28 | + { | |
| 29 | + "title": "关于申报2017年度国家重点引智项目的通知" | |
| 30 | + }, | |
| 31 | + { | |
| 32 | + "title": "关于申报2017-2018年度中山大学聘请境外专家校级重点项目的通知" | |
| 33 | + }, | |
| 34 | + { | |
| 35 | + "title": "中山大学公共卫生学院2017年暑假期间值班安排表" | |
| 36 | + }, | |
| 37 | + { | |
| 38 | + "title": "公共卫生学院关于调整部分院领导及相关人员分工的决定" | |
| 39 | + }, | |
| 40 | + { | |
| 41 | + "title": "公共卫生学院关于党政领导及相关人员分工的决定" | |
| 42 | + }, | |
| 43 | + { | |
| 44 | + "title": "转发国际合作与交流处关于开通大学服务中心网站因公临时出国(境)申报的通知" | |
| 45 | + }, | |
| 46 | + { | |
| 47 | + "title": "中山大学公共卫生学院2017年寒假期间值班安排表" | |
| 48 | + }, | |
| 49 | + { | |
| 50 | + "title": "中山大学公共卫生学院2016年暑假期间值班安排表" | |
| 51 | + }, | |
| 52 | + { | |
| 53 | + "title": "中山大学公共卫生学院2016年寒假期间值班安排表" | |
| 54 | + }, | |
| 55 | + { | |
| 56 | + "title": "中山大学转发财政部关于调整中央和国家机关差旅住宿费标准等有关问题的通知" | |
| 57 | + }, | |
| 58 | + { | |
| 59 | + "title": "转发校长办公室关于2016年寒假工作安排的通知" | |
| 60 | + }, | |
| 61 | + { | |
| 62 | + "title": "关于公共卫生学院党委换届选举结果的批复" | |
| 63 | + }, | |
| 64 | + { | |
| 65 | + "title": "关于学院实验室资源共享平台的通知" | |
| 66 | + }, | |
| 67 | + { | |
| 68 | + "title": "关于我院师生个人事项审批、签发办理流程的通知" | |
| 69 | + }, | |
| 70 | + { | |
| 71 | + "title": "关于第二届公共卫生实践技能演练大赛时间安排的通知" | |
| 72 | + } | |
| 73 | + ] | |
| 74 | + }; | |
| 75 | + | |
| 76 | + function _fill(element, data) { | |
| 77 | + element.val(data); | |
| 78 | + } | |
| 79 | + | |
| 80 | + function _selectOptioin(optionE) { | |
| 81 | + optionE.siblings().attr('selected', false); | |
| 82 | + optionE.attr('selected', true); | |
| 83 | + } | |
| 84 | + | |
| 85 | + function hasStorage(name, date) { | |
| 86 | + if (JSON.stringify(date) === '{}') { | |
| 87 | + return false; | |
| 88 | + } | |
| 89 | + | |
| 90 | + if (typeof localStorage.getItem(name) != 'string') { | |
| 91 | + localStorage.setItem(name, JSON.stringify(date)); | |
| 92 | + } | |
| 93 | + | |
| 94 | + return !!localStorage.getItem(name); | |
| 95 | + } | |
| 96 | + | |
| 97 | + $('#edit-category option').each(function(index, e) { | |
| 98 | + if ($(this).val() == '139') { | |
| 99 | + _selectOptioin($(this)); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + | |
| 103 | + $('#edit-department option').each(function(index, e) { | |
| 104 | + if ($(this).val() == '133') { | |
| 105 | + _selectOptioin($(this)); | |
| 106 | + } | |
| 107 | + $('#edit-approvers').trigger("chosen:updated"); | |
| 108 | + }); | |
| 109 | + | |
| 110 | + $('#edit-body-0-format--2 option').each(function(index, e) { | |
| 111 | + if ($(this).val() == 'full_html') { | |
| 112 | + _selectOptioin($(this)); | |
| 113 | + } | |
| 114 | + }); | |
| 115 | + | |
| 116 | + hasStorage('article_data', ARTICLE_DATA); | |
| 117 | + | |
| 118 | + if (hasStorage('article_data', ARTICLE_DATA) && $('[data-drupal-link-system-path="manage/article/add"]').length > 0) { | |
| 119 | + var article_data = $.parseJSON(localStorage.getItem('article_data')); | |
| 120 | + var admin_content = $('#block-ccms-admin-content tbody tr .views-field-title a'); | |
| 121 | + | |
| 122 | + admin_content.each(function() { | |
| 123 | + var _p = $(this).text(); | |
| 124 | + | |
| 125 | + $.each(article_data.Sheet1, function(index, e) { | |
| 126 | + | |
| 127 | + if (typeof article_data.Sheet1[index].title != 'undefined') { | |
| 128 | + if (article_data.Sheet1[index].title == _p) { | |
| 129 | + article_data.Sheet1[index] = {}; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + }); | |
| 134 | + }); | |
| 135 | + | |
| 136 | + localStorage.setItem('article_data', JSON.stringify(article_data)); | |
| 137 | + } | |
| 138 | + | |
| 139 | + article_data = $.parseJSON(localStorage.getItem('article_data')); | |
| 140 | + var _title = ''; | |
| 141 | + var _misc = ''; | |
| 142 | + | |
| 143 | + $.each(article_data.Sheet1, function(index, e) { | |
| 144 | + | |
| 145 | + if (typeof article_data.Sheet1[index].title != 'undefined') { | |
| 146 | + _title = article_data.Sheet1[index].title; | |
| 147 | + _misc = article_data.Sheet1[index].misc; | |
| 148 | + return false; | |
| 149 | + } | |
| 150 | + | |
| 151 | + }); | |
| 152 | + | |
| 153 | + //_misc = /:(.*) 作者/.exec(_misc)[1]; | |
| 154 | + _fill($('#edit-title-0-value'), _title); | |
| 155 | + // _fill($('#edit-origin-0-value'), _misc); | |
| 156 | + | |
| 157 | + | |
| 158 | +})(jQuery); | ... | ... |
Please
register
or
login
to post a comment