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