openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit 8807b6a25a8500bdfb31b4da9a0ccb0c93688c90
parent f5b8cb332a731aba1d6ad38ef3ccc6ff02b981d6
Author: Jan Dankert <develop@jandankert.de>
Date:   Fri, 10 Apr 2020 00:25:40 +0200

Fix: The server ping must call the correct JQuery 'getJSON()'-method.

Diffstat:
modules/cms/ui/themes/default/production/combined.min.js | 2+-
modules/cms/ui/themes/default/script/openrat/workbench.js | 2+-
modules/cms/ui/themes/default/script/openrat/workbench.min.js | 2+-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/cms/ui/themes/default/production/combined.min.js b/modules/cms/ui/themes/default/production/combined.min.js @@ -10829,7 +10829,7 @@ else{};return url}}; else{let url='./api/';this.setLoadStatus(!0);url+='';data.output='json';if(e==modes.closeAfterSubmit)this.close();let form=this;$.ajax({'type':'POST',url:url,data:data,success:function(t,s,o){form.setLoadStatus(!1);$(status).remove();form.doResponse(t,s,form.element,function(){if(e==modes.closeAfterSuccess){form.close();$(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(form.element).data('afterSuccess');let async=$(form.element).data('async');if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.Workbench.reloadAll()}} else{if(async);else Openrat.Workbench.reloadViews()}})},error:function(e,t,s){form.setLoadStatus(!1);$(status).remove();try{let error=jQuery.parseJSON(e.responseText);Openrat.Workbench.notify('','','error',error.error,[error.description])}catch(o){let msg=e.responseText;Openrat.Workbench.notify('','','error','Server Error',[msg])}}});$(form.element).fadeIn()}};this.doResponse=function(e,t,s,onSuccess=$.noop){if(t!='success'){alert('Server error: '+t);return};let form=this;$.each(e['notices'],function(t,e){let notifyBrowser=$(s).data('async');Openrat.Workbench.notify(e.type,e.name,e.status,e.text,e.log,notifyBrowser);if(e.status=='ok'){onSuccess();Openrat.Workbench.dataChangedHandler.fire()} else{}});$.each(e['errors'],function(e,t){$('input[name='+t+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(e.control.redirect)window.location.href=e.control.redirect}}; -/* ./modules/cms/ui/themes/default/script/openrat/workbench.min.js */;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.json(Openrat.View.createUrl('profile','ping',0,{},!0));pingPromise.fail(function(){console.warn('The server ping has failed.')})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);this.afterNewActionHandler.fire()};this.afterNewActionHandler=$.Callbacks();this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#editor').attr('data-extra',JSON.stringify(i));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view.view-loader, #workbench .view.view-static'));this.loadUserStyle();this.loadLanguage();this.loadUISettings()};this.loadUserStyle=function(){let url=Openrat.View.createUrl('profile','userinfo',0,{},!0);$.getJSON(url,function(t){let style=t.output['style'];Openrat.Workbench.setUserStyle(style);let color=t.output['theme-color'];Openrat.Workbench.setThemeColor(color)})};this.settings={};this.language={};this.loadLanguage=function(){let url=Openrat.View.createUrl('profile','language',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.language=t.output.language})};this.loadUISettings=function(){let url=Openrat.View.createUrl('profile','uisettings',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.settings=t.output.settings.settings})};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var e=$('html'),i=e.attr('class').split(/\s+/);$.each(i,function(t,i){if(i.startsWith('theme-')){e.removeClass(i)}});e.addClass('theme-'+t.toLowerCase())};this.setThemeColor=function(t){$('#theme-color').attr('content',t)};let notifyBrowser=function(t){if(!('Notification' in window)){return} +/* ./modules/cms/ui/themes/default/script/openrat/workbench.min.js */;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.getJSON(Openrat.View.createUrl('profile','ping',0,{},!0));pingPromise.fail(function(){console.warn('The server ping has failed.')})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);this.afterNewActionHandler.fire()};this.afterNewActionHandler=$.Callbacks();this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#editor').attr('data-extra',JSON.stringify(i));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view.view-loader, #workbench .view.view-static'));this.loadUserStyle();this.loadLanguage();this.loadUISettings()};this.loadUserStyle=function(){let url=Openrat.View.createUrl('profile','userinfo',0,{},!0);$.getJSON(url,function(t){let style=t.output['style'];Openrat.Workbench.setUserStyle(style);let color=t.output['theme-color'];Openrat.Workbench.setThemeColor(color)})};this.settings={};this.language={};this.loadLanguage=function(){let url=Openrat.View.createUrl('profile','language',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.language=t.output.language})};this.loadUISettings=function(){let url=Openrat.View.createUrl('profile','uisettings',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.settings=t.output.settings.settings})};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var e=$('html'),i=e.attr('class').split(/\s+/);$.each(i,function(t,i){if(i.startsWith('theme-')){e.removeClass(i)}});e.addClass('theme-'+t.toLowerCase())};this.setThemeColor=function(t){$('#theme-color').attr('content',t)};let notifyBrowser=function(t){if(!('Notification' in window)){return} else if(Notification.permission==='granted'){let notification=new Notification(t)} else if(Notification.permission!=='denied'){Notification.requestPermission(function(e){if(e==='granted'){let notification=new Notification(t)}})}};this.notify=function(t,i,e,o,log=[],notifyTheBrowser=!1){if(notifyTheBrowser)notifyBrowser(o);let notice=$('<div class="notice '+e+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);let id=0;if(i)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+t+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+t+'"></i> '+i+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(o)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(e=='ok')timeout=20;if(e=='info')timeout=60;if(e=='warning')timeout=120;if(e=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)};this.dataChangedHandler=$.Callbacks();this.dataChangedHandler.add(function(){if(popupWindow!==undefined)popupWindow.location.reload()});this.afterViewLoadedHandler=$.Callbacks();let afterViewFunctions=[];this.registerAfterViewLoaded=function(t){afterViewFunctions.push(t)};this.afterViewLoaded=function(t){afterViewFunctions.forEach(function(e){e(t)})}}; /* ./modules/cms/ui/themes/default/script/openrat/navigator.min.js */;Openrat.Navigator=new function(){'use strict';this.navigateTo=function(t){Openrat.Workbench.loadNewActionState(t)};this.navigateToNew=function(t){this.navigateTo(t);window.history.pushState(t,t.name,this.createShortUrl(t.action,t.id))};this.toActualHistory=function(t){window.history.replaceState(t,t.name,this.createShortUrl(t.action,t.id))};this.createShortUrl=function(t,i){return'./#/'+t+(i?'/'+i:'')}}; diff --git a/modules/cms/ui/themes/default/script/openrat/workbench.js b/modules/cms/ui/themes/default/script/openrat/workbench.js @@ -71,7 +71,7 @@ Openrat.Workbench = new function() */ let ping = function() { - let pingPromise = $.json( Openrat.View.createUrl('profile','ping',0, {}, true) ); + let pingPromise = $.getJSON( Openrat.View.createUrl('profile','ping',0, {}, true) ); pingPromise.fail( function() { console.warn('The server ping has failed.') diff --git a/modules/cms/ui/themes/default/script/openrat/workbench.min.js b/modules/cms/ui/themes/default/script/openrat/workbench.min.js @@ -1,3 +1,3 @@ -;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.json(Openrat.View.createUrl('profile','ping',0,{},!0));pingPromise.fail(function(){console.warn('The server ping has failed.')})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);this.afterNewActionHandler.fire()};this.afterNewActionHandler=$.Callbacks();this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#editor').attr('data-extra',JSON.stringify(i));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view.view-loader, #workbench .view.view-static'));this.loadUserStyle();this.loadLanguage();this.loadUISettings()};this.loadUserStyle=function(){let url=Openrat.View.createUrl('profile','userinfo',0,{},!0);$.getJSON(url,function(t){let style=t.output['style'];Openrat.Workbench.setUserStyle(style);let color=t.output['theme-color'];Openrat.Workbench.setThemeColor(color)})};this.settings={};this.language={};this.loadLanguage=function(){let url=Openrat.View.createUrl('profile','language',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.language=t.output.language})};this.loadUISettings=function(){let url=Openrat.View.createUrl('profile','uisettings',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.settings=t.output.settings.settings})};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var e=$('html'),i=e.attr('class').split(/\s+/);$.each(i,function(t,i){if(i.startsWith('theme-')){e.removeClass(i)}});e.addClass('theme-'+t.toLowerCase())};this.setThemeColor=function(t){$('#theme-color').attr('content',t)};let notifyBrowser=function(t){if(!('Notification' in window)){return} +;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.getJSON(Openrat.View.createUrl('profile','ping',0,{},!0));pingPromise.fail(function(){console.warn('The server ping has failed.')})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);this.afterNewActionHandler.fire()};this.afterNewActionHandler=$.Callbacks();this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#editor').attr('data-extra',JSON.stringify(i));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view.view-loader, #workbench .view.view-static'));this.loadUserStyle();this.loadLanguage();this.loadUISettings()};this.loadUserStyle=function(){let url=Openrat.View.createUrl('profile','userinfo',0,{},!0);$.getJSON(url,function(t){let style=t.output['style'];Openrat.Workbench.setUserStyle(style);let color=t.output['theme-color'];Openrat.Workbench.setThemeColor(color)})};this.settings={};this.language={};this.loadLanguage=function(){let url=Openrat.View.createUrl('profile','language',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.language=t.output.language})};this.loadUISettings=function(){let url=Openrat.View.createUrl('profile','uisettings',0,{},!0);$.getJSON(url,function(t){Openrat.Workbench.settings=t.output.settings.settings})};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var e=$('html'),i=e.attr('class').split(/\s+/);$.each(i,function(t,i){if(i.startsWith('theme-')){e.removeClass(i)}});e.addClass('theme-'+t.toLowerCase())};this.setThemeColor=function(t){$('#theme-color').attr('content',t)};let notifyBrowser=function(t){if(!('Notification' in window)){return} else if(Notification.permission==='granted'){let notification=new Notification(t)} else if(Notification.permission!=='denied'){Notification.requestPermission(function(e){if(e==='granted'){let notification=new Notification(t)}})}};this.notify=function(t,i,e,o,log=[],notifyTheBrowser=!1){if(notifyTheBrowser)notifyBrowser(o);let notice=$('<div class="notice '+e+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);let id=0;if(i)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+t+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+t+'"></i> '+i+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(o)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(e=='ok')timeout=20;if(e=='info')timeout=60;if(e=='warning')timeout=120;if(e=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)};this.dataChangedHandler=$.Callbacks();this.dataChangedHandler.add(function(){if(popupWindow!==undefined)popupWindow.location.reload()});this.afterViewLoadedHandler=$.Callbacks();let afterViewFunctions=[];this.registerAfterViewLoaded=function(t){afterViewFunctions.push(t)};this.afterViewLoaded=function(t){afterViewFunctions.forEach(function(e){e(t)})}}; \ No newline at end of file