mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	integrate all js files into assets
This commit is contained in:
		@@ -1,92 +0,0 @@
 | 
				
			|||||||
class Utils {
 | 
					 | 
				
			||||||
  static escape(text) {
 | 
					 | 
				
			||||||
    // https://codereview.stackexchange.com/a/126722
 | 
					 | 
				
			||||||
    var table = {
 | 
					 | 
				
			||||||
      '<': 'lt',
 | 
					 | 
				
			||||||
      '>': 'gt',
 | 
					 | 
				
			||||||
      '"': 'quot',
 | 
					 | 
				
			||||||
      '\'': 'apos',
 | 
					 | 
				
			||||||
      '&': 'amp',
 | 
					 | 
				
			||||||
      '\r': '#10',
 | 
					 | 
				
			||||||
      '\n': '#13'
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    return text.toString().replace(/[<>"'\r\n&]/g, (chr) => {
 | 
					 | 
				
			||||||
      return '&' + table[chr] + ';';
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static unescape(escapedText) {
 | 
					 | 
				
			||||||
    var table = {
 | 
					 | 
				
			||||||
      'lt': '<',
 | 
					 | 
				
			||||||
      'gt': '>',
 | 
					 | 
				
			||||||
      'quot': '"',
 | 
					 | 
				
			||||||
      'apos': "'",
 | 
					 | 
				
			||||||
      'amp': '&',
 | 
					 | 
				
			||||||
      '#10': '\r',
 | 
					 | 
				
			||||||
      '#13': '\n'
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    return escapedText.replace(/&(#?\w+);/g, (match, entity) => {
 | 
					 | 
				
			||||||
      if (table.hasOwnProperty(entity)) {
 | 
					 | 
				
			||||||
        return table[entity];
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      return match;
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static HTMLToElement(HTMLString) {
 | 
					 | 
				
			||||||
    let templateElement = document.createElement('template');
 | 
					 | 
				
			||||||
    templateElement.innerHTML = HTMLString.trim();
 | 
					 | 
				
			||||||
    return templateElement.content.firstChild;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static generateElementId(prefix='', suffix='') {
 | 
					 | 
				
			||||||
    for (let i = 0; true; i++) {
 | 
					 | 
				
			||||||
      if (document.querySelector(`#${prefix}${i}${suffix}`) !== null) {continue;}
 | 
					 | 
				
			||||||
      return `${prefix}${i}${suffix}`;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static isObject(object) {
 | 
					 | 
				
			||||||
    return object !== null && typeof object === 'object' && !Array.isArray(object);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static mergeObjectsDeep(...objects) {
 | 
					 | 
				
			||||||
    let mergedObject = {};
 | 
					 | 
				
			||||||
    if (objects.length === 0) {
 | 
					 | 
				
			||||||
      return mergedObject;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (!Utils.isObject(objects[0])) {throw 'Cannot merge non-object';}
 | 
					 | 
				
			||||||
    if (objects.length === 1) {
 | 
					 | 
				
			||||||
      return Utils.mergeObjectsDeep(mergedObject, objects[0]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (!Utils.isObject(objects[1])) {throw 'Cannot merge non-object';}
 | 
					 | 
				
			||||||
    for (let key in objects[0]) {
 | 
					 | 
				
			||||||
      if (objects[0].hasOwnProperty(key)) {
 | 
					 | 
				
			||||||
        if (objects[1].hasOwnProperty(key)) {
 | 
					 | 
				
			||||||
          if (Utils.isObject(objects[0][key]) && Utils.isObject(objects[1][key])) {
 | 
					 | 
				
			||||||
            mergedObject[key] = Utils.mergeObjectsDeep(objects[0][key], objects[1][key]);
 | 
					 | 
				
			||||||
          } else {
 | 
					 | 
				
			||||||
            mergedObject[key] = objects[1][key];
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          mergedObject[key] = objects[0][key];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    for (let key in objects[1]) {
 | 
					 | 
				
			||||||
      if (objects[1].hasOwnProperty(key)) {
 | 
					 | 
				
			||||||
        if (!objects[0].hasOwnProperty(key)) {
 | 
					 | 
				
			||||||
          mergedObject[key] = objects[1][key];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (objects.length === 2) {
 | 
					 | 
				
			||||||
      return mergedObject;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
class App {
 | 
					App.App = class App {
 | 
				
			||||||
  constructor() {
 | 
					  constructor() {
 | 
				
			||||||
    this.data = {
 | 
					    this.data = {
 | 
				
			||||||
      promises: {getUser: {}, subscribeUser: {}},
 | 
					      promises: {getUser: {}, subscribeUser: {}},
 | 
				
			||||||
@@ -101,4 +101,4 @@ class App {
 | 
				
			|||||||
    // Apply Patch
 | 
					    // Apply Patch
 | 
				
			||||||
    jsonpatch.applyPatch(this.data, filteredPatch);
 | 
					    jsonpatch.applyPatch(this.data, filteredPatch);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					};
 | 
				
			||||||
							
								
								
									
										1
									
								
								app/static/js/app/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								app/static/js/app/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					App = {};
 | 
				
			||||||
							
								
								
									
										1
									
								
								app/static/js/utils/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								app/static/js/utils/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					Utils = {};
 | 
				
			||||||
							
								
								
									
										89
									
								
								app/static/js/utils/utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								app/static/js/utils/utils.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
				
			|||||||
 | 
					Utils.escape = (text) => {
 | 
				
			||||||
 | 
					  // https://codereview.stackexchange.com/a/126722
 | 
				
			||||||
 | 
					  var table = {
 | 
				
			||||||
 | 
					    '<': 'lt',
 | 
				
			||||||
 | 
					    '>': 'gt',
 | 
				
			||||||
 | 
					    '"': 'quot',
 | 
				
			||||||
 | 
					    '\'': 'apos',
 | 
				
			||||||
 | 
					    '&': 'amp',
 | 
				
			||||||
 | 
					    '\r': '#10',
 | 
				
			||||||
 | 
					    '\n': '#13'
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return text.toString().replace(/[<>"'\r\n&]/g, (chr) => {
 | 
				
			||||||
 | 
					    return '&' + table[chr] + ';';
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Utils.unescape = (escapedText) => {
 | 
				
			||||||
 | 
					  var table = {
 | 
				
			||||||
 | 
					    'lt': '<',
 | 
				
			||||||
 | 
					    'gt': '>',
 | 
				
			||||||
 | 
					    'quot': '"',
 | 
				
			||||||
 | 
					    'apos': "'",
 | 
				
			||||||
 | 
					    'amp': '&',
 | 
				
			||||||
 | 
					    '#10': '\r',
 | 
				
			||||||
 | 
					    '#13': '\n'
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return escapedText.replace(/&(#?\w+);/g, (match, entity) => {
 | 
				
			||||||
 | 
					    if (table.hasOwnProperty(entity)) {
 | 
				
			||||||
 | 
					      return table[entity];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return match;
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Utils.HTMLToElement = (HTMLString) => {
 | 
				
			||||||
 | 
					  let templateElement = document.createElement('template');
 | 
				
			||||||
 | 
					  templateElement.innerHTML = HTMLString.trim();
 | 
				
			||||||
 | 
					  return templateElement.content.firstChild;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Utils.generateElementId = (prefix='', suffix='') => {
 | 
				
			||||||
 | 
					  for (let i = 0; true; i++) {
 | 
				
			||||||
 | 
					    if (document.querySelector(`#${prefix}${i}${suffix}`) !== null) {continue;}
 | 
				
			||||||
 | 
					    return `${prefix}${i}${suffix}`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Utils.isObject = (object) => {
 | 
				
			||||||
 | 
					  return object !== null && typeof object === 'object' && !Array.isArray(object);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Utils.mergeObjectsDeep = (...objects) => {
 | 
				
			||||||
 | 
					  let mergedObject = {};
 | 
				
			||||||
 | 
					  if (objects.length === 0) {
 | 
				
			||||||
 | 
					    return mergedObject;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (!Utils.isObject(objects[0])) {throw 'Cannot merge non-object';}
 | 
				
			||||||
 | 
					  if (objects.length === 1) {
 | 
				
			||||||
 | 
					    return Utils.mergeObjectsDeep(mergedObject, objects[0]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (!Utils.isObject(objects[1])) {throw 'Cannot merge non-object';}
 | 
				
			||||||
 | 
					  for (let key in objects[0]) {
 | 
				
			||||||
 | 
					    if (objects[0].hasOwnProperty(key)) {
 | 
				
			||||||
 | 
					      if (objects[1].hasOwnProperty(key)) {
 | 
				
			||||||
 | 
					        if (Utils.isObject(objects[0][key]) && Utils.isObject(objects[1][key])) {
 | 
				
			||||||
 | 
					          mergedObject[key] = Utils.mergeObjectsDeep(objects[0][key], objects[1][key]);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          mergedObject[key] = objects[1][key];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        mergedObject[key] = objects[0][key];
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  for (let key in objects[1]) {
 | 
				
			||||||
 | 
					    if (objects[1].hasOwnProperty(key)) {
 | 
				
			||||||
 | 
					      if (!objects[0].hasOwnProperty(key)) {
 | 
				
			||||||
 | 
					        mergedObject[key] = objects[1][key];
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (objects.length === 2) {
 | 
				
			||||||
 | 
					    return mergedObject;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return Utils.mergeObjectsDeep(mergedObject, ...objects.slice(2));
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -7,9 +7,17 @@
 | 
				
			|||||||
{%- assets
 | 
					{%- assets
 | 
				
			||||||
  filters='rjsmin',
 | 
					  filters='rjsmin',
 | 
				
			||||||
  output='gen/app.%(version)s.js',
 | 
					  output='gen/app.%(version)s.js',
 | 
				
			||||||
  'js/App.js',
 | 
					  'js/app/index.js',
 | 
				
			||||||
  'js/Utils.js',
 | 
					  'js/app/app.js'
 | 
				
			||||||
  'js/XMLtoObject.js'
 | 
					%}
 | 
				
			||||||
 | 
					<script src="{{ ASSET_URL }}"></script>
 | 
				
			||||||
 | 
					{%- endassets %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{%- assets
 | 
				
			||||||
 | 
					  filters='rjsmin',
 | 
				
			||||||
 | 
					  output='gen/utils.%(version)s.js',
 | 
				
			||||||
 | 
					  'js/utils/index.js',
 | 
				
			||||||
 | 
					  'js/utils/utils.js'
 | 
				
			||||||
%}
 | 
					%}
 | 
				
			||||||
<script src="{{ ASSET_URL }}"></script>
 | 
					<script src="{{ ASSET_URL }}"></script>
 | 
				
			||||||
{%- endassets %}
 | 
					{%- endassets %}
 | 
				
			||||||
@@ -110,7 +118,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
  // TODO: Implement an app.run method and use this for all of the following
 | 
					  // TODO: Implement an app.run method and use this for all of the following
 | 
				
			||||||
  const app = new App();
 | 
					  const app = new App.App();
 | 
				
			||||||
  {%- if current_user.is_authenticated %}
 | 
					  {%- if current_user.is_authenticated %}
 | 
				
			||||||
  const currentUserId = {{ current_user.hashid|tojson }};
 | 
					  const currentUserId = {{ current_user.hashid|tojson }};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -148,7 +148,8 @@
 | 
				
			|||||||
          return response.text();
 | 
					          return response.text();
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        .then((responseText) => {return new DOMParser().parseFromString(responseText, 'application/xml');})
 | 
					        .then((responseText) => {return new DOMParser().parseFromString(responseText, 'application/xml');})
 | 
				
			||||||
        .then((xmlDocument) => {return xmlDocument.toObject();})
 | 
					        // .then((xmlDocument) => {return xmlDocument.toObject();})
 | 
				
			||||||
 | 
					        .then((xmlDocument) => {return {};})
 | 
				
			||||||
        .then((feed) => {resolve(feed);});
 | 
					        .then((feed) => {resolve(feed);});
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user