From 767d16693c9df38a2f496d4ca2ba8559db5eba5d Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Fri, 31 Jul 2015 10:00:09 +0200
Subject: [PATCH] removed deprecated JavaScript

---
 lib/exe/js.php               |   4 +-
 lib/scripts/compatibility.js | 395 -----------------------------------
 lib/scripts/drag.js          |  87 --------
 lib/scripts/tw-sack.js       | 140 -------------
 4 files changed, 1 insertion(+), 625 deletions(-)
 delete mode 100644 lib/scripts/drag.js
 delete mode 100644 lib/scripts/tw-sack.js

diff --git a/lib/exe/js.php b/lib/exe/js.php
index 2df2d0ba6..16d22daf2 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -56,11 +56,9 @@ function js_out(){
                 DOKU_INC.'lib/scripts/delay.js',
                 DOKU_INC.'lib/scripts/cookie.js',
                 DOKU_INC.'lib/scripts/script.js',
-                DOKU_INC.'lib/scripts/tw-sack.js',
                 DOKU_INC.'lib/scripts/qsearch.js',
                 DOKU_INC.'lib/scripts/tree.js',
                 DOKU_INC.'lib/scripts/index.js',
-                DOKU_INC.'lib/scripts/drag.js',
                 DOKU_INC.'lib/scripts/textselection.js',
                 DOKU_INC.'lib/scripts/toolbar.js',
                 DOKU_INC.'lib/scripts/edit.js',
@@ -68,7 +66,7 @@ function js_out(){
                 DOKU_INC.'lib/scripts/locktimer.js',
                 DOKU_INC.'lib/scripts/linkwiz.js',
                 DOKU_INC.'lib/scripts/media.js',
-# deprecated                DOKU_INC.'lib/scripts/compatibility.js',
+                DOKU_INC.'lib/scripts/compatibility.js',
 # disabled for FS#1958                DOKU_INC.'lib/scripts/hotkeys.js',
                 DOKU_INC.'lib/scripts/behaviour.js',
                 DOKU_INC.'lib/scripts/page.js',
diff --git a/lib/scripts/compatibility.js b/lib/scripts/compatibility.js
index fc020cce8..154aeadf7 100644
--- a/lib/scripts/compatibility.js
+++ b/lib/scripts/compatibility.js
@@ -40,398 +40,3 @@ function DEPRECATED_WRAP(func, context) {
         return func.apply(context || this, arguments);
     };
 }
-
-/**
- * Handy shortcut to document.getElementById
- *
- * This function was taken from the prototype library
- *
- * @link http://prototype.conio.net/
- */
-function $() {
-    DEPRECATED('Please use the jQuery() function instead.');
-
-    var elements = new Array();
-
-    for (var i = 0; i < arguments.length; i++) {
-        var element = arguments[i];
-        if (typeof element == 'string')
-            element = document.getElementById(element);
-
-        if (arguments.length == 1)
-            return element;
-
-        elements.push(element);
-    }
-
-    return elements;
-}
-
-
-
-
-var index = {
-    throbber_delay: dw_index.throbber_delay,
-    toggle: DEPRECATED_WRAP(dw_index.toggle, dw_index),
-    treeattach: DEPRECATED_WRAP(dw_index.treeattach, dw_index)
-};
-
-var ajax_quicksearch = {
-    init: function() {
-        DEPRECATED('Use jQuery().dw_qsearch() instead');
-        jQuery('#qsearch__in').dw_qsearch({
-            output: '#qsearch__out'
-        });
-    },
-    clear_results: function() {
-        DEPRECATED('ajax_quicksearch.clear_results is removed');
-    },
-    onCompletion: function() {
-        DEPRECATED('ajax_quicksearch.onCompletion is removed');
-    }
-};
-var dw_qsearch = {
-    init: function(input, output) {
-        DEPRECATED('Use jQuery().dw_qsearch() instead');
-        jQuery(input).dw_qsearch({
-            output: output
-        });
-    },
-    clear_results: function() {
-        DEPRECATED('dw_qsearch.clear_results is removed');
-    },
-    onCompletion: function() {
-        DEPRECATED('dw_qsearch.onCompletion is removed');
-    }
-};
-
-var linkwiz = {
-    init: DEPRECATED_WRAP(dw_linkwiz.init, dw_linkwiz),
-    onEntry: DEPRECATED_WRAP(dw_linkwiz.onEntry, dw_linkwiz),
-    getResult: DEPRECATED_WRAP(dw_linkwiz.getResult, dw_linkwiz),
-    select: DEPRECATED_WRAP(dw_linkwiz.select, dw_linkwiz),
-    deselect: DEPRECATED_WRAP(dw_linkwiz.deselect, dw_linkwiz),
-    onResultClick: DEPRECATED_WRAP(dw_linkwiz.onResultClick, dw_linkwiz),
-    resultClick: DEPRECATED_WRAP(dw_linkwiz.resultClick, dw_linkwiz),
-    insertLink: DEPRECATED_WRAP(dw_linkwiz.insertLink, dw_linkwiz),
-    autocomplete: DEPRECATED_WRAP(dw_linkwiz.autocomplete, dw_linkwiz),
-    autocomplete_exec: DEPRECATED_WRAP(dw_linkwiz.autocomplete_exec, dw_linkwiz),
-    show: DEPRECATED_WRAP(dw_linkwiz.show, dw_linkwiz),
-    hide: DEPRECATED_WRAP(dw_linkwiz.hide, dw_linkwiz),
-    toggle: DEPRECATED_WRAP(dw_linkwiz.toggle, dw_linkwiz)
-};
-
-var locktimer = {
-    init: DEPRECATED_WRAP(dw_locktimer.init, dw_locktimer),
-    reset: DEPRECATED_WRAP(dw_locktimer.reset, dw_locktimer),
-    warning: DEPRECATED_WRAP(dw_locktimer.warning, dw_locktimer),
-    clear: DEPRECATED_WRAP(dw_locktimer.clear, dw_locktimer),
-    refresh: DEPRECATED_WRAP(dw_locktimer.refresh, dw_locktimer),
-    refreshed: DEPRECATED_WRAP(dw_locktimer.refreshed, dw_locktimer)
-};
-
-var media_manager = {
-    // treeattach, selectorattach, confirmattach are munched together into
-    // dw_mediamanager.init
-    attachoptions: DEPRECATED_WRAP(dw_mediamanager.attachoptions, dw_mediamanager),
-    togglekeepopen: function (event, cb) {
-        DEPRECATED('Use dw_mediamanager.toggleOption instead');
-        return dw_mediamanager.toggleOption.call(cb, 'keepopen');
-    },
-    togglehide: function (event, cb) {
-        DEPRECATED('Use dw_mediamanager.toggleOption instead');
-        return dw_mediamanager.toggleOption.call(cb, 'hide');
-    },
-    updatehide: DEPRECATED_WRAP(dw_mediamanager.updatehide, dw_mediamanager),
-    select: function (event, link) {
-        DEPRECATED('Use dw_mediamanager.select instead');
-        return dw_mediamanager.select.call(link, event);
-    },
-    initpopup: DEPRECATED_WRAP(dw_mediamanager.initpopup, dw_mediamanager),
-    insert: DEPRECATED_WRAP(dw_mediamanager.insert, dw_mediamanager),
-    list: function (event, link) {
-        DEPRECATED('Use dw_mediamanager.list instead');
-        return dw_mediamanager.list.call(link, event);
-    },
-    // toggle is handled by dw_tree
-    suggest: DEPRECATED_WRAP(dw_mediamanager.suggest, dw_mediamanager),
-    initFlashUpload: DEPRECATED_WRAP(dw_mediamanager.initFlashUpload, dw_mediamanager),
-    closePopup: function () {
-        DEPRECATED();
-        dw_mediamanager.$popup.dialog('close');
-    },
-    setalign: function (event, cb) {
-        DEPRECATED('Use dw_mediamanager.setOpt instead');
-        return dw_mediamanager.setOpt.call(this, 'align', event);
-    },
-    setlink: function (event, cb) {
-        DEPRECATED('Use dw_mediamanager.setOpt instead');
-        return dw_mediamanager.setOpt.call(this, 'link', event);
-    },
-    setsize: function (event, cb) {
-        DEPRECATED('Use dw_mediamanager.setOpt instead');
-        return dw_mediamanager.setOpt.call(this, 'size', event);
-    },
-    outSet: function (id) {
-        DEPRECATED();
-        return jQuery(id).removeClass('selected');
-    },
-    inSet: function (id) {
-        DEPRECATED();
-        return jQuery(id).addClass('selected');
-    }
-};
-
-initSizeCtl = DEPRECATED_WRAP(dw_editor.initSizeCtl);
-sizeCtl = DEPRECATED_WRAP(dw_editor.sizeCtl);
-toggleWrap = DEPRECATED_WRAP(dw_editor.toggleWrap);
-setWrap = DEPRECATED_WRAP(dw_editor.setWrap);
-
-function findPosX(object){
-    DEPRECATED('Use jQuery.offset() instead');
-    return jQuery(object).offset().left;
-}
-
-function findPosY(object){
-    DEPRECATED('Use jQuery.offset() instead');
-    return jQuery(object).offset().top;
-}
-
-function getElementsByClass(searchClass,node,tag){
-    DEPRECATED('Use jQuery() instead');
-    if(node == null) node = document;
-    if(typeof tag === 'undefined') tag = '';
-    return jQuery(node).find(tag+'.'+searchClass).toArray();
-}
-
-function prependChild(parent,element) {
-    DEPRECATED('Use jQuery.prepend() instead');
-    jQuery(parent).prepend(element);
-}
-
-function addEvent(element, type, handler) {
-    DEPRECATED('Use jQuery.bind() instead. Note that jQuery’s behaviour' +
-               ' when a handler returns false differs from addEvent’s');
-    jQuery(element).bind(type,{},function (e) {
-        // returning false in an addEvent event handler did not prevent
-        // bubbling but just canceled handlers on this node and prevented
-        // default behavior, so wrap the handler call and mimic that behavior.
-        //
-        // Refer to jQuery.event.handle().
-        var ret = handler.apply(this, Array.prototype.slice.call(arguments, 0));
-        if (typeof ret !== 'undefined') {
-            if ( ret !== false ) {
-                return ret;
-            }
-            // What jQuery does.
-            e.result = ret;
-            e.preventDefault();
-            // Not what jQuery does. This would be: event.stopPropagation();
-            // Hack it so that immediate propagation (other event handlers on
-            // this element) appears stopped without stopping the actual
-            // propagation (bubbling)
-            e.isImmediatePropagationStopped = function () { return true; };
-        }
-    });
-}
-
-function removeEvent(element, type, handler) {
-    DEPRECATED('Use jQuery.unbind() instead.');
-    jQuery(element).unbind(type,handler);
-}
-
-function addInitEvent(func) {
-    DEPRECATED('Use jQuery(<function>) instead');
-    jQuery(func);
-}
-
-
-function jsEscape(text){
-    DEPRECATED('Insert text through jQuery.text() instead of escaping on your own');
-    var re=new RegExp("\\\\","g");
-    text=text.replace(re,"\\\\");
-    re=new RegExp("'","g");
-    text=text.replace(re,"\\'");
-    re=new RegExp('"',"g");
-    text=text.replace(re,'&quot;');
-    re=new RegExp("\\\\\\\\n","g");
-    text=text.replace(re,"\\n");
-    return text;
-}
-
-/**
- * Simple function to check if a global var is defined
- *
- * @author Kae Verens
- * @link http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-2835
- */
-function isset(varname){
-    DEPRECATED("Use `typeof var !== 'undefined'` instead");
-    return(typeof(window[varname])!='undefined');
-}
-
-/**
- * Checks if property is undefined
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isUndefined (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'undefined'` instead");
-    return (typeof prop == 'undefined');
-}
-
-/**
- * Checks if property is function
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isFunction (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'function'` instead");
-    return (typeof prop == 'function');
-}
-/**
- * Checks if property is string
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isString (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'string'` instead");
-    return (typeof prop == 'string');
-}
-
-/**
- * Checks if property is number
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isNumber (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'number'` instead");
-    return (typeof prop == 'number');
-}
-
-/**
- * Checks if property is the calculable number
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isNumeric (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'number' && !isNaN(var) && isFinite(var)` instead");
-    return isNumber(prop)&&!isNaN(prop)&&isFinite(prop);
-}
-
-/**
- * Checks if property is array
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isArray (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `var instanceof Array` instead");
-    return (prop instanceof Array);
-}
-
-/**
- *  Checks if property is regexp
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isRegExp (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `var instanceof RegExp` instead");
-    return (prop instanceof RegExp);
-}
-
-/**
- * Checks if property is a boolean value
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isBoolean (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'boolean'` instead");
-    return ('boolean' == typeof prop);
-}
-
-/**
- * Checks if property is a scalar value (value that could be used as the hash key)
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isScalar (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED("Use `typeof var === 'string' || (typeof var === 'number' &&" +
-               " !isNaN(var) && isFinite(var))` instead");
-    return isNumeric(prop)||isString(prop);
-}
-
-/**
- * Checks if property is empty
- *
- * @param {Object} prop value to check
- * @return {Boolean} true if matched
- * @scope public
- * @author Ilya Lebedev <ilya@lebedev.net>
- */
-function isEmpty (prop /* :Object */) /* :Boolean */ {
-    DEPRECATED();
-    var i;
-    if (isBoolean(prop)) {
-        return false;
-    } else if (isRegExp(prop) && new RegExp("").toString() == prop.toString()) {
-        return true;
-    } else if (isString(prop) || isNumber(prop)) {
-        return !prop;
-    } else if (Boolean(prop) && false != prop) {
-        for (i in prop) {
-            if(prop.hasOwnProperty(i)) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-/**
- * Get the computed style of a node.
- *
- * @link https://acidmartin.wordpress.com/2008/08/26/style-get-any-css-property-value-of-an-object/
- * @link http://svn.dojotoolkit.org/src/dojo/trunk/_base/html.js
- */
-function gcs(node){
-    DEPRECATED('Use jQuery(node).style() instead');
-    if(node.currentStyle){
-        return node.currentStyle;
-    }else{
-        return node.ownerDocument.defaultView.getComputedStyle(node, null);
-    }
-}
-
-/**
- * Until 2011-05-25 "Rincewind", a code intended to fix some Safari issue
- * always declared the global _timer. plugin:sortablejs relies on _timer
- * being declared.
- */
-var _timer;
diff --git a/lib/scripts/drag.js b/lib/scripts/drag.js
deleted file mode 100644
index dd252d95d..000000000
--- a/lib/scripts/drag.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Makes a DOM object draggable
- *
- * If you just want to move objects around, use drag.attach. For full
- * customization, drag can be used as a javascript prototype, it is
- * inheritance-aware.
- *
- * @deprecated
- * @link http://nofunc.org/Drag_Drop/
- */
-var drag = {
-    obj: null,
-    handle: null,
-    oX: 0,  // object X position
-    oY: 0,  // object Y position
-    eX: 0,  // event X delta
-    eY: 0,  // event Y delta
-
-    /**
-     * Attaches the needed handlers to the given object
-     *
-     * This can be called for multiple objects, the right one is later
-     * determined from the event itself. The handle is optional
-     *
-     * @param DOMObject obj    The object that should be draggable
-     * @param DOMObject handle A handle on which the obj can be dragged
-     */
-    attach: function (obj,handle) {
-        DEPRECATED('Use jQuery.draggable() instead.');
-        if(handle){
-            handle.dragobject = obj;
-        }else{
-            handle = obj;
-        }
-        var _this = this;
-        addEvent($(handle),'mousedown',function (e) {return _this.start(e); });
-    },
-
-    /**
-     * Starts the dragging operation
-     */
-    start: function (e){
-        this.handle = e.target;
-        if(this.handle.dragobject){
-            this.obj = this.handle.dragobject;
-        }else{
-            this.obj = this.handle;
-        }
-
-        this.handle.className += ' ondrag';
-        this.obj.className    += ' ondrag';
-
-        this.oX = parseInt(this.obj.style.left);
-        this.oY = parseInt(this.obj.style.top);
-        this.eX = e.pageX;
-        this.eY = e.pageY;
-
-        var _this = this;
-        this.mousehandlers = [function (e) {return _this.drag(e);}, function (e) {return _this.stop(e);}];
-        addEvent(document,'mousemove', this.mousehandlers[0]);
-        addEvent(document,'mouseup', this.mousehandlers[1]);
-
-        return false;
-    },
-
-    /**
-     * Ends the dragging operation
-     */
-    stop: function(){
-        this.handle.className = this.handle.className.replace(/ ?ondrag/,'');
-        this.obj.className    = this.obj.className.replace(/ ?ondrag/,'');
-        removeEvent(document,'mousemove', this.mousehandlers[0]);
-        removeEvent(document,'mouseup', this.mousehandlers[1]);
-        this.obj = null;
-        this.handle = null;
-    },
-
-    /**
-     * Moves the object during the dragging operation
-     */
-    drag: function(e) {
-        if(this.obj) {
-            this.obj.style.top  = (e.pageY+this.oY-this.eY+'px');
-            this.obj.style.left = (e.pageX+this.oX-this.eX+'px');
-        }
-    }
-};
diff --git a/lib/scripts/tw-sack.js b/lib/scripts/tw-sack.js
deleted file mode 100644
index b0e570151..000000000
--- a/lib/scripts/tw-sack.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Simple AJAX Code-Kit (SACK) */
-/* ©2005 Gregory Wild-Smith */
-/* www.twilightuniverse.com */
-/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
-/* @deprecated */
-
-function sack(file){
-  this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
-  this.requestFile = file;
-  this.method = "POST";
-  this.URLString = "";
-  this.encodeURIString = true;
-  this.execute = false;
-  this.asynchronous = true;
-
-  this.onLoading = function() { };
-  this.onLoaded = function() { };
-  this.onInteractive = function() { };
-  this.onCompletion = function() { };
-  this.afterCompletion = function() { };
-
-  this.createAJAX = function() {
-    try {
-      this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
-    } catch (e) {
-      try {
-        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
-      } catch (err) {
-        this.xmlhttp = null;
-      }
-    }
-    if(!this.xmlhttp && typeof XMLHttpRequest != "undefined"){
-      this.xmlhttp = new XMLHttpRequest();
-    }
-    if (!this.xmlhttp){
-      this.failed = true;
-    }
-  };
-
-  this.setVar = function(name, value){
-    if (this.URLString.length < 3){
-      this.URLString = name + "=" + value;
-    } else {
-      this.URLString += "&" + name + "=" + value;
-    }
-  };
-
-  this.encVar = function(name, value){
-    var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
-  return varString;
-  };
-
-  this.encodeURLString = function(string){
-    varArray = string.split('&');
-    for (i = 0; i < varArray.length; i++){
-      urlVars = varArray[i].split('=');
-      if (urlVars[0].indexOf('amp;') != -1){
-        urlVars[0] = urlVars[0].substring(4);
-      }
-      varArray[i] = this.encVar(urlVars[0],urlVars[1]);
-    }
-  return varArray.join('&');
-  };
-
-  this.runResponse = function(){
-    eval(this.response);
-  };
-
-  this.runAJAX = function(urlstring){
-    DEPRECATED('Please use jQuery.post() or any other of jQuery\'s AJAX methods.');
-
-    this.responseStatus = new Array(2);
-    if(this.failed && this.AjaxFailedAlert){
-      alert(this.AjaxFailedAlert);
-    } else {
-      if (urlstring){
-        if (this.URLString.length){
-          this.URLString = this.URLString + "&" + urlstring;
-        } else {
-          this.URLString = urlstring;
-        }
-      }
-      if (this.encodeURIString){
-        var timeval = new Date().getTime();
-        this.URLString = this.encodeURLString(this.URLString);
-        this.setVar("rndval", timeval);
-      }
-      if (this.element) { this.elementObj = document.getElementById(this.element); }
-      if (this.xmlhttp) {
-        var self = this;
-        if (this.method == "GET") {
-          var totalurlstring = this.requestFile + "?" + this.URLString;
-          this.xmlhttp.open(this.method, totalurlstring, this.asynchronous);
-        } else {
-          this.xmlhttp.open(this.method, this.requestFile, this.asynchronous);
-        }
-        if (this.method == "POST"){
-          try {
-             this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
-          } catch (e) {}
-        }
-
-        this.xmlhttp.onreadystatechange = function() {
-          switch (self.xmlhttp.readyState){
-            case 1:
-              self.onLoading();
-            break;
-            case 2:
-              self.onLoaded();
-            break;
-            case 3:
-              self.onInteractive();
-            break;
-            case 4:
-              self.response = self.xmlhttp.responseText;
-              self.responseXML = self.xmlhttp.responseXML;
-              self.responseStatus[0] = self.xmlhttp.status;
-              self.responseStatus[1] = self.xmlhttp.statusText;
-              self.onCompletion();
-              if(self.execute){ self.runResponse(); }
-              if (self.elementObj) {
-                var elemNodeName = self.elementObj.nodeName;
-                elemNodeName.toLowerCase();
-                if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
-                  self.elementObj.value = self.response;
-                } else {
-                  self.elementObj.innerHTML = self.response;
-                }
-              }
-              self.afterCompletion();
-              self.URLString = "";
-            break;
-          }
-        };
-        this.xmlhttp.send(this.URLString);
-      }
-    }
-  };
-this.createAJAX();
-}
-- 
GitLab