📄 date_field.jsp
字号:
<%@ page language="java" %><%@ page import="org.jahia.data.*" %><%@ page import="org.jahia.data.fields.*" %><%@ page import="org.jahia.params.*" %><%@ page import="org.jahia.services.*" %><%@ page import="org.jahia.services.pages.*" %><%@ page import="org.jahia.registries.*" %><%@ page import="java.util.*" %><% HashMap engineMap = (HashMap) request.getAttribute( "org.jahia.engines.EngineHashMap" ); JahiaField theField = (JahiaField) engineMap.get( "theField" ); String engineUrl = (String) engineMap.get( "engineUrl" ); String dataSourceConnectUrl= (String) engineMap.get( "dataSourceConnectUrl" ); String dataSourceIDUrl = (String) engineMap.get( "dataSourceIDUrl" ); String localSwitchUrl = (String) engineMap.get( "localSwitchUrl" ); ParamBean jParams = (ParamBean) engineMap.get( "jParams" ); String theURL = (String) jParams.settings().getJahiaEnginesHttpPath(); int pageID = theField.getPageID(); JahiaPage thePage = ServicesRegistry.getInstance().getJahiaPageService().lookupPage( pageID ); String defValue = theField.getDefinition().getDefaultValue(thePage.getPageTemplateID()); String userAgent = request.getHeader( "user-agent" );%><SCRIPT type="text/javascript" src="<%=theURL%>/jahiatools/javascript/dynapi.js"></SCRIPT><SCRIPT type="text/javascript" src="<%=theURL%>/jahiatools/javascript/calendar.js"></SCRIPT><SCRIPT type="text/javascript"><!--DynAPI.setLibraryPath('<%=theURL%>/jahiatools/javascript/lib/');DynAPI.include('dynapi.api.*');//--></SCRIPT><SCRIPT type="text/javascript"><!--var ViewCalendarBG;var weekend = [0,6];var weekendColor = "#e0e0e0";var fontface = "Verdana";var fontsize = 2;var gNow = new Date();var gItem;var gFormat;var gDay = gNow.getDate();var gHH = "00";var gMM = "00";DynAPI.onLoad = function() { if (document.layers) { ViewCalendarBG = new DynLayer(null,179,184,250,158,'#4D4E6D'); } else if (parseInt(navigator.appVersion) == 5) { ViewCalendarBG = new DynLayer(null,179,190,250,158,'#4D4E6D'); } else { ViewCalendarBG = new DynLayer(null,175,190,250,158,'#4D4E6D'); } DynAPI.document.addChild(ViewCalendarBG);<% String DateFormat = "dd month yyyy"; if (defValue.toUpperCase().indexOf("JAHIA_MASKTYPE") == -1) { if (defValue != null && defValue.indexOf("[") != -1) { int startStr = defValue.indexOf("[") + 1; int endStr = defValue.indexOf("]"); DateFormat = defValue.substring(startStr,endStr); } }%> show_calendar('mainForm.datebox','','','<%=DateFormat%>'); document.mainForm.dateYear.value = gNow.getFullYear(); document.mainForm.dateMonth.selectedIndex = gNow.getMonth();}function setValue(txt) { document.mainForm.datebox.value = txt; var UTC = Date.UTC(document.mainForm.dateYear.value, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, gDay, gHH, gMM, 0, 0); document.mainForm.elements["_<%=theField.getID()%>"].value = UTC; document.mainForm.elements["_Str<%=theField.getID()%>"].value = txt;}//--></SCRIPT><TABLE width="250" border="1" cellpadding="5" cellspacing="0" bgcolor="#4D4E6D" bordercolor="#B3D9FF"><TR> <TD><table height="20" border="0" cellspacing="0" cellpadding="0"><tr><td height="20"><font face="Verdana, Arial, Helvetica, sans-serif" color="#B3D9FF" size="1"><b>Date :</b></font></td><td height="20"><img src="<%=theURL%>/jahiatools/images/pix.gif" border="0" width="40" height="20"></td><td height="20" class="input"><select class="input" name="dateMonth" onchange="Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);"><option value="0">January</option><option value="1">February</option><option value="2">March</option><option value="3">April</option><option value="4">May</option><option value="5">June</option><option value="6">July</option><option value="7">August</option><option value="8">September</option><option value="9">October</option><option value="10">November</option><option value="11">December</option></select></td><td height="20"> </td><td height="20"><input class="input" type="text" name="dateYear" size="4" value="" onchange="Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);" onkeyup="Build(gItem, document.mainForm.dateMonth.value, document.mainForm.dateYear.value, gFormat);"></td><td height="20"><img align="top" name="updown" src="<%=theURL%>/jahiatools/images/updown.gif" width="16" height="20" border="0" usemap="#Map"><map name="Map"><area onClick="document.mainForm.dateYear.value = (document.mainForm.dateYear.value - -1); Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);" onmousedown="document.updown.src='<%=theURL%>/jahiatools/images/updown_up.gif';" onmouseup="document.updown.src='<%=theURL%>/jahiatools/images/updown.gif';" onmouseout="document.updown.src='<%=theURL%>/jahiatools/images/updown.gif';" shape="rect" coords="-1,-3,67,11" href="#"><area onClick="document.mainForm.dateYear.value = (document.mainForm.dateYear.value - 1); Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);" onmousedown="document.updown.src='<%=theURL%>/jahiatools/images/updown_down.gif';" onmouseup="document.updown.src='<%=theURL%>/jahiatools/images/updown.gif';" onmouseout="document.updown.src='<%=theURL%>/jahiatools/images/updown.gif';" shape="rect" coords="-2,10,80,78" href="#"></map></td></tr></table><img src="<%=theURL%>/jahiatools/images/pix.gif" border="0" width="252" height="165"></td></tr><% if (DateFormat.toUpperCase().indexOf("HH:MM") != -1) { %><tr><td height="20"><table height="20" border="0" cellspacing="0" cellpadding="0"><tr><td height="20"><font face="Verdana, Arial, Helvetica, sans-serif" color="#B3D9FF" size="1"><b>Time :</b></font></td><td height="20"><img src="<%=theURL%>/jahiatools/images/pix.gif" border="0" width="46" height="20"></td><td height="20" class="input"><select class="input" name="timeHours" onChange="gHH = document.mainForm.timeHours.options[document.mainForm.timeHours.selectedIndex].value; Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);"><option value="00" selected>00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select></td><td height="20"> </td><td height="20" class="input"><select class="input" name="timeMinutes" onChange="gMM = document.mainForm.timeMinutes.options[document.mainForm.timeMinutes.selectedIndex].value; Build(gItem, document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedIndex].value, document.mainForm.dateYear.value, gFormat);"><option value="00" selected>00</option><option value="05">05</option><option value="10">10</option><option value="15">15</option><option value="20">20</option><option value="25">25</option><option value="30">30</option><option value="35">35</option><option value="40">40</option><option value="45">45</option><option value="50">50</option><option value="55">55</option></select></td></tr></table></td></tr><% } %><tr><% String theOldField = theField.getValue(); String theOldField_long = (String)theField.getObject(); String theNewField = ""; String strToRemove[] = {"<JAHIA", "_CALENDAR"}; for (int i = 0; i < strToRemove.length; i++) { String upperCaseField = theOldField.toUpperCase(); int index = upperCaseField.indexOf(strToRemove[i]); if (index != -1) { theNewField = theOldField.substring(0, index) + theOldField.substring(index + strToRemove[i].length(), theOldField.length()); theOldField = theNewField; } } if (theOldField.indexOf("[") != -1) { int startStr = theOldField.indexOf("["); int endStr = theOldField.indexOf("]>") + 2; theOldField = theOldField.substring(0,startStr) + theOldField.substring(endStr,theOldField.length()); } int textSize = 17; if (userAgent != null) { if (userAgent.indexOf( "MSIE" ) != -1) { textSize = 26; } else if (userAgent.indexOf( "Mozilla/5" ) != -1) { textSize = 26; } }%><td height="20"><font face="Verdana, Arial, Helvetica, sans-serif" color="#B3D9FF" size="1"><b>Formated Date : </b> <input class="input" type="text" name="datebox" size="<%=textSize%>" value="<%=theOldField%>" onChange="setValue(document.mainForm.datebox.value)" disabled> <input type="hidden" name="_<%=theField.getID()%>" value="<%=theOldField_long%>"> <input type="hidden" name="_Str<%=theField.getID()%>" value="<%=theOldField%>"></font></td></tr></table><SCRIPT type="text/javascript"><!--function check() { return true; }// --></SCRIPT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -