First save these there files to your computer. Then upload them to your SharePoint.
I uploaded the Item_calculator.html here:
And the style.css & script.js here:
Check the lines 14,34 and 35 in the Item_Calculator.html to make sure, that your uploaded files are really in that place.
You don’t have to change anything in the style.css and script.js to get the calculator work.
After that you have to create a Query Rule. I did that like this:
1. Open SharePoint Central Administration and click on “Manage Service Application”.
2. Click on Search Service Application and then on the left bottom side on Query Rules.
3. First select the context (1) (I selected Local SharePoint Results) and then click on “New Query Rule”(2).
4. The “Add Query Rule form” should be displayed.
5. Fill in the Rule name (1), change the Query Condition to Advanced Query Text Match (2) and set the field “Query matches this regular expression” to: d+s*[/+-/*]s*d+ (3)
6. Next Step (4) click on “Add Result Block”.
7. In the displayed “Add Result Block form” configure the Query (1) with just a *.
(You are essentially telling the rule, to get any result, no matter what). Otherwise you probably can’t calculate e.g. 500360-23, because there are no items found for that query.
8. Select only one Item (2).
9. I selected to show the block always above the core results (3).
10. And of course set the path of your Item_Calculator.js .
In my case: ~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Calculator.js
(Should have been created automatically by uploading the .html file).
11. Save the Result Block and save the Query Rule. After that it should look similar to this:
12. That’s it. After you did the above steps you should get an output like this:
If you have any questions don’t be afraIT. Ask!