Показать сообщение отдельно
  #18 (permalink)  
Старый 05.03.2012, 15:48
Интересующийся
Отправить личное сообщение для NiCKSoNka Посмотреть профиль Найти все сообщения от NiCKSoNka
 
Регистрация: 05.03.2012
Сообщений: 10

Сообщение от GuardCat Посмотреть сообщение
NiCKSoNka, тады ой =)

UPD погуглите System.Gadget.Settings
Есть такая тема в гаджете, когда надо было текст вводить сохранял через innerText, а сейчас если так делать то, из select'a все пропадает(

Вот полный код Settings:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
    <style>body{width: 250px; height: 350px; font-family: Tahoma; font-size: 10px;}p{top-margin: .5em;}</style>
    <script>

	var serverType = new Array(["Counter-Strike", "-a2s  "]);

        System.Gadget.onSettingsClosing = settingsClosing;
        function loadSettings(){

			for(var i=0;i<serverType.length;i++){
        		server1.options[i]=new Option(serverType[i][0], serverType[i][1]);
        		server1.options[i].title=serverType[i][0];}
			for(var i=0;i<serverType.length;i++){
        		server2.options[i]=new Option(serverType[i][0], serverType[i][1]);
        		server2.options[i].title=serverType[i][0];}
			for(var i=0;i<serverType.length;i++){
        		server3.options[i]=new Option(serverType[i][0], serverType[i][1]);
        		server3.options[i].title=serverType[i][0];}
			
			if (System.Gadget.Settings.read("SettingsExist")){
				server1NameField.inner = System.Gadget.Settings.read("savedServer1Name");
				server1PortField.innerText = System.Gadget.Settings.read("savedServer1Port");
				with (server1){
					value = System.Gadget.Settings.read("savedServer0Type");}
				server1DisplayName.innerText = System.Gadget.Settings.read("savedServer0DisplayName");
				server2PortField.innerText = System.Gadget.Settings.read("savedServer2Port");
				with (server2){
					value = System.Gadget.Settings.read("savedServer3Type");}
				[B]server2NameField.inner = System.Gadget.Settings.read("savedServer2Name");[/B]
				server2DisplayName.innerText = System.Gadget.Settings.read("savedServer3DisplayName");

				[B]server3NameField.inner = System.Gadget.Settings.read("savedServer3Name");[/B]
				server3PortField.innerText = System.Gadget.Settings.read("savedServer3Port");
				with (server3){
					value = System.Gadget.Settings.read("savedServer6Type");}
				server3DisplayName.innerText = System.Gadget.Settings.read("savedServer6DisplayName");
			}
		}
    	
        function settingsClosing(event)
        {
            if (event.closeAction == event.Action.commit)
            {
				WriteFirstLnBat(server1NameField.value, server1PortField.value, server1.value.substr(0,6));
				System.Gadget.Settings.write("savedServer1Name", server1NameField.value);		
				System.Gadget.Settings.write("savedServer1Port", server1PortField.value);
				System.Gadget.Settings.write("savedServer0Type", server1.value);
				System.Gadget.Settings.write("savedServer0DisplayName", server1DisplayName.value);
				
				if ( server2NameField.value != "" )
					WriteRestBat(server2NameField.value, server2PortField.value, server2.value.substr(0,6));
				System.Gadget.Settings.write("savedServer2Name", server2NameField.value);		
				System.Gadget.Settings.write("savedServer2Port", server2PortField.value);
				System.Gadget.Settings.write("savedServer3Type", server2.value);
				System.Gadget.Settings.write("savedServer3DisplayName", server2DisplayName.value);

				if ( server3NameField.value != "" )
					WriteRestBat(server3NameField.value, server3PortField.value, server3.value.substr(0,6));
				System.Gadget.Settings.write("savedServer3Name", server3NameField.value);		
				System.Gadget.Settings.write("savedServer3Port", server3PortField.value);
				System.Gadget.Settings.write("savedServer6Type", server3.value);
				System.Gadget.Settings.write("savedServer6DisplayName", server3DisplayName.value);


				System.Gadget.Settings.write("SettingsExist", true);
            }
        }
    </script>

    <script language="VBScript" type="text/VBScript">

		Function WriteFirstLnBat(server1,port1,stype1)
			Set objFSO = CreateObject("Scripting.FileSystemObject")
			strPath = System.Gadget.path & "\en-US\"
			Set ta=objFSO.OpenTextFile(strPath & "qstat.bat" ,2)
			ta.WriteLine("""" & strPath & "qstat.exe"" -noconsole -Ts """ & strPath & "cssource.tmp"" " & stype1 & " " & server1 & " > """ & strPath & "qstat.txt""")
			ta.Close
		End Function

		Function WriteRestBat(server2,port2,stype2)
			Set objFSO = CreateObject("Scripting.FileSystemObject")
			strPath = System.Gadget.path & "\en-US\"
			Set ta=objFSO.OpenTextFile(strPath & "qstat.bat" ,8)
			ta.WriteLine("""" & strPath & "qstat.exe"" -noconsole -Ts """ & strPath & "cssource.tmp"" " & stype2 & " " & server2 & " >> """ & strPath & "qstat.txt""")
			ta.Close
		End Function
    </script>

</head>

	<body onload="loadSettings()">
		<label for="server1NameField"><b>Сервер №1:</b></label><br />   			 
<select name="server1NameField" id="server1NameField" size="1" />
			<option selected value=""></option>
			<option value="212.16.194.69:27016">Classic CS:S</option>
 			 <option value="212.16.194.69:27015">Meat CS:S</option>
			<option value="212.16.218.170:27016">SKH CS:S</option>
   			 <option value="212.16.194.69:27017">Mix CS:S</option>
			<option value="212.16.194.69:27018">Mix2 CS:S</option>
			<option value="212.16.218.170:27018">SKH Mix CS:S</option>
			<option value="80.243.68.74:27016">Neo-Sfera CS:S</option>
			<option value="80.243.68.74:27018">Neo-Sfera Mix CS:S</option>
			<option value="212.16.194.66:27022">Classic CS1.6</option>
 			<option value="212.16.194.66:27015">Meat CS1.6</option>
			<option value="212.16.218.170:27015">SKH CS1.6</option>
   			 <option value="212.16.194.66:27019">Mix CS1.6</option>
			<option value="212.16.194.66:27021">Mix2 CS1.6</option>
			<option value="212.16.218.170:27017">SKH Mix CS1.6</option>			
			<option value="212.16.194.66:27016">DM CS1.6</option>
			<option value="212.16.194.66:27017">Aim CS1.6</option>
			<option value="80.243.68.74:27015">Neo-Sfera CS1.6</option>
			<option value="80.243.68.74:27017">Neo-Sfera Mix CS1.6</option>
		</select></script>
<label for="server1PortField"></label>
		<br /><input type="text" name="server1PortField" id="server1PortField" style="position:absolute;left:-2001px;width:2001px" size=1 />
		<select id="server1" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;"></select>
		<label for="server1DisplayName">Имя Сервера(Опционально):</label>
		<input type="text" name="server1DisplayName" id="server1DisplayName" size=9 length="20" />
<br />		<label for="server2NameField"><b>Сервер №2:</b></label><br />
<select type="text" name="server2NameField" id="server2NameField"  size="1" />   			 
			<option selected value=""></option>
			<option value="212.16.194.69:27016">Classic CS:S</option>
 			 <option value="212.16.194.69:27015">Meat CS:S</option>
			<option value="212.16.218.170:27016">SKH CS:S</option>
   			 <option value="212.16.194.69:27017">Mix CS:S</option>
			<option value="212.16.194.69:27018">Mix2 CS:S</option>
			<option value="212.16.218.170:27018">SKH Mix CS:S</option>
			<option value="80.243.68.74:27016">Neo-Sfera CS:S</option>
			<option value="80.243.68.74:27018">Neo-Sfera Mix CS:S</option>
			<option value="212.16.194.66:27022">Classic CS1.6</option>
 			<option value="212.16.194.66:27015">Meat CS1.6</option>
			<option value="212.16.218.170:27015">SKH CS1.6</option>
   			 <option value="212.16.194.66:27019">Mix CS1.6</option>
			<option value="212.16.194.66:27021">Mix2 CS1.6</option>
			<option value="212.16.218.170:27017">SKH Mix CS1.6</option>			
			<option value="212.16.194.66:27016">DM CS1.6</option>
			<option value="212.16.194.66:27017">Aim CS1.6</option>
			<option value="80.243.68.74:27015">Neo-Sfera CS1.6</option>
			<option value="80.243.68.74:27017">Neo-Sfera Mix CS1.6</option>
		</select>
		<label for="server2PortField"></label>
		<input type="text" name="server2PortField" id="server2PortField" style="position:absolute;left:-2001px;width:2001px" size=4 length="6" />
		<br /><select id="server2" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;"></select>
<label for="server2DisplayName">Имя Сервера(Опционально):</label>
		<input type="text" name="server2DisplayName" id="server2DisplayName" size=9 length="20" />
<br />

		<label for="server3PortField"></label>
		<input type="text" name="server3PortField" id="server3PortField" style="position:absolute;left:-2001px;width:2001px" size=1 length="1" />
<br /><select id="server3" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;" "unvisible"></select>
		<label for="server3DisplayName">Имя Сервера(Опционально):</label>
		<input type="text" name="server3DisplayName" id="server3DisplayName" size=9 length="20" />
<br /><b>Пинг</b>:
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<a href= ".\pingon.exe" onfocus="this.blur()"><img src= ".\images\on.png"></a>&nbsp &nbsp
<a href= ".\pingoff.exe" onfocus="this.blur()" style="cursor:pointer;"><img src= ".\images\off.png"> </a>		<p>
	</body>
</html>

server1NameField.inner = System.Gadget.Settings.read("savedServer1Name");
server2NameField.inner = System.Gadget.Settings.read("savedServer2Name");
server3NameField.inner = System.Gadget.Settings.read("savedServer3Name");
Эти параметры раньше сохраняли текст.

Последний раз редактировалось NiCKSoNka, 05.03.2012 в 15:54.
Ответить с цитированием