1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

www_back_end, www_front_end -> www_core, www_options

This commit is contained in:
root 2020-03-08 15:26:05 -04:00
parent 010a6b5fde
commit 5f63941127
61 changed files with 39 additions and 39 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,108 @@
(function () {
var output, Converter;
if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module
output = exports;
Converter = require("./Markdown.Converter").Converter;
} else {
output = window.Markdown;
Converter = output.Converter;
}
output.getSanitizingConverter = function () {
var converter = new Converter();
converter.hooks.chain("postConversion", sanitizeHtml);
converter.hooks.chain("postConversion", balanceTags);
return converter;
}
function sanitizeHtml(html) {
return html.replace(/<[^>]*>?/gi, sanitizeTag);
}
// (tags that can be opened/closed) | (tags that stand alone)
var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol(?: start="\d+")?|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i;
// <a href="url..." optional title>|</a>
var a_white = /^(<a\shref="((https?|ftp):\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)*[\]$]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i;
// <img src="url..." optional width optional height optional alt optional title
var img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)*[\]$]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;
function sanitizeTag(tag) {
if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white))
return tag;
else
return "";
}
/// <summary>
/// attempt to balance HTML tags in the html string
/// by removing any unmatched opening or closing tags
/// IMPORTANT: we *assume* HTML has *already* been
/// sanitized and is safe/sane before balancing!
///
/// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593
/// </summary>
function balanceTags(html) {
if (html == "")
return "";
var re = /<\/?\w+[^>]*(\s|$|>)/g;
// convert everything to lower case; this makes
// our case insensitive comparisons easier
var tags = html.toLowerCase().match(re);
// no HTML tags present? nothing to do; exit now
var tagcount = (tags || []).length;
if (tagcount == 0)
return html;
var tagname, tag;
var ignoredtags = "<p><img><br><li><hr>";
var match;
var tagpaired = [];
var tagremove = [];
var needsRemoval = false;
// loop through matched tags in forward order
for (var ctag = 0; ctag < tagcount; ctag++) {
tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1");
// skip any already paired tags
// and skip tags in our ignore list; assume they're self-closed
if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1)
continue;
tag = tags[ctag];
match = -1;
if (!/^<\//.test(tag)) {
// this is an opening tag
// search forwards (next tags), look for closing tags
for (var ntag = ctag + 1; ntag < tagcount; ntag++) {
if (!tagpaired[ntag] && tags[ntag] == "</" + tagname + ">") {
match = ntag;
break;
}
}
}
if (match == -1)
needsRemoval = tagremove[ctag] = true; // mark for removal
else
tagpaired[match] = true; // mark paired
}
if (!needsRemoval)
return html;
// delete all orphaned tags from the string
var ctag = 0;
html = html.replace(re, function (match) {
var res = tagremove[ctag] ? "" : match;
ctag++;
return res;
});
return html;
}
})();

View file

@ -0,0 +1,263 @@
/* Copyright (c) 2007 Lev Muchnik <LevMuchnik@gmail.com>. All rights reserved.
* You may copy and modify this script as long as the above copyright notice,
* this condition and the following disclaimer is left intact.
* This software is provided by the author "AS IS" and no warranties are
* implied, including fitness for a particular purpose. In no event shall
* the author be liable for any damages arising in any way out of the use
* of this software, even if advised of the possibility of such damage.
* $Date: 2007-10-03 19:08:15 -0700 (Wed, 03 Oct 2007) $
*/
function LoadXML(ParentElementID,URL)
{
var xmlHolderElement = GetParentElement(ParentElementID);
if (xmlHolderElement==null) { return false; }
ToggleElementVisibility(xmlHolderElement);
return RequestURL(URL,URLReceiveCallback,ParentElementID);
}
function LoadXMLDom(ParentElementID,xmlDoc)
{
if (xmlDoc) {
var xmlHolderElement = GetParentElement(ParentElementID);
if (xmlHolderElement==null) { return false; }
while (xmlHolderElement.childNodes.length) { xmlHolderElement.removeChild(xmlHolderElement.childNodes.item(xmlHolderElement.childNodes.length-1)); }
var Result = ShowXML(xmlHolderElement,xmlDoc.documentElement,0);
var ReferenceElement = document.createElement('div');
var Link = document.createElement('a');
Link.setAttribute('href','http://www.levmuchnik.net/Content/ProgrammingTips/WEB/XMLDisplay/DisplayXMLFileWithJavascript.html');
var TextNode = document.createTextNode('Source: Lev Muchnik');
Link.appendChild(TextNode);
xmlHolderElement.appendChild(Link);
return Result;
}
else { return false; }
}
function LoadXMLString(ParentElementID,XMLString)
{
xmlDoc = CreateXMLDOM(XMLString);
return LoadXMLDom(ParentElementID,xmlDoc) ;
}
////////////////////////////////////////////////////////////
// HELPER FUNCTIONS - SHOULD NOT BE DIRECTLY CALLED BY USERS
////////////////////////////////////////////////////////////
function GetParentElement(ParentElementID)
{
if (typeof(ParentElementID)=='string') { return document.getElementById(ParentElementID); }
else if (typeof(ParentElementID)=='object') { return ParentElementID;}
else { return null; }
}
function URLReceiveCallback(httpRequest,xmlHolderElement)
{
try {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
var xmlDoc = httpRequest.responseXML;
if (xmlHolderElement && xmlHolderElement!=null) {
xmlHolderElement.innerHTML = '';
return LoadXMLDom(xmlHolderElement,xmlDoc);
}
} else {
return false;
}
}
}
catch( e ) {
return false;
}
}
function RequestURL(url,callback,ExtraData) { // based on: http://developer.mozilla.org/en/docs/AJAX:Getting_Started
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); }
}
else if (window.ActiveXObject) { // IE
try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) {
try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) {}
}
}
if (!httpRequest) { return false; }
httpRequest.onreadystatechange = function() { callback(httpRequest,ExtraData); };
httpRequest.open('GET', url, true);
httpRequest.send('');
return true;
}
function CreateXMLDOM(XMLStr)
{
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.loadXML(XMLStr);
return xmlDoc;
}
else if (document.implementation && document.implementation.createDocument) {
var parser=new DOMParser();
return parser.parseFromString(XMLStr,"text/xml");
}
else {
return null;
}
}
var IDCounter = 1;
var NestingIndent = 15;
function ShowXML(xmlHolderElement,RootNode,indent)
{
if (RootNode==null || xmlHolderElement==null) { return false; }
var Result = true;
var TagEmptyElement = document.createElement('div');
TagEmptyElement.className = 'Element';
TagEmptyElement.style.position = 'relative';
TagEmptyElement.style.left = NestingIndent+'px';
if (RootNode.childNodes.length==0) {
var ClickableElement = AddTextNode(TagEmptyElement,'','Clickable') ;
ClickableElement.id = 'div_empty_' + IDCounter;
AddTextNode(TagEmptyElement,'<','Utility') ;
AddTextNode(TagEmptyElement,RootNode.nodeName ,'NodeName')
for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
CurrentAttribute = RootNode.attributes.item(i);
AddTextNode(TagEmptyElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
AddTextNode(TagEmptyElement,'=','Utility') ;
AddTextNode(TagEmptyElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
}
AddTextNode(TagEmptyElement,' />') ;
xmlHolderElement.appendChild(TagEmptyElement);
//SetVisibility(TagEmptyElement,true);
}
else { // mo child nodes
var ClickableElement = AddTextNode(TagEmptyElement,'+','Clickable') ;
ClickableElement.onclick = function() {ToggleElementVisibility(this); }
ClickableElement.id = 'div_empty_' + IDCounter;
AddTextNode(TagEmptyElement,'<','Utility') ;
AddTextNode(TagEmptyElement,RootNode.nodeName ,'NodeName')
for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
CurrentAttribute = RootNode.attributes.item(i);
AddTextNode(TagEmptyElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
AddTextNode(TagEmptyElement,'=','Utility') ;
AddTextNode(TagEmptyElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
}
AddTextNode(TagEmptyElement,'> </','Utility') ;
AddTextNode(TagEmptyElement,RootNode.nodeName,'NodeName') ;
AddTextNode(TagEmptyElement,'>','Utility') ;
xmlHolderElement.appendChild(TagEmptyElement);
SetVisibility(TagEmptyElement,false);
//----------------------------------------------
var TagElement = document.createElement('div');
TagElement.className = 'Element';
TagElement.style.position = 'relative';
TagElement.style.left = NestingIndent+'px';
ClickableElement = AddTextNode(TagElement,'-','Clickable') ;
ClickableElement.onclick = function() {ToggleElementVisibility(this); }
ClickableElement.id = 'div_content_' + IDCounter;
++IDCounter;
AddTextNode(TagElement,'<','Utility') ;
AddTextNode(TagElement,RootNode.nodeName ,'NodeName') ;
for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
CurrentAttribute = RootNode.attributes.item(i);
AddTextNode(TagElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
AddTextNode(TagElement,'=','Utility') ;
AddTextNode(TagElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
}
AddTextNode(TagElement,'>','Utility') ;
TagElement.appendChild(document.createElement('br'));
var NodeContent = null;
for (var i = 0; RootNode.childNodes && i < RootNode.childNodes.length; ++i) {
if (RootNode.childNodes.item(i).nodeName != '#text') {
Result &= ShowXML(TagElement,RootNode.childNodes.item(i),indent+1);
}
else {
NodeContent =RootNode.childNodes.item(i).nodeValue;
}
}
if (RootNode.nodeValue) {
NodeContent = RootNode.nodeValue;
}
if (NodeContent) {
var ContentElement = document.createElement('div');
ContentElement.style.position = 'relative';
ContentElement.style.left = NestingIndent+'px';
AddTextNode(ContentElement,NodeContent ,'NodeValue') ;
TagElement.appendChild(ContentElement);
}
AddTextNode(TagElement,' </','Utility') ;
AddTextNode(TagElement,RootNode.nodeName,'NodeName') ;
AddTextNode(TagElement,'>','Utility') ;
xmlHolderElement.appendChild(TagElement);
}
// if (indent==0) { ToggleElementVisibility(TagElement.childNodes(0)); } - uncomment to collapse the external element
return Result;
}
function AddTextNode(ParentNode,Text,Class)
{
NewNode = document.createElement('span');
if (Class) { NewNode.className = Class;}
if (Text) { NewNode.appendChild(document.createTextNode(Text)); }
if (ParentNode) { ParentNode.appendChild(NewNode); }
return NewNode;
}
function CompatibleGetElementByID(id)
{
if (!id) { return null; }
if (document.getElementById) { // DOM3 = IE5, NS6
return document.getElementById(id);
}
else {
if (document.layers) { // Netscape 4
return document.id;
}
else { // IE 4
return document.all.id;
}
}
}
function SetVisibility(HTMLElement,Visible)
{
if (!HTMLElement) { return; }
var VisibilityStr = (Visible) ? 'block' : 'none';
if (document.getElementById) { // DOM3 = IE5, NS6
HTMLElement.style.display =VisibilityStr;
}
else {
if (document.layers) { // Netscape 4
HTMLElement.display = VisibilityStr;
}
else { // IE 4
HTMLElement.id.style.display = VisibilityStr;
}
}
}
function ToggleElementVisibility(Element)
{
if (!Element|| !Element.id) { return; }
try {
ElementType = Element.id.slice(0,Element.id.lastIndexOf('_')+1);
ElementID = parseInt(Element.id.slice(Element.id.lastIndexOf('_')+1));
}
catch(e) { return ; }
var ElementToHide = null;
var ElementToShow= null;
if (ElementType=='div_content_') {
ElementToHide = 'div_content_' + ElementID;
ElementToShow = 'div_empty_' + ElementID;
}
else if (ElementType=='div_empty_') {
ElementToShow= 'div_content_' + ElementID;
ElementToHide = 'div_empty_' + ElementID;
}
ElementToHide = CompatibleGetElementByID(ElementToHide);
ElementToShow = CompatibleGetElementByID(ElementToShow);
if (ElementToHide) { ElementToHide = ElementToHide.parentNode;}
if (ElementToShow) { ElementToShow = ElementToShow.parentNode;}
SetVisibility(ElementToHide,false);
SetVisibility(ElementToShow,true);
}

2377
roles/www_base/files/html/js/bootstrap.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long