Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Remove:
Modernizr, Old JS polyfills
Move venn.js to include as JS
Rename d3.min.js to d3_OLD_VERSION.min.js
  • Loading branch information
danjasuw committed Jun 15, 2019
1 parent f0feb6a commit 7c9831e
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 725 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* venn.js
*
* Copyright (C) 2013 Ben Frederickson
*
Expand All @@ -15,6 +16,10 @@
*
* Changes made for Proxl web app:
*
* Update for ES6 Imports ( Add export )
*
* add import * as d3 from "d3";
*
* In function: venn.drawD3Diagram
*
* After: var colours = d3.scale.category10();
Expand All @@ -30,8 +35,21 @@
*
*/

// import of d3 does not work. Likely this code does not work with current d3 considering how old this code is.

// import * as d3 from "d3";

// This fails: var colours = d3.scale.category10();

// Cannot read property 'category10' of undefined

(function(venn) {


//(function(venn) {

const venn = {};


"use strict";
/** given a list of set objects, and their corresponding overlaps.
updates the (x, y, radius) attribute on each set such that their positions
Expand Down Expand Up @@ -608,7 +626,6 @@

venn.drawD3Diagram = function(element, dataset, width, height, parameters) {


parameters = parameters || {};

var colours = d3.scale.category10();
Expand Down Expand Up @@ -910,4 +927,6 @@
center.y /= points.length;
return center;
};
}(window.venn = window.venn || {}));
//}(window.venn = window.venn || {}));

export { venn }
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function addOpenLorikeetViewerClickHandlers( $openLorkeetLinks ) {

var svgSupportedSnapLoaded = false;

if ( typeof Modernizr !== 'undefined' && Modernizr.svg && typeof Snap !== 'undefined' ) {
if ( typeof Snap !== 'undefined' ) {

svgSupportedSnapLoaded = true;
}
Expand Down Expand Up @@ -666,7 +666,7 @@ function addOpenLorikeetViewerClickHandlers( $openLorkeetLinks ) {

// END: Create Text representation of Looplink

} // else of if ( Modernizr && Modernizr.svg && Snap ) {
} // else of if ( Snap ) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

//mergedSearchesVennDiagramCreator.js
// mergedSearchesVennDiagramCreator.js

//JavaScript directive: all variables have to be declared with "var", maybe other things
"use strict";


import { venn } from 'libs/venn.js';

/**
* Constructor
*/
var CreateMergedSearchesLinkCountsVennDiagram = function() {

let retryCountOnMissing_d3_Object = 0;

///////////////////////////////////////////
// This is a copy of colors in CSS classes altered to compensate for fill-opacity: 0.3 in the venn diagram
// CSS class names start with "merged-search-search-background-color-" and are in the file global.css
Expand All @@ -24,6 +26,22 @@ var CreateMergedSearchesLinkCountsVennDiagram = function() {
///////////////////////////////////////////
// This function is called on the page to create the Venn diagram
this.createMergedSearchesLinkCountsVennDiagram = function({ vennDiagramDataToJSON }) {

if ( ! window.d3 ) {
retryCountOnMissing_d3_Object++;
// d3 object not on page yet so try again in 1 second
if ( retryCountOnMissing_d3_Object > 1 ) {
throw Error("window.d3 not exist");
}
window.setTimeout( () => {
try {
this.createMergedSearchesLinkCountsVennDiagram({ vennDiagramDataToJSON });
} catch( e ) {
reportWebErrorToServer.reportErrorObjectToServer( { errorException : e } );
throw e;
}
}, 1000);
}
try {
var venn_diagram_data = vennDiagramDataToJSON;

Expand Down Expand Up @@ -51,7 +69,7 @@ var CreateMergedSearchesLinkCountsVennDiagram = function() {
// Apply a stroke width
$circle_All.attr("stroke-width","1");

this.addDownloadClickHandlers();
this._addDownloadClickHandlers();

var $searches_intersection_venn_diagram_outer_container = $("#searches_intersection_venn_diagram_outer_container");
$searches_intersection_venn_diagram_outer_container.show();
Expand All @@ -69,7 +87,7 @@ var CreateMergedSearchesLinkCountsVennDiagram = function() {
* If the element $chart_outer_container_for_download_jq was dynamically added, need to run to add tool tips on download links:
* addToolTips( $chartOuterContainer );
*/
this.addDownloadClickHandlers = function( params ) {
this._addDownloadClickHandlers = function( params ) {
var objectThis = this;
var $searches_intersection_venn_diagram_outer_container = $("#searches_intersection_venn_diagram_outer_container");
var $venn_diagram_download_link_jq_All = $searches_intersection_venn_diagram_outer_container.find(".venn_diagram_download_link_jq");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6157,10 +6157,6 @@ var ImagePagePrimaryRootCodeClass = function() {
populateAnnotationDataDisplayProcessingCommonCodeFromHash();
proteinAnnotationStore.init();

if ( Modernizr && ! Modernizr.svg ) { // Modernizr.svg is false if SVG not supported
console.log( "SVG not supported." );
throw Error( "SVG not supported" );
}
_projectSearchIds = [];
var $project_search_id_jq = $(".project_search_id_jq");
if ( $project_search_id_jq.length === 0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6552,11 +6552,6 @@ var StructurePagePrimaryRootCodeClass = function() {

console.log( "Initializing the page." );

if ( Modernizr && ! Modernizr.svg ) { // Modernizr.svg is false if SVG not supported
console.log( "SVG not supported." );
throw Error( "SVG not supported" );
}

_projectSearchIds = [];

var $project_search_id_jq = $(".project_search_id_jq");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@

<link rel="icon" href="images/favicon.ico" />

<script type="text/javascript" src="js/libs/modernizr.v2.7.1__custom.39924_min.js"></script>

<%--
<script type="text/javascript" src="js/libs/modernizr.v2.7.1__custom.39924.js"></script>
--%>

<script type="text/javascript" src="js/libs/jquery-1.11.0.min.js"></script>
<%--
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
Expand Down Expand Up @@ -62,117 +56,6 @@
var _PROXL_COLOR_LINK_TYPE_UNLINKED = _PROXL_COLOR_SITE_BLUE;
var _PROXL_COLOR_LINK_TYPE_ALL_COMBINED = "#A5A5A5";
<%--
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
// Polyfill for String.trim()
// Running the following code before any other code will create trim() if it's not natively available.
--%>
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
};
}
<%--
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
// Polyfill for Array.isArray()
// Running the following code before any other code will create Array.isArray() if it's not natively available.
--%>
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
<%--
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now
// Polyfill for Date.now()
// Running the following code before any other code will create Date.now() if it's not natively available.
// Date.now() returns the milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now as a Number.
--%>
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
<%--
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
Polyfill
forEach() was added to the ECMA-262 standard in the 5th edition; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of forEach() in implementations that don't natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming Object and TypeError have their original values and that callback.call() evaluates to the original value of Function.prototype.call().
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
--%>
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback/*, thisArg*/) {
var T, k;
if (this == null) {
throw new TypeError('this is null or not defined');
}
// 1. Let O be the result of calling toObject() passing the
// |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get() internal
// method of O with the argument "length".
// 3. Let len be toUint32(lenValue).
var len = O.length >>> 0;
// 4. If isCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let
// T be undefined.
if (arguments.length > 1) {
T = arguments[1];
}
// 6. Let k be 0.
k = 0;
// 7. Repeat while k < len.
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator.
// b. Let kPresent be the result of calling the HasProperty
// internal method of O with argument Pk.
// This step can be combined with c.
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal
// method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as
// the this value and argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined.
};
}
</script>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ response.addHeader("Cache-control", "max-age=0"); // stale right away

<!DOCTYPE html>

<html class="no-js"> <!-- Modernizr will change "no-js" to "js" if Javascript is enabled -->
<html >


<head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

<script type="text/javascript" src="js/libs/jquery.tablesorter_Modified.js"></script>

<script type="text/javascript" src="js/libs/d3.min.js"></script>
<script type="text/javascript" src="js/libs/venn.js"></script>
<%-- Old version of d3 used in venn.js and mergedSearchesVennDiagramCreator.js
to create the Venn Diagram --%>
<script type="text/javascript" src="js/libs/d3_OLD_VERSION.min.js"></script>


<%-- Start of Lorikeet Core Parts --%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
<script type="text/javascript" src="js/libs/jquery.tablesorter_Modified.js"></script>
<script type="text/javascript" src="js/libs/jquery.qtip.min.js"></script>

<script type="text/javascript" src="js/libs/d3.min.js"></script>
<script type="text/javascript" src="js/libs/venn.js"></script>
<%-- Old version of d3 used in venn.js and mergedSearchesVennDiagramCreator.js
to create the Venn Diagram --%>
<script type="text/javascript" src="js/libs/d3_OLD_VERSION.min.js"></script>


<%-- Start of Lorikeet Core Parts --%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<script type="text/javascript" src="js/libs/jquery.tablesorter_Modified.js"></script>
<script type="text/javascript" src="js/libs/jquery.qtip.min.js"></script>

<script type="text/javascript" src="js/libs/d3.min.js"></script>
<script type="text/javascript" src="js/libs/venn.js"></script>
<%-- Old version of d3 used in venn.js and mergedSearchesVennDiagramCreator.js
to create the Venn Diagram --%>
<script type="text/javascript" src="js/libs/d3_OLD_VERSION.min.js"></script>


<%-- Start of Lorikeet Core Parts --%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<script type="text/javascript" src="js/libs/jquery.tablesorter_Modified.js"></script>
<script type="text/javascript" src="js/libs/jquery.qtip.min.js"></script>

<script type="text/javascript" src="js/libs/d3.min.js"></script>
<script type="text/javascript" src="js/libs/venn.js"></script>
<%-- Old version of d3 used in venn.js and mergedSearchesVennDiagramCreator.js
to create the Venn Diagram --%>
<script type="text/javascript" src="js/libs/d3_OLD_VERSION.min.js"></script>


<%-- Start of Lorikeet Core Parts --%>
Expand Down

Large diffs are not rendered by default.

0 comments on commit 7c9831e

Please sign in to comment.