Jelajahi Sumber

removing unused pieces of code (legacy?), resolves #165

El RIDO 9 tahun lalu
induk
melakukan
368aa2305b
2 mengubah file dengan 5 tambahan dan 100 penghapusan
  1. 5 82
      js/privatebin.js
  2. 0 18
      js/test.js

+ 5 - 82
js/privatebin.js

@@ -69,84 +69,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
             return [v, 'month'];
         },
 
-        /**
-         * converts an associative array to an encoded string
-         * for appending to the anchor
-         *
-         * @name   helper.hashToParameterString
-         * @function
-         * @param  {Object} hashMap - Object to be serialized
-         * @return {string}
-         */
-        hashToParameterString: function(hashMap)
-        {
-            var parameterString = '';
-            for (var key in hashMap)
-            {
-                if (parameterString === '')
-                {
-                    parameterString = encodeURIComponent(key);
-                    parameterString += '=' + encodeURIComponent(hashMap[key]);
-                }
-                else
-                {
-                    parameterString += '&' + encodeURIComponent(key);
-                    parameterString += '=' + encodeURIComponent(hashMap[key]);
-                }
-            }
-            // padding for URL shorteners
-            if (parameterString.length > 0) {
-                parameterString += '&';
-            }
-            parameterString += 'p=p';
-
-            return parameterString;
-        },
-
-        /**
-         * converts a anchor string to an associative array
-         *
-         * @name   helper.parameterStringToHash
-         * @function
-         * @param  {string} parameterString - String containing parameters
-         * @return {Object} hash map
-         */
-        parameterStringToHash: function(parameterString)
-        {
-            var parameterHash = {};
-            var parameterArray = parameterString.split('&');
-            for (var i = 0; i < parameterArray.length; i++)
-            {
-                if (parameterArray[i] != '') {
-                    var pair = parameterArray[i].split('=');
-                    var key = decodeURIComponent(pair[0]);
-                    var value = decodeURIComponent(pair[1]);
-                    parameterHash[key] = value;
-                }
-            }
-            return parameterHash;
-        },
-
-        /**
-         * get an associative array of the parameters found in the anchor
-         *
-         * @name   helper.getParameterHash
-         * @function
-         * @return {Object}
-         */
-        getParameterHash: function()
-        {
-            var hashIndex = window.location.href.indexOf('#');
-            if (hashIndex >= 0)
-            {
-                return this.parameterStringToHash(window.location.href.substring(hashIndex + 1));
-            }
-            else
-            {
-                return {};
-            }
-        },
-
         /**
          * text range selection
          *
@@ -747,10 +669,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
                 case 'markdown':
                     if (typeof showdown === 'object')
                     {
-                        showdown.setOption('strikethrough', true);
-                        showdown.setOption('tables', true);
-                        showdown.setOption('tablesHeaderId', true);
-                        var converter = new showdown.Converter();
+                        var converter = new showdown.Converter({
+                            strikethrough: true,
+                            tables: true,
+                            tablesHeaderId: true
+                        });
                         this.clearText.html(
                             converter.makeHtml(text)
                         );

+ 0 - 18
js/test.js

@@ -56,23 +56,5 @@ describe('helper', function () {
             return $.PrivateBin.helper.secondsToHuman(number)[1] === 'month';
         });
     });
-
-    describe('hashToParameterString', function () {
-        jsc.property('returns strings', 'dict nestring', function (dict) {
-            return typeof $.PrivateBin.helper.hashToParameterString(dict) === 'string';
-        });
-    });
-
-    describe('parameterStringToHash', function () {
-        jsc.property('returns objects', 'string', function (string) {
-            return typeof $.PrivateBin.helper.parameterStringToHash(string) === 'object';
-        });
-        jsc.property('decodes hashes generated with hashToParameterString', 'dict nestring', function (dict) {
-            var result = $.PrivateBin.helper.parameterStringToHash($.PrivateBin.helper.hashToParameterString(dict));
-            // padding for URL shorteners
-            dict.p = 'p';
-            return JSON.stringify(result) === JSON.stringify(dict);
-        });
-    });
 });