Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
BOLD MOVE: remove PrototypeJS !!! 10 YEARS OF GLORY !!! ♥♥♥
Browse files Browse the repository at this point in the history
[ok many things are broken right now]
  • Loading branch information
cdujeu committed Feb 22, 2017
1 parent 1204f72 commit 756bebc
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 141 deletions.
Expand Up @@ -316,7 +316,7 @@

static sessionLogout(){

global.clearRememberData();
PydioApi.clearRememberData();
let client = PydioApi.getClient();
client.request({get_action:'logout'}, function(responseObject){
client.parseXmlMessage(responseObject.responseXML);
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/gui.ajax/Gruntfile.js
Expand Up @@ -172,7 +172,8 @@ module.exports = function(grunt) {
dist: {
files: {
'res/js/vendor/nodejs/bundle.prod.js': 'res/js/vendor/nodejs/export.js',
'res/js/vendor/nodejs/bundle.legacy.prod.js': 'res/js/vendor/nodejs/export.legacy.js'
'res/js/vendor/nodejs/bundle.legacy.prod.js': 'res/js/vendor/nodejs/export.legacy.js',
'res/js/vendor/nodejs/boot.prod.js': 'res/js/vendor/nodejs/boot.js'
}
},
ui : {
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/gui.ajax/package.json
Expand Up @@ -15,6 +15,7 @@
"classnames": "~2.1.3",
"clipboard": "^1.5.8",
"cronstrue": "0.3.1",
"doc-ready": "^1.0.4",
"he": "1.1.0",
"lodash": "^3.10.1",
"material-ui": "^0.17.0",
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer_boot.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer_boot_list.txt
@@ -1,7 +1,5 @@
js/vendor/es6/browser-polyfill.js
js/vendor/prototype/prototype.js
js/vendor/prototype/prototype.livepipe.js
js/vendor/prototype/prototype.oo.js
js/vendor/nodejs/boot.prod.js
js/core/util/HasherUtils.js
js/core/http/Connexion.js
js/ui/prototype/class.AjxpBootstrap.js
js/core/PydioBootstrap.js
58 changes: 1 addition & 57 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer_ui.txt
@@ -1,58 +1,2 @@
js/ui/prototype/util/ajxp_utils.js
js/vendor/modernizr/modernizr.min.js
js/ui/prototype/interfaces/class.IAjxpNodeProvider.js
js/ui/prototype/interfaces/class.IAjxpWidget.js
js/ui/prototype/interfaces/class.IActionProvider.js
js/ui/prototype/interfaces/class.IFocusable.js
js/ui/prototype/interfaces/class.IContextMenuable.js
js/ui/prototype/class.AjxpPane.js
js/vendor/prototype/webfx.selectable.js
js/vendor/prototype/webfx.sortable.js
js/vendor/prototype/proto.menu.js
js/vendor/prototype/splitter.js
js/vendor/prototype/cookiejar.js
js/vendor/prototype/protopass.js
js/vendor/prototype/resizable.js
js/vendor/leightbox/lightbox.js
js/vendor/scriptaculous/src/builder.js
js/vendor/scriptaculous/src/effects.js
js/vendor/scriptaculous/src/dragdrop.js
js/vendor/scriptaculous/src/slider.js
js/vendor/prototype/cssfx.js
js/vendor/prototype/proto.scroller.js
js/vendor/prototype/accordion.js
js/vendor/webfx/xtree.js
js/vendor/webfx/ajxptree.js
js/vendor/chosen/event.simulate.js
js/vendor/chosen/chosen.proto.js
js/ui/prototype/class.AjxpDraggable.js
js/ui/prototype/class.AjxpSortable.js
js/ui/prototype/class.AjxpTabulator.js
js/ui/prototype/class.VisibilityToggler.js
js/ui/prototype/class.AjxpSimpleTabs.js
js/ui/prototype/class.RepositorySelect.js
js/ui/prototype/class.RepositorySimpleLabel.js
js/ui/prototype/class.Breadcrumb.js
js/ui/prototype/class.UserWidget.js
js/ui/prototype/class.LogoWidget.js
js/ui/prototype/class.TreeSelector.js
js/ui/prototype/class.SliderInput.js
js/ui/prototype/class.ActionsToolbar.js
js/ui/prototype/class.HeaderResizer.js
js/ui/prototype/class.PreviewFactory.js
js/ui/prototype/class.FilesList.js
js/ui/prototype/class.FoldersTree.js
js/ui/prototype/class.SearchEngine.js
js/ui/prototype/class.FetchedResultPane.js
js/ui/prototype/class.InfoPanel.js
js/ui/prototype/class.PropertyPanel.js
js/ui/prototype/class.AbstractEditor.js
js/ui/prototype/class.Modal.js
js/ui/prototype/class.BookmarksBar.js
js/ui/prototype/class.FormManager.js
js/ui/prototype/class.DataModelProperty.js
js/ui/prototype/class.MultiDownloader.js
js/ui/prototype/class.ActivityMonitor.js
js/ui/prototype/class.AjxpReactComponent.js
js/ui/prototype/class.AjxpReactDialogLoader.js
js/ui/prototype/class.PydioUI.js
js/vendor/modernizr/modernizr.min.js
2 changes: 0 additions & 2 deletions core/src/plugins/gui.ajax/res/js/es6/Pydio.es6
Expand Up @@ -126,8 +126,6 @@ class Pydio extends Observable{
ResourcesManager.loadClassesAndApply(["React", "PydioReactUI"], function(){
this.UI = new PydioReactUI.Builder(this);
this.UI.initTemplates();
this.UI.modal.initForms();
this.UI.initObjects();

if(!this.user) {
PydioApi.getClient().tryToLogUserFromRememberData();
Expand Down
269 changes: 269 additions & 0 deletions core/src/plugins/gui.ajax/res/js/es6/PydioBootstrap.es6
@@ -0,0 +1,269 @@
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <https://pydio.com>.
*/

/**
* Main BootLoader.
* Defaults params for constructor should be {} and content.php?get_action=get_boot_conf
*/
class PydioBootstrap{

/**
* Constructor
* @param startParameters Object The options
*/
constructor(startParameters){
this.parameters = new Map();
for(var i in startParameters){
if(startParameters.hasOwnProperty(i)) {
this.parameters.set(i, startParameters[i]);
}
}
this.detectBaseParameters();

if(this.parameters.get("ALERT")){
window.setTimeout(() => {window.alert(this.parameters.get("ALERT"));},0);
}

docReady(function(){

var startedFromOpener = false;
try{
if(window.opener && window.opener.pydioBootstrap && this.parameters.get('serverAccessPath') === window.opener.pydioBootstrap.parameters.get('serverAccessPath')){
this.parameters = window.opener.pydioBootstrap.parameters;
// Handle queryString case, as it's not passed via get_boot_conf
var qParams = document.location.href.toQueryParams();
if(qParams['external_selector_type']){
this.parameters.set('SELECTOR_DATA', {type:qParams['external_selector_type'], data:qParams});
}else{
if(this.parameters.get('SELECTOR_DATA')) {
this.parameters.unset('SELECTOR_DATA');
}
}
this.refreshContextVariablesAndInit(new Connexion());
startedFromOpener = true;
}
}catch(e){
if(window.console && console.log) console.log(e);
}
if(!startedFromOpener){
this.loadBootConfig();
}

}.bind(this));

window.pydioBootstrap = this;
}

/**
* Real loading action
*/
loadBootConfig(){
if(this.parameters.get('PRELOADED_BOOT_CONF')){
const preloaded = this.parameters.get('PRELOADED_BOOT_CONF');
for(let k in preloaded){
if(preloaded.hasOwnProperty(k)){
this.parameters.set(k, preloaded[k]);
}
}
if(this.parameters.get('SECURE_TOKEN')){
Connexion.SECURE_TOKEN = this.parameters.get('SECURE_TOKEN');
}
if(this.parameters.get('SERVER_PREFIX_URI')){
this.parameters.set('ajxpResourcesFolder', this.parameters.get('SERVER_PREFIX_URI') + this.parameters.get('ajxpResourcesFolder'));
this.parameters.set('ajxpServerAccess', this.parameters.get('SERVER_PREFIX_URI') + this.parameters.get('ajxpServerAccess') + '?' + (Connexion.SECURE_TOKEN? 'secure_token='+Connexion.SECURE_TOKEN:''));
}else{
this.parameters.set('ajxpServerAccess', this.parameters.get('ajxpServerAccess') + '?' + (Connexion.SECURE_TOKEN? 'secure_token='+Connexion.SECURE_TOKEN:''));
}
if(this.parameters.get('SERVER_PERMANENT_PARAMS')){
this.parameters.set('ajxpServerAccess', this.parameters.get('ajxpServerAccess') + '&' + this.parameters.get('SERVER_PERMANENT_PARAMS') + '&');
}
this.refreshContextVariablesAndInit(new Connexion());
return;
}

var url = this.parameters.get('BOOTER_URL')+(this.parameters.get("debugMode")?'&debug=true':'');
if(this.parameters.get('SERVER_PREFIX_URI')){
url += '&server_prefix_uri=' + this.parameters.get('SERVER_PREFIX_URI').replace(/\.\.\//g, "_UP_/");
}
var connexion = new Connexion(url);
connexion.onComplete = function(transport){
if(transport.responseXML && transport.responseXML.documentElement && transport.responseXML.documentElement.nodeName == "tree"){
var alert = XPathSelectSingleNode(transport.responseXML.documentElement, "message");
window.alert('Exception caught by application : ' + alert.firstChild.nodeValue);
return;
}
var phpError;
try{
var data = transport.responseText.evalJSON();
}catch(e){
phpError = 'Error while parsing JSON response : ' + e.message;
}
if(!typeof data == "object"){
phpError = 'Exception uncaught by application : ' + transport.responseText;
}
if(phpError){
document.write(phpError);
if(phpError.indexOf('<b>Notice</b>')>-1 || phpError.indexOf('<b>Strict Standards</b>')>-1){
window.alert('Php errors detected, it seems that Notice or Strict are detected, you may consider changing the PHP Error Reporting level!');
}
return;
}
this.parameters.update(data);

if(this.parameters.get('SECURE_TOKEN')){
Connexion.SECURE_TOKEN = this.parameters.get('SECURE_TOKEN');
}
if(this.parameters.get('SERVER_PREFIX_URI')){
this.parameters.set('ajxpResourcesFolder', this.parameters.get('SERVER_PREFIX_URI') + this.parameters.get('ajxpResourcesFolder'));
this.parameters.set('ajxpServerAccess', this.parameters.get('SERVER_PREFIX_URI') + this.parameters.get('ajxpServerAccess') + '?' + (Connexion.SECURE_TOKEN? 'secure_token='+Connexion.SECURE_TOKEN:''));
}else{
this.parameters.set('ajxpServerAccess', this.parameters.get('ajxpServerAccess') + '?' + (Connexion.SECURE_TOKEN? 'secure_token='+Connexion.SECURE_TOKEN:''));
}
if(this.parameters.get('SERVER_PERMANENT_PARAMS')){
this.parameters.set('ajxpServerAccess', this.parameters.get('ajxpServerAccess') + '&' + this.parameters.get('SERVER_PERMANENT_PARAMS') + '&');
}

this.refreshContextVariablesAndInit(connexion);

}.bind(this);
connexion.sendAsync();

}

refreshContextVariablesAndInit(connexion){
if(this.parameters.get('SECURE_TOKEN') && !Connexion.SECURE_TOKEN){
Connexion.SECURE_TOKEN = this.parameters.get('SECURE_TOKEN');
}

// Refresh window variable
window.ajxpServerAccessPath = this.parameters.get('ajxpServerAccess');
var cssRes = this.parameters.get("cssResources");
if(cssRes) cssRes.map(this.loadCSSResource.bind(this));

if(this.parameters.get('ajxpResourcesFolder')){
connexion._libUrl = this.parameters.get('ajxpResourcesFolder') + "/js";
window.ajxpResourcesFolder = this.parameters.get('ajxpResourcesFolder') + "/themes/" + this.parameters.get("theme");
}

if(this.parameters.get('additional_js_resource')){
connexion.loadLibrary(this.parameters.get('additional_js_resource?v='+this.parameters.get("ajxpVersion")), null, true);
}

//this.insertLoaderProgress();
window.MessageHash = this.parameters.get("i18nMessages");
if(!Object.keys(MessageHash).length){
alert('Ooups, this should not happen, your message file is empty!');
}
for(var key in MessageHash){
MessageHash[key] = MessageHash[key].replace("\\n", "\n");
}
window.zipEnabled = this.parameters.get("zipEnabled");
window.multipleFilesDownloadEnabled = this.parameters.get("multipleFilesDownloadEnabled");

var masterClassLoaded = function(){

let pydio = new Pydio(this.parameters);
window.pydio = window.ajaxplorer = pydio;

pydio.observe("actions_loaded", function(){
if(!this.parameters.get("SELECTOR_DATA") && pydio.getController().actions.get("ext_select")){
if(pydio.getController().actions._object){
pydio.getController().actions.unset("ext_select");
}else{
pydio.getController().actions['delete']("ext_select");
}
pydio.getController().fireContextChange();
pydio.getController().fireSelectionChange();
}else if(this.parameters.get("SELECTOR_DATA")){
pydio.getController().defaultActions.set("file", "ext_select");
}
}.bind(this));

pydio.observe("loaded", function(e){
if(this.parameters.get("SELECTOR_DATA")){
pydio.getController().defaultActions.set("file", "ext_select");
pydio.getController().selectorData = this.parameters.get("SELECTOR_DATA");
}
}.bind(this));

if(this.parameters.get("currentLanguage")){
pydio.currentLanguage = this.parameters.get("currentLanguage");
}

//$('version_span').update(' - Version '+this.parameters.get("ajxpVersion") + ' - '+ this.parameters.get("ajxpVersionDate"));

pydio.init();

}.bind(this);

if(!this.parameters.get("debugMode")){
connexion.loadLibrary("pydio.min.js?v="+this.parameters.get("ajxpVersion"), masterClassLoaded, true);
}else{
masterClassLoaded();
}
}

/**
* Detect the base path of the javascripts based on the script tags
*/
detectBaseParameters(){

const scripts = document.getElementsByTagName('script');
for(let i=0; i<scripts.length; i++){
const scriptTag = scripts[i];
if(scriptTag.src.match("/js/ajaxplorer_boot") || scriptTag.src.match("/js/core/PydioBootstrap.js")){
if(scriptTag.src.match("/js/ajaxplorer_boot")){
this.parameters.set("debugMode", false);
}else{
this.parameters.set("debugMode", true);
}
var src = scriptTag.src.replace('/js/core/PydioBootstrap.js','').replace('/js/ajaxplorer_boot.js', '').replace('/js/ajaxplorer_boot_protolegacy.js', '');
if(src.indexOf("?")!=-1) src = src.split("?")[0];
this.parameters.set("ajxpResourcesFolder", src);
}
}
if(this.parameters.get("ajxpResourcesFolder")){
window.ajxpResourcesFolder = this.parameters.get("ajxpResourcesFolder");
}else{
alert("Cannot find resource folder");
}
var booterUrl = this.parameters.get("BOOTER_URL");
if(booterUrl.indexOf("?") > -1){
booterUrl = booterUrl.substring(0, booterUrl.indexOf("?"));
}
this.parameters.set('ajxpServerAccessPath', booterUrl);
this.parameters.set('serverAccessPath', booterUrl);
window.ajxpServerAccessPath = booterUrl;
}

/**
* Loads a CSS file
* @param fileName String
*/
loadCSSResource(fileName){
var head = document.getElementsByTagName('head')[0];
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = this.parameters.get("ajxpResourcesFolder") + '/' + fileName;
cssNode.media = 'screen';
head.appendChild(cssNode);
}
}

0 comments on commit 756bebc

Please sign in to comment.