Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-isaac authored Oct 31, 2017
1 parent 6dc3a01 commit 89dbb99
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 75 deletions.
3 changes: 2 additions & 1 deletion Catalog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,9 @@ end
function RemoveTrailingSpecialCharacters(item)
local trailingCharacters = { '\\', '/', ',', '.', ';', ':', '-', '=' };
for _, value in ipairs(trailingCharacters) do
if (string.match(item, value, -1)) then
if (string.find(item, value, -1, true)) then
return Utility.Trim(item:sub(1, -2))
end
end
return item;
end
2 changes: 1 addition & 1 deletion Config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Alma Blacklight Catalog Search</Name>
<Author>Atlas Systems</Author>
<Version>1.1.0</Version>
<Version>1.2.1</Version>
<Active>True</Active>
<Type>Addon</Type>
<Description>Catalog Search and Import Addon that uses Alma as the catalog and Blacklight as the discovery layer</Description>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

**1.1.0 -** Added LocationCode row. Corrected library mapping.

**1.2.0 -** Correct bug that removes a incorrect characters from certain fields when `RemoveTrailingSpecialCharacters` is on.

## Summary
The addon is located within an item record of an Atlas Product. It is found on the `"Catalog Search"` tab. The addon takes information from the fields in the Atlas Product and searches the catalog in the configured ordered. When the item is found, one selects the desired holding in the *Item Grid* below the browser and clicks *Import*. The addon then makes the necessary API calls to the Alma API and imports the item's information into the Atlas Product.

Expand Down
73 changes: 0 additions & 73 deletions Utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,78 +229,6 @@ local function URLEncode(s)
end


-- from sam_lie
-- Compatible with Lua 5.0 and 5.1.
-- Disclaimer : use at own risk especially for hedge fund reports :-)
---============================================================
-- add comma to separate thousands
--
local function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end

---============================================================
-- rounds a number to the nearest decimal places
--
local function round(val, decimal)
if (decimal) then
return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
else
return math.floor(val+0.5)
end
end

--===================================================================
-- given a numeric value formats output with comma to separate thousands
-- and rounded to given decimal places
--
--
local function format_num(amount, decimal, prefix, neg_prefix)
Log("[Utility.format_num] ");

local str_amount, formatted, famount, remain

decimal = decimal or 2 -- default 2 decimal places
neg_prefix = neg_prefix or "-" -- default negative sign

famount = math.abs(round(amount,decimal))
famount = math.floor(famount)

remain = round(math.abs(amount) - famount, decimal)

-- comma to separate the thousands
formatted = comma_value(famount)

-- attach the decimal portion
if (decimal > 0) then
remain = string.sub(tostring(remain),3)
formatted = formatted .. "." .. remain ..
string.rep("0", decimal - string.len(remain))
end

-- attach prefix string e.g '$'
formatted = (prefix or "") .. formatted;

-- if value is negative then format accordingly
if (amount < 0) then
if (neg_prefix=="()") then
formatted = "("..formatted ..")"
else
formatted = neg_prefix .. formatted
end
end

return formatted;
end


UtilityInternal.Trim = Trim;
UtilityInternal.IsType = IsType;
UtilityInternal.Log = Log;
Expand All @@ -310,4 +238,3 @@ local function URLEncode(s)
UtilityInternal.CreateQueryString = CreateQueryString;
UtilityInternal.GetXmlChildValue = GetChildValue;
UtilityInternal.GetXmlNodeCount = GetNodeCount;
UtilityInternal.FormatNumber = format_num;

0 comments on commit 89dbb99

Please sign in to comment.