|
@@ -179,20 +179,20 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
*
|
|
*
|
|
|
* @name Helper.urls2links
|
|
* @name Helper.urls2links
|
|
|
* @function
|
|
* @function
|
|
|
- * @param {Object} element - a jQuery DOM element
|
|
|
|
|
|
|
+ * @param {Object} $element - a jQuery DOM element
|
|
|
*/
|
|
*/
|
|
|
me.urls2links = function($element)
|
|
me.urls2links = function($element)
|
|
|
{
|
|
{
|
|
|
var markup = '<a href="$1" rel="nofollow">$1</a>';
|
|
var markup = '<a href="$1" rel="nofollow">$1</a>';
|
|
|
$element.html(
|
|
$element.html(
|
|
|
$element.html().replace(
|
|
$element.html().replace(
|
|
|
- /((http|https|ftp):\/\/[\w?=&.\/-;#@~%+-]+(?![\w\s?&.\/;#~%"=-]*>))/ig,
|
|
|
|
|
|
|
+ /((http|https|ftp):\/\/[\w?=&.\/-;#@~%+*-]+(?![\w\s?&.\/;#~%"=-]*>))/ig,
|
|
|
markup
|
|
markup
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
$element.html(
|
|
$element.html(
|
|
|
$element.html().replace(
|
|
$element.html().replace(
|
|
|
- /((magnet):[\w?=&.\/-;#@~%+-]+)/ig,
|
|
|
|
|
|
|
+ /((magnet):[\w?=&.\/-;#@~%+*-]+)/ig,
|
|
|
markup
|
|
markup
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
@@ -201,6 +201,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
/**
|
|
/**
|
|
|
* minimal sprintf emulation for %s and %d formats
|
|
* minimal sprintf emulation for %s and %d formats
|
|
|
*
|
|
*
|
|
|
|
|
+ * Note that this function needs the parameters in the same order as the
|
|
|
|
|
+ * format strings appear in the string, contrary to the original.
|
|
|
|
|
+ *
|
|
|
* @see {@link https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format#4795914}
|
|
* @see {@link https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format#4795914}
|
|
|
* @name Helper.sprintf
|
|
* @name Helper.sprintf
|
|
|
* @function
|
|
* @function
|
|
@@ -213,27 +216,22 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
var format = args[0],
|
|
var format = args[0],
|
|
|
i = 1;
|
|
i = 1;
|
|
|
- return format.replace(/%((%)|s|d)/g, function (m) {
|
|
|
|
|
|
|
+ return format.replace(/%(s|d)/g, function (m) {
|
|
|
// m is the matched format, e.g. %s, %d
|
|
// m is the matched format, e.g. %s, %d
|
|
|
- var val;
|
|
|
|
|
- if (m[2]) {
|
|
|
|
|
- val = m[2];
|
|
|
|
|
- } else {
|
|
|
|
|
- val = args[i];
|
|
|
|
|
- // A switch statement so that the formatter can be extended.
|
|
|
|
|
- switch (m)
|
|
|
|
|
- {
|
|
|
|
|
- case '%d':
|
|
|
|
|
- val = parseFloat(val);
|
|
|
|
|
- if (isNaN(val)) {
|
|
|
|
|
- val = 0;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- // Default is %s
|
|
|
|
|
- }
|
|
|
|
|
- ++i;
|
|
|
|
|
|
|
+ var val = args[i];
|
|
|
|
|
+ // A switch statement so that the formatter can be extended.
|
|
|
|
|
+ switch (m)
|
|
|
|
|
+ {
|
|
|
|
|
+ case '%d':
|
|
|
|
|
+ val = parseFloat(val);
|
|
|
|
|
+ if (isNaN(val)) {
|
|
|
|
|
+ val = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ // Default is %s
|
|
|
}
|
|
}
|
|
|
|
|
+ ++i;
|
|
|
return val;
|
|
return val;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -244,7 +242,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @see {@link http://www.w3schools.com/js/js_cookies.asp}
|
|
* @see {@link http://www.w3schools.com/js/js_cookies.asp}
|
|
|
* @name Helper.getCookie
|
|
* @name Helper.getCookie
|
|
|
* @function
|
|
* @function
|
|
|
- * @param {string} cname
|
|
|
|
|
|
|
+ * @param {string} cname - may not be empty
|
|
|
* @return {string}
|
|
* @return {string}
|
|
|
*/
|
|
*/
|
|
|
me.getCookie = function(cname) {
|
|
me.getCookie = function(cname) {
|
|
@@ -675,7 +673,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @function
|
|
* @function
|
|
|
* @return {string} func
|
|
* @return {string} func
|
|
|
*/
|
|
*/
|
|
|
- me.getSymmetricKey = function(func)
|
|
|
|
|
|
|
+ me.getSymmetricKey = function()
|
|
|
{
|
|
{
|
|
|
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
|
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
|
|
|
}
|
|
}
|
|
@@ -903,8 +901,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
me.isVisible = function($element)
|
|
me.isVisible = function($element)
|
|
|
{
|
|
{
|
|
|
var elementTop = $element.offset().top;
|
|
var elementTop = $element.offset().top;
|
|
|
- var elementBottom = elementTop + $element.outerHeight();
|
|
|
|
|
-
|
|
|
|
|
var viewportTop = $(window).scrollTop();
|
|
var viewportTop = $(window).scrollTop();
|
|
|
var viewportBottom = viewportTop + $(window).height();
|
|
var viewportBottom = viewportTop + $(window).height();
|
|
|
|
|
|
|
@@ -985,11 +981,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* Alert/error manager
|
|
* Alert/error manager
|
|
|
*
|
|
*
|
|
|
* @name Alert
|
|
* @name Alert
|
|
|
- * @param {object} window
|
|
|
|
|
- * @param {object} document
|
|
|
|
|
* @class
|
|
* @class
|
|
|
*/
|
|
*/
|
|
|
- var Alert = (function (window, document) {
|
|
|
|
|
|
|
+ var Alert = (function () {
|
|
|
var me = {};
|
|
var me = {};
|
|
|
|
|
|
|
|
var $errorMessage,
|
|
var $errorMessage,
|
|
@@ -1249,17 +1243,16 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
return me;
|
|
|
- })(window, document);
|
|
|
|
|
|
|
+ })();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* handles paste status/result
|
|
* handles paste status/result
|
|
|
*
|
|
*
|
|
|
* @name PasteStatus
|
|
* @name PasteStatus
|
|
|
* @param {object} window
|
|
* @param {object} window
|
|
|
- * @param {object} document
|
|
|
|
|
* @class
|
|
* @class
|
|
|
*/
|
|
*/
|
|
|
- var PasteStatus = (function (window, document) {
|
|
|
|
|
|
|
+ var PasteStatus = (function (window) {
|
|
|
var me = {};
|
|
var me = {};
|
|
|
|
|
|
|
|
var $pasteSuccess,
|
|
var $pasteSuccess,
|
|
@@ -1402,17 +1395,15 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
return me;
|
|
|
- })(window, document);
|
|
|
|
|
|
|
+ })(window);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* password prompt
|
|
* password prompt
|
|
|
*
|
|
*
|
|
|
* @name Prompt
|
|
* @name Prompt
|
|
|
- * @param {object} window
|
|
|
|
|
- * @param {object} document
|
|
|
|
|
* @class
|
|
* @class
|
|
|
*/
|
|
*/
|
|
|
- var Prompt = (function (window, document) {
|
|
|
|
|
|
|
+ var Prompt = (function () {
|
|
|
var me = {};
|
|
var me = {};
|
|
|
|
|
|
|
|
var $passwordDecrypt,
|
|
var $passwordDecrypt,
|
|
@@ -1512,7 +1503,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
return me;
|
|
|
- })(window, document);
|
|
|
|
|
|
|
+ })();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Manage paste/message input, and preview tab
|
|
* Manage paste/message input, and preview tab
|
|
@@ -1520,11 +1511,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* Note that the actual preview is handled by PasteViewer.
|
|
* Note that the actual preview is handled by PasteViewer.
|
|
|
*
|
|
*
|
|
|
* @name Editor
|
|
* @name Editor
|
|
|
- * @param {object} window
|
|
|
|
|
- * @param {object} document
|
|
|
|
|
* @class
|
|
* @class
|
|
|
*/
|
|
*/
|
|
|
- var Editor = (function (window, document) {
|
|
|
|
|
|
|
+ var Editor = (function () {
|
|
|
var me = {};
|
|
var me = {};
|
|
|
|
|
|
|
|
var $editorTabs,
|
|
var $editorTabs,
|
|
@@ -1728,17 +1717,15 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
return me;
|
|
|
- })(window, document);
|
|
|
|
|
|
|
+ })();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* (view) Parse and show paste.
|
|
* (view) Parse and show paste.
|
|
|
*
|
|
*
|
|
|
* @name PasteViewer
|
|
* @name PasteViewer
|
|
|
- * @param {object} window
|
|
|
|
|
- * @param {object} document
|
|
|
|
|
* @class
|
|
* @class
|
|
|
*/
|
|
*/
|
|
|
- var PasteViewer = (function (window, document) {
|
|
|
|
|
|
|
+ var PasteViewer = (function () {
|
|
|
var me = {};
|
|
var me = {};
|
|
|
|
|
|
|
|
var $placeholder,
|
|
var $placeholder,
|
|
@@ -1904,7 +1891,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @function
|
|
* @function
|
|
|
* @return {string}
|
|
* @return {string}
|
|
|
*/
|
|
*/
|
|
|
- me.getText = function(newText)
|
|
|
|
|
|
|
+ me.getText = function()
|
|
|
{
|
|
{
|
|
|
return text;
|
|
return text;
|
|
|
}
|
|
}
|
|
@@ -1981,7 +1968,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
return me;
|
|
|
- })(window, document);
|
|
|
|
|
|
|
+ })();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* (view) Show attachment and preview if possible
|
|
* (view) Show attachment and preview if possible
|
|
@@ -1998,8 +1985,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
$attachmentPreview,
|
|
$attachmentPreview,
|
|
|
$attachment;
|
|
$attachment;
|
|
|
|
|
|
|
|
- var attachmentChanged = false,
|
|
|
|
|
- attachmentHasPreview = false;
|
|
|
|
|
|
|
+ var attachmentHasPreview = false;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* sets the attachment but does not yet show it
|
|
* sets the attachment but does not yet show it
|
|
@@ -2027,8 +2013,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
);
|
|
);
|
|
|
attachmentHasPreview = true;
|
|
attachmentHasPreview = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- attachmentChanged = true;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3043,7 +3027,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @private
|
|
* @private
|
|
|
* @function
|
|
* @function
|
|
|
* @param {int} status
|
|
* @param {int} status
|
|
|
- * @param {int} data - optional
|
|
|
|
|
|
|
+ * @param {int} result - optional
|
|
|
*/
|
|
*/
|
|
|
function success(status, result)
|
|
function success(status, result)
|
|
|
{
|
|
{
|
|
@@ -3063,7 +3047,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @private
|
|
* @private
|
|
|
* @function
|
|
* @function
|
|
|
* @param {int} status - internal code
|
|
* @param {int} status - internal code
|
|
|
- * @param {int} data - original error code
|
|
|
|
|
|
|
+ * @param {int} result - original error code
|
|
|
*/
|
|
*/
|
|
|
function fail(status, result)
|
|
function fail(status, result)
|
|
|
{
|
|
{
|
|
@@ -3107,7 +3091,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
*
|
|
*
|
|
|
* @name Uploader.setUrl
|
|
* @name Uploader.setUrl
|
|
|
* @function
|
|
* @function
|
|
|
- * @param {function} func
|
|
|
|
|
|
|
+ * @param {function} newUrl
|
|
|
*/
|
|
*/
|
|
|
me.setUrl = function(newUrl)
|
|
me.setUrl = function(newUrl)
|
|
|
{
|
|
{
|
|
@@ -3236,17 +3220,18 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
* @return {array}
|
|
* @return {array}
|
|
|
*/
|
|
*/
|
|
|
me.parseUploadError = function(status, data, doThisThing) {
|
|
me.parseUploadError = function(status, data, doThisThing) {
|
|
|
- var errorArray = ['Error while parsing error message.'];
|
|
|
|
|
|
|
+ var errorArray;
|
|
|
|
|
|
|
|
switch (status) {
|
|
switch (status) {
|
|
|
- case Uploader.error['custom']:
|
|
|
|
|
|
|
+ case me.error['custom']:
|
|
|
errorArray = ['Could not ' + doThisThing + ': %s', data.message];
|
|
errorArray = ['Could not ' + doThisThing + ': %s', data.message];
|
|
|
break;
|
|
break;
|
|
|
- case Uploader.error['unknown']:
|
|
|
|
|
|
|
+ case me.error['unknown']:
|
|
|
errorArray = ['Could not ' + doThisThing + ': %s', I18n._('unknown status')];
|
|
errorArray = ['Could not ' + doThisThing + ': %s', I18n._('unknown status')];
|
|
|
break;
|
|
break;
|
|
|
- case Uploader.error['serverError']:
|
|
|
|
|
- errorArray = ['Could not ' + doThisThing + ': %s', I18n._('server error or not responding')]; break;
|
|
|
|
|
|
|
+ case me.error['serverError']:
|
|
|
|
|
+ errorArray = ['Could not ' + doThisThing + ': %s', I18n._('server error or not responding')];
|
|
|
|
|
+ break;
|
|
|
default:
|
|
default:
|
|
|
errorArray = ['Could not ' + doThisThing + ': %s', I18n._('unknown error')];
|
|
errorArray = ['Could not ' + doThisThing + ': %s', I18n._('unknown error')];
|
|
|
break;
|
|
break;
|
|
@@ -3884,7 +3869,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
|
|
|
|
|
// show proper elements on screen
|
|
// show proper elements on screen
|
|
|
PasteDecrypter.run();
|
|
PasteDecrypter.run();
|
|
|
- return;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|