var Items var Targets var Locations adding document ready function aja

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
var Items;
var Targets;
var Locations;
//adding
$(document).ready(function() {
$.ajax({ type: "GET", url: "Item.xml", dataType: "xml", async: false, success: function (xml) {
Items= xml.getElementsByTagName("ITEM");
}
});
$.ajax({ type: "GET", url: "Target.xml", dataType: "xml", async: false, success: function (xml) {
Targets= xml.getElementsByTagName("TARGET");
}
});
$.ajax({ type: "GET", url: "Location.xml", dataType: "xml", async: false, success: function (xml) {
Locations= xml.getElementsByTagName("LOCATION");
}
});
$("#time").animate({
width:0},
600000, function() {
$("body").load("gameover.html");
});
//
$(".item").click(function() {
var check = $(this).attr('id');
for(var i=0;i<Items.length;i++)
{
var id=Items[i].getElementsByTagName("ID")[0];
if(check==id.childNodes[0].nodeValue){
var icon=Items[i].getElementsByTagName("IMG")[0];
var tar=Items[i].getElementsByTagName("TARGET")[0];
$("#Interface").append("<img class="+"icon"+" id="+tar.childNodes[0].nodeValue+" "+icon.childNodes[0].nodeValue+">");/*Добавляем иконку с id*/
$(this).remove();
}
}
});
//
$(".target").click(function() {
var targetID=$(this).attr('id');
$(".icon").click(function() {
var iconID = $(this).attr('id');
for(var i=0;i<Targets.length;i++)
{
var trueTargetID=Targets[i].getElementsByTagName("NIC")[0];
if(trueTargetID.childNodes[0].nodeValue==targetID)
{
trueID = Targets[i].getElementsByTagName("ID")[0];
if(iconID==trueID.hildNodes[0].nodeValue)
{
$(this).remove();
$("#"+targetID).remove();
}
}
}
});
});
//
$(".location").click(function() {
var loc = $(this).attr('id');
for(var i=0;i<Locations.length;i++)
{
var l=Locations[i].getElementsByTagName("ID")[0];
if(loc==l.childNodes[0].nodeValue){
$("#Location").load(""+loc+".html");
$("#Location").css("zIndex","100");
}
}
});
});
//
function clearL()
{
$("#Location").css("zIndex","-10");
$("#Location").empty();
}
function movechair()
{
$("#chair").animate({
zoom:"0.68",
left: "+=380",
top:"+=50"
}, 2000, function() {
// Animation complete.
});
}
function keyone()
{
$("#Interface").append("<img class="+"icon"+" id="+"Target"+" src="+"item3.jpg"+">");/*Добавляем иконку с id*/
$(Item3).remove();
}
function tool()
{
$("#Interface").append("<img class="+"icon"+" id="+"item3"+" src="+"item3.jpg"+">");/*Добавляем иконку с id*/
$(Item3).remove();
}