25.05.2017, 11:42
|
#8
|
Участник
Регистрация: 29.11.2001
Адрес: Москва
|
Спасибо Ivanhoe.
Да, для мини-сайта, который предназначен для браузеров ТСД, вполне оправдан подход "никаких внешних библиотек".
Да, согласен, что в акс7 такой инструмент уже не нужен.
Цитата:
Сообщение от Ivanhoe
Мини-сайт появился в AX 2012 R3 для ТСД. Ниже исходник страницы с логином.
PHP код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1"><title> Warehouse Mobile Devices Portal </title><meta name="viewport" content="width=device-width" /><link href="/Content/CSS/RFCSS/defaultrf.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
var submitted = false;
// all functions here that you want to run when the page is loaded function addListener(element, type, expression) {
"use strict";
element.attachEvent(type, expression); }
function attachOnFocus() {
"use strict;"
var elm, f;
elm = document.getElementById('UserId');
f = Function('HandleOnFocusEvents(0);');
addListener(elm, 'onfocus', f);
elm = document.getElementById('Password');
f = Function('HandleOnFocusEvents(1);');
addListener(elm, 'onfocus', f);
elm = document.getElementById('Login');
f = Function('HandleOnFocusEvents(2);');
addListener(elm, 'onfocus', f);
}
function buildOnFocusArray() {
"use strict";
var focusme = [];
focusme[0] = "UserId";
focusme[1] = "Password";
focusme[2] = "Login";
return focusme; }
function buildOnKeyDownArray() {
"use strict";
var menu = [];
return menu;
}
function submitForm(btnId) {
"use strict";
var btn = document.getElementById(btnId);
if (btn !== null || btnId === 'ENTERPRESSED') {
if (!submitted) { submitted = true;
if (btnId !== 'ENTERPRESSED') {
var clickedButton = document.getElementById('ClickedButton');
// if clicked button is empty, we know it was submitted by default button var type = btn.getAttribute('type'); if (type === 'button') { clickedButton.value = btn.id; } else { clickedButton.value = ''; } }
document.forms[0].submit(); } }
return false; }
function determineButtonClick(element) {
"use strict";
// we know this scenario is valid because there is a menu
submitForm(element.id); }
function focusFirstEnabledInput() {
"use strict";
// get all form elements var elms, elmFocused; elms = document.forms[0].elements; elmFocused = false;
var i, j, elm, type, toFocusElms, toFocusElm; for (i = 0; i < elms.length; i += 1) {
// set focus on first enabled empty text field elm = elms[i];
// ensure it doesn't have a selectedtac index as we won't be setting focus to textfields // trying to get the type on a select in Intermec fails because it doesn't exist... // only select has a selectedIndex if (elm.selectedIndex === undefined) {
type = elm.getAttribute('type');
if ((type === 'text' || type === 'password') && !elm.disabled && elm.style.display !== 'none' && elm.value === '') {
// update the current focus hidden field then set focus
toFocusElms = buildOnFocusArray();
for (j = 0; j < toFocusElms.length; j += 1) {
toFocusElm = toFocusElms[j];
if (elm.id === toFocusElm) {
document.getElementById('CurrentFocus').value = j; } }
elmFocused = true; elm.focus(); return false; } } }
// if no elm was focused, show the hidden focus element and set focus inorder to allow for submit // if no elm was focused and its not menu, show the hidden focus element and set focus inorder to allow for submit if (!elmFocused) { var isMenu = document.getElementById('IsMenu').value;
if (isMenu !== 'True') {
var hidfocus = document.getElementById('hiddenfocus'); hidfocus.style.display = 'block'; hidfocus.focus();
} } }
function handleTab() {
"use strict";
var cachedFocusId = document.getElementById('CurrentFocus');
var currentFocusId = parseInt(cachedFocusId.value, 10);
var focusElms = buildOnFocusArray();
var nextFocusId = (focusElms.length - 1) === currentFocusId ? 0 : (currentFocusId + 1);
cachedFocusId.value = nextFocusId;
var elmToFocus = focusElms[nextFocusId];
var etf = document.getElementById(elmToFocus);
etf.focus(); }
var firstFocusEvent = true;
function handleOnFocusEvents(key) {
"use strict";
// only want this to run after the first time as we are already handling that if (!firstFocusEvent) {
var elmsToFocus = buildOnFocusArray();
if (elmsToFocus.length > 0) {
var elmId = elmsToFocus[key];
var elm = document.getElementById(elmId);
// update the current focus hidden field then set focus document.getElementById('CurrentFocus').value = key;
elm.focus(); } }
firstFocusEvent = false; }
function handleOnKeyDown(e) {
"use strict";
var kd = buildOnKeyDownArray(); var key = e.keyCode || e.which;
var elmToSubmit;
if (key === 13) { elmToSubmit = 'ENTERPRESSED'; } else { // grab element out of the array elmToSubmit = kd[key]; }
// if we have a valid key, example function key, prevent the default if (elmToSubmit !== undefined) { if (e.stopPropagation) { // ff e.stopPropagation(); e.preventDefault(); } else { // ie e.returnValue = false; e.keyCode = 0;
} }
submitForm(elmToSubmit);
return false; }
function iBKeyHandler(id) {
"use strict";
submitForm(id); }
function submitFormBarcode() {
"use strict";
submitForm('ENTERPRESSED'); }
document.onkeydown = function(e) {
"use strict";
e = e || event;
handleOnKeyDown(e); }
function init() {
"use strict";
focusFirstEnabledInput(); }
</script>
<!-- not used everywhere (used @ forney) <meta http-equiv="IB_UPCA_Reencode_As_EAN13" content="False" /> --> <meta http-equiv="IB_Scanner" content="Enabled" /><meta http-equiv="IB_ScannerNavigate" content="Javascript: submitFormBarcode();" /><meta http-equiv="IB_OnKey13" content="Javascript: submitForm('ENTERPRESSED')" /><meta http-equiv="IB_OnKey9" content="Javascript: handleTab()" /></head> <body onload="init();"> <div class="whsMainRFWrap"> <form action="/Execute/Display" class="whsMainRFForm" method="post" onsubmit="return submitForm('ENTERPRESSED')"><input id="ClickedButton" name="ClickedButton" type="hidden" value="" /> <input id="IsMenu" name="IsMenu" type="hidden" value="False" /> <input id="SessionGuid" name="SessionGuid" type="hidden" value="4e01cfb2-6115-4850-bc19-952bfac6fc97" />
<input name="__RequestVerificationToken" type="hidden" value="rGh5T4oy/CpYHvAG9KA/u0afgWZhUOYtoyvz5EMMtc9LMBOb0Gw/nz/lKlilCCElhlTwl07NdB4P61rVSFS38FDtWj8udXk+H3QEL7ZOwH/jOc9hu7VrOG2bKjv9DP6oh2E/uEEjd0pGoaaNLHOOwA==" />
<table class="whsMainRFTable">
<tr class="whsMainRFTableRow"> <td colspan="2" class="whsMainRFTableCell"> <label class="whsLabel" id="SignInLbl" style="color:#000000;">Sign in to AX</label> </td> </tr> <tr class="whsMainRFTableRow"> <td class="whsMainRFTableCell"> <label class="whsTextLabel" for="UserId">User ID</label> </td> <td class="whsMainRFTableCell"> <input class="whsText" type="text" name="UserId" id="UserId" value="" /> </td> </tr> <tr class="whsMainRFTableRow"> <td class="whsMainRFTableCell"> <label class="whsPasswordLabel" for="Password">Password</label> </td> <td class="whsMainRFTableCell"> <input class="whsPassword" type="password" name="Password" id="Password" value="" maxlength="20" /> </td> </tr> <tr class="whsMainRFTableRow"> <td colspan="2" class="whsMainRFTableCell"> <input class="whsBtn whsBtnDefault whsBtnMulti" type="submit" name="WHSButton" id="Login" value="Login" /> </td> </tr>
</table>
<!-- below is to ensure form submit on mobile ie when all input fields are disabled/hidden/don't exist. -->
<input type="text" id="hiddenfocus" style="display: none" />
<!-- end form submit -->
</form> <input type="hidden" id="CurrentFocus" name="CurrentFocus" /> </div> </body> </html>
|
|