Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hunter-ht.cn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘莹莹
hunter-ht.cn
Commits
9fbad193
Commit
9fbad193
authored
Apr 28, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一上午都没搞完一个
parent
777382f8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
3603 additions
and
69 deletions
+3603
-69
models.py
Hunter_ht/hunter/models.py
+1
-0
bootstrap-datetimepicker.js
Hunter_ht/hunter/static/hunter/bootstrap-datetimepicker.js
+1967
-0
bootstrap-datetimepicker.zh-CN.js
...ht/hunter/static/hunter/bootstrap-datetimepicker.zh-CN.js
+16
-0
delete.png
Hunter_ht/hunter/static/hunter/images/delete.png
+0
-0
jquery.form.js
Hunter_ht/hunter/static/hunter/jquery.form.js
+1531
-0
style.css
Hunter_ht/hunter/static/hunter/style.css
+7
-2
detail.html
Hunter_ht/hunter/templates/hunter/detail.html
+9
-3
user.html
Hunter_ht/hunter/templates/hunter/user.html
+32
-56
views.py
Hunter_ht/hunter/views.py
+40
-8
No files found.
Hunter_ht/hunter/models.py
View file @
9fbad193
...
@@ -43,6 +43,7 @@ class Publications(models.Model):
...
@@ -43,6 +43,7 @@ class Publications(models.Model):
class
PubToUser
(
models
.
Model
):
class
PubToUser
(
models
.
Model
):
pubID
=
models
.
BigIntegerField
()
pubID
=
models
.
BigIntegerField
()
username
=
models
.
CharField
(
max_length
=
50
)
username
=
models
.
CharField
(
max_length
=
50
)
userID
=
models
.
IntegerField
(
default
=
0
)
class
Articles
(
models
.
Model
):
class
Articles
(
models
.
Model
):
...
...
Hunter_ht/hunter/static/hunter/bootstrap-datetimepicker.js
0 → 100644
View file @
9fbad193
/* =========================================================
* bootstrap-datetimepicker.js
* =========================================================
* Copyright 2012 Stefan Petre
*
* Improvements by Andrew Rowls
* Improvements by Sébastien Malot
* Improvements by Yun Lai
* Improvements by Kenneth Henderick
* Improvements by CuGBabyBeaR
* Improvements by Christian Vaas <auspex@auspex.eu>
*
* Project URL : http://www.malot.fr/bootstrap-datetimepicker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
(
function
(
factory
){
if
(
typeof
define
===
'function'
&&
define
.
amd
)
define
([
'jquery'
],
factory
);
else
if
(
typeof
exports
===
'object'
)
factory
(
require
(
'jquery'
));
else
factory
(
jQuery
);
}(
function
(
$
,
undefined
){
// Add ECMA262-5 Array methods if not supported natively (IE8)
if
(
!
(
'indexOf'
in
Array
.
prototype
))
{
Array
.
prototype
.
indexOf
=
function
(
find
,
i
)
{
if
(
i
===
undefined
)
i
=
0
;
if
(
i
<
0
)
i
+=
this
.
length
;
if
(
i
<
0
)
i
=
0
;
for
(
var
n
=
this
.
length
;
i
<
n
;
i
++
)
{
if
(
i
in
this
&&
this
[
i
]
===
find
)
{
return
i
;
}
}
return
-
1
;
}
}
// Add timezone abbreviation support for ie6+, Chrome, Firefox
function
timeZoneAbbreviation
()
{
var
abbreviation
,
date
,
formattedStr
,
i
,
len
,
matchedStrings
,
ref
,
str
;
date
=
(
new
Date
()).
toString
();
formattedStr
=
((
ref
=
date
.
split
(
'('
)[
1
])
!=
null
?
ref
.
slice
(
0
,
-
1
)
:
0
)
||
date
.
split
(
' '
);
if
(
formattedStr
instanceof
Array
)
{
matchedStrings
=
[];
for
(
var
i
=
0
,
len
=
formattedStr
.
length
;
i
<
len
;
i
++
)
{
str
=
formattedStr
[
i
];
if
((
abbreviation
=
(
ref
=
str
.
match
(
/
\b[
A-Z
]
+
\b
/
))
!==
null
)
?
ref
[
0
]
:
0
)
{
matchedStrings
.
push
(
abbreviation
);
}
}
formattedStr
=
matchedStrings
.
pop
();
}
return
formattedStr
;
}
function
UTCDate
()
{
return
new
Date
(
Date
.
UTC
.
apply
(
Date
,
arguments
));
}
// Picker object
var
Datetimepicker
=
function
(
element
,
options
)
{
var
that
=
this
;
this
.
element
=
$
(
element
);
// add container for single page application
// when page switch the datetimepicker div will be removed also.
this
.
container
=
options
.
container
||
'body'
;
this
.
language
=
options
.
language
||
this
.
element
.
data
(
'date-language'
)
||
'en'
;
this
.
language
=
this
.
language
in
dates
?
this
.
language
:
this
.
language
.
split
(
'-'
)[
0
];
// fr-CA fallback to fr
this
.
language
=
this
.
language
in
dates
?
this
.
language
:
'en'
;
this
.
isRTL
=
dates
[
this
.
language
].
rtl
||
false
;
this
.
formatType
=
options
.
formatType
||
this
.
element
.
data
(
'format-type'
)
||
'standard'
;
this
.
format
=
DPGlobal
.
parseFormat
(
options
.
format
||
this
.
element
.
data
(
'date-format'
)
||
dates
[
this
.
language
].
format
||
DPGlobal
.
getDefaultFormat
(
this
.
formatType
,
'input'
),
this
.
formatType
);
this
.
isInline
=
false
;
this
.
isVisible
=
false
;
this
.
isInput
=
this
.
element
.
is
(
'input'
);
this
.
fontAwesome
=
options
.
fontAwesome
||
this
.
element
.
data
(
'font-awesome'
)
||
false
;
this
.
bootcssVer
=
options
.
bootcssVer
||
(
this
.
isInput
?
(
this
.
element
.
is
(
'.form-control'
)
?
3
:
2
)
:
(
this
.
bootcssVer
=
this
.
element
.
is
(
'.input-group'
)
?
3
:
2
));
this
.
component
=
this
.
element
.
is
(
'.date'
)
?
(
this
.
bootcssVer
===
3
?
this
.
element
.
find
(
'.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-remove, .input-group-addon .glyphicon-calendar, .input-group-addon .fa-calendar, .input-group-addon .fa-clock-o'
).
parent
()
:
this
.
element
.
find
(
'.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar, .add-on .fa-calendar, .add-on .fa-clock-o'
).
parent
())
:
false
;
this
.
componentReset
=
this
.
element
.
is
(
'.date'
)
?
(
this
.
bootcssVer
===
3
?
this
.
element
.
find
(
'.input-group-addon .glyphicon-remove, .input-group-addon .fa-times'
).
parent
():
this
.
element
.
find
(
'.add-on .icon-remove, .add-on .fa-times'
).
parent
())
:
false
;
this
.
hasInput
=
this
.
component
&&
this
.
element
.
find
(
'input'
).
length
;
if
(
this
.
component
&&
this
.
component
.
length
===
0
)
{
this
.
component
=
false
;
}
this
.
linkField
=
options
.
linkField
||
this
.
element
.
data
(
'link-field'
)
||
false
;
this
.
linkFormat
=
DPGlobal
.
parseFormat
(
options
.
linkFormat
||
this
.
element
.
data
(
'link-format'
)
||
DPGlobal
.
getDefaultFormat
(
this
.
formatType
,
'link'
),
this
.
formatType
);
this
.
minuteStep
=
options
.
minuteStep
||
this
.
element
.
data
(
'minute-step'
)
||
5
;
this
.
pickerPosition
=
options
.
pickerPosition
||
this
.
element
.
data
(
'picker-position'
)
||
'bottom-right'
;
this
.
showMeridian
=
options
.
showMeridian
||
this
.
element
.
data
(
'show-meridian'
)
||
false
;
this
.
initialDate
=
options
.
initialDate
||
new
Date
();
this
.
zIndex
=
options
.
zIndex
||
this
.
element
.
data
(
'z-index'
)
||
undefined
;
this
.
title
=
typeof
options
.
title
===
'undefined'
?
false
:
options
.
title
;
this
.
timezone
=
options
.
timezone
||
timeZoneAbbreviation
();
this
.
icons
=
{
leftArrow
:
this
.
fontAwesome
?
'fa-arrow-left'
:
(
this
.
bootcssVer
===
3
?
'glyphicon-arrow-left'
:
'icon-arrow-left'
),
rightArrow
:
this
.
fontAwesome
?
'fa-arrow-right'
:
(
this
.
bootcssVer
===
3
?
'glyphicon-arrow-right'
:
'icon-arrow-right'
)
}
this
.
icontype
=
this
.
fontAwesome
?
'fa'
:
'glyphicon'
;
this
.
_attachEvents
();
this
.
clickedOutside
=
function
(
e
)
{
// Clicked outside the datetimepicker, hide it
if
(
$
(
e
.
target
).
closest
(
'.datetimepicker'
).
length
===
0
)
{
that
.
hide
();
}
}
this
.
formatViewType
=
'datetime'
;
if
(
'formatViewType'
in
options
)
{
this
.
formatViewType
=
options
.
formatViewType
;
}
else
if
(
'formatViewType'
in
this
.
element
.
data
())
{
this
.
formatViewType
=
this
.
element
.
data
(
'formatViewType'
);
}
this
.
minView
=
0
;
if
(
'minView'
in
options
)
{
this
.
minView
=
options
.
minView
;
}
else
if
(
'minView'
in
this
.
element
.
data
())
{
this
.
minView
=
this
.
element
.
data
(
'min-view'
);
}
this
.
minView
=
DPGlobal
.
convertViewMode
(
this
.
minView
);
this
.
maxView
=
DPGlobal
.
modes
.
length
-
1
;
if
(
'maxView'
in
options
)
{
this
.
maxView
=
options
.
maxView
;
}
else
if
(
'maxView'
in
this
.
element
.
data
())
{
this
.
maxView
=
this
.
element
.
data
(
'max-view'
);
}
this
.
maxView
=
DPGlobal
.
convertViewMode
(
this
.
maxView
);
this
.
wheelViewModeNavigation
=
false
;
if
(
'wheelViewModeNavigation'
in
options
)
{
this
.
wheelViewModeNavigation
=
options
.
wheelViewModeNavigation
;
}
else
if
(
'wheelViewModeNavigation'
in
this
.
element
.
data
())
{
this
.
wheelViewModeNavigation
=
this
.
element
.
data
(
'view-mode-wheel-navigation'
);
}
this
.
wheelViewModeNavigationInverseDirection
=
false
;
if
(
'wheelViewModeNavigationInverseDirection'
in
options
)
{
this
.
wheelViewModeNavigationInverseDirection
=
options
.
wheelViewModeNavigationInverseDirection
;
}
else
if
(
'wheelViewModeNavigationInverseDirection'
in
this
.
element
.
data
())
{
this
.
wheelViewModeNavigationInverseDirection
=
this
.
element
.
data
(
'view-mode-wheel-navigation-inverse-dir'
);
}
this
.
wheelViewModeNavigationDelay
=
100
;
if
(
'wheelViewModeNavigationDelay'
in
options
)
{
this
.
wheelViewModeNavigationDelay
=
options
.
wheelViewModeNavigationDelay
;
}
else
if
(
'wheelViewModeNavigationDelay'
in
this
.
element
.
data
())
{
this
.
wheelViewModeNavigationDelay
=
this
.
element
.
data
(
'view-mode-wheel-navigation-delay'
);
}
this
.
startViewMode
=
2
;
if
(
'startView'
in
options
)
{
this
.
startViewMode
=
options
.
startView
;
}
else
if
(
'startView'
in
this
.
element
.
data
())
{
this
.
startViewMode
=
this
.
element
.
data
(
'start-view'
);
}
this
.
startViewMode
=
DPGlobal
.
convertViewMode
(
this
.
startViewMode
);
this
.
viewMode
=
this
.
startViewMode
;
this
.
viewSelect
=
this
.
minView
;
if
(
'viewSelect'
in
options
)
{
this
.
viewSelect
=
options
.
viewSelect
;
}
else
if
(
'viewSelect'
in
this
.
element
.
data
())
{
this
.
viewSelect
=
this
.
element
.
data
(
'view-select'
);
}
this
.
viewSelect
=
DPGlobal
.
convertViewMode
(
this
.
viewSelect
);
this
.
forceParse
=
true
;
if
(
'forceParse'
in
options
)
{
this
.
forceParse
=
options
.
forceParse
;
}
else
if
(
'dateForceParse'
in
this
.
element
.
data
())
{
this
.
forceParse
=
this
.
element
.
data
(
'date-force-parse'
);
}
var
template
=
this
.
bootcssVer
===
3
?
DPGlobal
.
templateV3
:
DPGlobal
.
template
;
while
(
template
.
indexOf
(
'{iconType}'
)
!==
-
1
)
{
template
=
template
.
replace
(
'{iconType}'
,
this
.
icontype
);
}
while
(
template
.
indexOf
(
'{leftArrow}'
)
!==
-
1
)
{
template
=
template
.
replace
(
'{leftArrow}'
,
this
.
icons
.
leftArrow
);
}
while
(
template
.
indexOf
(
'{rightArrow}'
)
!==
-
1
)
{
template
=
template
.
replace
(
'{rightArrow}'
,
this
.
icons
.
rightArrow
);
}
this
.
picker
=
$
(
template
)
.
appendTo
(
this
.
isInline
?
this
.
element
:
this
.
container
)
// 'body')
.
on
({
click
:
$
.
proxy
(
this
.
click
,
this
),
mousedown
:
$
.
proxy
(
this
.
mousedown
,
this
)
});
if
(
this
.
wheelViewModeNavigation
)
{
if
(
$
.
fn
.
mousewheel
)
{
this
.
picker
.
on
({
mousewheel
:
$
.
proxy
(
this
.
mousewheel
,
this
)});
}
else
{
console
.
log
(
'Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option'
);
}
}
if
(
this
.
isInline
)
{
this
.
picker
.
addClass
(
'datetimepicker-inline'
);
}
else
{
this
.
picker
.
addClass
(
'datetimepicker-dropdown-'
+
this
.
pickerPosition
+
' dropdown-menu'
);
}
if
(
this
.
isRTL
)
{
this
.
picker
.
addClass
(
'datetimepicker-rtl'
);
var
selector
=
this
.
bootcssVer
===
3
?
'.prev span, .next span'
:
'.prev i, .next i'
;
this
.
picker
.
find
(
selector
).
toggleClass
(
this
.
icons
.
leftArrow
+
' '
+
this
.
icons
.
rightArrow
);
}
$
(
document
).
on
(
'mousedown touchend'
,
this
.
clickedOutside
);
this
.
autoclose
=
false
;
if
(
'autoclose'
in
options
)
{
this
.
autoclose
=
options
.
autoclose
;
}
else
if
(
'dateAutoclose'
in
this
.
element
.
data
())
{
this
.
autoclose
=
this
.
element
.
data
(
'date-autoclose'
);
}
this
.
keyboardNavigation
=
true
;
if
(
'keyboardNavigation'
in
options
)
{
this
.
keyboardNavigation
=
options
.
keyboardNavigation
;
}
else
if
(
'dateKeyboardNavigation'
in
this
.
element
.
data
())
{
this
.
keyboardNavigation
=
this
.
element
.
data
(
'date-keyboard-navigation'
);
}
this
.
todayBtn
=
(
options
.
todayBtn
||
this
.
element
.
data
(
'date-today-btn'
)
||
false
);
this
.
clearBtn
=
(
options
.
clearBtn
||
this
.
element
.
data
(
'date-clear-btn'
)
||
false
);
this
.
todayHighlight
=
(
options
.
todayHighlight
||
this
.
element
.
data
(
'date-today-highlight'
)
||
false
);
this
.
weekStart
=
0
;
if
(
typeof
options
.
weekStart
!==
'undefined'
)
{
this
.
weekStart
=
options
.
weekStart
;
}
else
if
(
typeof
this
.
element
.
data
(
'date-weekstart'
)
!==
'undefined'
)
{
this
.
weekStart
=
this
.
element
.
data
(
'date-weekstart'
);
}
else
if
(
typeof
dates
[
this
.
language
].
weekStart
!==
'undefined'
)
{
this
.
weekStart
=
dates
[
this
.
language
].
weekStart
;
}
this
.
weekStart
=
this
.
weekStart
%
7
;
this
.
weekEnd
=
((
this
.
weekStart
+
6
)
%
7
);
this
.
onRenderDay
=
function
(
date
)
{
var
render
=
(
options
.
onRenderDay
||
function
()
{
return
[];
})(
date
);
if
(
typeof
render
===
'string'
)
{
render
=
[
render
];
}
var
res
=
[
'day'
];
return
res
.
concat
((
render
?
render
:
[]));
};
this
.
onRenderHour
=
function
(
date
)
{
var
render
=
(
options
.
onRenderHour
||
function
()
{
return
[];
})(
date
);
var
res
=
[
'hour'
];
if
(
typeof
render
===
'string'
)
{
render
=
[
render
];
}
return
res
.
concat
((
render
?
render
:
[]));
};
this
.
onRenderMinute
=
function
(
date
)
{
var
render
=
(
options
.
onRenderMinute
||
function
()
{
return
[];
})(
date
);
var
res
=
[
'minute'
];
if
(
typeof
render
===
'string'
)
{
render
=
[
render
];
}
if
(
date
<
this
.
startDate
||
date
>
this
.
endDate
)
{
res
.
push
(
'disabled'
);
}
else
if
(
Math
.
floor
(
this
.
date
.
getUTCMinutes
()
/
this
.
minuteStep
)
===
Math
.
floor
(
date
.
getUTCMinutes
()
/
this
.
minuteStep
))
{
res
.
push
(
'active'
);
}
return
res
.
concat
((
render
?
render
:
[]));
};
this
.
onRenderYear
=
function
(
date
)
{
var
render
=
(
options
.
onRenderYear
||
function
()
{
return
[];
})(
date
);
var
res
=
[
'year'
];
if
(
typeof
render
===
'string'
)
{
render
=
[
render
];
}
if
(
this
.
date
.
getUTCFullYear
()
===
date
.
getUTCFullYear
())
{
res
.
push
(
'active'
);
}
var
currentYear
=
date
.
getUTCFullYear
();
var
endYear
=
this
.
endDate
.
getUTCFullYear
();
if
(
date
<
this
.
startDate
||
currentYear
>
endYear
)
{
res
.
push
(
'disabled'
);
}
return
res
.
concat
((
render
?
render
:
[]));
}
this
.
onRenderMonth
=
function
(
date
)
{
var
render
=
(
options
.
onRenderMonth
||
function
()
{
return
[];
})(
date
);
var
res
=
[
'month'
];
if
(
typeof
render
===
'string'
)
{
render
=
[
render
];
}
return
res
.
concat
((
render
?
render
:
[]));
}
this
.
startDate
=
new
Date
(
-
8639968443048000
);
this
.
endDate
=
new
Date
(
8639968443048000
);
this
.
datesDisabled
=
[];
this
.
daysOfWeekDisabled
=
[];
this
.
setStartDate
(
options
.
startDate
||
this
.
element
.
data
(
'date-startdate'
));
this
.
setEndDate
(
options
.
endDate
||
this
.
element
.
data
(
'date-enddate'
));
this
.
setDatesDisabled
(
options
.
datesDisabled
||
this
.
element
.
data
(
'date-dates-disabled'
));
this
.
setDaysOfWeekDisabled
(
options
.
daysOfWeekDisabled
||
this
.
element
.
data
(
'date-days-of-week-disabled'
));
this
.
setMinutesDisabled
(
options
.
minutesDisabled
||
this
.
element
.
data
(
'date-minute-disabled'
));
this
.
setHoursDisabled
(
options
.
hoursDisabled
||
this
.
element
.
data
(
'date-hour-disabled'
));
this
.
fillDow
();
this
.
fillMonths
();
this
.
update
();
this
.
showMode
();
if
(
this
.
isInline
)
{
this
.
show
();
}
};
Datetimepicker
.
prototype
=
{
constructor
:
Datetimepicker
,
_events
:
[],
_attachEvents
:
function
()
{
this
.
_detachEvents
();
if
(
this
.
isInput
)
{
// single input
this
.
_events
=
[
[
this
.
element
,
{
focus
:
$
.
proxy
(
this
.
show
,
this
),
keyup
:
$
.
proxy
(
this
.
update
,
this
),
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
}]
];
}
else
if
(
this
.
component
&&
this
.
hasInput
)
{
// component: input + button
this
.
_events
=
[
// For components that are not readonly, allow keyboard nav
[
this
.
element
.
find
(
'input'
),
{
focus
:
$
.
proxy
(
this
.
show
,
this
),
keyup
:
$
.
proxy
(
this
.
update
,
this
),
keydown
:
$
.
proxy
(
this
.
keydown
,
this
)
}],
[
this
.
component
,
{
click
:
$
.
proxy
(
this
.
show
,
this
)
}]
];
if
(
this
.
componentReset
)
{
this
.
_events
.
push
([
this
.
componentReset
,
{
click
:
$
.
proxy
(
this
.
reset
,
this
)}
]);
}
}
else
if
(
this
.
element
.
is
(
'div'
))
{
// inline datetimepicker
this
.
isInline
=
true
;
}
else
{
this
.
_events
=
[
[
this
.
element
,
{
click
:
$
.
proxy
(
this
.
show
,
this
)
}]
];
}
for
(
var
i
=
0
,
el
,
ev
;
i
<
this
.
_events
.
length
;
i
++
)
{
el
=
this
.
_events
[
i
][
0
];
ev
=
this
.
_events
[
i
][
1
];
el
.
on
(
ev
);
}
},
_detachEvents
:
function
()
{
for
(
var
i
=
0
,
el
,
ev
;
i
<
this
.
_events
.
length
;
i
++
)
{
el
=
this
.
_events
[
i
][
0
];
ev
=
this
.
_events
[
i
][
1
];
el
.
off
(
ev
);
}
this
.
_events
=
[];
},
show
:
function
(
e
)
{
this
.
picker
.
show
();
this
.
height
=
this
.
component
?
this
.
component
.
outerHeight
()
:
this
.
element
.
outerHeight
();
if
(
this
.
forceParse
)
{
this
.
update
();
}
this
.
place
();
$
(
window
).
on
(
'resize'
,
$
.
proxy
(
this
.
place
,
this
));
if
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
}
this
.
isVisible
=
true
;
this
.
element
.
trigger
({
type
:
'show'
,
date
:
this
.
date
});
},
hide
:
function
()
{
if
(
!
this
.
isVisible
)
return
;
if
(
this
.
isInline
)
return
;
this
.
picker
.
hide
();
$
(
window
).
off
(
'resize'
,
this
.
place
);
this
.
viewMode
=
this
.
startViewMode
;
this
.
showMode
();
if
(
!
this
.
isInput
)
{
$
(
document
).
off
(
'mousedown'
,
this
.
hide
);
}
if
(
this
.
forceParse
&&
(
this
.
isInput
&&
this
.
element
.
val
()
||
this
.
hasInput
&&
this
.
element
.
find
(
'input'
).
val
()
)
)
this
.
setValue
();
this
.
isVisible
=
false
;
this
.
element
.
trigger
({
type
:
'hide'
,
date
:
this
.
date
});
},
remove
:
function
()
{
this
.
_detachEvents
();
$
(
document
).
off
(
'mousedown'
,
this
.
clickedOutside
);
this
.
picker
.
remove
();
delete
this
.
picker
;
delete
this
.
element
.
data
().
datetimepicker
;
},
getDate
:
function
()
{
var
d
=
this
.
getUTCDate
();
if
(
d
===
null
)
{
return
null
;
}
return
new
Date
(
d
.
getTime
()
+
(
d
.
getTimezoneOffset
()
*
60000
));
},
getUTCDate
:
function
()
{
return
this
.
date
;
},
getInitialDate
:
function
()
{
return
this
.
initialDate
},
setInitialDate
:
function
(
initialDate
)
{
this
.
initialDate
=
initialDate
;
},
setDate
:
function
(
d
)
{
this
.
setUTCDate
(
new
Date
(
d
.
getTime
()
-
(
d
.
getTimezoneOffset
()
*
60000
)));
},
setUTCDate
:
function
(
d
)
{
if
(
d
>=
this
.
startDate
&&
d
<=
this
.
endDate
)
{
this
.
date
=
d
;
this
.
setValue
();
this
.
viewDate
=
this
.
date
;
this
.
fill
();
}
else
{
this
.
element
.
trigger
({
type
:
'outOfRange'
,
date
:
d
,
startDate
:
this
.
startDate
,
endDate
:
this
.
endDate
});
}
},
setFormat
:
function
(
format
)
{
this
.
format
=
DPGlobal
.
parseFormat
(
format
,
this
.
formatType
);
var
element
;
if
(
this
.
isInput
)
{
element
=
this
.
element
;
}
else
if
(
this
.
component
)
{
element
=
this
.
element
.
find
(
'input'
);
}
if
(
element
&&
element
.
val
())
{
this
.
setValue
();
}
},
setValue
:
function
()
{
var
formatted
=
this
.
getFormattedDate
();
if
(
!
this
.
isInput
)
{
if
(
this
.
component
)
{
this
.
element
.
find
(
'input'
).
val
(
formatted
);
}
this
.
element
.
data
(
'date'
,
formatted
);
}
else
{
this
.
element
.
val
(
formatted
);
}
if
(
this
.
linkField
)
{
$
(
'#'
+
this
.
linkField
).
val
(
this
.
getFormattedDate
(
this
.
linkFormat
));
}
},
getFormattedDate
:
function
(
format
)
{
format
=
format
||
this
.
format
;
return
DPGlobal
.
formatDate
(
this
.
date
,
format
,
this
.
language
,
this
.
formatType
,
this
.
timezone
);
},
setStartDate
:
function
(
startDate
)
{
this
.
startDate
=
startDate
||
this
.
startDate
;
if
(
this
.
startDate
.
valueOf
()
!==
8639968443048000
)
{
this
.
startDate
=
DPGlobal
.
parseDate
(
this
.
startDate
,
this
.
format
,
this
.
language
,
this
.
formatType
,
this
.
timezone
);
}
this
.
update
();
this
.
updateNavArrows
();
},
setEndDate
:
function
(
endDate
)
{
this
.
endDate
=
endDate
||
this
.
endDate
;
if
(
this
.
endDate
.
valueOf
()
!==
8639968443048000
)
{
this
.
endDate
=
DPGlobal
.
parseDate
(
this
.
endDate
,
this
.
format
,
this
.
language
,
this
.
formatType
,
this
.
timezone
);
}
this
.
update
();
this
.
updateNavArrows
();
},
setDatesDisabled
:
function
(
datesDisabled
)
{
this
.
datesDisabled
=
datesDisabled
||
[];
if
(
!
$
.
isArray
(
this
.
datesDisabled
))
{
this
.
datesDisabled
=
this
.
datesDisabled
.
split
(
/,
\s
*/
);
}
var
mThis
=
this
;
this
.
datesDisabled
=
$
.
map
(
this
.
datesDisabled
,
function
(
d
)
{
return
DPGlobal
.
parseDate
(
d
,
mThis
.
format
,
mThis
.
language
,
mThis
.
formatType
,
mThis
.
timezone
).
toDateString
();
});
this
.
update
();
this
.
updateNavArrows
();
},
setTitle
:
function
(
selector
,
value
)
{
return
this
.
picker
.
find
(
selector
)
.
find
(
'th:eq(1)'
)
.
text
(
this
.
title
===
false
?
value
:
this
.
title
);
},
setDaysOfWeekDisabled
:
function
(
daysOfWeekDisabled
)
{
this
.
daysOfWeekDisabled
=
daysOfWeekDisabled
||
[];
if
(
!
$
.
isArray
(
this
.
daysOfWeekDisabled
))
{
this
.
daysOfWeekDisabled
=
this
.
daysOfWeekDisabled
.
split
(
/,
\s
*/
);
}
this
.
daysOfWeekDisabled
=
$
.
map
(
this
.
daysOfWeekDisabled
,
function
(
d
)
{
return
parseInt
(
d
,
10
);
});
this
.
update
();
this
.
updateNavArrows
();
},
setMinutesDisabled
:
function
(
minutesDisabled
)
{
this
.
minutesDisabled
=
minutesDisabled
||
[];
if
(
!
$
.
isArray
(
this
.
minutesDisabled
))
{
this
.
minutesDisabled
=
this
.
minutesDisabled
.
split
(
/,
\s
*/
);
}
this
.
minutesDisabled
=
$
.
map
(
this
.
minutesDisabled
,
function
(
d
)
{
return
parseInt
(
d
,
10
);
});
this
.
update
();
this
.
updateNavArrows
();
},
setHoursDisabled
:
function
(
hoursDisabled
)
{
this
.
hoursDisabled
=
hoursDisabled
||
[];
if
(
!
$
.
isArray
(
this
.
hoursDisabled
))
{
this
.
hoursDisabled
=
this
.
hoursDisabled
.
split
(
/,
\s
*/
);
}
this
.
hoursDisabled
=
$
.
map
(
this
.
hoursDisabled
,
function
(
d
)
{
return
parseInt
(
d
,
10
);
});
this
.
update
();
this
.
updateNavArrows
();
},
place
:
function
()
{
if
(
this
.
isInline
)
return
;
if
(
!
this
.
zIndex
)
{
var
index_highest
=
0
;
$
(
'div'
).
each
(
function
()
{
var
index_current
=
parseInt
(
$
(
this
).
css
(
'zIndex'
),
10
);
if
(
index_current
>
index_highest
)
{
index_highest
=
index_current
;
}
});
this
.
zIndex
=
index_highest
+
10
;
}
var
offset
,
top
,
left
,
containerOffset
;
if
(
this
.
container
instanceof
$
)
{
containerOffset
=
this
.
container
.
offset
();
}
else
{
containerOffset
=
$
(
this
.
container
).
offset
();
}
if
(
this
.
component
)
{
offset
=
this
.
component
.
offset
();
left
=
offset
.
left
;
if
(
this
.
pickerPosition
===
'bottom-left'
||
this
.
pickerPosition
===
'top-left'
)
{
left
+=
this
.
component
.
outerWidth
()
-
this
.
picker
.
outerWidth
();
}
}
else
{
offset
=
this
.
element
.
offset
();
left
=
offset
.
left
;
if
(
this
.
pickerPosition
===
'bottom-left'
||
this
.
pickerPosition
===
'top-left'
)
{
left
+=
this
.
element
.
outerWidth
()
-
this
.
picker
.
outerWidth
();
}
}
var
bodyWidth
=
document
.
body
.
clientWidth
||
window
.
innerWidth
;
if
(
left
+
220
>
bodyWidth
)
{
left
=
bodyWidth
-
220
;
}
if
(
this
.
pickerPosition
===
'top-left'
||
this
.
pickerPosition
===
'top-right'
)
{
top
=
offset
.
top
-
this
.
picker
.
outerHeight
();
}
else
{
top
=
offset
.
top
+
this
.
height
;
}
top
=
top
-
containerOffset
.
top
;
left
=
left
-
containerOffset
.
left
;
this
.
picker
.
css
({
top
:
top
,
left
:
left
,
zIndex
:
this
.
zIndex
});
},
hour_minute
:
"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]"
,
update
:
function
()
{
var
date
,
fromArgs
=
false
;
if
(
arguments
&&
arguments
.
length
&&
(
typeof
arguments
[
0
]
===
'string'
||
arguments
[
0
]
instanceof
Date
))
{
date
=
arguments
[
0
];
fromArgs
=
true
;
}
else
{
date
=
(
this
.
isInput
?
this
.
element
.
val
()
:
this
.
element
.
find
(
'input'
).
val
())
||
this
.
element
.
data
(
'date'
)
||
this
.
initialDate
;
if
(
typeof
date
===
'string'
)
{
date
=
date
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
}
}
if
(
!
date
)
{
date
=
new
Date
();
fromArgs
=
false
;
}
if
(
typeof
date
===
"string"
)
{
if
(
new
RegExp
(
this
.
hour_minute
).
test
(
date
)
||
new
RegExp
(
this
.
hour_minute
+
":[0-5][0-9]"
).
test
(
date
))
{
date
=
this
.
getDate
()
}
}
this
.
date
=
DPGlobal
.
parseDate
(
date
,
this
.
format
,
this
.
language
,
this
.
formatType
,
this
.
timezone
);
if
(
fromArgs
)
this
.
setValue
();
if
(
this
.
date
<
this
.
startDate
)
{
this
.
viewDate
=
new
Date
(
this
.
startDate
);
}
else
if
(
this
.
date
>
this
.
endDate
)
{
this
.
viewDate
=
new
Date
(
this
.
endDate
);
}
else
{
this
.
viewDate
=
new
Date
(
this
.
date
);
}
this
.
fill
();
},
fillDow
:
function
()
{
var
dowCnt
=
this
.
weekStart
,
html
=
'<tr>'
;
while
(
dowCnt
<
this
.
weekStart
+
7
)
{
html
+=
'<th class="dow">'
+
dates
[
this
.
language
].
daysMin
[(
dowCnt
++
)
%
7
]
+
'</th>'
;
}
html
+=
'</tr>'
;
this
.
picker
.
find
(
'.datetimepicker-days thead'
).
append
(
html
);
},
fillMonths
:
function
()
{
var
html
=
''
;
var
d
=
new
Date
(
this
.
viewDate
);
for
(
var
i
=
0
;
i
<
12
;
i
++
)
{
d
.
setUTCMonth
(
i
);
var
classes
=
this
.
onRenderMonth
(
d
);
html
+=
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
dates
[
this
.
language
].
monthsShort
[
i
]
+
'</span>'
;
}
this
.
picker
.
find
(
'.datetimepicker-months td'
).
html
(
html
);
},
fill
:
function
()
{
if
(
!
this
.
date
||
!
this
.
viewDate
)
{
return
;
}
var
d
=
new
Date
(
this
.
viewDate
),
year
=
d
.
getUTCFullYear
(),
month
=
d
.
getUTCMonth
(),
dayMonth
=
d
.
getUTCDate
(),
hours
=
d
.
getUTCHours
(),
startYear
=
this
.
startDate
.
getUTCFullYear
(),
startMonth
=
this
.
startDate
.
getUTCMonth
(),
endYear
=
this
.
endDate
.
getUTCFullYear
(),
endMonth
=
this
.
endDate
.
getUTCMonth
()
+
1
,
currentDate
=
(
new
UTCDate
(
this
.
date
.
getUTCFullYear
(),
this
.
date
.
getUTCMonth
(),
this
.
date
.
getUTCDate
())).
valueOf
(),
today
=
new
Date
();
this
.
setTitle
(
'.datetimepicker-days'
,
dates
[
this
.
language
].
months
[
month
]
+
' '
+
year
)
if
(
this
.
formatViewType
===
'time'
)
{
var
formatted
=
this
.
getFormattedDate
();
this
.
setTitle
(
'.datetimepicker-hours'
,
formatted
);
this
.
setTitle
(
'.datetimepicker-minutes'
,
formatted
);
}
else
{
this
.
setTitle
(
'.datetimepicker-hours'
,
dayMonth
+
' '
+
dates
[
this
.
language
].
months
[
month
]
+
' '
+
year
);
this
.
setTitle
(
'.datetimepicker-minutes'
,
dayMonth
+
' '
+
dates
[
this
.
language
].
months
[
month
]
+
' '
+
year
);
}
this
.
picker
.
find
(
'tfoot th.today'
)
.
text
(
dates
[
this
.
language
].
today
||
dates
[
'en'
].
today
)
.
toggle
(
this
.
todayBtn
!==
false
);
this
.
picker
.
find
(
'tfoot th.clear'
)
.
text
(
dates
[
this
.
language
].
clear
||
dates
[
'en'
].
clear
)
.
toggle
(
this
.
clearBtn
!==
false
);
this
.
updateNavArrows
();
this
.
fillMonths
();
var
prevMonth
=
UTCDate
(
year
,
month
-
1
,
28
,
0
,
0
,
0
,
0
),
day
=
DPGlobal
.
getDaysInMonth
(
prevMonth
.
getUTCFullYear
(),
prevMonth
.
getUTCMonth
());
prevMonth
.
setUTCDate
(
day
);
prevMonth
.
setUTCDate
(
day
-
(
prevMonth
.
getUTCDay
()
-
this
.
weekStart
+
7
)
%
7
);
var
nextMonth
=
new
Date
(
prevMonth
);
nextMonth
.
setUTCDate
(
nextMonth
.
getUTCDate
()
+
42
);
nextMonth
=
nextMonth
.
valueOf
();
var
html
=
[];
var
classes
;
while
(
prevMonth
.
valueOf
()
<
nextMonth
)
{
if
(
prevMonth
.
getUTCDay
()
===
this
.
weekStart
)
{
html
.
push
(
'<tr>'
);
}
classes
=
this
.
onRenderDay
(
prevMonth
);
if
(
prevMonth
.
getUTCFullYear
()
<
year
||
(
prevMonth
.
getUTCFullYear
()
===
year
&&
prevMonth
.
getUTCMonth
()
<
month
))
{
classes
.
push
(
'old'
);
}
else
if
(
prevMonth
.
getUTCFullYear
()
>
year
||
(
prevMonth
.
getUTCFullYear
()
===
year
&&
prevMonth
.
getUTCMonth
()
>
month
))
{
classes
.
push
(
'new'
);
}
// Compare internal UTC date with local today, not UTC today
if
(
this
.
todayHighlight
&&
prevMonth
.
getUTCFullYear
()
===
today
.
getFullYear
()
&&
prevMonth
.
getUTCMonth
()
===
today
.
getMonth
()
&&
prevMonth
.
getUTCDate
()
===
today
.
getDate
())
{
classes
.
push
(
'today'
);
}
if
(
prevMonth
.
valueOf
()
===
currentDate
)
{
classes
.
push
(
'active'
);
}
if
((
prevMonth
.
valueOf
()
+
86400000
)
<=
this
.
startDate
||
prevMonth
.
valueOf
()
>
this
.
endDate
||
$
.
inArray
(
prevMonth
.
getUTCDay
(),
this
.
daysOfWeekDisabled
)
!==
-
1
||
$
.
inArray
(
prevMonth
.
toDateString
(),
this
.
datesDisabled
)
!==
-
1
)
{
classes
.
push
(
'disabled'
);
}
html
.
push
(
'<td class="'
+
classes
.
join
(
' '
)
+
'">'
+
prevMonth
.
getUTCDate
()
+
'</td>'
);
if
(
prevMonth
.
getUTCDay
()
===
this
.
weekEnd
)
{
html
.
push
(
'</tr>'
);
}
prevMonth
.
setUTCDate
(
prevMonth
.
getUTCDate
()
+
1
);
}
this
.
picker
.
find
(
'.datetimepicker-days tbody'
).
empty
().
append
(
html
.
join
(
''
));
html
=
[];
var
txt
=
''
,
meridian
=
''
,
meridianOld
=
''
;
var
hoursDisabled
=
this
.
hoursDisabled
||
[];
d
=
new
Date
(
this
.
viewDate
)
for
(
var
i
=
0
;
i
<
24
;
i
++
)
{
d
.
setUTCHours
(
i
);
classes
=
this
.
onRenderHour
(
d
);
if
(
hoursDisabled
.
indexOf
(
i
)
!==
-
1
)
{
classes
.
push
(
'disabled'
);
}
var
actual
=
UTCDate
(
year
,
month
,
dayMonth
,
i
);
// We want the previous hour for the startDate
if
((
actual
.
valueOf
()
+
3600000
)
<=
this
.
startDate
||
actual
.
valueOf
()
>
this
.
endDate
)
{
classes
.
push
(
'disabled'
);
}
else
if
(
hours
===
i
)
{
classes
.
push
(
'active'
);
}
if
(
this
.
showMeridian
&&
dates
[
this
.
language
].
meridiem
.
length
===
2
)
{
meridian
=
(
i
<
12
?
dates
[
this
.
language
].
meridiem
[
0
]
:
dates
[
this
.
language
].
meridiem
[
1
]);
if
(
meridian
!==
meridianOld
)
{
if
(
meridianOld
!==
''
)
{
html
.
push
(
'</fieldset>'
);
}
html
.
push
(
'<fieldset class="hour"><legend>'
+
meridian
.
toUpperCase
()
+
'</legend>'
);
}
meridianOld
=
meridian
;
txt
=
(
i
%
12
?
i
%
12
:
12
);
if
(
i
<
12
)
{
classes
.
push
(
'hour_am'
);
}
else
{
classes
.
push
(
'hour_pm'
);
}
html
.
push
(
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
txt
+
'</span>'
);
if
(
i
===
23
)
{
html
.
push
(
'</fieldset>'
);
}
}
else
{
txt
=
i
+
':00'
;
html
.
push
(
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
txt
+
'</span>'
);
}
}
this
.
picker
.
find
(
'.datetimepicker-hours td'
).
html
(
html
.
join
(
''
));
html
=
[];
txt
=
''
;
meridian
=
''
;
meridianOld
=
''
;
var
minutesDisabled
=
this
.
minutesDisabled
||
[];
d
=
new
Date
(
this
.
viewDate
);
for
(
var
i
=
0
;
i
<
60
;
i
+=
this
.
minuteStep
)
{
if
(
minutesDisabled
.
indexOf
(
i
)
!==
-
1
)
continue
;
d
.
setUTCMinutes
(
i
);
d
.
setUTCSeconds
(
0
);
classes
=
this
.
onRenderMinute
(
d
);
if
(
this
.
showMeridian
&&
dates
[
this
.
language
].
meridiem
.
length
===
2
)
{
meridian
=
(
hours
<
12
?
dates
[
this
.
language
].
meridiem
[
0
]
:
dates
[
this
.
language
].
meridiem
[
1
]);
if
(
meridian
!==
meridianOld
)
{
if
(
meridianOld
!==
''
)
{
html
.
push
(
'</fieldset>'
);
}
html
.
push
(
'<fieldset class="minute"><legend>'
+
meridian
.
toUpperCase
()
+
'</legend>'
);
}
meridianOld
=
meridian
;
txt
=
(
hours
%
12
?
hours
%
12
:
12
);
html
.
push
(
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
txt
+
':'
+
(
i
<
10
?
'0'
+
i
:
i
)
+
'</span>'
);
if
(
i
===
59
)
{
html
.
push
(
'</fieldset>'
);
}
}
else
{
txt
=
i
+
':00'
;
html
.
push
(
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
hours
+
':'
+
(
i
<
10
?
'0'
+
i
:
i
)
+
'</span>'
);
}
}
this
.
picker
.
find
(
'.datetimepicker-minutes td'
).
html
(
html
.
join
(
''
));
var
currentYear
=
this
.
date
.
getUTCFullYear
();
var
months
=
this
.
setTitle
(
'.datetimepicker-months'
,
year
)
.
end
()
.
find
(
'.month'
).
removeClass
(
'active'
);
if
(
currentYear
===
year
)
{
// getUTCMonths() returns 0 based, and we need to select the next one
// To cater bootstrap 2 we don't need to select the next one
months
.
eq
(
this
.
date
.
getUTCMonth
()).
addClass
(
'active'
);
}
if
(
year
<
startYear
||
year
>
endYear
)
{
months
.
addClass
(
'disabled'
);
}
if
(
year
===
startYear
)
{
months
.
slice
(
0
,
startMonth
).
addClass
(
'disabled'
);
}
if
(
year
===
endYear
)
{
months
.
slice
(
endMonth
).
addClass
(
'disabled'
);
}
html
=
''
;
year
=
parseInt
(
year
/
10
,
10
)
*
10
;
var
yearCont
=
this
.
setTitle
(
'.datetimepicker-years'
,
year
+
'-'
+
(
year
+
9
))
.
end
()
.
find
(
'td'
);
year
-=
1
;
d
=
new
Date
(
this
.
viewDate
);
for
(
var
i
=
-
1
;
i
<
11
;
i
++
)
{
d
.
setUTCFullYear
(
year
);
classes
=
this
.
onRenderYear
(
d
);
if
(
i
===
-
1
||
i
===
10
)
{
classes
.
push
(
old
);
}
html
+=
'<span class="'
+
classes
.
join
(
' '
)
+
'">'
+
year
+
'</span>'
;
year
+=
1
;
}
yearCont
.
html
(
html
);
this
.
place
();
},
updateNavArrows
:
function
()
{
var
d
=
new
Date
(
this
.
viewDate
),
year
=
d
.
getUTCFullYear
(),
month
=
d
.
getUTCMonth
(),
day
=
d
.
getUTCDate
(),
hour
=
d
.
getUTCHours
();
switch
(
this
.
viewMode
)
{
case
0
:
if
(
year
<=
this
.
startDate
.
getUTCFullYear
()
&&
month
<=
this
.
startDate
.
getUTCMonth
()
&&
day
<=
this
.
startDate
.
getUTCDate
()
&&
hour
<=
this
.
startDate
.
getUTCHours
())
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'visible'
});
}
if
(
year
>=
this
.
endDate
.
getUTCFullYear
()
&&
month
>=
this
.
endDate
.
getUTCMonth
()
&&
day
>=
this
.
endDate
.
getUTCDate
()
&&
hour
>=
this
.
endDate
.
getUTCHours
())
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'visible'
});
}
break
;
case
1
:
if
(
year
<=
this
.
startDate
.
getUTCFullYear
()
&&
month
<=
this
.
startDate
.
getUTCMonth
()
&&
day
<=
this
.
startDate
.
getUTCDate
())
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'visible'
});
}
if
(
year
>=
this
.
endDate
.
getUTCFullYear
()
&&
month
>=
this
.
endDate
.
getUTCMonth
()
&&
day
>=
this
.
endDate
.
getUTCDate
())
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'visible'
});
}
break
;
case
2
:
if
(
year
<=
this
.
startDate
.
getUTCFullYear
()
&&
month
<=
this
.
startDate
.
getUTCMonth
())
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'visible'
});
}
if
(
year
>=
this
.
endDate
.
getUTCFullYear
()
&&
month
>=
this
.
endDate
.
getUTCMonth
())
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'visible'
});
}
break
;
case
3
:
case
4
:
if
(
year
<=
this
.
startDate
.
getUTCFullYear
())
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.prev'
).
css
({
visibility
:
'visible'
});
}
if
(
year
>=
this
.
endDate
.
getUTCFullYear
())
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'hidden'
});
}
else
{
this
.
picker
.
find
(
'.next'
).
css
({
visibility
:
'visible'
});
}
break
;
}
},
mousewheel
:
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
if
(
this
.
wheelPause
)
{
return
;
}
this
.
wheelPause
=
true
;
var
originalEvent
=
e
.
originalEvent
;
var
delta
=
originalEvent
.
wheelDelta
;
var
mode
=
delta
>
0
?
1
:
(
delta
===
0
)
?
0
:
-
1
;
if
(
this
.
wheelViewModeNavigationInverseDirection
)
{
mode
=
-
mode
;
}
this
.
showMode
(
mode
);
setTimeout
(
$
.
proxy
(
function
()
{
this
.
wheelPause
=
false
},
this
),
this
.
wheelViewModeNavigationDelay
);
},
click
:
function
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
var
target
=
$
(
e
.
target
).
closest
(
'span, td, th, legend'
);
if
(
target
.
is
(
'.'
+
this
.
icontype
))
{
target
=
$
(
target
).
parent
().
closest
(
'span, td, th, legend'
);
}
if
(
target
.
length
===
1
)
{
if
(
target
.
is
(
'.disabled'
))
{
this
.
element
.
trigger
({
type
:
'outOfRange'
,
date
:
this
.
viewDate
,
startDate
:
this
.
startDate
,
endDate
:
this
.
endDate
});
return
;
}
switch
(
target
[
0
].
nodeName
.
toLowerCase
())
{
case
'th'
:
switch
(
target
[
0
].
className
)
{
case
'switch'
:
this
.
showMode
(
1
);
break
;
case
'prev'
:
case
'next'
:
var
dir
=
DPGlobal
.
modes
[
this
.
viewMode
].
navStep
*
(
target
[
0
].
className
===
'prev'
?
-
1
:
1
);
switch
(
this
.
viewMode
)
{
case
0
:
this
.
viewDate
=
this
.
moveHour
(
this
.
viewDate
,
dir
);
break
;
case
1
:
this
.
viewDate
=
this
.
moveDate
(
this
.
viewDate
,
dir
);
break
;
case
2
:
this
.
viewDate
=
this
.
moveMonth
(
this
.
viewDate
,
dir
);
break
;
case
3
:
case
4
:
this
.
viewDate
=
this
.
moveYear
(
this
.
viewDate
,
dir
);
break
;
}
this
.
fill
();
this
.
element
.
trigger
({
type
:
target
[
0
].
className
+
':'
+
this
.
convertViewModeText
(
this
.
viewMode
),
date
:
this
.
viewDate
,
startDate
:
this
.
startDate
,
endDate
:
this
.
endDate
});
break
;
case
'clear'
:
this
.
reset
();
if
(
this
.
autoclose
)
{
this
.
hide
();
}
break
;
case
'today'
:
var
date
=
new
Date
();
date
=
UTCDate
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
date
.
getHours
(),
date
.
getMinutes
(),
date
.
getSeconds
(),
0
);
// Respect startDate and endDate.
if
(
date
<
this
.
startDate
)
date
=
this
.
startDate
;
else
if
(
date
>
this
.
endDate
)
date
=
this
.
endDate
;
this
.
viewMode
=
this
.
startViewMode
;
this
.
showMode
(
0
);
this
.
_setDate
(
date
);
this
.
fill
();
if
(
this
.
autoclose
)
{
this
.
hide
();
}
break
;
}
break
;
case
'span'
:
if
(
!
target
.
is
(
'.disabled'
))
{
var
year
=
this
.
viewDate
.
getUTCFullYear
(),
month
=
this
.
viewDate
.
getUTCMonth
(),
day
=
this
.
viewDate
.
getUTCDate
(),
hours
=
this
.
viewDate
.
getUTCHours
(),
minutes
=
this
.
viewDate
.
getUTCMinutes
(),
seconds
=
this
.
viewDate
.
getUTCSeconds
();
if
(
target
.
is
(
'.month'
))
{
this
.
viewDate
.
setUTCDate
(
1
);
month
=
target
.
parent
().
find
(
'span'
).
index
(
target
);
day
=
this
.
viewDate
.
getUTCDate
();
this
.
viewDate
.
setUTCMonth
(
month
);
this
.
element
.
trigger
({
type
:
'changeMonth'
,
date
:
this
.
viewDate
});
if
(
this
.
viewSelect
>=
3
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
0
));
}
}
else
if
(
target
.
is
(
'.year'
))
{
this
.
viewDate
.
setUTCDate
(
1
);
year
=
parseInt
(
target
.
text
(),
10
)
||
0
;
this
.
viewDate
.
setUTCFullYear
(
year
);
this
.
element
.
trigger
({
type
:
'changeYear'
,
date
:
this
.
viewDate
});
if
(
this
.
viewSelect
>=
4
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
0
));
}
}
else
if
(
target
.
is
(
'.hour'
))
{
hours
=
parseInt
(
target
.
text
(),
10
)
||
0
;
if
(
target
.
hasClass
(
'hour_am'
)
||
target
.
hasClass
(
'hour_pm'
))
{
if
(
hours
===
12
&&
target
.
hasClass
(
'hour_am'
))
{
hours
=
0
;
}
else
if
(
hours
!==
12
&&
target
.
hasClass
(
'hour_pm'
))
{
hours
+=
12
;
}
}
this
.
viewDate
.
setUTCHours
(
hours
);
this
.
element
.
trigger
({
type
:
'changeHour'
,
date
:
this
.
viewDate
});
if
(
this
.
viewSelect
>=
1
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
0
));
}
}
else
if
(
target
.
is
(
'.minute'
))
{
minutes
=
parseInt
(
target
.
text
().
substr
(
target
.
text
().
indexOf
(
':'
)
+
1
),
10
)
||
0
;
this
.
viewDate
.
setUTCMinutes
(
minutes
);
this
.
element
.
trigger
({
type
:
'changeMinute'
,
date
:
this
.
viewDate
});
if
(
this
.
viewSelect
>=
0
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
0
));
}
}
if
(
this
.
viewMode
!==
0
)
{
var
oldViewMode
=
this
.
viewMode
;
this
.
showMode
(
-
1
);
this
.
fill
();
if
(
oldViewMode
===
this
.
viewMode
&&
this
.
autoclose
)
{
this
.
hide
();
}
}
else
{
this
.
fill
();
if
(
this
.
autoclose
)
{
this
.
hide
();
}
}
}
break
;
case
'td'
:
if
(
target
.
is
(
'.day'
)
&&
!
target
.
is
(
'.disabled'
))
{
var
day
=
parseInt
(
target
.
text
(),
10
)
||
1
;
var
year
=
this
.
viewDate
.
getUTCFullYear
(),
month
=
this
.
viewDate
.
getUTCMonth
(),
hours
=
this
.
viewDate
.
getUTCHours
(),
minutes
=
this
.
viewDate
.
getUTCMinutes
(),
seconds
=
this
.
viewDate
.
getUTCSeconds
();
if
(
target
.
is
(
'.old'
))
{
if
(
month
===
0
)
{
month
=
11
;
year
-=
1
;
}
else
{
month
-=
1
;
}
}
else
if
(
target
.
is
(
'.new'
))
{
if
(
month
===
11
)
{
month
=
0
;
year
+=
1
;
}
else
{
month
+=
1
;
}
}
this
.
viewDate
.
setUTCFullYear
(
year
);
this
.
viewDate
.
setUTCMonth
(
month
,
day
);
this
.
element
.
trigger
({
type
:
'changeDay'
,
date
:
this
.
viewDate
});
if
(
this
.
viewSelect
>=
2
)
{
this
.
_setDate
(
UTCDate
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
0
));
}
}
var
oldViewMode
=
this
.
viewMode
;
this
.
showMode
(
-
1
);
this
.
fill
();
if
(
oldViewMode
===
this
.
viewMode
&&
this
.
autoclose
)
{
this
.
hide
();
}
break
;
}
}
},
_setDate
:
function
(
date
,
which
)
{
if
(
!
which
||
which
===
'date'
)
this
.
date
=
date
;
if
(
!
which
||
which
===
'view'
)
this
.
viewDate
=
date
;
this
.
fill
();
this
.
setValue
();
var
element
;
if
(
this
.
isInput
)
{
element
=
this
.
element
;
}
else
if
(
this
.
component
)
{
element
=
this
.
element
.
find
(
'input'
);
}
if
(
element
)
{
element
.
change
();
}
this
.
element
.
trigger
({
type
:
'changeDate'
,
date
:
this
.
getDate
()
});
if
(
date
===
null
)
this
.
date
=
this
.
viewDate
;
},
moveMinute
:
function
(
date
,
dir
)
{
if
(
!
dir
)
return
date
;
var
new_date
=
new
Date
(
date
.
valueOf
());
//dir = dir > 0 ? 1 : -1;
new_date
.
setUTCMinutes
(
new_date
.
getUTCMinutes
()
+
(
dir
*
this
.
minuteStep
));
return
new_date
;
},
moveHour
:
function
(
date
,
dir
)
{
if
(
!
dir
)
return
date
;
var
new_date
=
new
Date
(
date
.
valueOf
());
//dir = dir > 0 ? 1 : -1;
new_date
.
setUTCHours
(
new_date
.
getUTCHours
()
+
dir
);
return
new_date
;
},
moveDate
:
function
(
date
,
dir
)
{
if
(
!
dir
)
return
date
;
var
new_date
=
new
Date
(
date
.
valueOf
());
//dir = dir > 0 ? 1 : -1;
new_date
.
setUTCDate
(
new_date
.
getUTCDate
()
+
dir
);
return
new_date
;
},
moveMonth
:
function
(
date
,
dir
)
{
if
(
!
dir
)
return
date
;
var
new_date
=
new
Date
(
date
.
valueOf
()),
day
=
new_date
.
getUTCDate
(),
month
=
new_date
.
getUTCMonth
(),
mag
=
Math
.
abs
(
dir
),
new_month
,
test
;
dir
=
dir
>
0
?
1
:
-
1
;
if
(
mag
===
1
)
{
test
=
dir
===
-
1
// If going back one month, make sure month is not current month
// (eg, Mar 31 -> Feb 31 === Feb 28, not Mar 02)
?
function
()
{
return
new_date
.
getUTCMonth
()
===
month
;
}
// If going forward one month, make sure month is as expected
// (eg, Jan 31 -> Feb 31 === Feb 28, not Mar 02)
:
function
()
{
return
new_date
.
getUTCMonth
()
!==
new_month
;
};
new_month
=
month
+
dir
;
new_date
.
setUTCMonth
(
new_month
);
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
if
(
new_month
<
0
||
new_month
>
11
)
new_month
=
(
new_month
+
12
)
%
12
;
}
else
{
// For magnitudes >1, move one month at a time...
for
(
var
i
=
0
;
i
<
mag
;
i
++
)
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
new_date
=
this
.
moveMonth
(
new_date
,
dir
);
// ...then reset the day, keeping it in the new month
new_month
=
new_date
.
getUTCMonth
();
new_date
.
setUTCDate
(
day
);
test
=
function
()
{
return
new_month
!==
new_date
.
getUTCMonth
();
};
}
// Common date-resetting loop -- if date is beyond end of month, make it
// end of month
while
(
test
())
{
new_date
.
setUTCDate
(
--
day
);
new_date
.
setUTCMonth
(
new_month
);
}
return
new_date
;
},
moveYear
:
function
(
date
,
dir
)
{
return
this
.
moveMonth
(
date
,
dir
*
12
);
},
dateWithinRange
:
function
(
date
)
{
return
date
>=
this
.
startDate
&&
date
<=
this
.
endDate
;
},
keydown
:
function
(
e
)
{
if
(
this
.
picker
.
is
(
':not(:visible)'
))
{
if
(
e
.
keyCode
===
27
)
// allow escape to hide and re-show picker
this
.
show
();
return
;
}
var
dateChanged
=
false
,
dir
,
newDate
,
newViewDate
;
switch
(
e
.
keyCode
)
{
case
27
:
// escape
this
.
hide
();
e
.
preventDefault
();
break
;
case
37
:
// left
case
39
:
// right
if
(
!
this
.
keyboardNavigation
)
break
;
dir
=
e
.
keyCode
===
37
?
-
1
:
1
;
var
viewMode
=
this
.
viewMode
;
if
(
e
.
ctrlKey
)
{
viewMode
+=
2
;
}
else
if
(
e
.
shiftKey
)
{
viewMode
+=
1
;
}
if
(
viewMode
===
4
)
{
newDate
=
this
.
moveYear
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveYear
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
3
)
{
newDate
=
this
.
moveMonth
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveMonth
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
2
)
{
newDate
=
this
.
moveDate
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveDate
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
1
)
{
newDate
=
this
.
moveHour
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveHour
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
0
)
{
newDate
=
this
.
moveMinute
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveMinute
(
this
.
viewDate
,
dir
);
}
if
(
this
.
dateWithinRange
(
newDate
))
{
this
.
date
=
newDate
;
this
.
viewDate
=
newViewDate
;
this
.
setValue
();
this
.
update
();
e
.
preventDefault
();
dateChanged
=
true
;
}
break
;
case
38
:
// up
case
40
:
// down
if
(
!
this
.
keyboardNavigation
)
break
;
dir
=
e
.
keyCode
===
38
?
-
1
:
1
;
viewMode
=
this
.
viewMode
;
if
(
e
.
ctrlKey
)
{
viewMode
+=
2
;
}
else
if
(
e
.
shiftKey
)
{
viewMode
+=
1
;
}
if
(
viewMode
===
4
)
{
newDate
=
this
.
moveYear
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveYear
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
3
)
{
newDate
=
this
.
moveMonth
(
this
.
date
,
dir
);
newViewDate
=
this
.
moveMonth
(
this
.
viewDate
,
dir
);
}
else
if
(
viewMode
===
2
)
{
newDate
=
this
.
moveDate
(
this
.
date
,
dir
*
7
);
newViewDate
=
this
.
moveDate
(
this
.
viewDate
,
dir
*
7
);
}
else
if
(
viewMode
===
1
)
{
if
(
this
.
showMeridian
)
{
newDate
=
this
.
moveHour
(
this
.
date
,
dir
*
6
);
newViewDate
=
this
.
moveHour
(
this
.
viewDate
,
dir
*
6
);
}
else
{
newDate
=
this
.
moveHour
(
this
.
date
,
dir
*
4
);
newViewDate
=
this
.
moveHour
(
this
.
viewDate
,
dir
*
4
);
}
}
else
if
(
viewMode
===
0
)
{
newDate
=
this
.
moveMinute
(
this
.
date
,
dir
*
4
);
newViewDate
=
this
.
moveMinute
(
this
.
viewDate
,
dir
*
4
);
}
if
(
this
.
dateWithinRange
(
newDate
))
{
this
.
date
=
newDate
;
this
.
viewDate
=
newViewDate
;
this
.
setValue
();
this
.
update
();
e
.
preventDefault
();
dateChanged
=
true
;
}
break
;
case
13
:
// enter
if
(
this
.
viewMode
!==
0
)
{
var
oldViewMode
=
this
.
viewMode
;
this
.
showMode
(
-
1
);
this
.
fill
();
if
(
oldViewMode
===
this
.
viewMode
&&
this
.
autoclose
)
{
this
.
hide
();
}
}
else
{
this
.
fill
();
if
(
this
.
autoclose
)
{
this
.
hide
();
}
}
e
.
preventDefault
();
break
;
case
9
:
// tab
this
.
hide
();
break
;
}
if
(
dateChanged
)
{
var
element
;
if
(
this
.
isInput
)
{
element
=
this
.
element
;
}
else
if
(
this
.
component
)
{
element
=
this
.
element
.
find
(
'input'
);
}
if
(
element
)
{
element
.
change
();
}
this
.
element
.
trigger
({
type
:
'changeDate'
,
date
:
this
.
getDate
()
});
}
},
showMode
:
function
(
dir
)
{
if
(
dir
)
{
var
newViewMode
=
Math
.
max
(
0
,
Math
.
min
(
DPGlobal
.
modes
.
length
-
1
,
this
.
viewMode
+
dir
));
if
(
newViewMode
>=
this
.
minView
&&
newViewMode
<=
this
.
maxView
)
{
this
.
element
.
trigger
({
type
:
'changeMode'
,
date
:
this
.
viewDate
,
oldViewMode
:
this
.
viewMode
,
newViewMode
:
newViewMode
});
this
.
viewMode
=
newViewMode
;
}
}
/*
vitalets: fixing bug of very special conditions:
jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
Method show() does not set display css correctly and datetimepicker is not shown.
Changed to .css('display', 'block') solve the problem.
See https://github.com/vitalets/x-editable/issues/37
In jquery 1.7.2+ everything works fine.
*/
//this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
this
.
picker
.
find
(
'>div'
).
hide
().
filter
(
'.datetimepicker-'
+
DPGlobal
.
modes
[
this
.
viewMode
].
clsName
).
css
(
'display'
,
'block'
);
this
.
updateNavArrows
();
},
reset
:
function
()
{
this
.
_setDate
(
null
,
'date'
);
},
convertViewModeText
:
function
(
viewMode
)
{
switch
(
viewMode
)
{
case
4
:
return
'decade'
;
case
3
:
return
'year'
;
case
2
:
return
'month'
;
case
1
:
return
'day'
;
case
0
:
return
'hour'
;
}
}
};
var
old
=
$
.
fn
.
datetimepicker
;
$
.
fn
.
datetimepicker
=
function
(
option
)
{
var
args
=
Array
.
apply
(
null
,
arguments
);
args
.
shift
();
var
internal_return
;
this
.
each
(
function
()
{
var
$this
=
$
(
this
),
data
=
$this
.
data
(
'datetimepicker'
),
options
=
typeof
option
===
'object'
&&
option
;
if
(
!
data
)
{
$this
.
data
(
'datetimepicker'
,
(
data
=
new
Datetimepicker
(
this
,
$
.
extend
({},
$
.
fn
.
datetimepicker
.
defaults
,
options
))));
}
if
(
typeof
option
===
'string'
&&
typeof
data
[
option
]
===
'function'
)
{
internal_return
=
data
[
option
].
apply
(
data
,
args
);
if
(
internal_return
!==
undefined
)
{
return
false
;
}
}
});
if
(
internal_return
!==
undefined
)
return
internal_return
;
else
return
this
;
};
$
.
fn
.
datetimepicker
.
defaults
=
{
};
$
.
fn
.
datetimepicker
.
Constructor
=
Datetimepicker
;
var
dates
=
$
.
fn
.
datetimepicker
.
dates
=
{
en
:
{
days
:
[
'Sunday'
,
'Monday'
,
'Tuesday'
,
'Wednesday'
,
'Thursday'
,
'Friday'
,
'Saturday'
,
'Sunday'
],
daysShort
:
[
'Sun'
,
'Mon'
,
'Tue'
,
'Wed'
,
'Thu'
,
'Fri'
,
'Sat'
,
'Sun'
],
daysMin
:
[
'Su'
,
'Mo'
,
'Tu'
,
'We'
,
'Th'
,
'Fr'
,
'Sa'
,
'Su'
],
months
:
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'July'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
],
monthsShort
:
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
],
meridiem
:
[
'am'
,
'pm'
],
suffix
:
[
'st'
,
'nd'
,
'rd'
,
'th'
],
today
:
'Today'
,
clear
:
'Clear'
}
};
var
DPGlobal
=
{
modes
:
[
{
clsName
:
'minutes'
,
navFnc
:
'Hours'
,
navStep
:
1
},
{
clsName
:
'hours'
,
navFnc
:
'Date'
,
navStep
:
1
},
{
clsName
:
'days'
,
navFnc
:
'Month'
,
navStep
:
1
},
{
clsName
:
'months'
,
navFnc
:
'FullYear'
,
navStep
:
1
},
{
clsName
:
'years'
,
navFnc
:
'FullYear'
,
navStep
:
10
}
],
isLeapYear
:
function
(
year
)
{
return
(((
year
%
4
===
0
)
&&
(
year
%
100
!==
0
))
||
(
year
%
400
===
0
))
},
getDaysInMonth
:
function
(
year
,
month
)
{
return
[
31
,
(
DPGlobal
.
isLeapYear
(
year
)
?
29
:
28
),
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
][
month
]
},
getDefaultFormat
:
function
(
type
,
field
)
{
if
(
type
===
'standard'
)
{
if
(
field
===
'input'
)
return
'yyyy-mm-dd hh:ii'
;
else
return
'yyyy-mm-dd hh:ii:ss'
;
}
else
if
(
type
===
'php'
)
{
if
(
field
===
'input'
)
return
'Y-m-d H:i'
;
else
return
'Y-m-d H:i:s'
;
}
else
{
throw
new
Error
(
'Invalid format type.'
);
}
},
validParts
:
function
(
type
)
{
if
(
type
===
'standard'
)
{
return
/t|hh
?
|HH
?
|p|P|z|Z|ii
?
|ss
?
|dd
?
|DD
?
|mm
?
|MM
?
|yy
(?:
yy
)?
/g
;
}
else
if
(
type
===
'php'
)
{
return
/
[
dDjlNwzFmMnStyYaABgGhHis
]
/g
;
}
else
{
throw
new
Error
(
'Invalid format type.'
);
}
},
nonpunctuation
:
/
[^
-
\/
:-@
\[
-`{-~
\t\n\r
TZ
]
+/g
,
parseFormat
:
function
(
format
,
type
)
{
// IE treats \0 as a string end in inputs (truncating the value),
// so it's a bad format delimiter, anyway
var
separators
=
format
.
replace
(
this
.
validParts
(
type
),
'
\
0'
).
split
(
'
\
0'
),
parts
=
format
.
match
(
this
.
validParts
(
type
));
if
(
!
separators
||
!
separators
.
length
||
!
parts
||
parts
.
length
===
0
)
{
throw
new
Error
(
'Invalid date format.'
);
}
return
{
separators
:
separators
,
parts
:
parts
};
},
parseDate
:
function
(
date
,
format
,
language
,
type
,
timezone
)
{
if
(
date
instanceof
Date
)
{
var
dateUTC
=
new
Date
(
date
.
valueOf
()
-
date
.
getTimezoneOffset
()
*
60000
);
dateUTC
.
setMilliseconds
(
0
);
return
dateUTC
;
}
if
(
/^
\d{4}\-\d{1,2}\-\d{1,2}
$/
.
test
(
date
))
{
format
=
this
.
parseFormat
(
'yyyy-mm-dd'
,
type
);
}
if
(
/^
\d{4}\-\d{1,2}\-\d{1,2}[
T
]\d{1,2}\:\d{1,2}
$/
.
test
(
date
))
{
format
=
this
.
parseFormat
(
'yyyy-mm-dd hh:ii'
,
type
);
}
if
(
/^
\d{4}\-\d{1,2}\-\d{1,2}[
T
]\d{1,2}\:\d{1,2}\:\d{1,2}[
Z
]{0,1}
$/
.
test
(
date
))
{
format
=
this
.
parseFormat
(
'yyyy-mm-dd hh:ii:ss'
,
type
);
}
if
(
/^
[
-+
]\d
+
[
dmwy
]([\s
,
]
+
[
-+
]\d
+
[
dmwy
])
*$/
.
test
(
date
))
{
var
part_re
=
/
([
-+
]\d
+
)([
dmwy
])
/
,
parts
=
date
.
match
(
/
([
-+
]\d
+
)([
dmwy
])
/g
),
part
,
dir
;
date
=
new
Date
();
for
(
var
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
part
=
part_re
.
exec
(
parts
[
i
]);
dir
=
parseInt
(
part
[
1
]);
switch
(
part
[
2
])
{
case
'd'
:
date
.
setUTCDate
(
date
.
getUTCDate
()
+
dir
);
break
;
case
'm'
:
date
=
Datetimepicker
.
prototype
.
moveMonth
.
call
(
Datetimepicker
.
prototype
,
date
,
dir
);
break
;
case
'w'
:
date
.
setUTCDate
(
date
.
getUTCDate
()
+
dir
*
7
);
break
;
case
'y'
:
date
=
Datetimepicker
.
prototype
.
moveYear
.
call
(
Datetimepicker
.
prototype
,
date
,
dir
);
break
;
}
}
return
UTCDate
(
date
.
getUTCFullYear
(),
date
.
getUTCMonth
(),
date
.
getUTCDate
(),
date
.
getUTCHours
(),
date
.
getUTCMinutes
(),
date
.
getUTCSeconds
(),
0
);
}
var
parts
=
date
&&
date
.
toString
().
match
(
this
.
nonpunctuation
)
||
[],
date
=
new
Date
(
0
,
0
,
0
,
0
,
0
,
0
,
0
),
parsed
=
{},
setters_order
=
[
'hh'
,
'h'
,
'ii'
,
'i'
,
'ss'
,
's'
,
'yyyy'
,
'yy'
,
'M'
,
'MM'
,
'm'
,
'mm'
,
'D'
,
'DD'
,
'd'
,
'dd'
,
'H'
,
'HH'
,
'p'
,
'P'
,
'z'
,
'Z'
],
setters_map
=
{
hh
:
function
(
d
,
v
)
{
return
d
.
setUTCHours
(
v
);
},
h
:
function
(
d
,
v
)
{
return
d
.
setUTCHours
(
v
);
},
HH
:
function
(
d
,
v
)
{
return
d
.
setUTCHours
(
v
===
12
?
0
:
v
);
},
H
:
function
(
d
,
v
)
{
return
d
.
setUTCHours
(
v
===
12
?
0
:
v
);
},
ii
:
function
(
d
,
v
)
{
return
d
.
setUTCMinutes
(
v
);
},
i
:
function
(
d
,
v
)
{
return
d
.
setUTCMinutes
(
v
);
},
ss
:
function
(
d
,
v
)
{
return
d
.
setUTCSeconds
(
v
);
},
s
:
function
(
d
,
v
)
{
return
d
.
setUTCSeconds
(
v
);
},
yyyy
:
function
(
d
,
v
)
{
return
d
.
setUTCFullYear
(
v
);
},
yy
:
function
(
d
,
v
)
{
return
d
.
setUTCFullYear
(
2000
+
v
);
},
m
:
function
(
d
,
v
)
{
v
-=
1
;
while
(
v
<
0
)
v
+=
12
;
v
%=
12
;
d
.
setUTCMonth
(
v
);
while
(
d
.
getUTCMonth
()
!==
v
)
if
(
isNaN
(
d
.
getUTCMonth
()))
return
d
;
else
d
.
setUTCDate
(
d
.
getUTCDate
()
-
1
);
return
d
;
},
d
:
function
(
d
,
v
)
{
return
d
.
setUTCDate
(
v
);
},
p
:
function
(
d
,
v
)
{
return
d
.
setUTCHours
(
v
===
1
?
d
.
getUTCHours
()
+
12
:
d
.
getUTCHours
());
},
z
:
function
()
{
return
timezone
}
},
val
,
filtered
,
part
;
setters_map
[
'M'
]
=
setters_map
[
'MM'
]
=
setters_map
[
'mm'
]
=
setters_map
[
'm'
];
setters_map
[
'dd'
]
=
setters_map
[
'd'
];
setters_map
[
'P'
]
=
setters_map
[
'p'
];
setters_map
[
'Z'
]
=
setters_map
[
'z'
];
date
=
UTCDate
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
date
.
getHours
(),
date
.
getMinutes
(),
date
.
getSeconds
());
if
(
parts
.
length
===
format
.
parts
.
length
)
{
for
(
var
i
=
0
,
cnt
=
format
.
parts
.
length
;
i
<
cnt
;
i
++
)
{
val
=
parseInt
(
parts
[
i
],
10
);
part
=
format
.
parts
[
i
];
if
(
isNaN
(
val
))
{
switch
(
part
)
{
case
'MM'
:
filtered
=
$
(
dates
[
language
].
months
).
filter
(
function
()
{
var
m
=
this
.
slice
(
0
,
parts
[
i
].
length
),
p
=
parts
[
i
].
slice
(
0
,
m
.
length
);
return
m
===
p
;
});
val
=
$
.
inArray
(
filtered
[
0
],
dates
[
language
].
months
)
+
1
;
break
;
case
'M'
:
filtered
=
$
(
dates
[
language
].
monthsShort
).
filter
(
function
()
{
var
m
=
this
.
slice
(
0
,
parts
[
i
].
length
),
p
=
parts
[
i
].
slice
(
0
,
m
.
length
);
return
m
.
toLowerCase
()
===
p
.
toLowerCase
();
});
val
=
$
.
inArray
(
filtered
[
0
],
dates
[
language
].
monthsShort
)
+
1
;
break
;
case
'p'
:
case
'P'
:
val
=
$
.
inArray
(
parts
[
i
].
toLowerCase
(),
dates
[
language
].
meridiem
);
break
;
case
'z'
:
case
'Z'
:
timezone
;
break
;
}
}
parsed
[
part
]
=
val
;
}
for
(
var
i
=
0
,
s
;
i
<
setters_order
.
length
;
i
++
)
{
s
=
setters_order
[
i
];
if
(
s
in
parsed
&&
!
isNaN
(
parsed
[
s
]))
setters_map
[
s
](
date
,
parsed
[
s
])
}
}
return
date
;
},
formatDate
:
function
(
date
,
format
,
language
,
type
,
timezone
)
{
if
(
date
===
null
)
{
return
''
;
}
var
val
;
if
(
type
===
'standard'
)
{
val
=
{
t
:
date
.
getTime
(),
// year
yy
:
date
.
getUTCFullYear
().
toString
().
substring
(
2
),
yyyy
:
date
.
getUTCFullYear
(),
// month
m
:
date
.
getUTCMonth
()
+
1
,
M
:
dates
[
language
].
monthsShort
[
date
.
getUTCMonth
()],
MM
:
dates
[
language
].
months
[
date
.
getUTCMonth
()],
// day
d
:
date
.
getUTCDate
(),
D
:
dates
[
language
].
daysShort
[
date
.
getUTCDay
()],
DD
:
dates
[
language
].
days
[
date
.
getUTCDay
()],
p
:
(
dates
[
language
].
meridiem
.
length
===
2
?
dates
[
language
].
meridiem
[
date
.
getUTCHours
()
<
12
?
0
:
1
]
:
''
),
// hour
h
:
date
.
getUTCHours
(),
// minute
i
:
date
.
getUTCMinutes
(),
// second
s
:
date
.
getUTCSeconds
(),
// timezone
z
:
timezone
};
if
(
dates
[
language
].
meridiem
.
length
===
2
)
{
val
.
H
=
(
val
.
h
%
12
===
0
?
12
:
val
.
h
%
12
);
}
else
{
val
.
H
=
val
.
h
;
}
val
.
HH
=
(
val
.
H
<
10
?
'0'
:
''
)
+
val
.
H
;
val
.
P
=
val
.
p
.
toUpperCase
();
val
.
Z
=
val
.
z
;
val
.
hh
=
(
val
.
h
<
10
?
'0'
:
''
)
+
val
.
h
;
val
.
ii
=
(
val
.
i
<
10
?
'0'
:
''
)
+
val
.
i
;
val
.
ss
=
(
val
.
s
<
10
?
'0'
:
''
)
+
val
.
s
;
val
.
dd
=
(
val
.
d
<
10
?
'0'
:
''
)
+
val
.
d
;
val
.
mm
=
(
val
.
m
<
10
?
'0'
:
''
)
+
val
.
m
;
}
else
if
(
type
===
'php'
)
{
// php format
val
=
{
// year
y
:
date
.
getUTCFullYear
().
toString
().
substring
(
2
),
Y
:
date
.
getUTCFullYear
(),
// month
F
:
dates
[
language
].
months
[
date
.
getUTCMonth
()],
M
:
dates
[
language
].
monthsShort
[
date
.
getUTCMonth
()],
n
:
date
.
getUTCMonth
()
+
1
,
t
:
DPGlobal
.
getDaysInMonth
(
date
.
getUTCFullYear
(),
date
.
getUTCMonth
()),
// day
j
:
date
.
getUTCDate
(),
l
:
dates
[
language
].
days
[
date
.
getUTCDay
()],
D
:
dates
[
language
].
daysShort
[
date
.
getUTCDay
()],
w
:
date
.
getUTCDay
(),
// 0 -> 6
N
:
(
date
.
getUTCDay
()
===
0
?
7
:
date
.
getUTCDay
()),
// 1 -> 7
S
:
(
date
.
getUTCDate
()
%
10
<=
dates
[
language
].
suffix
.
length
?
dates
[
language
].
suffix
[
date
.
getUTCDate
()
%
10
-
1
]
:
''
),
// hour
a
:
(
dates
[
language
].
meridiem
.
length
===
2
?
dates
[
language
].
meridiem
[
date
.
getUTCHours
()
<
12
?
0
:
1
]
:
''
),
g
:
(
date
.
getUTCHours
()
%
12
===
0
?
12
:
date
.
getUTCHours
()
%
12
),
G
:
date
.
getUTCHours
(),
// minute
i
:
date
.
getUTCMinutes
(),
// second
s
:
date
.
getUTCSeconds
()
};
val
.
m
=
(
val
.
n
<
10
?
'0'
:
''
)
+
val
.
n
;
val
.
d
=
(
val
.
j
<
10
?
'0'
:
''
)
+
val
.
j
;
val
.
A
=
val
.
a
.
toString
().
toUpperCase
();
val
.
h
=
(
val
.
g
<
10
?
'0'
:
''
)
+
val
.
g
;
val
.
H
=
(
val
.
G
<
10
?
'0'
:
''
)
+
val
.
G
;
val
.
i
=
(
val
.
i
<
10
?
'0'
:
''
)
+
val
.
i
;
val
.
s
=
(
val
.
s
<
10
?
'0'
:
''
)
+
val
.
s
;
}
else
{
throw
new
Error
(
'Invalid format type.'
);
}
var
date
=
[],
seps
=
$
.
extend
([],
format
.
separators
);
for
(
var
i
=
0
,
cnt
=
format
.
parts
.
length
;
i
<
cnt
;
i
++
)
{
if
(
seps
.
length
)
{
date
.
push
(
seps
.
shift
());
}
date
.
push
(
val
[
format
.
parts
[
i
]]);
}
if
(
seps
.
length
)
{
date
.
push
(
seps
.
shift
());
}
return
date
.
join
(
''
);
},
convertViewMode
:
function
(
viewMode
)
{
switch
(
viewMode
)
{
case
4
:
case
'decade'
:
viewMode
=
4
;
break
;
case
3
:
case
'year'
:
viewMode
=
3
;
break
;
case
2
:
case
'month'
:
viewMode
=
2
;
break
;
case
1
:
case
'day'
:
viewMode
=
1
;
break
;
case
0
:
case
'hour'
:
viewMode
=
0
;
break
;
}
return
viewMode
;
},
headTemplate
:
'<thead>'
+
'<tr>'
+
'<th class="prev"><i class="{iconType} {leftArrow}"/></th>'
+
'<th colspan="5" class="switch"></th>'
+
'<th class="next"><i class="{iconType} {rightArrow}"/></th>'
+
'</tr>'
+
'</thead>'
,
headTemplateV3
:
'<thead>'
+
'<tr>'
+
'<th class="prev"><span class="{iconType} {leftArrow}"></span> </th>'
+
'<th colspan="5" class="switch"></th>'
+
'<th class="next"><span class="{iconType} {rightArrow}"></span> </th>'
+
'</tr>'
+
'</thead>'
,
contTemplate
:
'<tbody><tr><td colspan="7"></td></tr></tbody>'
,
footTemplate
:
'<tfoot>'
+
'<tr><th colspan="7" class="today"></th></tr>'
+
'<tr><th colspan="7" class="clear"></th></tr>'
+
'</tfoot>'
};
DPGlobal
.
template
=
'<div class="datetimepicker">'
+
'<div class="datetimepicker-minutes">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplate
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-hours">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplate
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-days">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplate
+
'<tbody></tbody>'
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-months">'
+
'<table class="table-condensed">'
+
DPGlobal
.
headTemplate
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-years">'
+
'<table class="table-condensed">'
+
DPGlobal
.
headTemplate
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'</div>'
;
DPGlobal
.
templateV3
=
'<div class="datetimepicker">'
+
'<div class="datetimepicker-minutes">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplateV3
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-hours">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplateV3
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-days">'
+
'<table class=" table-condensed">'
+
DPGlobal
.
headTemplateV3
+
'<tbody></tbody>'
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-months">'
+
'<table class="table-condensed">'
+
DPGlobal
.
headTemplateV3
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'<div class="datetimepicker-years">'
+
'<table class="table-condensed">'
+
DPGlobal
.
headTemplateV3
+
DPGlobal
.
contTemplate
+
DPGlobal
.
footTemplate
+
'</table>'
+
'</div>'
+
'</div>'
;
$
.
fn
.
datetimepicker
.
DPGlobal
=
DPGlobal
;
/* DATETIMEPICKER NO CONFLICT
* =================== */
$
.
fn
.
datetimepicker
.
noConflict
=
function
()
{
$
.
fn
.
datetimepicker
=
old
;
return
this
;
};
/* DATETIMEPICKER DATA-API
* ================== */
$
(
document
).
on
(
'focus.datetimepicker.data-api click.datetimepicker.data-api'
,
'[data-provide="datetimepicker"]'
,
function
(
e
)
{
var
$this
=
$
(
this
);
if
(
$this
.
data
(
'datetimepicker'
))
return
;
e
.
preventDefault
();
// component click requires us to explicitly show it
$this
.
datetimepicker
(
'show'
);
}
);
$
(
function
()
{
$
(
'[data-provide="datetimepicker-inline"]'
).
datetimepicker
();
});
}));
Hunter_ht/hunter/static/hunter/bootstrap-datetimepicker.zh-CN.js
0 → 100644
View file @
9fbad193
/**
* Simplified Chinese translation for bootstrap-datetimepicker
* Yuan Cheung <advanimal@gmail.com>
*/
;(
function
(
$
){
$
.
fn
.
datetimepicker
.
dates
[
'zh-CN'
]
=
{
days
:
[
"星期日"
,
"星期一"
,
"星期二"
,
"星期三"
,
"星期四"
,
"星期五"
,
"星期六"
,
"星期日"
],
daysShort
:
[
"周日"
,
"周一"
,
"周二"
,
"周三"
,
"周四"
,
"周五"
,
"周六"
,
"周日"
],
daysMin
:
[
"日"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
,
"日"
],
months
:
[
"01"
,
"02"
,
"03"
,
"04"
,
"05"
,
"06"
,
"07"
,
"08"
,
"09"
,
"10"
,
"11"
,
"12"
],
monthsShort
:
[
"01"
,
"02"
,
"03"
,
"04"
,
"05"
,
"06"
,
"07"
,
"08"
,
"09"
,
"10"
,
"11"
,
"12"
],
today
:
"今天"
,
suffix
:
[],
meridiem
:
[
"上午"
,
"下午"
]
};
}(
jQuery
));
Hunter_ht/hunter/static/hunter/images/delete.png
0 → 100644
View file @
9fbad193
308 Bytes
Hunter_ht/hunter/static/hunter/jquery.form.js
0 → 100644
View file @
9fbad193
/*!
* jQuery Form Plugin
* version: 4.2.2
* Requires jQuery v1.7.2 or later
* Project repository: https://github.com/jquery-form/form
* Copyright 2017 Kevin Morris
* Copyright 2006 M. Alsup
* Dual licensed under the LGPL-2.1+ or MIT licenses
* https://github.com/jquery-form/form#license
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
/* global ActiveXObject */
/* eslint-disable */
(
function
(
factory
)
{
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
// AMD. Register as an anonymous module.
define
([
'jquery'
],
factory
);
}
else
if
(
typeof
module
===
'object'
&&
module
.
exports
)
{
// Node/CommonJS
module
.
exports
=
function
(
root
,
jQuery
)
{
if
(
typeof
jQuery
===
'undefined'
)
{
// require('jQuery') returns a factory that requires window to build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop if it's defined (how jquery works)
if
(
typeof
window
!==
'undefined'
)
{
jQuery
=
require
(
'jquery'
);
}
else
{
jQuery
=
require
(
'jquery'
)(
root
);
}
}
factory
(
jQuery
);
return
jQuery
;
};
}
else
{
// Browser globals
factory
(
jQuery
);
}
}(
function
(
$
)
{
/* eslint-enable */
'use strict'
;
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm:
$('#myForm').ajaxForm({
delegation: true,
target: '#output'
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
var
rCRLF
=
/
\r?\n
/g
;
/**
* Feature detection
*/
var
feature
=
{};
feature
.
fileapi
=
$
(
'<input type="file">'
).
get
(
0
).
files
!==
undefined
;
feature
.
formdata
=
(
typeof
window
.
FormData
!==
'undefined'
);
var
hasProp
=
!!
$
.
fn
.
prop
;
// attr2 uses prop when it can but checks the return type for
// an expected string. This accounts for the case where a form
// contains inputs with names like "action" or "method"; in those
// cases "prop" returns the element
$
.
fn
.
attr2
=
function
()
{
if
(
!
hasProp
)
{
return
this
.
attr
.
apply
(
this
,
arguments
);
}
var
val
=
this
.
prop
.
apply
(
this
,
arguments
);
if
((
val
&&
val
.
jquery
)
||
typeof
val
===
'string'
)
{
return
val
;
}
return
this
.
attr
.
apply
(
this
,
arguments
);
};
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*
* @param {object|string} options jquery.form.js parameters or custom url for submission
* @param {object} data extraData
* @param {string} dataType ajax dataType
* @param {function} onSuccess ajax success callback function
*/
$
.
fn
.
ajaxSubmit
=
function
(
options
,
data
,
dataType
,
onSuccess
)
{
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if
(
!
this
.
length
)
{
log
(
'ajaxSubmit: skipping submit process - no element selected'
);
return
this
;
}
/* eslint consistent-this: ["error", "$form"] */
var
method
,
action
,
url
,
$form
=
this
;
if
(
typeof
options
===
'function'
)
{
options
=
{
success
:
options
};
}
else
if
(
typeof
options
===
'string'
||
(
options
===
false
&&
arguments
.
length
>
0
))
{
options
=
{
'url'
:
options
,
'data'
:
data
,
'dataType'
:
dataType
};
if
(
typeof
onSuccess
===
'function'
)
{
options
.
success
=
onSuccess
;
}
}
else
if
(
typeof
options
===
'undefined'
)
{
options
=
{};
}
method
=
options
.
method
||
options
.
type
||
this
.
attr2
(
'method'
);
action
=
options
.
url
||
this
.
attr2
(
'action'
);
url
=
(
typeof
action
===
'string'
)
?
$
.
trim
(
action
)
:
''
;
url
=
url
||
window
.
location
.
href
||
''
;
if
(
url
)
{
// clean url (don't include hash vaue)
url
=
(
url
.
match
(
/^
([^
#
]
+
)
/
)
||
[])[
1
];
}
options
=
$
.
extend
(
true
,
{
url
:
url
,
success
:
$
.
ajaxSettings
.
success
,
type
:
method
||
$
.
ajaxSettings
.
type
,
iframeSrc
:
/^https/i
.
test
(
window
.
location
.
href
||
''
)
?
'javascript:false'
:
'about:blank'
// eslint-disable-line no-script-url
},
options
);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var
veto
=
{};
this
.
trigger
(
'form-pre-serialize'
,
[
this
,
options
,
veto
]);
if
(
veto
.
veto
)
{
log
(
'ajaxSubmit: submit vetoed via form-pre-serialize trigger'
);
return
this
;
}
// provide opportunity to alter form data before it is serialized
if
(
options
.
beforeSerialize
&&
options
.
beforeSerialize
(
this
,
options
)
===
false
)
{
log
(
'ajaxSubmit: submit aborted via beforeSerialize callback'
);
return
this
;
}
var
traditional
=
options
.
traditional
;
if
(
typeof
traditional
===
'undefined'
)
{
traditional
=
$
.
ajaxSettings
.
traditional
;
}
var
elements
=
[];
var
qx
,
a
=
this
.
formToArray
(
options
.
semantic
,
elements
,
options
.
filtering
);
if
(
options
.
data
)
{
var
optionsData
=
$
.
isFunction
(
options
.
data
)
?
options
.
data
(
a
)
:
options
.
data
;
options
.
extraData
=
optionsData
;
qx
=
$
.
param
(
optionsData
,
traditional
);
}
// give pre-submit callback an opportunity to abort the submit
if
(
options
.
beforeSubmit
&&
options
.
beforeSubmit
(
a
,
this
,
options
)
===
false
)
{
log
(
'ajaxSubmit: submit aborted via beforeSubmit callback'
);
return
this
;
}
// fire vetoable 'validate' event
this
.
trigger
(
'form-submit-validate'
,
[
a
,
this
,
options
,
veto
]);
if
(
veto
.
veto
)
{
log
(
'ajaxSubmit: submit vetoed via form-submit-validate trigger'
);
return
this
;
}
var
q
=
$
.
param
(
a
,
traditional
);
if
(
qx
)
{
q
=
(
q
?
(
q
+
'&'
+
qx
)
:
qx
);
}
if
(
options
.
type
.
toUpperCase
()
===
'GET'
)
{
options
.
url
+=
(
options
.
url
.
indexOf
(
'?'
)
>=
0
?
'&'
:
'?'
)
+
q
;
options
.
data
=
null
;
// data is null for 'get'
}
else
{
options
.
data
=
q
;
// data is the query string for 'post'
}
var
callbacks
=
[];
if
(
options
.
resetForm
)
{
callbacks
.
push
(
function
()
{
$form
.
resetForm
();
});
}
if
(
options
.
clearForm
)
{
callbacks
.
push
(
function
()
{
$form
.
clearForm
(
options
.
includeHidden
);
});
}
// perform a load on the target only if dataType is not provided
if
(
!
options
.
dataType
&&
options
.
target
)
{
var
oldSuccess
=
options
.
success
||
function
(){};
callbacks
.
push
(
function
(
data
,
textStatus
,
jqXHR
)
{
var
successArguments
=
arguments
,
fn
=
options
.
replaceTarget
?
'replaceWith'
:
'html'
;
$
(
options
.
target
)[
fn
](
data
).
each
(
function
(){
oldSuccess
.
apply
(
this
,
successArguments
);
});
});
}
else
if
(
options
.
success
)
{
if
(
$
.
isArray
(
options
.
success
))
{
$
.
merge
(
callbacks
,
options
.
success
);
}
else
{
callbacks
.
push
(
options
.
success
);
}
}
options
.
success
=
function
(
data
,
status
,
xhr
)
{
// jQuery 1.4+ passes xhr as 3rd arg
var
context
=
options
.
context
||
this
;
// jQuery 1.4+ supports scope context
for
(
var
i
=
0
,
max
=
callbacks
.
length
;
i
<
max
;
i
++
)
{
callbacks
[
i
].
apply
(
context
,
[
data
,
status
,
xhr
||
$form
,
$form
]);
}
};
if
(
options
.
error
)
{
var
oldError
=
options
.
error
;
options
.
error
=
function
(
xhr
,
status
,
error
)
{
var
context
=
options
.
context
||
this
;
oldError
.
apply
(
context
,
[
xhr
,
status
,
error
,
$form
]);
};
}
if
(
options
.
complete
)
{
var
oldComplete
=
options
.
complete
;
options
.
complete
=
function
(
xhr
,
status
)
{
var
context
=
options
.
context
||
this
;
oldComplete
.
apply
(
context
,
[
xhr
,
status
,
$form
]);
};
}
// are there files to upload?
// [value] (issue #113), also see comment:
// https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
var
fileInputs
=
$
(
'input[type=file]:enabled'
,
this
).
filter
(
function
()
{
return
$
(
this
).
val
()
!==
''
;
});
var
hasFileInputs
=
fileInputs
.
length
>
0
;
var
mp
=
'multipart/form-data'
;
var
multipart
=
(
$form
.
attr
(
'enctype'
)
===
mp
||
$form
.
attr
(
'encoding'
)
===
mp
);
var
fileAPI
=
feature
.
fileapi
&&
feature
.
formdata
;
log
(
'fileAPI :'
+
fileAPI
);
var
shouldUseFrame
=
(
hasFileInputs
||
multipart
)
&&
!
fileAPI
;
var
jqxhr
;
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if
(
options
.
iframe
!==
false
&&
(
options
.
iframe
||
shouldUseFrame
))
{
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if
(
options
.
closeKeepAlive
)
{
$
.
get
(
options
.
closeKeepAlive
,
function
()
{
jqxhr
=
fileUploadIframe
(
a
);
});
}
else
{
jqxhr
=
fileUploadIframe
(
a
);
}
}
else
if
((
hasFileInputs
||
multipart
)
&&
fileAPI
)
{
jqxhr
=
fileUploadXhr
(
a
);
}
else
{
jqxhr
=
$
.
ajax
(
options
);
}
$form
.
removeData
(
'jqxhr'
).
data
(
'jqxhr'
,
jqxhr
);
// clear element array
for
(
var
k
=
0
;
k
<
elements
.
length
;
k
++
)
{
elements
[
k
]
=
null
;
}
// fire 'notify' event
this
.
trigger
(
'form-submit-notify'
,
[
this
,
options
]);
return
this
;
// utility fn for deep serialization
function
deepSerialize
(
extraData
)
{
var
serialized
=
$
.
param
(
extraData
,
options
.
traditional
).
split
(
'&'
);
var
len
=
serialized
.
length
;
var
result
=
[];
var
i
,
part
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
// #252; undo param space replacement
serialized
[
i
]
=
serialized
[
i
].
replace
(
/
\+
/g
,
' '
);
part
=
serialized
[
i
].
split
(
'='
);
// #278; use array instead of object storage, favoring array serializations
result
.
push
([
decodeURIComponent
(
part
[
0
]),
decodeURIComponent
(
part
[
1
])]);
}
return
result
;
}
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
function
fileUploadXhr
(
a
)
{
var
formdata
=
new
FormData
();
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
{
formdata
.
append
(
a
[
i
].
name
,
a
[
i
].
value
);
}
if
(
options
.
extraData
)
{
var
serializedData
=
deepSerialize
(
options
.
extraData
);
for
(
i
=
0
;
i
<
serializedData
.
length
;
i
++
)
{
if
(
serializedData
[
i
])
{
formdata
.
append
(
serializedData
[
i
][
0
],
serializedData
[
i
][
1
]);
}
}
}
options
.
data
=
null
;
var
s
=
$
.
extend
(
true
,
{},
$
.
ajaxSettings
,
options
,
{
contentType
:
false
,
processData
:
false
,
cache
:
false
,
type
:
method
||
'POST'
});
if
(
options
.
uploadProgress
)
{
// workaround because jqXHR does not expose upload property
s
.
xhr
=
function
()
{
var
xhr
=
$
.
ajaxSettings
.
xhr
();
if
(
xhr
.
upload
)
{
xhr
.
upload
.
addEventListener
(
'progress'
,
function
(
event
)
{
var
percent
=
0
;
var
position
=
event
.
loaded
||
event
.
position
;
/* event.position is deprecated */
var
total
=
event
.
total
;
if
(
event
.
lengthComputable
)
{
percent
=
Math
.
ceil
(
position
/
total
*
100
);
}
options
.
uploadProgress
(
event
,
position
,
total
,
percent
);
},
false
);
}
return
xhr
;
};
}
s
.
data
=
null
;
var
beforeSend
=
s
.
beforeSend
;
s
.
beforeSend
=
function
(
xhr
,
o
)
{
// Send FormData() provided by user
if
(
options
.
formData
)
{
o
.
data
=
options
.
formData
;
}
else
{
o
.
data
=
formdata
;
}
if
(
beforeSend
)
{
beforeSend
.
call
(
this
,
xhr
,
o
);
}
};
return
$
.
ajax
(
s
);
}
// private function for handling file uploads (hat tip to YAHOO!)
function
fileUploadIframe
(
a
)
{
var
form
=
$form
[
0
],
el
,
i
,
s
,
g
,
id
,
$io
,
io
,
xhr
,
sub
,
n
,
timedOut
,
timeoutHandle
;
var
deferred
=
$
.
Deferred
();
// #341
deferred
.
abort
=
function
(
status
)
{
xhr
.
abort
(
status
);
};
if
(
a
)
{
// ensure that every serialized input is still enabled
for
(
i
=
0
;
i
<
elements
.
length
;
i
++
)
{
el
=
$
(
elements
[
i
]);
if
(
hasProp
)
{
el
.
prop
(
'disabled'
,
false
);
}
else
{
el
.
removeAttr
(
'disabled'
);
}
}
}
s
=
$
.
extend
(
true
,
{},
$
.
ajaxSettings
,
options
);
s
.
context
=
s
.
context
||
s
;
id
=
'jqFormIO'
+
new
Date
().
getTime
();
var
ownerDocument
=
form
.
ownerDocument
;
var
$body
=
$form
.
closest
(
'body'
);
if
(
s
.
iframeTarget
)
{
$io
=
$
(
s
.
iframeTarget
,
ownerDocument
);
n
=
$io
.
attr2
(
'name'
);
if
(
!
n
)
{
$io
.
attr2
(
'name'
,
id
);
}
else
{
id
=
n
;
}
}
else
{
$io
=
$
(
'<iframe name="'
+
id
+
'" src="'
+
s
.
iframeSrc
+
'" />'
,
ownerDocument
);
$io
.
css
({
position
:
'absolute'
,
top
:
'-1000px'
,
left
:
'-1000px'
});
}
io
=
$io
[
0
];
xhr
=
{
// mock object
aborted
:
0
,
responseText
:
null
,
responseXML
:
null
,
status
:
0
,
statusText
:
'n/a'
,
getAllResponseHeaders
:
function
()
{},
getResponseHeader
:
function
()
{},
setRequestHeader
:
function
()
{},
abort
:
function
(
status
)
{
var
e
=
(
status
===
'timeout'
?
'timeout'
:
'aborted'
);
log
(
'aborting upload... '
+
e
);
this
.
aborted
=
1
;
try
{
// #214, #257
if
(
io
.
contentWindow
.
document
.
execCommand
)
{
io
.
contentWindow
.
document
.
execCommand
(
'Stop'
);
}
}
catch
(
ignore
)
{}
$io
.
attr
(
'src'
,
s
.
iframeSrc
);
// abort op in progress
xhr
.
error
=
e
;
if
(
s
.
error
)
{
s
.
error
.
call
(
s
.
context
,
xhr
,
e
,
status
);
}
if
(
g
)
{
$
.
event
.
trigger
(
'ajaxError'
,
[
xhr
,
s
,
e
]);
}
if
(
s
.
complete
)
{
s
.
complete
.
call
(
s
.
context
,
xhr
,
e
);
}
}
};
g
=
s
.
global
;
// trigger ajax global events so that activity/block indicators work like normal
if
(
g
&&
$
.
active
++
===
0
)
{
$
.
event
.
trigger
(
'ajaxStart'
);
}
if
(
g
)
{
$
.
event
.
trigger
(
'ajaxSend'
,
[
xhr
,
s
]);
}
if
(
s
.
beforeSend
&&
s
.
beforeSend
.
call
(
s
.
context
,
xhr
,
s
)
===
false
)
{
if
(
s
.
global
)
{
$
.
active
--
;
}
deferred
.
reject
();
return
deferred
;
}
if
(
xhr
.
aborted
)
{
deferred
.
reject
();
return
deferred
;
}
// add submitting element to data if we know it
sub
=
form
.
clk
;
if
(
sub
)
{
n
=
sub
.
name
;
if
(
n
&&
!
sub
.
disabled
)
{
s
.
extraData
=
s
.
extraData
||
{};
s
.
extraData
[
n
]
=
sub
.
value
;
if
(
sub
.
type
===
'image'
)
{
s
.
extraData
[
n
+
'.x'
]
=
form
.
clk_x
;
s
.
extraData
[
n
+
'.y'
]
=
form
.
clk_y
;
}
}
}
var
CLIENT_TIMEOUT_ABORT
=
1
;
var
SERVER_ABORT
=
2
;
function
getDoc
(
frame
)
{
/* it looks like contentWindow or contentDocument do not
* carry the protocol property in ie8, when running under ssl
* frame.document is the only valid response document, since
* the protocol is know but not on the other two objects. strange?
* "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
*/
var
doc
=
null
;
// IE8 cascading access check
try
{
if
(
frame
.
contentWindow
)
{
doc
=
frame
.
contentWindow
.
document
;
}
}
catch
(
err
)
{
// IE8 access denied under ssl & missing protocol
log
(
'cannot get iframe.contentWindow document: '
+
err
);
}
if
(
doc
)
{
// successful getting content
return
doc
;
}
try
{
// simply checking may throw in ie8 under ssl or mismatched protocol
doc
=
frame
.
contentDocument
?
frame
.
contentDocument
:
frame
.
document
;
}
catch
(
err
)
{
// last attempt
log
(
'cannot get iframe.contentDocument: '
+
err
);
doc
=
frame
.
document
;
}
return
doc
;
}
// Rails CSRF hack (thanks to Yvan Barthelemy)
var
csrf_token
=
$
(
'meta[name=csrf-token]'
).
attr
(
'content'
);
var
csrf_param
=
$
(
'meta[name=csrf-param]'
).
attr
(
'content'
);
if
(
csrf_param
&&
csrf_token
)
{
s
.
extraData
=
s
.
extraData
||
{};
s
.
extraData
[
csrf_param
]
=
csrf_token
;
}
// take a breath so that pending repaints get some cpu time before the upload starts
function
doSubmit
()
{
// make sure form attrs are set
var
t
=
$form
.
attr2
(
'target'
),
a
=
$form
.
attr2
(
'action'
),
mp
=
'multipart/form-data'
,
et
=
$form
.
attr
(
'enctype'
)
||
$form
.
attr
(
'encoding'
)
||
mp
;
// update form attrs in IE friendly way
form
.
setAttribute
(
'target'
,
id
);
if
(
!
method
||
/post/i
.
test
(
method
))
{
form
.
setAttribute
(
'method'
,
'POST'
);
}
if
(
a
!==
s
.
url
)
{
form
.
setAttribute
(
'action'
,
s
.
url
);
}
// ie borks in some cases when setting encoding
if
(
!
s
.
skipEncodingOverride
&&
(
!
method
||
/post/i
.
test
(
method
)))
{
$form
.
attr
({
encoding
:
'multipart/form-data'
,
enctype
:
'multipart/form-data'
});
}
// support timout
if
(
s
.
timeout
)
{
timeoutHandle
=
setTimeout
(
function
()
{
timedOut
=
true
;
cb
(
CLIENT_TIMEOUT_ABORT
);
},
s
.
timeout
);
}
// look for server aborts
function
checkState
()
{
try
{
var
state
=
getDoc
(
io
).
readyState
;
log
(
'state = '
+
state
);
if
(
state
&&
state
.
toLowerCase
()
===
'uninitialized'
)
{
setTimeout
(
checkState
,
50
);
}
}
catch
(
e
)
{
log
(
'Server abort: '
,
e
,
' ('
,
e
.
name
,
')'
);
cb
(
SERVER_ABORT
);
// eslint-disable-line callback-return
if
(
timeoutHandle
)
{
clearTimeout
(
timeoutHandle
);
}
timeoutHandle
=
undefined
;
}
}
// add "extra" data to form if provided in options
var
extraInputs
=
[];
try
{
if
(
s
.
extraData
)
{
for
(
var
n
in
s
.
extraData
)
{
if
(
s
.
extraData
.
hasOwnProperty
(
n
))
{
// if using the $.param format that allows for multiple values with the same name
if
(
$
.
isPlainObject
(
s
.
extraData
[
n
])
&&
s
.
extraData
[
n
].
hasOwnProperty
(
'name'
)
&&
s
.
extraData
[
n
].
hasOwnProperty
(
'value'
))
{
extraInputs
.
push
(
$
(
'<input type="hidden" name="'
+
s
.
extraData
[
n
].
name
+
'">'
,
ownerDocument
).
val
(
s
.
extraData
[
n
].
value
)
.
appendTo
(
form
)[
0
]);
}
else
{
extraInputs
.
push
(
$
(
'<input type="hidden" name="'
+
n
+
'">'
,
ownerDocument
).
val
(
s
.
extraData
[
n
])
.
appendTo
(
form
)[
0
]);
}
}
}
}
if
(
!
s
.
iframeTarget
)
{
// add iframe to doc and submit the form
$io
.
appendTo
(
$body
);
}
if
(
io
.
attachEvent
)
{
io
.
attachEvent
(
'onload'
,
cb
);
}
else
{
io
.
addEventListener
(
'load'
,
cb
,
false
);
}
setTimeout
(
checkState
,
15
);
try
{
form
.
submit
();
}
catch
(
err
)
{
// just in case form has element with name/id of 'submit'
var
submitFn
=
document
.
createElement
(
'form'
).
submit
;
submitFn
.
apply
(
form
);
}
}
finally
{
// reset attrs and remove "extra" input elements
form
.
setAttribute
(
'action'
,
a
);
form
.
setAttribute
(
'enctype'
,
et
);
// #380
if
(
t
)
{
form
.
setAttribute
(
'target'
,
t
);
}
else
{
$form
.
removeAttr
(
'target'
);
}
$
(
extraInputs
).
remove
();
}
}
if
(
s
.
forceSync
)
{
doSubmit
();
}
else
{
setTimeout
(
doSubmit
,
10
);
// this lets dom updates render
}
var
data
,
doc
,
domCheckCount
=
50
,
callbackProcessed
;
function
cb
(
e
)
{
if
(
xhr
.
aborted
||
callbackProcessed
)
{
return
;
}
doc
=
getDoc
(
io
);
if
(
!
doc
)
{
log
(
'cannot access response document'
);
e
=
SERVER_ABORT
;
}
if
(
e
===
CLIENT_TIMEOUT_ABORT
&&
xhr
)
{
xhr
.
abort
(
'timeout'
);
deferred
.
reject
(
xhr
,
'timeout'
);
return
;
}
else
if
(
e
===
SERVER_ABORT
&&
xhr
)
{
xhr
.
abort
(
'server abort'
);
deferred
.
reject
(
xhr
,
'error'
,
'server abort'
);
return
;
}
if
(
!
doc
||
doc
.
location
.
href
===
s
.
iframeSrc
)
{
// response not received yet
if
(
!
timedOut
)
{
return
;
}
}
if
(
io
.
detachEvent
)
{
io
.
detachEvent
(
'onload'
,
cb
);
}
else
{
io
.
removeEventListener
(
'load'
,
cb
,
false
);
}
var
status
=
'success'
,
errMsg
;
try
{
if
(
timedOut
)
{
throw
'timeout'
;
}
var
isXml
=
s
.
dataType
===
'xml'
||
doc
.
XMLDocument
||
$
.
isXMLDoc
(
doc
);
log
(
'isXml='
+
isXml
);
if
(
!
isXml
&&
window
.
opera
&&
(
doc
.
body
===
null
||
!
doc
.
body
.
innerHTML
))
{
if
(
--
domCheckCount
)
{
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log
(
'requeing onLoad callback, DOM not available'
);
setTimeout
(
cb
,
250
);
return
;
}
// let this fall through because server response could be an empty document
// log('Could not access iframe DOM after mutiple tries.');
// throw 'DOMException: not available';
}
// log('response detected');
var
docRoot
=
doc
.
body
?
doc
.
body
:
doc
.
documentElement
;
xhr
.
responseText
=
docRoot
?
docRoot
.
innerHTML
:
null
;
xhr
.
responseXML
=
doc
.
XMLDocument
?
doc
.
XMLDocument
:
doc
;
if
(
isXml
)
{
s
.
dataType
=
'xml'
;
}
xhr
.
getResponseHeader
=
function
(
header
){
var
headers
=
{
'content-type'
:
s
.
dataType
};
return
headers
[
header
.
toLowerCase
()];
};
// support for XHR 'status' & 'statusText' emulation :
if
(
docRoot
)
{
xhr
.
status
=
Number
(
docRoot
.
getAttribute
(
'status'
))
||
xhr
.
status
;
xhr
.
statusText
=
docRoot
.
getAttribute
(
'statusText'
)
||
xhr
.
statusText
;
}
var
dt
=
(
s
.
dataType
||
''
).
toLowerCase
();
var
scr
=
/
(
json|script|text
)
/
.
test
(
dt
);
if
(
scr
||
s
.
textarea
)
{
// see if user embedded response in textarea
var
ta
=
doc
.
getElementsByTagName
(
'textarea'
)[
0
];
if
(
ta
)
{
xhr
.
responseText
=
ta
.
value
;
// support for XHR 'status' & 'statusText' emulation :
xhr
.
status
=
Number
(
ta
.
getAttribute
(
'status'
))
||
xhr
.
status
;
xhr
.
statusText
=
ta
.
getAttribute
(
'statusText'
)
||
xhr
.
statusText
;
}
else
if
(
scr
)
{
// account for browsers injecting pre around json response
var
pre
=
doc
.
getElementsByTagName
(
'pre'
)[
0
];
var
b
=
doc
.
getElementsByTagName
(
'body'
)[
0
];
if
(
pre
)
{
xhr
.
responseText
=
pre
.
textContent
?
pre
.
textContent
:
pre
.
innerText
;
}
else
if
(
b
)
{
xhr
.
responseText
=
b
.
textContent
?
b
.
textContent
:
b
.
innerText
;
}
}
}
else
if
(
dt
===
'xml'
&&
!
xhr
.
responseXML
&&
xhr
.
responseText
)
{
xhr
.
responseXML
=
toXml
(
xhr
.
responseText
);
// eslint-disable-line no-use-before-define
}
try
{
data
=
httpData
(
xhr
,
dt
,
s
);
// eslint-disable-line no-use-before-define
}
catch
(
err
)
{
status
=
'parsererror'
;
xhr
.
error
=
errMsg
=
(
err
||
status
);
}
}
catch
(
err
)
{
log
(
'error caught: '
,
err
);
status
=
'error'
;
xhr
.
error
=
errMsg
=
(
err
||
status
);
}
if
(
xhr
.
aborted
)
{
log
(
'upload aborted'
);
status
=
null
;
}
if
(
xhr
.
status
)
{
// we've set xhr.status
status
=
((
xhr
.
status
>=
200
&&
xhr
.
status
<
300
)
||
xhr
.
status
===
304
)
?
'success'
:
'error'
;
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if
(
status
===
'success'
)
{
if
(
s
.
success
)
{
s
.
success
.
call
(
s
.
context
,
data
,
'success'
,
xhr
);
}
deferred
.
resolve
(
xhr
.
responseText
,
'success'
,
xhr
);
if
(
g
)
{
$
.
event
.
trigger
(
'ajaxSuccess'
,
[
xhr
,
s
]);
}
}
else
if
(
status
)
{
if
(
typeof
errMsg
===
'undefined'
)
{
errMsg
=
xhr
.
statusText
;
}
if
(
s
.
error
)
{
s
.
error
.
call
(
s
.
context
,
xhr
,
status
,
errMsg
);
}
deferred
.
reject
(
xhr
,
'error'
,
errMsg
);
if
(
g
)
{
$
.
event
.
trigger
(
'ajaxError'
,
[
xhr
,
s
,
errMsg
]);
}
}
if
(
g
)
{
$
.
event
.
trigger
(
'ajaxComplete'
,
[
xhr
,
s
]);
}
if
(
g
&&
!--
$
.
active
)
{
$
.
event
.
trigger
(
'ajaxStop'
);
}
if
(
s
.
complete
)
{
s
.
complete
.
call
(
s
.
context
,
xhr
,
status
);
}
callbackProcessed
=
true
;
if
(
s
.
timeout
)
{
clearTimeout
(
timeoutHandle
);
}
// clean up
setTimeout
(
function
()
{
if
(
!
s
.
iframeTarget
)
{
$io
.
remove
();
}
else
{
// adding else to clean up existing iframe response.
$io
.
attr
(
'src'
,
s
.
iframeSrc
);
}
xhr
.
responseXML
=
null
;
},
100
);
}
var
toXml
=
$
.
parseXML
||
function
(
s
,
doc
)
{
// use parseXML if available (jQuery 1.5+)
if
(
window
.
ActiveXObject
)
{
doc
=
new
ActiveXObject
(
'Microsoft.XMLDOM'
);
doc
.
async
=
'false'
;
doc
.
loadXML
(
s
);
}
else
{
doc
=
(
new
DOMParser
()).
parseFromString
(
s
,
'text/xml'
);
}
return
(
doc
&&
doc
.
documentElement
&&
doc
.
documentElement
.
nodeName
!==
'parsererror'
)
?
doc
:
null
;
};
var
parseJSON
=
$
.
parseJSON
||
function
(
s
)
{
/* jslint evil:true */
return
window
[
'eval'
](
'('
+
s
+
')'
);
// eslint-disable-line dot-notation
};
var
httpData
=
function
(
xhr
,
type
,
s
)
{
// mostly lifted from jq1.4.4
var
ct
=
xhr
.
getResponseHeader
(
'content-type'
)
||
''
,
xml
=
((
type
===
'xml'
||
!
type
)
&&
ct
.
indexOf
(
'xml'
)
>=
0
),
data
=
xml
?
xhr
.
responseXML
:
xhr
.
responseText
;
if
(
xml
&&
data
.
documentElement
.
nodeName
===
'parsererror'
)
{
if
(
$
.
error
)
{
$
.
error
(
'parsererror'
);
}
}
if
(
s
&&
s
.
dataFilter
)
{
data
=
s
.
dataFilter
(
data
,
type
);
}
if
(
typeof
data
===
'string'
)
{
if
((
type
===
'json'
||
!
type
)
&&
ct
.
indexOf
(
'json'
)
>=
0
)
{
data
=
parseJSON
(
data
);
}
else
if
((
type
===
'script'
||
!
type
)
&&
ct
.
indexOf
(
'javascript'
)
>=
0
)
{
$
.
globalEval
(
data
);
}
}
return
data
;
};
return
deferred
;
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image"> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$
.
fn
.
ajaxForm
=
function
(
options
,
data
,
dataType
,
onSuccess
)
{
if
(
typeof
options
===
'string'
||
(
options
===
false
&&
arguments
.
length
>
0
))
{
options
=
{
'url'
:
options
,
'data'
:
data
,
'dataType'
:
dataType
};
if
(
typeof
onSuccess
===
'function'
)
{
options
.
success
=
onSuccess
;
}
}
options
=
options
||
{};
options
.
delegation
=
options
.
delegation
&&
$
.
isFunction
(
$
.
fn
.
on
);
// in jQuery 1.3+ we can fix mistakes with the ready state
if
(
!
options
.
delegation
&&
this
.
length
===
0
)
{
var
o
=
{
s
:
this
.
selector
,
c
:
this
.
context
};
if
(
!
$
.
isReady
&&
o
.
s
)
{
log
(
'DOM not ready, queuing ajaxForm'
);
$
(
function
()
{
$
(
o
.
s
,
o
.
c
).
ajaxForm
(
options
);
});
return
this
;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log
(
'terminating; zero elements found by selector'
+
(
$
.
isReady
?
''
:
' (DOM not ready)'
));
return
this
;
}
if
(
options
.
delegation
)
{
$
(
document
)
.
off
(
'submit.form-plugin'
,
this
.
selector
,
doAjaxSubmit
)
.
off
(
'click.form-plugin'
,
this
.
selector
,
captureSubmittingElement
)
.
on
(
'submit.form-plugin'
,
this
.
selector
,
options
,
doAjaxSubmit
)
.
on
(
'click.form-plugin'
,
this
.
selector
,
options
,
captureSubmittingElement
);
return
this
;
}
return
this
.
ajaxFormUnbind
()
.
on
(
'submit.form-plugin'
,
options
,
doAjaxSubmit
)
.
on
(
'click.form-plugin'
,
options
,
captureSubmittingElement
);
};
// private event handlers
function
doAjaxSubmit
(
e
)
{
/* jshint validthis:true */
var
options
=
e
.
data
;
if
(
!
e
.
isDefaultPrevented
())
{
// if event has been canceled, don't proceed
e
.
preventDefault
();
$
(
e
.
target
).
closest
(
'form'
).
ajaxSubmit
(
options
);
// #365
}
}
function
captureSubmittingElement
(
e
)
{
/* jshint validthis:true */
var
target
=
e
.
target
;
var
$el
=
$
(
target
);
if
(
!
$el
.
is
(
'[type=submit],[type=image]'
))
{
// is this a child element of the submit el? (ex: a span within a button)
var
t
=
$el
.
closest
(
'[type=submit]'
);
if
(
t
.
length
===
0
)
{
return
;
}
target
=
t
[
0
];
}
var
form
=
target
.
form
;
form
.
clk
=
target
;
if
(
target
.
type
===
'image'
)
{
if
(
typeof
e
.
offsetX
!==
'undefined'
)
{
form
.
clk_x
=
e
.
offsetX
;
form
.
clk_y
=
e
.
offsetY
;
}
else
if
(
typeof
$
.
fn
.
offset
===
'function'
)
{
var
offset
=
$el
.
offset
();
form
.
clk_x
=
e
.
pageX
-
offset
.
left
;
form
.
clk_y
=
e
.
pageY
-
offset
.
top
;
}
else
{
form
.
clk_x
=
e
.
pageX
-
target
.
offsetLeft
;
form
.
clk_y
=
e
.
pageY
-
target
.
offsetTop
;
}
}
// clear form vars
setTimeout
(
function
()
{
form
.
clk
=
form
.
clk_x
=
form
.
clk_y
=
null
;
},
100
);
}
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$
.
fn
.
ajaxFormUnbind
=
function
()
{
return
this
.
off
(
'submit.form-plugin click.form-plugin'
);
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$
.
fn
.
formToArray
=
function
(
semantic
,
elements
,
filtering
)
{
var
a
=
[];
if
(
this
.
length
===
0
)
{
return
a
;
}
var
form
=
this
[
0
];
var
formId
=
this
.
attr
(
'id'
);
var
els
=
(
semantic
||
typeof
form
.
elements
===
'undefined'
)
?
form
.
getElementsByTagName
(
'*'
)
:
form
.
elements
;
var
els2
;
if
(
els
)
{
els
=
$
.
makeArray
(
els
);
// convert to standard array
}
// #386; account for inputs outside the form which use the 'form' attribute
// FinesseRus: in non-IE browsers outside fields are already included in form.elements.
if
(
formId
&&
(
semantic
||
/
(
Edge|Trident
)\/
/
.
test
(
navigator
.
userAgent
)))
{
els2
=
$
(
':input[form="'
+
formId
+
'"]'
).
get
();
// hat tip @thet
if
(
els2
.
length
)
{
els
=
(
els
||
[]).
concat
(
els2
);
}
}
if
(
!
els
||
!
els
.
length
)
{
return
a
;
}
if
(
$
.
isFunction
(
filtering
))
{
els
=
$
.
map
(
els
,
filtering
);
}
var
i
,
j
,
n
,
v
,
el
,
max
,
jmax
;
for
(
i
=
0
,
max
=
els
.
length
;
i
<
max
;
i
++
)
{
el
=
els
[
i
];
n
=
el
.
name
;
if
(
!
n
||
el
.
disabled
)
{
continue
;
}
if
(
semantic
&&
form
.
clk
&&
el
.
type
===
'image'
)
{
// handle image inputs on the fly when semantic == true
if
(
form
.
clk
===
el
)
{
a
.
push
({
name
:
n
,
value
:
$
(
el
).
val
(),
type
:
el
.
type
});
a
.
push
({
name
:
n
+
'.x'
,
value
:
form
.
clk_x
},
{
name
:
n
+
'.y'
,
value
:
form
.
clk_y
});
}
continue
;
}
v
=
$
.
fieldValue
(
el
,
true
);
if
(
v
&&
v
.
constructor
===
Array
)
{
if
(
elements
)
{
elements
.
push
(
el
);
}
for
(
j
=
0
,
jmax
=
v
.
length
;
j
<
jmax
;
j
++
)
{
a
.
push
({
name
:
n
,
value
:
v
[
j
]});
}
}
else
if
(
feature
.
fileapi
&&
el
.
type
===
'file'
)
{
if
(
elements
)
{
elements
.
push
(
el
);
}
var
files
=
el
.
files
;
if
(
files
.
length
)
{
for
(
j
=
0
;
j
<
files
.
length
;
j
++
)
{
a
.
push
({
name
:
n
,
value
:
files
[
j
],
type
:
el
.
type
});
}
}
else
{
// #180
a
.
push
({
name
:
n
,
value
:
''
,
type
:
el
.
type
});
}
}
else
if
(
v
!==
null
&&
typeof
v
!==
'undefined'
)
{
if
(
elements
)
{
elements
.
push
(
el
);
}
a
.
push
({
name
:
n
,
value
:
v
,
type
:
el
.
type
,
required
:
el
.
required
});
}
}
if
(
!
semantic
&&
form
.
clk
)
{
// input type=='image' are not found in elements array! handle it here
var
$input
=
$
(
form
.
clk
),
input
=
$input
[
0
];
n
=
input
.
name
;
if
(
n
&&
!
input
.
disabled
&&
input
.
type
===
'image'
)
{
a
.
push
({
name
:
n
,
value
:
$input
.
val
()});
a
.
push
({
name
:
n
+
'.x'
,
value
:
form
.
clk_x
},
{
name
:
n
+
'.y'
,
value
:
form
.
clk_y
});
}
}
return
a
;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&name2=value2
*/
$
.
fn
.
formSerialize
=
function
(
semantic
)
{
// hand off to jQuery.param for proper encoding
return
$
.
param
(
this
.
formToArray
(
semantic
));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&name2=value2
*/
$
.
fn
.
fieldSerialize
=
function
(
successful
)
{
var
a
=
[];
this
.
each
(
function
()
{
var
n
=
this
.
name
;
if
(
!
n
)
{
return
;
}
var
v
=
$
.
fieldValue
(
this
,
successful
);
if
(
v
&&
v
.
constructor
===
Array
)
{
for
(
var
i
=
0
,
max
=
v
.
length
;
i
<
max
;
i
++
)
{
a
.
push
({
name
:
n
,
value
:
v
[
i
]});
}
}
else
if
(
v
!==
null
&&
typeof
v
!==
'undefined'
)
{
a
.
push
({
name
:
this
.
name
,
value
:
v
});
}
});
// hand off to jQuery.param for proper encoding
return
$
.
param
(
a
);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text">
* <input name="A" type="text">
* <input name="B" type="checkbox" value="B1">
* <input name="B" type="checkbox" value="B2">
* <input name="C" type="radio" value="C1">
* <input name="C" type="radio" value="C2">
* </fieldset></form>
*
* var v = $('input[type=text]').fieldValue();
* // if no values are entered into the text inputs
* v === ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v === ['foo','bar']
*
* var v = $('input[type=checkbox]').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v === ['B1', 'B2']
*
* var v = $('input[type=radio]').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v === ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$
.
fn
.
fieldValue
=
function
(
successful
)
{
for
(
var
val
=
[],
i
=
0
,
max
=
this
.
length
;
i
<
max
;
i
++
)
{
var
el
=
this
[
i
];
var
v
=
$
.
fieldValue
(
el
,
successful
);
if
(
v
===
null
||
typeof
v
===
'undefined'
||
(
v
.
constructor
===
Array
&&
!
v
.
length
))
{
continue
;
}
if
(
v
.
constructor
===
Array
)
{
$
.
merge
(
val
,
v
);
}
else
{
val
.
push
(
v
);
}
}
return
val
;
};
/**
* Returns the value of the field element.
*/
$
.
fieldValue
=
function
(
el
,
successful
)
{
var
n
=
el
.
name
,
t
=
el
.
type
,
tag
=
el
.
tagName
.
toLowerCase
();
if
(
typeof
successful
===
'undefined'
)
{
successful
=
true
;
}
/* eslint-disable no-mixed-operators */
if
(
successful
&&
(
!
n
||
el
.
disabled
||
t
===
'reset'
||
t
===
'button'
||
(
t
===
'checkbox'
||
t
===
'radio'
)
&&
!
el
.
checked
||
(
t
===
'submit'
||
t
===
'image'
)
&&
el
.
form
&&
el
.
form
.
clk
!==
el
||
tag
===
'select'
&&
el
.
selectedIndex
===
-
1
))
{
/* eslint-enable no-mixed-operators */
return
null
;
}
if
(
tag
===
'select'
)
{
var
index
=
el
.
selectedIndex
;
if
(
index
<
0
)
{
return
null
;
}
var
a
=
[],
ops
=
el
.
options
;
var
one
=
(
t
===
'select-one'
);
var
max
=
(
one
?
index
+
1
:
ops
.
length
);
for
(
var
i
=
(
one
?
index
:
0
);
i
<
max
;
i
++
)
{
var
op
=
ops
[
i
];
if
(
op
.
selected
&&
!
op
.
disabled
)
{
var
v
=
op
.
value
;
if
(
!
v
)
{
// extra pain for IE...
v
=
(
op
.
attributes
&&
op
.
attributes
.
value
&&
!
(
op
.
attributes
.
value
.
specified
))
?
op
.
text
:
op
.
value
;
}
if
(
one
)
{
return
v
;
}
a
.
push
(
v
);
}
}
return
a
;
}
return
$
(
el
).
val
().
replace
(
rCRLF
,
'
\
r
\
n'
);
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$
.
fn
.
clearForm
=
function
(
includeHidden
)
{
return
this
.
each
(
function
()
{
$
(
'input,select,textarea'
,
this
).
clearFields
(
includeHidden
);
});
};
/**
* Clears the selected form elements.
*/
$
.
fn
.
clearFields
=
$
.
fn
.
clearInputs
=
function
(
includeHidden
)
{
var
re
=
/^
(?:
color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week
)
$/i
;
// 'hidden' is not in this list
return
this
.
each
(
function
()
{
var
t
=
this
.
type
,
tag
=
this
.
tagName
.
toLowerCase
();
if
(
re
.
test
(
t
)
||
tag
===
'textarea'
)
{
this
.
value
=
''
;
}
else
if
(
t
===
'checkbox'
||
t
===
'radio'
)
{
this
.
checked
=
false
;
}
else
if
(
tag
===
'select'
)
{
this
.
selectedIndex
=
-
1
;
}
else
if
(
t
===
'file'
)
{
if
(
/MSIE/
.
test
(
navigator
.
userAgent
))
{
$
(
this
).
replaceWith
(
$
(
this
).
clone
(
true
));
}
else
{
$
(
this
).
val
(
''
);
}
}
else
if
(
includeHidden
)
{
// includeHidden can be the value true, or it can be a selector string
// indicating a special test; for example:
// $('#myForm').clearForm('.special:hidden')
// the above would clean hidden inputs that have the class of 'special'
if
((
includeHidden
===
true
&&
/hidden/
.
test
(
t
))
||
(
typeof
includeHidden
===
'string'
&&
$
(
this
).
is
(
includeHidden
)))
{
this
.
value
=
''
;
}
}
});
};
/**
* Resets the form data or individual elements. Takes the following actions
* on the selected tags:
* - all fields within form elements will be reset to their original value
* - input / textarea / select fields will be reset to their original value
* - option / optgroup fields (for multi-selects) will defaulted individually
* - non-multiple options will find the right select to default
* - label elements will be searched against its 'for' attribute
* - all others will be searched for appropriate children to default
*/
$
.
fn
.
resetForm
=
function
()
{
return
this
.
each
(
function
()
{
var
el
=
$
(
this
);
var
tag
=
this
.
tagName
.
toLowerCase
();
switch
(
tag
)
{
case
'input'
:
this
.
checked
=
this
.
defaultChecked
;
// fall through
case
'textarea'
:
this
.
value
=
this
.
defaultValue
;
return
true
;
case
'option'
:
case
'optgroup'
:
var
select
=
el
.
parents
(
'select'
);
if
(
select
.
length
&&
select
[
0
].
multiple
)
{
if
(
tag
===
'option'
)
{
this
.
selected
=
this
.
defaultSelected
;
}
else
{
el
.
find
(
'option'
).
resetForm
();
}
}
else
{
select
.
resetForm
();
}
return
true
;
case
'select'
:
el
.
find
(
'option'
).
each
(
function
(
i
)
{
// eslint-disable-line consistent-return
this
.
selected
=
this
.
defaultSelected
;
if
(
this
.
defaultSelected
&&
!
el
[
0
].
multiple
)
{
el
[
0
].
selectedIndex
=
i
;
return
false
;
}
});
return
true
;
case
'label'
:
var
forEl
=
$
(
el
.
attr
(
'for'
));
var
list
=
el
.
find
(
'input,select,textarea'
);
if
(
forEl
[
0
])
{
list
.
unshift
(
forEl
[
0
]);
}
list
.
resetForm
();
return
true
;
case
'form'
:
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if
(
typeof
this
.
reset
===
'function'
||
(
typeof
this
.
reset
===
'object'
&&
!
this
.
reset
.
nodeType
))
{
this
.
reset
();
}
return
true
;
default
:
el
.
find
(
'form,input,label,select,textarea'
).
resetForm
();
return
true
;
}
});
};
/**
* Enables or disables any matching elements.
*/
$
.
fn
.
enable
=
function
(
b
)
{
if
(
typeof
b
===
'undefined'
)
{
b
=
true
;
}
return
this
.
each
(
function
()
{
this
.
disabled
=
!
b
;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$
.
fn
.
selected
=
function
(
select
)
{
if
(
typeof
select
===
'undefined'
)
{
select
=
true
;
}
return
this
.
each
(
function
()
{
var
t
=
this
.
type
;
if
(
t
===
'checkbox'
||
t
===
'radio'
)
{
this
.
checked
=
select
;
}
else
if
(
this
.
tagName
.
toLowerCase
()
===
'option'
)
{
var
$sel
=
$
(
this
).
parent
(
'select'
);
if
(
select
&&
$sel
[
0
]
&&
$sel
[
0
].
type
===
'select-one'
)
{
// deselect all other options
$sel
.
find
(
'option'
).
selected
(
false
);
}
this
.
selected
=
select
;
}
});
};
// expose debug var
$
.
fn
.
ajaxSubmit
.
debug
=
false
;
// helper fn for console logging
function
log
()
{
if
(
!
$
.
fn
.
ajaxSubmit
.
debug
)
{
return
;
}
var
msg
=
'[jquery.form] '
+
Array
.
prototype
.
join
.
call
(
arguments
,
''
);
if
(
window
.
console
&&
window
.
console
.
log
)
{
window
.
console
.
log
(
msg
);
}
else
if
(
window
.
opera
&&
window
.
opera
.
postError
)
{
window
.
opera
.
postError
(
msg
);
}
}
}));
Hunter_ht/hunter/static/hunter/style.css
View file @
9fbad193
...
@@ -656,8 +656,13 @@ section > .smaller_box{
...
@@ -656,8 +656,13 @@ section > .smaller_box{
li
svg
{
li
svg
{
margin
:
10px
5px
;
margin
:
10px
5px
;
}
}
.right
button
,
.li_right
button
{
background
:
transparent
;
.dele_img
{
width
:
20px
;
height
:
20px
;
margin
:
5px
0
;
background-image
:
url("/static/hunter/images/delete.png")
;
}
}
.add_one
button
svg
{
.add_one
button
svg
{
margin
:
8px
5px
;
margin
:
8px
5px
;
...
...
Hunter_ht/hunter/templates/hunter/detail.html
View file @
9fbad193
...
@@ -17,11 +17,12 @@
...
@@ -17,11 +17,12 @@
<span>
{{ user.mailAddress }}
</span>
<span>
{{ user.mailAddress }}
</span>
{% endif %}
{% endif %}
{% if user.personal_website %}
{% if user.personal_website %}
<a
href=
"
{{ user.personal_website }}
"
target=
"_blank"
>
{{ user.personal_website }}
</a>
<a
href=
"
javascript:goUrl({{ user.personal_website }})
"
target=
"_blank"
>
{{ user.personal_website }}
</a>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
{% if publications %}
<div
class=
"section"
>
<div
class=
"section"
>
<span>
PUBLICATIONS
</span>
<span>
PUBLICATIONS
</span>
{% for year,publications in publication_year_list.items %}
{% for year,publications in publication_year_list.items %}
...
@@ -31,7 +32,6 @@
...
@@ -31,7 +32,6 @@
{{ year }}
{{ year }}
</span>
</span>
</div>
</div>
{% if publications %}
{% for publication in publications %}
{% for publication in publications %}
<ul>
<ul>
<li>
<li>
...
@@ -45,10 +45,10 @@
...
@@ -45,10 +45,10 @@
</li>
</li>
</ul>
</ul>
{% endfor %}
{% endfor %}
{% endif %}
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
{% endif %}
{% if cve_year_list.items %}
{% if cve_year_list.items %}
<div
class=
"section"
>
<div
class=
"section"
>
<span>
MY-CVE
</span>
<span>
MY-CVE
</span>
...
@@ -79,5 +79,10 @@
...
@@ -79,5 +79,10 @@
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<script>
function
goUrl
(
url
){
window
.
open
(
url
);
}
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
Hunter_ht/hunter/templates/hunter/user.html
View file @
9fbad193
...
@@ -57,8 +57,7 @@
...
@@ -57,8 +57,7 @@
{% for publication in publications %}
{% for publication in publications %}
<ul
id=
"pubid{{ publication.pubID }}"
>
<ul
id=
"pubid{{ publication.pubID }}"
>
<li
class=
"big_text li_long"
><a
href=
"{% static 'hunter/publications/' %}{{ publication.link }}"
target=
"_blank"
>
{{ publication.title }}
</a></li>
<li
class=
"big_text li_long"
><a
href=
"{% static 'hunter/publications/' %}{{ publication.link }}"
target=
"_blank"
>
{{ publication.title }}
</a></li>
<li
class=
"right"
><button
onclick=
"delePub({{ publication.pubID }})"
><svg
t=
"1587713476030"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"4730"
width=
"20"
height=
"20"
><path
d=
"M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z"
fill=
"#b34340"
p-id=
"4731"
></path></svg>
<li
class=
"right"
><button
class=
"dele_img"
onclick=
"delePub({{ publication.pubID }})"
></button></li>
</button></li>
{#
<li
class=
"right"
><button
onclick=
"editPublication({{ publication.pubID }})"
><svg
t=
"1587711451871"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2741"
width=
"20"
height=
"20"
><path
d=
"M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z"
p-id=
"2742"
fill=
"#6e829e"
></path></svg>
#}
{#
<li
class=
"right"
><button
onclick=
"editPublication({{ publication.pubID }})"
><svg
t=
"1587711451871"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2741"
width=
"20"
height=
"20"
><path
d=
"M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z"
p-id=
"2742"
fill=
"#6e829e"
></path></svg>
#}
{#
</button></li>
#}
{#
</button></li>
#}
<li
class=
"middle_text right"
>
{{ publication.date }}
</li>
<li
class=
"middle_text right"
>
{{ publication.date }}
</li>
...
@@ -89,24 +88,19 @@
...
@@ -89,24 +88,19 @@
</div>
</div>
<div
class=
"wrap smaller_wrap"
>
<div
class=
"wrap smaller_wrap"
>
{% for year, cves in cve_year_list.items %}
{% for year, cves in cve_year_list.items %}
<blockquote
><p>
{{ year }}
</p></blockquote>
<blockquote><p>
{{ year }}
</p></blockquote>
{% if cves %}
{% if cves %}
{% for cve in cves %}
{% for cve in cves %}
<ul
id=
"cveid{{ cve.identifier }}"
>
<ul
id=
"cveid{{ cve.identifier }}"
>
<li
class=
"cve_big_text"
><a
href=
"{{ cve.url }}"
target=
"_blank"
>
{{ cve.identifier }}
</a></li>
<li
class=
"cve_big_text"
><a
href=
"{{ cve.url }}"
target=
"_blank"
>
{{ cve.identifier }}
</a></li>
<li
class=
"li_right"
><button
onclick=
"deleCVE({{ cve.identifier }})"
><svg
t=
"1587713476030"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"4730"
width=
"20"
height=
"20"
><path
d=
"M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z"
fill=
"#b34340"
p-id=
"4731"
></path></svg>
<li
class=
"li_right"
><button
class=
"dele_img"
onclick=
"deleCVE({{ cve.identifier }})"
></button></li>
</button></li>
<li
class=
"li_right"
>
{{ cve.datetime }}
</li>
{#
<li
class=
"li_right"
><button
onclick=
"editCVE('{{ cve.identifier }}')"
><svg
t=
"1587711451871"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2741"
width=
"20"
height=
"20"
><path
d=
"M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z"
p-id=
"2742"
fill=
"#6e829e"
></path></svg>
#}
<li
class=
"li_right"
>
{{ cve.software }}
</li>
{#
</button></li>
#}
<li
class=
"li_right"
>
{{ cve.bugType }}
</li>
<li
class=
"li_right"
>
{{ cve.datetime }}
</li>
<li
class=
"li_long li_small_text"
>
{{ cve.description }}
</li>
<li
class=
"li_right"
>
{{ cve.software }}
</li>
</ul>
<li
class=
"li_right"
>
{{ cve.bugType }}
</li>
{% endfor %}
<li
class=
"li_long li_small_text"
>
{{ cve.description }}
</li>
{% endif %}
</ul>
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
</div>
</div>
...
@@ -127,7 +121,7 @@
...
@@ -127,7 +121,7 @@
</div>
</div>
<div
class=
"wrap smaller_wrap"
>
<div
class=
"wrap smaller_wrap"
>
{% for year, arts in article_year_list.items %}
{% for year, arts in article_year_list.items %}
<blockquote
><p>
{{ year }}
</p></blockquote>
<blockquote
><p>
{{ year }}
</p></blockquote>
{% if arts %}
{% if arts %}
{% for art in arts %}
{% for art in arts %}
<ul
id=
"articleid{{ art.articleID }}"
>
<ul
id=
"articleid{{ art.articleID }}"
>
...
@@ -224,7 +218,7 @@
...
@@ -224,7 +218,7 @@
console
.
log
(
pubid
);
console
.
log
(
pubid
);
create_html
();
create_html
();
}
}
function
submit_pub
(){
function
submit_pub
lication
(){
let
title
=
$
(
'input[name="title"]'
).
val
();
let
title
=
$
(
'input[name="title"]'
).
val
();
let
authors
=
$
(
'input[name="authors"]'
).
val
();
let
authors
=
$
(
'input[name="authors"]'
).
val
();
let
journalname
=
$
(
'input[name="journalname"]'
).
val
();
let
journalname
=
$
(
'input[name="journalname"]'
).
val
();
...
@@ -258,31 +252,13 @@
...
@@ -258,31 +252,13 @@
if
(
this
.
children
[
0
].
innerText
===
year
){
if
(
this
.
children
[
0
].
innerText
===
year
){
isFind
=
1
;
isFind
=
1
;
$
(
this
.
parentElement
).
append
(
' <ul>
\
n'
+
var
$h1
=
' <ul><li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li><li class="right"><button class="dele_img" onclick="delePub('
+
response
[
'pubID'
]
+
')"></button></li><li class="middle_text right">'
+
date_month
+
'</li><li class="right">'
+
journalname
+
'</li><li class="right">'
+
type
+
'</li><li class="small_text">'
+
authors
+
'</li></ul>'
;
' <li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li>
\
n'
+
$
(
this
).
after
(
$h1
);
' <li class="right"><button onclick="delePub('
+
response
[
'pubID'
]
+
')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
\
n'
+
' </button></li>
\
n'
+
' <li class="right"><button onclick="editPublication('
+
response
[
'pubID'
]
+
')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>
\
n'
+
' </button></li>
\
n'
+
' <li class="middle_text right">'
+
date_month
+
'}</li>
\
n'
+
' <li class="right">'
+
journalname
+
'</li>
\
n'
+
' <li class="right">'
+
type
+
'</li>
\
n'
+
' <li class="small_text">'
+
authors
+
'</li>
\
n'
+
' </ul>'
);
}
}
});
});
if
(
!
isFind
){
if
(
!
isFind
){
$
(
'#publish wrap'
)[
0
].
prepend
(
'<blockquote><p>'
+
year
+
'</p></blockquote>'
+
' <ul>
\
n'
+
var
$h2
=
'<blockquote><p>'
+
year
+
'</p></blockquote><ul><li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li> <li class="right"><button class="dele_img" onclick="delePub('
+
response
[
'pubID'
]
+
')"></button></li><li class="middle_text right">'
+
date_month
+
'</li><li class="right">'
+
journalname
+
'</li><li class="right">'
+
type
+
'</li><li class="small_text">'
+
authors
+
'</li></ul>'
;
' <li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li>
\
n'
+
$
(
'#publish .wrap'
)[
0
].
prepend
(
$h2
);
' <li class="right"><button onclick="delePub('
+
response
[
'pubID'
]
+
')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
\
n'
+
' </button></li>
\
n'
+
' <li class="right"><button onclick="editPublication('
+
response
[
'pubID'
]
+
')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>
\
n'
+
' </button></li>
\
n'
+
' <li class="middle_text right">'
+
date_month
+
'}</li>
\
n'
+
' <li class="right">'
+
journalname
+
'</li>
\
n'
+
' <li class="right">'
+
type
+
'</li>
\
n'
+
' <li class="small_text">'
+
authors
+
'</li>
\
n'
+
' </ul>'
);
}
}
}
else
{
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
$
(
'#error_log'
).
append
(
response
[
'error'
]);
...
@@ -383,27 +359,27 @@
...
@@ -383,27 +359,27 @@
$
(
'#cve blockquote'
).
each
(
function
(){
$
(
'#cve blockquote'
).
each
(
function
(){
if
(
this
.
children
[
0
].
innerText
===
year
){
if
(
this
.
children
[
0
].
innerText
===
year
){
isFind
=
1
;
isFind
=
1
;
$
(
this
.
parentElement
).
prepend
(
'<ul id="cveid'
+
cve_id
+
'">
\
n'
+
let
$h1
=
'<ul id="cveid'
+
cve_id
+
'">
\
n'
+
' <li class="cve_big_text"><a href="'
+
url_cve
+
'" target="_blank">'
+
cve_id
+
'</a></li>
\
n'
+
' <li class="cve_big_text"><a href='
+
url_cve
+
' target="_blank">'
+
cve_id
+
'</a></li>
\
n'
+
' <li class="li_right"><button onclick="deleCVE('
+
cve_id
+
')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
\
n'
+
' <li class="li_right"><button class="dele_img" onclick="deleCVE('
+
cve_id
+
')"></button></li>
\
n'
+
' </button></li>
\
n'
+
' <li class="li_right">'
+
date_month
+
'</li>
\
n'
+
' <li class="li_right">'
+
date_month
+
'</li>
\
n'
+
' <li class="li_right">'
+
software
+
'</li>
\
n'
+
' <li class="li_right">'
+
software
+
'</li>
\
n'
+
' <li class="li_right">'
+
bugtype
+
'</li>
\
n'
+
' <li class="li_right">'
+
bugtype
+
'</li>
\
n'
+
' <li class="li_long li_small_text">'
+
software
+
'</li>
\
n'
+
' <li class="li_long li_small_text">'
+
software
+
'</li>
\
n'
+
' </ul>'
);
' </ul>'
;
$
(
this
).
after
(
$h1
);
}
}
});
});
if
(
!
isFind
){
if
(
!
isFind
){
$
(
'#cve wrap'
)[
0
].
prepend
(
'<blockquote><p>'
+
year
+
'</p></blockquote>'
+
'<ul id="cveid'
+
cve_id
+
'">
\
n'
+
let
$h2
=
'<blockquote"><p>'
+
year
+
'</p></blockquote>'
+
'<ul id="cveid'
+
cve_id
+
'">
\
n'
+
' <li class="cve_big_text"><a href="'
+
url_cve
+
'" target="_blank">'
+
cve_id
+
'</a></li>
\
n'
+
' <li class="cve_big_text"><a href='
+
url_cve
+
'target="_blank">'
+
cve_id
+
'</a></li>
\
n'
+
' <li class="li_right"><button onclick="deleCVE('
+
cve_id
+
')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
\
n'
+
' <li class="li_right"><button class="dele_img" onclick="deleCVE('
+
cve_id
+
')"></button></li>
\
n'
+
' </button></li>
\
n'
+
' <li class="li_right">'
+
date_month
+
'</li>
\
n'
+
' <li class="li_right">'
+
date_month
+
'</li>
\
n'
+
' <li class="li_right">'
+
software
+
'</li>
\
n'
+
' <li class="li_right">'
+
software
+
'</li>
\
n'
+
' <li class="li_right">'
+
bugtype
+
'</li>
\
n'
+
' <li class="li_right">'
+
bugtype
+
'</li>
\
n'
+
' <li class="li_long li_small_text">'
+
software
+
'</li>
\
n'
+
' <li class="li_long li_small_text">'
+
software
+
'</li>
\
n'
+
' </ul>'
);
' </ul>'
;
$
(
'#cve .wrap'
)[
1
].
prepend
(
$h2
);
}
}
}
else
{
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
$
(
'#error_log'
).
append
(
response
[
'error'
]);
...
@@ -474,7 +450,7 @@
...
@@ -474,7 +450,7 @@
' </div>
\
n'
+
' </div>
\
n'
+
' <div>
\
n'
+
' <div>
\
n'
+
' <label for="softwore">存在于</label>
\
n'
+
' <label for="softwore">存在于</label>
\
n'
+
' <input type="text" name="softw
o
re" placeholder="xx软件/系统/..." required>
\
n'
+
' <input type="text" name="softw
a
re" placeholder="xx软件/系统/..." required>
\
n'
+
' </div>
\
n'
+
' </div>
\
n'
+
' <div>
\
n'
+
' <div>
\
n'
+
' <label for="bugtype">漏洞类型</label>
\
n'
+
' <label for="bugtype">漏洞类型</label>
\
n'
+
...
@@ -519,7 +495,7 @@
...
@@ -519,7 +495,7 @@
}
}
function
submit_edit
(){
function
submit_edit
(){
if
(
submit_what
===
'publication'
)
{
if
(
submit_what
===
'publication'
)
{
submit_pub
();
submit_pub
lication
();
}
}
if
(
submit_what
===
'cve'
){
if
(
submit_what
===
'cve'
){
submit_cve
();
submit_cve
();
...
...
Hunter_ht/hunter/views.py
View file @
9fbad193
...
@@ -149,7 +149,7 @@ def user(request, user_id):
...
@@ -149,7 +149,7 @@ def user(request, user_id):
username
=
usr
.
name
username
=
usr
.
name
u
=
{
'userID'
:
user_id
,
'name'
:
username
}
u
=
{
'userID'
:
user_id
,
'name'
:
username
}
my_publication_year_list
=
{}
my_publication_year_list
=
{}
pub_ids
=
PubToUser
.
objects
.
filter
(
user
name
=
username
)
.
all
()
.
values
(
"pubID"
)
pub_ids
=
PubToUser
.
objects
.
filter
(
user
ID
=
user_id
)
.
all
()
.
values
(
"pubID"
)
for
pub_id
in
pub_ids
:
for
pub_id
in
pub_ids
:
print
(
pub_id
)
print
(
pub_id
)
pub
=
get_object_or_404
(
Publications
,
pk
=
pub_id
[
'pubID'
])
pub
=
get_object_or_404
(
Publications
,
pk
=
pub_id
[
'pubID'
])
...
@@ -195,7 +195,7 @@ def detail(request, user_id):
...
@@ -195,7 +195,7 @@ def detail(request, user_id):
usr
=
get_object_or_404
(
User
,
pk
=
user_id
)
usr
=
get_object_or_404
(
User
,
pk
=
user_id
)
username
=
usr
.
name
username
=
usr
.
name
my_publication_year_list
=
{}
my_publication_year_list
=
{}
pub_ids
=
PubToUser
.
objects
.
filter
(
user
name
=
username
)
.
all
()
.
values
(
"pubID"
)
pub_ids
=
PubToUser
.
objects
.
filter
(
user
ID
=
user_id
)
.
all
()
.
values
(
"pubID"
)
for
pub_id
in
pub_ids
:
for
pub_id
in
pub_ids
:
pub
=
get_object_or_404
(
Publications
,
pk
=
pub_id
[
'pubID'
])
pub
=
get_object_or_404
(
Publications
,
pk
=
pub_id
[
'pubID'
])
year
=
str
(
pub
.
date
)[
0
:
4
]
year
=
str
(
pub
.
date
)[
0
:
4
]
...
@@ -228,7 +228,7 @@ def detail(request, user_id):
...
@@ -228,7 +228,7 @@ def detail(request, user_id):
my_article_year_list
[
year
]
=
[
art
]
my_article_year_list
[
year
]
=
[
art
]
context
=
{
context
=
{
'user'
:
usr
,
'user'
:
usr
,
'art_year_list'
:
my_article_year_list
,
'art_year_list'
:
my_article_year_list
,
'publication_year_list'
:
my_publication_year_list
,
'publication_year_list'
:
my_publication_year_list
,
'cve_year_list'
:
my_cve_year_list
,
'cve_year_list'
:
my_cve_year_list
,
}
}
...
@@ -376,11 +376,43 @@ def add_publication(request):
...
@@ -376,11 +376,43 @@ def add_publication(request):
authorArr
=
authors
.
split
(
','
)
authorArr
=
authors
.
split
(
','
)
print
(
authorArr
)
print
(
authorArr
)
for
author
in
authorArr
:
for
author
in
authorArr
:
try
:
users_list
=
User
.
objects
.
all
()
.
values
(
'name'
)
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
)
user_list
=
[]
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
for
user
in
users_list
:
except
ProgrammingError
as
e
:
user_list
.
append
(
user
[
'name'
])
return
JsonResponse
({
"message"
:
0
})
author
=
str
(
author
)
.
lower
()
.
strip
()
if
' '
in
author
:
author_version1
=
author
.
replace
(
' '
,
''
)
author_version2
=
author
.
split
(
' '
)[
1
]
+
str
(
author
)
.
lower
()
.
strip
()
.
split
(
' '
)[
0
]
else
:
author_version1
=
author
.
replace
(
' '
,
''
)
author_version2
=
author
print
(
user_list
)
print
(
author_version1
)
print
(
author_version2
)
if
author_version1
in
user_list
:
userID
=
User
.
objects
.
filter
(
name
=
author_version1
)
.
values
(
'userID'
)[
0
][
'userID'
]
try
:
print
(
"测试:LIU Yingying"
)
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
,
userID
=
userID
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
else
:
if
author_version2
in
user_list
:
print
(
"测试:Yingying LIU"
)
userID
=
User
.
objects
.
filter
(
name
=
author_version2
)
.
values
(
'userID'
)[
0
][
'userID'
]
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
,
userID
=
userID
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
else
:
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
# message["warning"] = "上传成功"
# message["warning"] = "上传成功"
# return HttpResponse(json.dumps(message), content_type='application/json')
# return HttpResponse(json.dumps(message), content_type='application/json')
return
response
return
response
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment