Skip to content

Commit

Permalink
#1 initial creation
Browse files Browse the repository at this point in the history
Clean up of dependent resources for floria and jslib which are not
loading properly when just linked.

Additional cleanups
  • Loading branch information
ldhasson-hmhn committed Jan 18, 2023
1 parent dd0a294 commit 9ddba87
Show file tree
Hide file tree
Showing 79 changed files with 11,086 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</natures>
<linkedResources>
<link>
<name>WebContent/static/floria.v2.0</name>
<name>WebContent/static/floria.v2.0.OLD</name>
<type>2</type>
<locationURI>PARENT-2-PROJECT_LOC/CapsicoBase/CapsicoWebStatic/WebContent/floria.v2.0</locationURI>
</link>
Expand Down
4 changes: 2 additions & 2 deletions WebContent/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
packages: [ { name: "dojo", location: "dojo-release-1.16.4/dojo" },
{ name: "dijit", location: "dojo-release-1.16.4/dijit" },
{ name: "dojox", location: "dojo-release-1.16.4/dojox" },
{ name: "floria", location: "floria" },
{ name: "floria", location: "floria.v2.0" },
{ name: "js", location: "js" },
{ name: "json", location: "json" }
]
};
window.CapsicoDojoSimpleLibJS = "floria/dojoSimple";
window.CapsicoDojoSimpleLibJS = "floria.v2.0/dojoSimple";
</SCRIPT>
<script src="/static/dojo-release-1.16.4/dojo/dojo.js"></script>
<SCRIPT type="module">
Expand Down
78 changes: 78 additions & 0 deletions WebContent/static/floria.v2.0/minitours.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"use strict";

// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Date extensions
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

define(["floria/textutil", "floria/superdom", "jslibs/popper", "floria/collections"], function(FloriaText, SuperDOM, Popper, FloriaCollections)
{

var dojoSimple = require(CapsicoDojoSimpleLibJS)

var x = {};


function doTooltip(tourItem)
{
var node = document.createElement("SPAN");
node.id = "TOUR_"+tourItem.tour;
node.classList.add("activeTourItem");
node.innerHTML = `<B>Step ${tourItem.seq}</B><BR>
${tourItem.txt}<BR>
<BR>
`;

SuperDOM.insertAfter(tourItem.element, node);
}


x.run = function(name)
{
var elements = document.querySelectorAll('[data-tour]');
var tourItems = [];
elements.forEach(function(e) {
var val = e.dataset.tour;
val = val.split("`");
if (val.length == 3 && val[0] == name)
tourItems.push({element: e, tour:val[0], seq:val[1], text:val[2]});
else
console.log("Element "+e.id+" defined a data-tour attribute '"+e.dataset.tour+"' which is not well formed.");
});

tourItems.sort(function(a, b) { return SuperDOM.compareValues(a.seq, b.seq); });

doTooltip(tourItems[0]);
}

x.isPageTourEnabled = function()
{

}


function start(data)
{

}

x.startTour = function(tourName, jsonUrl)
{
dojoSimple.ajaxUrl(jsonUrl, "GET", null,
function(data) {
start(data);
},
function() {
alert("The tour '"+tourName+"' is not available for this page.")
}
);

}

x.endTour = function()
{

}

return x;

});
100 changes: 100 additions & 0 deletions WebContent/static/floria.v2.0/module-ajax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use strict';

import { FloriaDOM } from "./module-dom.js";
import { DojoSimple } from "./module-dojosimple.js";

export var FloriaAjax = {

ajaxUrl: function(url, method, errorMsg, successFunc, errorFunc, postContents, timeout, handleAs)
{
if (postContents != null)
{
if (method != 'POST')
return FloriaDOM.alertThrow("Error: you cannot post data in a non POST ajax request");
url = url + "?" + (FloriaDOM.isObject(postContents) == true ? FloriaDOM.makeUrlParams(postContents) : postContents);
}


if (handleAs == null)
handleAs = 'json';

// Is this used at all anymore?????
if (handleAs != 'json')
{
alert("AjaxRequest.ajaxUrl called with handleAs: '"+handleAs+"'. Check consle logs for stack trace.\n\nThis was deprecated!");
console.trace();
return;
}

let xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.timeout = timeout
xhr.setRequestHeader("Content-type", "application/"+(handleAs||'json')+"; charset=utf-8");
if (handleAs==null||handleAs=='json')
xhr.responseType = 'json';
xhr.onload = function() {
try
{
if (xhr.getResponseHeader("x-wanda-canceler") == "1")
alert("FYI THAT YOU CANCELED ANOTHER REQUEST!\n\nYou (or another user on the same account) was running a request you interrupted.");

let data = xhr.response;
if (data?.code != 200 || xhr.status != 200)
return xhr.onerror({code: data?.code||xhr.status, message : data?.msg||xhr.statusText, errors: data?.errors, type: data?.type });
if (data == null)
throw ("An error occurred: no data for " + FloriaDOM.truncateUrl(url));
if (data.code == undefined)
throw ("An error occurred: invalid JSON data for " + FloriaDOM.truncateUrl(url));

if (data.perfMessage != null)
setTimeout(function(){ alert(data.perfMessage); }, 10);
if (successFunc != null)
successFunc(data.data);
}
catch (e)
{
FloriaDOM.alertException(e, "Caught exception in AjaxRequest.ajaxUrl.onload()\nUrl:"+url+"\nFrom: "+successFunc+"\nError: ", true);
}
};
xhr.onerror = function(error) { // only triggers if the request couldn't be made at all
console.error("ajaxUrl error: ", error);
try
{
if (error != null && error.status||error.code == 401 && DojoSimple.PopupLogin.isAuthPassthrough(url) == false)
{
// return alert("NO ACL!");
return DojoSimple.PopupLogin.show(true, function() { FloriaAjax.ajaxUrl(url, method, errorMsg, successFunc, errorFunc, postContents, timeout, handleAs) });
}
else
{
if (error.type == 'CANCELED')
alert("YOUR REQUEST WAS CANCELED!\n\nYou (or another person using the same account) have just invoked the same data from another browser window.");
else if (error.type == 'DEADLOCKED')
alert("YOUR REQUEST DEADLOCKED!\nA database issue has occurred that caused your request to deadlock with another request.");

var msg = error == null ? null : error.message != null ? error.message : error.msg;
if (errorMsg != null)
{
var Str = errorMsg;
if (msg != null)
Str+="\n"+msg;
if (error.errors != null && error.errors.length != 0)
for (var i = 0; i < error.errors.length; ++i)
Str+="\n - "+error.errors[i].p+': '+error.errors[i].m;
alert(Str);
}
if (errorFunc != null)
errorFunc(error.code||error.status, msg, error.errors, error.type);
}
}
catch (e)
{
FloriaDOM.alertException(e, "Caught exception in ajaxUrl.error()\nUrl:"+url+"\nFrom: "+errorFunc+"\nError: ", true);
}
};
xhr.ontimeout = function() {
alert("TIMEOUT!");
};
xhr.send();
}
};
Loading

0 comments on commit 9ddba87

Please sign in to comment.