IDEMPIERE-5137 Login page reload continuously using http (#1158)

Improve error message, change:
   This request has been blocked, the content must be served over HTTPS
by
   Direct http:// is forbidden - please use https:// instead with the SSL port used in your installation

Improve indentation of the whole script (readability)
Change EOL character to unix
This commit is contained in:
Carlos Ruiz 2022-02-04 15:42:07 +01:00 committed by GitHub
parent 68db1fd3b7
commit 497c93fc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 266 additions and 264 deletions

View File

@ -14,15 +14,14 @@ Copyright (C) 2007 Ashley G Ramdass.
<?link rel="stylesheet" type="text/css" href="css/PAPanel.css"?> <?link rel="stylesheet" type="text/css" href="css/PAPanel.css"?>
<?link rel="manifest" href="manifest.json"?> <?link rel="manifest" href="manifest.json"?>
<?style content=" <?style content="
.z-grid-header > table > tbody > tr.z-columns > th.z-column.hiddencol > .z-column-content { .z-grid-header > table > tbody > tr.z-columns > th.z-column.hiddencol > .z-column-content {
white-space: nowrap !important; white-space: nowrap !important;
text-overflow: unset !important; text-overflow: unset !important;
} }
"?> "?>
<zk> <zk>
<script><![CDATA[ <script><![CDATA[
if (window.location.protocol == 'https:') if (window.location.protocol == 'https:') {
{
zk.load("jawwa.atmosphere"); zk.load("jawwa.atmosphere");
zk.load("org.idempiere.websocket"); zk.load("org.idempiere.websocket");
@ -40,12 +39,14 @@ Copyright (C) 2007 Ashley G Ramdass.
zk.$package('id.zk'); zk.$package('id.zk');
id.zk.Extend = zk.$extends(zk.Object, {}, { id.zk.Extend = zk.$extends(zk.Object, {}, {
fakeOnchange: function (wgt) { fakeOnchange: function(wgt) {
// just sent fake event when control is textfield and value is not yet sync to server // just sent fake event when control is textfield and value is not yet sync to server
if ((wgt.$instanceof(zul.inp.Textbox) || wgt.$instanceof(zul.inp.Decimalbox)) && wgt.$n().value != wgt.getText()) if ((wgt.$instanceof(zul.inp.Textbox) || wgt.$instanceof(zul.inp.Decimalbox)) && wgt.$n().value != wgt.getText())
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange',{"value":wgt.$n().value})); zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange', {
"value": wgt.$n().value
}));
else if (zk.$import("ckez.CKeditor") != undefined && wgt.$instanceof(ckez.CKeditor)){//https://www.zkoss.org/javadoc/latest/jsdoc/_global_/zk.html#$import(_global_.String) else if (zk.$import("ckez.CKeditor") != undefined && wgt.$instanceof(ckez.CKeditor)) { //https://www.zkoss.org/javadoc/latest/jsdoc/_global_/zk.html#$import(_global_.String)
// CKEditor extend from zul.Widget not from wget zul.inp.InputWidget // CKEditor extend from zul.Widget not from wget zul.inp.InputWidget
// so some behavior is not same standard input // so some behavior is not same standard input
// this code bring from ckez.CKeditor.onBlur // this code bring from ckez.CKeditor.onBlur
@ -63,117 +64,119 @@ Copyright (C) 2007 Ashley G Ramdass.
var val = editor.getData(); var val = editor.getData();
wgt._value = val; //save for onRestore wgt._value = val; //save for onRestore
//ZKCK-16, 17 use sendAhead to make sure onChange always happens first //ZKCK-16, 17 use sendAhead to make sure onChange always happens first
wgt.fire('onChange', {value: val}); wgt.fire('onChange', {
value: val
});
editor.resetDirty(); editor.resetDirty();
} }
} }
}, },
fireOnInitEdit: function (wgt) { fireOnInitEdit: function(wgt) {
// sent even to indicate field is start edit, this event sent new value to server but now don't use this data. // sent even to indicate field is start edit, this event sent new value to server but now don't use this data.
if (wgt.$instanceof(zul.inp.Textbox)) if (wgt.$instanceof(zul.inp.Textbox))
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onInitEdit',{"value":wgt.$n().value})); zAu.send(new zk.Event(zk.Widget.$(wgt), 'onInitEdit', {
"value": wgt.$n().value
}));
} }
}); });
}); });
zk.afterLoad('zul.inp', function () { zk.afterLoad('zul.inp', function() {
// should filter out for only component inside standard window or component wish fire this event, // should filter out for only component inside standard window or component wish fire this event,
// or ever rise other event like start editting to distinguish with true onChange event // or ever rise other event like start editting to distinguish with true onChange event
zk.override(zul.inp.InputWidget.prototype, "doInput_", function (evt) { zk.override(zul.inp.InputWidget.prototype, "doInput_", function(evt) {
this.$doInput_(evt); this.$doInput_(evt);
if (this.get ("isOnStardardWindow") == 'false' || this.get ("isChangeEventWhenEditing") != true){ if (this.get("isOnStardardWindow") == 'false' || this.get("isChangeEventWhenEditing") != true) {
return; // don't waste time to check component don't lay on standard window return; // don't waste time to check component don't lay on standard window
} }
var domElemOfLayout = jq('#' + this.$n().id).closest(".adwindow-layout"); // return a array var domElemOfLayout = jq('#' + this.$n().id).closest(".adwindow-layout"); // return a array
if (domElemOfLayout.length == 0){ if (domElemOfLayout.length == 0) {
this.set ("isOnStardardWindow", "false");// next time don't waste time to check this component this.set("isOnStardardWindow", "false"); // next time don't waste time to check this component
// in case, you move this component to a standard window, please update this properties at client by javascript Widget.set () // in case, you move this component to a standard window, please update this properties at client by javascript Widget.set ()
// or at server by java function component.setWidgetOverride // or at server by java function component.setWidgetOverride
}else{ } else {
var winLayoutWg = zk.Widget.$(domElemOfLayout); var winLayoutWg = zk.Widget.$(domElemOfLayout);
if (winLayoutWg == null){ if (winLayoutWg == null) {
;// do nothing, this case rare happen because ".adwindow-layout" always is a component ; // do nothing, this case rare happen because ".adwindow-layout" always is a component
}else{ } else {
var isEditting = winLayoutWg.get ("isEditting"); var isEditting = winLayoutWg.get("isEditting");
// winLayoutWg should cache to improve perfomance // winLayoutWg should cache to improve perfomance
if (isEditting == "false"){ if (isEditting == "false") {
winLayoutWg.set ("isEditting", "true"); winLayoutWg.set("isEditting", "true");
id.zk.Extend.fireOnInitEdit (this);//fire change event to move to edit id.zk.Extend.fireOnInitEdit(this); //fire change event to move to edit
} }
} }
} }
}); });
zk.override(zk.Widget.prototype, "onAutofill", function(evt) {
zk.override(zk.Widget.prototype, "onAutofill", function (evt) { id.zk.Extend.fakeOnchange(this); //fire change event to move to edit
id.zk.Extend.fakeOnchange (this);//fire change event to move to edit
}); });
zk.override(zul.inp.Textbox.prototype, "bind_", function (dt, skipper, after) { zk.override(zul.inp.Textbox.prototype, "bind_", function(dt, skipper, after) {
if (!this.$bind_) if (!this.$bind_)
return; return;
this.$bind_(dt, skipper, after); this.$bind_(dt, skipper, after);
var txtid = this.getId() var txtid = this.getId()
if (txtid != "txtUserId" && txtid != "txtPassword" ){ if (txtid != "txtUserId" && txtid != "txtPassword") {
return; return;
} }
this.domListen_(this.$n(), "onChange", "onAutofill"); this.domListen_(this.$n(), "onChange", "onAutofill");
}); });
zk.override(zul.inp.Textbox.prototype, "unbind_", function(dt, skipper) {
zk.override(zul.inp.Textbox.prototype, "unbind_", function (dt, skipper) {
if (!this.$unbind_) if (!this.$unbind_)
return; return;
this.$unbind_(dt, skipper); this.$unbind_(dt, skipper);
var txtid = this.getId() var txtid = this.getId()
if (txtid != "txtUserId" && txtid != "txtPassword" ){ if (txtid != "txtUserId" && txtid != "txtPassword") {
return; return;
} }
this.domUnlisten_(this.$n(), "onChange", "onAutofill"); //unlisten this.domUnlisten_(this.$n(), "onChange", "onAutofill"); //unlisten
}); });
zk.override(zul.inp.Combobox.prototype, "doKeyDown_", function (evt) { zk.override(zul.inp.Combobox.prototype, "doKeyDown_", function(evt) {
// avoid confuse of idempiere shortcut key and function key of combobox // avoid confuse of idempiere shortcut key and function key of combobox
if ( (evt.altKey || evt.ctrlKey || evt.shiftKey) && if ((evt.altKey || evt.ctrlKey || evt.shiftKey) &&
(evt.keyCode == 33 || evt.keyCode == 34 || evt.keyCode == 35 || evt.keyCode == 36 || evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 37 || evt.keyCode == 39) ){//page up | page down | end | home | up | down | left | write (evt.keyCode == 33 || evt.keyCode == 34 || evt.keyCode == 35 || evt.keyCode == 36 || evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 37 || evt.keyCode == 39)) { //page up | page down | end | home | up | down | left | write
if (this.isOpen())//close drop down if already open. it will let combobox select current item, it's consistent with lost focus if (this.isOpen()) //close drop down if already open. it will let combobox select current item, it's consistent with lost focus
this.close({sendOnOpen: true}); this.close({
sendOnOpen: true
});
return; return;
// TODO:current idempiere use alt + down/up to move child parrent tab, but combobox also use it to open, close drop down // TODO:current idempiere use alt + down/up to move child parrent tab, but combobox also use it to open, close drop down
// at the moment, idempiere shortcut is more useful, so just get it work // at the moment, idempiere shortcut is more useful, so just get it work
}else{ } else {
this.$doKeyDown_(evt); this.$doKeyDown_(evt);
} }
}); });
}); });
zk.afterLoad('zul.mesh', function () { zk.afterLoad('zul.mesh', function() {
zk.override(zul.mesh.Paging.prototype, "bind_", function () { zk.override(zul.mesh.Paging.prototype, "bind_", function() {
this.$bind_.apply(this, arguments); this.$bind_.apply(this, arguments);
if (this._totalSize == 0x7fffffff){ if (this._totalSize == 0x7fffffff) {
jq(".z-paging-text", this).text(" / ?"); jq(".z-paging-text", this).text(" / ?");
} }
}); });
zk.override(zul.mesh.Paging.prototype, "infoText_", zk.override(zul.mesh.Paging.prototype, "infoText_",
function () { function() {
//this.$infoText_.apply(this, arguments); //this.$infoText_.apply(this, arguments);
var acp = this._activePage, var acp = this._activePage,
psz = this._pageSize, psz = this._pageSize,
@ -192,8 +195,8 @@ Copyright (C) 2007 Ashley G Ramdass.
}); });
}); });
zk.afterLoad('calendar', function () { zk.afterLoad('calendar', function() {
zk.override(calendar.Event.prototype, "calculate_", function () { zk.override(calendar.Event.prototype, "calculate_", function() {
if (typeof this.event === "undefined" || this.event == null) { if (typeof this.event === "undefined" || this.event == null) {
return; return;
} }
@ -211,7 +214,7 @@ Copyright (C) 2007 Ashley G Ramdass.
this.$unbind_.apply(this, arguments); this.$unbind_.apply(this, arguments);
}); });
zk.override(calendar.CalendarsMonth.prototype, "onSize", function () { zk.override(calendar.CalendarsMonth.prototype, "onSize", function() {
var cmp = this.$n(); var cmp = this.$n();
if (typeof cmp === "undefined" || cmp == null) { if (typeof cmp === "undefined" || cmp == null) {
return; return;
@ -219,7 +222,7 @@ Copyright (C) 2007 Ashley G Ramdass.
this.$onSize.apply(this, arguments); this.$onSize.apply(this, arguments);
}); });
zk.override(calendar.CalendarsDefault.prototype, "onSize", function () { zk.override(calendar.CalendarsDefault.prototype, "onSize", function() {
var cmp = this.$n(); var cmp = this.$n();
if (typeof cmp === "undefined" || cmp == null) { if (typeof cmp === "undefined" || cmp == null) {
return; return;
@ -228,7 +231,7 @@ Copyright (C) 2007 Ashley G Ramdass.
}); });
}); });
zk.afterLoad("zul.mesh", function () { zk.afterLoad("zul.mesh", function() {
var _xFrozen = {}; var _xFrozen = {};
zk.override(zul.mesh.Frozen.prototype, _xFrozen, { zk.override(zul.mesh.Frozen.prototype, _xFrozen, {
_doScrollNow: function() { _doScrollNow: function() {
@ -252,13 +255,12 @@ Copyright (C) 2007 Ashley G Ramdass.
}); });
}); });
} //window.location.protocol check } //window.location.protocol check
else else {
{ alert("Direct http:// is forbidden - please use https:// instead with the SSL port used in your installation");
alert("This request has been blocked, the content must be served over HTTPS"); }
} ]]>
]]> </script>
</script> <include src="${themePreference}" if="${execution.getScheme() == 'https'}"/>
<include src="${themePreference}" if="${execution.getScheme() == 'https'}"/> <window use="org.adempiere.webui.AdempiereWebUI" if="${execution.getScheme() == 'https'}"/>
<window use="org.adempiere.webui.AdempiereWebUI" if="${execution.getScheme() == 'https'}"/>
</zk> </zk>