Code Duplication    Length = 49-50 lines in 2 locations

dev/View/Popup/Compose.js 2 locations

@@ 1952-2001 (lines=50) @@
1949
1950
	oAttachment.fromMessage = false;
1951
	oAttachment.cancel = this.cancelAttachmentHelper(oDriveFile.downloadUrl);
1952
	oAttachment.waiting(false).uploading(true).complete(false);
1953
1954
	this.attachments.push(oAttachment);
1955
1956
	this.attachmentsPlace(true);
1957
1958
	if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
1959
	{
1960
		oAttachment.uploading(false).complete(true);
1961
		oAttachment.error(Translator.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'));
1962
		return false;
1963
	}
1964
1965
	Remote.composeUploadDrive(function(sResult, oData) {
1966
1967
		var bResult = false;
1968
		oAttachment.uploading(false).complete(true);
1969
1970
		if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
1971
		{
1972
			if (oData.Result[oAttachment.id])
1973
			{
1974
				bResult = true;
1975
				oAttachment.tempName(oData.Result[oAttachment.id][0]);
1976
				oAttachment.size(Utils.pInt(oData.Result[oAttachment.id][1]));
1977
			}
1978
		}
1979
1980
		if (!bResult)
1981
		{
1982
			oAttachment.error(Translator.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded));
1983
		}
1984
1985
	}, oDriveFile.downloadUrl, sAccessToken);
1986
1987
	return true;
1988
};
1989
1990
/**
1991
 * @param {MessageModel} oMessage
1992
 * @param {string} sType
1993
 */
1994
ComposePopupView.prototype.prepearMessageAttachments = function(oMessage, sType)
1995
{
1996
	if (oMessage)
1997
	{
1998
		var
1999
			aAttachments = Utils.isNonEmptyArray(oMessage.attachments()) ? oMessage.attachments() : [],
2000
			iIndex = 0,
2001
			iLen = aAttachments.length,
2002
			oAttachment = null,
2003
			oItem = null,
2004
			bAdd = false;
@@ 1897-1945 (lines=49) @@
1894
1895
	oAttachment.fromMessage = false;
1896
	oAttachment.cancel = this.cancelAttachmentHelper(oDropboxFile.link);
1897
	oAttachment.waiting(false).uploading(true).complete(false);
1898
1899
	this.attachments.push(oAttachment);
1900
1901
	this.attachmentsPlace(true);
1902
1903
	if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize)
1904
	{
1905
		oAttachment.uploading(false).complete(true);
1906
		oAttachment.error(Translator.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'));
1907
		return false;
1908
	}
1909
1910
	Remote.composeUploadExternals(function(sResult, oData) {
1911
1912
		var bResult = false;
1913
		oAttachment.uploading(false).complete(true);
1914
1915
		if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
1916
		{
1917
			if (oData.Result[oAttachment.id])
1918
			{
1919
				bResult = true;
1920
				oAttachment.tempName(oData.Result[oAttachment.id]);
1921
			}
1922
		}
1923
1924
		if (!bResult)
1925
		{
1926
			oAttachment.error(Translator.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded));
1927
		}
1928
1929
	}, [oDropboxFile.link]);
1930
1931
	return true;
1932
};
1933
1934
/**
1935
 * @param {Object} oDriveFile
1936
 * @param {string} sAccessToken
1937
 * @returns {boolean}
1938
 */
1939
ComposePopupView.prototype.addDriveAttachment = function(oDriveFile, sAccessToken)
1940
{
1941
	var
1942
		iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')),
1943
		oAttachment = null,
1944
		mSize = oDriveFile.fileSize ? Utils.pInt(oDriveFile.fileSize) : 0;
1945
1946
	oAttachment = new ComposeAttachmentModel(
1947
		oDriveFile.downloadUrl, oDriveFile.title, mSize
1948
	);