From 368aa2305bf551a9b8ca3c88354c0131d1a1442d Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 29 Jan 2017 16:19:12 +0100 Subject: [PATCH] removing unused pieces of code (legacy?), resolves #165 --- js/privatebin.js | 87 +++--------------------------------------------- js/test.js | 18 ---------- 2 files changed, 5 insertions(+), 100 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index c80cd3e..fed80c3 100644 --- a/js/privatebin.js +++ b/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) ); diff --git a/js/test.js b/js/test.js index 5208fd3..b979534 100644 --- a/js/test.js +++ b/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); - }); - }); });