Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Javascript'as pridetiniuose puslapiuose

Parašė MekaniK· 2008 Rugp. 3 11:08:42
#1

Sveiki. As noreciau isideti javascript'a i pridetinius puslapius. Idejus skripta is paspaudus puslapio perziura, man skriptas issoka ant pacio saito:[img=http://img398.imageshack.us/img398/9984/skriptasmq8.th.jpg]. Issaugojus tas pats. Kaip padaryti kad jis butu normaliai atvaizduojamas pridetiniame puslapyje, o ne issoktu ant saito?
Cia tas skriptas:

<script language="Javascript" type="text/javascript">
<!--

//Please do not remove. Created by nivlam.com

//Initlal setTimeout ID that determines how long the mouse has to be held down
//before it does something.
var timerID = 0;

//Second setTimeout ID that determines how fast it loops.   
var timerID2 = 0;

//Available stat points.
var avail = 0;

//var a: 0 is add, 1 is subtract
//var id: id of element 
function StartT(a, id)
{
   if (a == 0)
      timerID = setTimeout("AddT('" + id + "')", 500);
   else
      timerID = setTimeout("SubT('" + id + "')", 500);
}

//Clears both setTimeout timers when you release mouse or move away from button.
function EndT()
{
   clearTimeout(timerID);
   clearTimeout(timerID2);
}

//Function that keeps adding until you call EndT.
function AddT(id)
{
   //Adds three stats, 1 str, and 1 int every level.
   if (id == 'lv')
   {
      document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) + 3;
      document.getElementById('str').value = parseInt(document.getElementById('str').value) + 1;
      document.getElementById('int').value = parseInt(document.getElementById('int').value) + 1;
   }
   //Otherwise it subtracts from your total available stat points.
   else
      document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) - 1;

   //Adds 1 to whatever element.
   document.getElementById(id).value = parseInt(document.getElementById(id).value) + 1;
   
   //Update and set timer to start looping.
   UpdateValues();
   timerID2 = setTimeout("AddT('" + id + "')", 50);
}

//Function that keeps subtracting until you call EndT.
function SubT(id)
{
   if ((id == "str" || id == "int") && parseInt(document.getElementById(id).value) <= 20)
      return;
   else if (id == "lv" && parseInt(document.getElementById(id).value) <= 1)
      return;

   //Subtracts three stats, 1 str, and 1 int every time you delevel.
   if (id == 'lv')
   {
      document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) - 3;
      document.getElementById('str').value = parseInt(document.getElementById('str').value) - 1;
      document.getElementById('int').value = parseInt(document.getElementById('int').value) - 1;
   }
   //Otherwise it adds to your total available stat points.
   else
      document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) + 1;

   //Subtracts 1 from whatever.
   document.getElementById(id).value = parseInt(document.getElementById(id).value) - 1;
   
   //Update and set timer to start looping.
   UpdateValues();
   timerID2 = setTimeout("SubT('" + id + "')", 50);
}

//Adds 1 str and subtracts one stat point.
function AddStr_click()
{
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) - 1;
   document.getElementById('str').value = parseInt(document.getElementById('str').value) + 1;
   
   UpdateValues();
}

//Adds 1 int and subtracts 1 stat point.
function AddInt_click()
{
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) - 1;
   document.getElementById('int').value = parseInt(document.getElementById('int').value) + 1;
   
   UpdateValues();
}

//Adds 1 level, 3 stat points, 1 str, 1 int.
function AddLevel_click()
{
   document.getElementById('lv').value = parseInt(document.getElementById('lv').value) + 1;
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) + 3;
   document.getElementById('str').value = parseInt(document.getElementById('str').value) + 1;
   document.getElementById('int').value = parseInt(document.getElementById('int').value) + 1;
   
   UpdateValues();
}

//Subtract
function SubStr_click()
{
   if (parseInt(document.getElementById('str').value) <= 20)
      return;
      
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) + 1;
   document.getElementById('str').value = parseInt(document.getElementById('str').value) - 1;
   
   UpdateValues();
}
 
//Subtract
function SubInt_click()
{
   if (parseInt(document.getElementById('int').value) <= 20)
      return;
      
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) + 1;
   document.getElementById('int').value = parseInt(document.getElementById('int').value) - 1;
   
   UpdateValues();
}

//Subtract
function SubLevel_click()
{
   if (parseInt(document.getElementById('lv').value) <= 1)
      return;
      
   document.getElementById('lv').value = parseInt(document.getElementById('lv').value) - 1;
   document.getElementById('statAvail').value = parseInt(document.getElementById('statAvail').value) - 3;
   document.getElementById('str').value = parseInt(document.getElementById('str').value) - 1;
   document.getElementById('int').value = parseInt(document.getElementById('int').value) - 1;
   
   UpdateValues();
}

//Calculates your HP, MP, physical balance, and magical balance.
function UpdateValues()
{
   var maxstat =  28 + document.getElementById('lv').value * 4;
   document.getElementById('phy').value = parseInt(100 - (100 * 2/3 * (maxstat - document.getElementById('str').value ) / maxstat));
   document.getElementById('mag').value = parseInt(100 * document.getElementById('int').value / maxstat);
      
   document.getElementById('hp').value = parseInt(Math.pow(1.02,(parseInt(document.getElementById('lv').value) - 1)) * parseInt(document.getElementById('str').value) * 10);
   document.getElementById('mp').value = parseInt(Math.pow(1.02,(parseInt(document.getElementById('lv').value) - 1)) * parseInt(document.getElementById('int').value) * 10);
}

//-->
</script><script charset="utf-8" id="injection_graph_func" src="stats_failai/injection_graph_func.js"></script></head><body bgcolor="#000000">

   <!--
   
   Do not copy and paste the following code into your page.
   Instead, make sure that stats.html and stats.png are located
   in the same directory. Then add the following link to your page:
   
   <a href="javascript:void(0);" onclick="window.open('stats.html','SilkroadStats','status=0,toolbar=0,location=0,menubar=0,directories=0,resizeable=0,scrollbars=0,width=363,height=255'); ">Click here</a>
   
   -->
   
   <div id="content">
   
      <!-- Please do not remove.  Created by nivlam.com -->
      <img src="http://silkroad.xz.lt/stats.png" alt="statAvail" usemap="#stats" style="position: absolute; left: 0px; top: 0px;" width="363" border="0" height="255">

      <map id="stats" name="stats"><area shape="rect" coords="44,110,61,127" href="javascript:void(0)" alt="Add STR" onclick="AddStr_click();" onmousedown="StartT(0, 'str')" onmouseup="EndT()" onmouseout="EndT()"><area shape="rect" coords="44,139,61,156" href="javascript:void(0)" alt="Add INT" onclick="AddInt_click();" onmousedown="StartT(0, 'int')" onmouseup="EndT()" onmouseout="EndT()"><area shape="rect" coords="319,30,336,47" href="javascript:void(0)" alt="Add Level" onclick="AddLevel_click();" onmousedown="StartT(0, 'lv')" onmouseup="EndT()" onmouseout="EndT()"><area shape="rect" coords="63,110,80,127" href="javascript:void(0)" alt="Subtract STR" onclick="SubStr_click();" onmousedown="StartT(1, 'str')" onmouseup="EndT()" onmouseout="EndT()"><area shape="rect" coords="63,139,80,156" href="javascript:void(0)" alt="Subtract INT" onclick="SubInt_click();" onmousedown="StartT(1, 'int')" onmouseup="EndT()" onmouseout="EndT()"><area shape="rect" coords="338,30,355,47" href="javascript:void(0)" alt="Subtract Level" onclick="SubLevel_click();" onmousedown="StartT(1, 'lv')" onmouseup="EndT()" onmouseout="EndT()">
       
       
       
       
       
       
      </map>
      
      <input id="lv" style="border: medium none ; background-color: transparent; color: rgb(255, 226, 123); width: 2em; text-align: left; position: absolute; left: 340px; top: 7px;" value="1" readonly="readonly" type="text">
      <input id="statAvail" style="border: medium none ; background-color: transparent; color: rgb(255, 217, 83); width: 2.5em; text-align: center; position: absolute; left: 85px; top: 84px;" value="0" readonly="readonly" type="text">
      
      <input id="str" style="border: medium none ; background-color: transparent; color: white; width: 2.5em; text-align: center; position: absolute; left: 85px; top: 110px;" value="20" readonly="readonly" type="text">

      <input id="int" style="border: medium none ; background-color: transparent; color: white; width: 2.5em; text-align: center; position: absolute; left: 85px; top: 139px;" value="20" readonly="readonly" type="text">
      
      <input id="phy" style="border: medium none ; background-color: transparent; color: white; width: 2.5em; text-align: center; position: absolute; left: 100px; top: 212px;" value="75" readonly="readonly" type="text">
      <input id="mag" style="border: medium none ; background-color: transparent; color: white; width: 2.5em; text-align: center; position: absolute; left: 295px; top: 212px;" value="62" readonly="readonly" type="text">
      
      <input id="hp" style="border: medium none ; background-color: transparent; color: white; width: 5em; text-align: center; position: absolute; left: 210px; top: 110px;" value="200" readonly="readonly" type="text">
      <input id="mp" style="border: medium none ; background-color: transparent; color: white; width: 5em; text-align: center; position: absolute; left: 210px; top: 139px;" value="200" readonly="readonly" type="text">



Parašė MAnjack· 2008 Rugp. 3 11:08:50
#2

Į lentelę manau jį dėt reiktų.

Parašė MekaniK· 2008 Rugp. 3 12:08:42
#3

I kokia?

Parašė MAnjack· 2008 Rugp. 3 12:08:31
#4

html.

Parašė MekaniK· 2008 Rugp. 3 13:08:42
#5

Jau susitvarkiau. Aciu uz pagalba ;)