Commit fcbd393c8989997073cee934e4099e5c631b1848

Authored by muyulingshi
1 parent cfd346ff

rm bug

Showing 1 changed file with 82 additions and 88 deletions
... ... @@ -9,112 +9,106 @@
9 9 // ==/UserScript==
10 10
11 11 (function($) {
12   - 'use strict';
13   -
14   - // Your code here...
15   - var MENU_DATE = {
16   - '0': {
17   - 'title': '首页'
18   - }
19   - },
20   - TAXONOMY_DATE = {
21   - '0': {
22   - 'title': '首页'
23   - }
24   - },
25   - NODE_DATE = {
26   - '0': {
27   - 'title': '首页'
28   - }
29   - },
30   - TAXONOMY_INIT_DATE = {},
31   - NODE_INIT_DATE = {};
32   -
33   - function hasStorage(name, date) {
34   - if (JSON.stringify(date) === '{}') {
35   - return false;
36   - }
  12 + 'use strict';
37 13
38   - if (typeof localStorage.getItem(name) != 'string') {
39   - localStorage.setItem(name, JSON.stringify(date));
  14 + // Your code here...
  15 + var MENU_DATE = {
  16 + '0': {
  17 + 'title': 'menu首页'
  18 + }
  19 + },
  20 + TAXONOMY_DATE = {
  21 + '0': {
  22 + 'title': 'date首页'
40 23 }
  24 + },
  25 + NODE_DATE = {
  26 + '0': {
  27 + 'title': 'node首页'
  28 + }
  29 + },
  30 + TAXONOMY_INIT_DATE = {},
  31 + NODE_INIT_DATE = {};
41 32
42   - return !!localStorage.getItem(name);
  33 + function hasStorage(name, date) {
  34 + if (JSON.stringify(date) === '{}') {
  35 + return false;
43 36 }
44 37
45   - function storageOper(_cookieName, obj) {
46   - var settingObj = {};
  38 + if (typeof localStorage.getItem(name) != 'string') {
  39 + localStorage.setItem(name, JSON.stringify(date));
  40 + }
  41 +
  42 + return !!localStorage.getItem(name);
  43 + }
  44 +
  45 + function storageOper(_cookieName, obj) {
  46 + var settingObj = {};
47 47
48   - $.each(obj, function(index, arr) {
49   - if (obj[index].hasOwnProperty('parent')) {
50   - settingObj.parent = obj[index].parent;
  48 + $.each(obj, function(index, arr) {
  49 + if (obj[index].hasOwnProperty('parent')) {
  50 + settingObj.parent = obj[index].parent;
  51 + }
  52 + settingObj.title = obj[index].title;
  53 + delete obj[index];
  54 + localStorage.setItem(_cookieName, JSON.stringify(obj));
  55 + return false;
  56 + });
  57 +
  58 + if (hasStorage('link_date', TAXONOMY_INIT_DATE)) {
  59 + var link_obj = $.parseJSON(localStorage.getItem('link_date'));
  60 + $.each(link_obj, function(index, arr) {
  61 + if (link_obj[index].taxonomy == settingObj.title) {
  62 + settingObj.url = link_obj[index].url;
  63 + delete link_obj[index];
51 64 }
52   - settingObj.title = obj[index].title;
53   - delete obj[index];
54   - localStorage.setItem(_cookieName, JSON.stringify(obj));
55   - return false;
56 65 });
  66 + }
57 67
58   - if (hasStorage('link_date', TAXONOMY_INIT_DATE)) {
59   - var link_obj = $.parseJSON(localStorage.getItem('link_date'));
60   - $.each(link_obj, function(index, arr) {
61   - if (link_obj[index].taxonomy == settingObj.title) {
62   - settingObj.url = link_obj[index].url;
63   - delete link_obj[index];
64   - }
65   - });
66   - }
  68 + return settingObj;
  69 + }
67 70
68   - return settingObj;
69   - }
  71 + hasStorage('menu_date', MENU_DATE);
  72 + hasStorage('toxonomy_link_date', TAXONOMY_INIT_DATE);
  73 + hasStorage('node_link_date', NODE_INIT_DATE);
70 74
71   - hasStorage('menu_date', MENU_DATE);
72   - hasStorage('toxonomy_link_date', TAXONOMY_INIT_DATE);
73   - hasStorage('node_link_date', NODE_INIT_DATE);
  75 + if ($('[data-drupal-link-system-path="manage/department/add"]').length > 0) {
  76 + $('[data-drupal-link-system-path="manage/department/add"]')[0].click();
  77 + }
74 78
75   - if ($('[data-drupal-link-system-path="manage/department/add"]').length > 0) {
76   - $('[data-drupal-link-system-path="manage/department/add"]')[0].click();
77   - }
  79 + if ($('[data-drupal-link-system-path="admin/structure/menu/manage/main/add"]').length > 0) {
  80 + $('[data-drupal-link-system-path="admin/structure/menu/manage/main/add"]')[0].click();
  81 + }
78 82
79   - if ($('[data-drupal-link-system-path="admin/structure/menu/manage/main/add"]').length > 0) {
80   - $('[data-drupal-link-system-path="admin/structure/menu/manage/main/add"]')[0].click();
81   - }
  83 + if ($('[data-drupal-link-system-path="manage/page/add"]').length > 0) {
  84 + $('[data-drupal-link-system-path="manage/page/add"]')[0].click();
  85 + }
82 86
83   - //栏目
84   - if ($('.taxonomy-term-department-form #edit-name-0-value').length > 0 && hasStorage('taxonomy_date', TAXONOMY_DATE)) {
85   - var settingObj = storageOper('taxonomy_date', $.parseJSON(localStorage.getItem('taxonomy_date')));
86   -
87   - $('#edit-name-0-value').val(settingObj.title);
88   - if (settingObj.hasOwnProperty('parent')) {
89   - $('#edit-parent option').each(function() {
90   - if ($(this).text() == settingObj.parent) {
91   - $('#edit-parent option').attr('selected', false);
92   - $(this).attr('selected', true);
93   - }
94   - });
95   - }
  87 + //栏目
  88 + if ($('.taxonomy-term-department-form #edit-name-0-value').length > 0 && hasStorage('taxonomy_date', TAXONOMY_DATE)) {
  89 + var settingObj = storageOper('taxonomy_date', $.parseJSON(localStorage.getItem('taxonomy_date')));
96 90
97   - $('#edit-submit').trigger('click');
  91 + $('#edit-name-0-value').val(settingObj.title);
  92 + if (settingObj.hasOwnProperty('parent')) {
  93 + $('#edit-parent option').each(function() {
  94 + if ($(this).text() == settingObj.parent) {
  95 + $('#edit-parent option').attr('selected', false);
  96 + $(this).attr('selected', true);
  97 + }
  98 + });
98 99 }
99 100
100   - //基本页
101   - if ($('.node-page-form #edit-name-0-value').length > 0 && hasStorage('node_date', NODE_DATE)) {
102   - var NodesettingObj = storageOper('node_date', $.parseJSON(localStorage.getItem('node_date')));
103   -
104   - $('#edit-name-0-value').val(NodesettingObj.title);
105   - if (NodesettingObj.hasOwnProperty('parent')) {
106   - $('#edit-parent option').each(function() {
107   - if ($(this).text() == NodesettingObj.parent) {
108   - $('#edit-parent option').attr('selected', false);
109   - $(this).attr('selected', true);
110   - }
111   - });
112   - }
  101 + $('#edit-submit').trigger('click');
  102 + }
113 103
114   - $('#edit-submit').trigger('click');
115   - }
116   - //菜单
117   - if ($('#edit-title-0-value').length > 0 && $('#edit-link-0-uri').length > 0 && hasStorage('menu_date', MENU_DATE) && (JSON.stringify(localStorage.getItem('toxonomy_link_date')) !== '{}') || (JSON.stringify(localStorage.getItem('node_link_date')) !== '{}')) {
  104 + //基本页
  105 + if ($('.node-page-form #edit-title-0-value').length > 0 && hasStorage('node_date', NODE_DATE)) {
  106 + var NodesettingObj = storageOper('node_date', $.parseJSON(localStorage.getItem('node_date')));
  107 + $('##edit-title-0-value').val(NodesettingObj.title);
  108 + $('#edit-submit').trigger('click');
  109 + }
  110 + //菜单
  111 + if ($('#edit-title-0-value').length > 0 && $('#edit-link-0-uri').length > 0 && hasStorage('menu_date', MENU_DATE) && ((JSON.stringify(localStorage.getItem('toxonomy_link_date')) !== '{}') || (JSON.stringify(localStorage.getItem('node_link_date')) !== '{}'))) {
118 112 var MenusettingObj = storageOper('menu_date', $.parseJSON(localStorage.getItem('menu_date')));
119 113
120 114 $('#edit-link-0-uri').val('/');
... ...
Please register or login to post a comment