Thread:ShayneSteer/@comment-5631351-20130412082226

Hey!

You said you know JS so I was wondering if you could help me do this.

This is a calculator I made to calculate experiance necessary to level us in Clash of Clans you can check it out here. I was wondering if you could do me a favor and re-code it so it will suit the Hay Day leveling up system. This is the code for the Clash of Clans experiance calculator. function doExperience ( Level) { if ( isNaN( Level) ) return ( "???" ) ; if ( Level <span class="sy0" style="color:rgb(51,153,51);">< <span class="nu0" style="color:rgb(204,0,0);">0 <span class="br0" style="color:rgb(0,153,0);">) <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">return <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"???" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">else <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">if <span class="br0" style="color:rgb(0,153,0);">( Level <span class="sy0" style="color:rgb(51,153,51);">== <span class="nu0" style="color:rgb(204,0,0);">0 <span class="br0" style="color:rgb(0,153,0);">) <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">return <span class="br0" style="color:rgb(0,153,0);">( <span class="nu0" style="color:rgb(204,0,0);">0 <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">else <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">if <span class="br0" style="color:rgb(0,153,0);">( Level <span class="sy0" style="color:rgb(51,153,51);">> <span class="nu0" style="color:rgb(204,0,0);">0 <span class="br0" style="color:rgb(0,153,0);">) <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">return <span class="br0" style="color:rgb(0,153,0);">( <span class="br0" style="color:rgb(0,153,0);">( <span class="br0" style="color:rgb(0,153,0);">( Level <span class="sy0" style="color:rgb(51,153,51);">* <span class="nu0" style="color:rgb(204,0,0);">50 <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">- <span class="nu0" style="color:rgb(204,0,0);">50 <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">return <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"???" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="br0" style="color:rgb(0,153,0);">} <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">function calcExperience <span class="br0" style="color:rgb(0,153,0);">( index<span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">{ <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var Level <span class="sy0" style="color:rgb(51,153,51);">= parseInt<span class="br0" style="color:rgb(0,153,0);">( document.<span class="me1" style="color:rgb(102,0,102);">getElementById <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"lev_input_" <span class="sy0" style="color:rgb(51,153,51);">+ index<span class="br0" style="color:rgb(0,153,0);">) .<span class="me1" style="color:rgb(102,0,102);">value <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var result <span class="sy0" style="color:rgb(51,153,51);">= doExperience<span class="br0" style="color:rgb(0,153,0);">( Level<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">if <span class="br0" style="color:rgb(0,153,0);">( result <span class="sy0" style="color:rgb(51,153,51);">!= <span class="nu0" style="color:rgb(204,0,0);">1 <span class="br0" style="color:rgb(0,153,0);">) document.<span class="me1" style="color:rgb(102,0,102);">getElementById <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"ex_result_" <span class="sy0" style="color:rgb(51,153,51);">+ index<span class="br0" style="color:rgb(0,153,0);">) .<span class="me1" style="color:rgb(102,0,102);">innerHTML <span class="sy0" style="color:rgb(51,153,51);">= <span class="st0" style="color:rgb(51,102,204);">" = " <span class="sy0" style="color:rgb(51,153,51);">+ result <span class="sy0" style="color:rgb(51,153,51);">+ <span class="st0" style="color:rgb(51,102,204);">" Experience" <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">else document.<span class="me1" style="color:rgb(102,0,102);">getElementById <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"ex_result_" <span class="sy0" style="color:rgb(51,153,51);">+ index<span class="br0" style="color:rgb(0,153,0);">) .<span class="me1" style="color:rgb(102,0,102);">innerHTML <span class="sy0" style="color:rgb(51,153,51);">= <span class="st0" style="color:rgb(51,102,204);">" = " <span class="sy0" style="color:rgb(51,153,51);">+ result <span class="sy0" style="color:rgb(51,153,51);">+ <span class="st0" style="color:rgb(51,102,204);">" Experience" <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">return <span class="kw2" style="font-weight:bold;color:rgb(0,51,102);">false <span class="sy0" style="color:rgb(51,153,51);">; <span class="br0" style="color:rgb(0,153,0);">} <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">function createExperience<span class="br0" style="color:rgb(0,153,0);">( <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">{ <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var paras <span class="sy0" style="color:rgb(51,153,51);">= document.<span class="me1" style="color:rgb(102,0,102);">getElementsByTagName <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"p" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var offset <span class="sy0" style="color:rgb(51,153,51);">= <span class="nu0" style="color:rgb(204,0,0);">0 <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">for <span class="br0" style="color:rgb(0,153,0);">( <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var index <span class="sy0" style="color:rgb(51,153,51);">= <span class="nu0" style="color:rgb(204,0,0);">0 <span class="sy0" style="color:rgb(51,153,51);">; index <span class="sy0" style="color:rgb(51,153,51);">< paras.<span class="me1" style="color:rgb(102,0,102);">length <span class="sy0" style="color:rgb(51,153,51);">; index<span class="sy0" style="color:rgb(51,153,51);">++ <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">{ <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">if <span class="br0" style="color:rgb(0,153,0);">( hasClassTest<span class="br0" style="color:rgb(0,153,0);">( paras<span class="br0" style="color:rgb(0,153,0);">[ index<span class="br0" style="color:rgb(0,153,0);">] <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"calc-ex" <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">{ <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var form <span class="sy0" style="color:rgb(51,153,51);">= document.<span class="me1" style="color:rgb(102,0,102);">createElement <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"form" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var input1 <span class="sy0" style="color:rgb(51,153,51);">= document.<span class="me1" style="color:rgb(102,0,102);">createElement <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"input" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var input2 <span class="sy0" style="color:rgb(51,153,51);">= document.<span class="me1" style="color:rgb(102,0,102);">createElement <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"input" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <span class="kw1" style="font-weight:bold;color:rgb(0,0,102);">var span <span class="sy0" style="color:rgb(51,153,51);">= document.<span class="me1" style="color:rgb(102,0,102);">createElement <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"span" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; form.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"onSubmit" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"return calcExperience(" <span class="sy0" style="color:rgb(51,153,51);">+ offset <span class="sy0" style="color:rgb(51,153,51);">+ <span class="st0" style="color:rgb(51,102,204);">");" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input1.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"size" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"10" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input1.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"value" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"0" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input1.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"id" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"lev_input_" <span class="sy0" style="color:rgb(51,153,51);">+ offset<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input2.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"type" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"button" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input2.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"value" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"Calculate Experience" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; input2.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"onclick" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"javascript:calcExperience(" <span class="sy0" style="color:rgb(51,153,51);">+ offset <span class="sy0" style="color:rgb(51,153,51);">+ <span class="st0" style="color:rgb(51,102,204);">");" <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; span.<span class="me1" style="color:rgb(102,0,102);">setAttribute <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"id" <span class="sy0" style="color:rgb(51,153,51);">, <span class="st0" style="color:rgb(51,102,204);">"ex_result_" <span class="sy0" style="color:rgb(51,153,51);">+ offset<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; span.<span class="me1" style="color:rgb(102,0,102);">innerHTML <span class="sy0" style="color:rgb(51,153,51);">= <span class="st0" style="color:rgb(51,102,204);">" = 0 Experience" <span class="sy0" style="color:rgb(51,153,51);">; form.<span class="me1" style="color:rgb(102,0,102);">appendChild <span class="br0" style="color:rgb(0,153,0);">( document.<span class="me1" style="color:rgb(102,0,102);">createTextNode <span class="br0" style="color:rgb(0,153,0);">( <span class="st0" style="color:rgb(51,102,204);">"Level: " <span class="br0" style="color:rgb(0,153,0);">) <span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; form.<span class="me1" style="color:rgb(102,0,102);">appendChild <span class="br0" style="color:rgb(0,153,0);">( input1<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; form.<span class="me1" style="color:rgb(102,0,102);">appendChild <span class="br0" style="color:rgb(0,153,0);">( input2<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; form.<span class="me1" style="color:rgb(102,0,102);">appendChild <span class="br0" style="color:rgb(0,153,0);">( span<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; paras<span class="br0" style="color:rgb(0,153,0);">[ index<span class="br0" style="color:rgb(0,153,0);">] .<span class="me1" style="color:rgb(102,0,102);">appendChild <span class="br0" style="color:rgb(0,153,0);">( form<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; offset<span class="sy0" style="color:rgb(51,153,51);">++; <span class="br0" style="color:rgb(0,153,0);">} <span class="br0" style="color:rgb(0,153,0);">} <span class="br0" style="color:rgb(0,153,0);">} addOnloadHook<span class="br0" style="color:rgb(0,153,0);">( createExperience<span class="br0" style="color:rgb(0,153,0);">) <span class="sy0" style="color:rgb(51,153,51);">; <ac_metadata title="JS"> </ac_metadata>