Improving my Loading Bar function

I trying to code a loading animation from (Single Element CSS Spinners), the one I’m coding is the most top left corner, However I code it up but it looks too complicated so I’m wondering does any one have a better solution(less code)
(hostcode.sourceforge.net/view/5376), thanks