Jump to content


Henderson's Content

There have been 11 items by Henderson (Search limited from 29/03/2023)


Ordernar por                Order  

#1012730 [Duvida] Duvida Sobre Uma Verificação

Posted by Henderson on 15/08/2011, 15:53 in Javascript / DOM / AJAX / ECMAScript

tenta assim
<script>
parent.location = "index.html";
</script>

coloca esse código na página que exibe a confirmação de voto, a página que aparece depois que o usuário dá ENTER.



#1012729 Carregando No Campo Errado

Posted by Henderson on 15/08/2011, 15:48 in Javascript / DOM / AJAX / ECMAScript

não testei, mas veja se funciona.

/* Busca do primeiro para o segundo select */
function list_dados( valor )
{
http.open("GET", "categorias_busca.php?id=" + valor, true);
http.onreadystatechange = handleHttpResponse1;
http.send(null);
}

function handleHttpResponse1()
{
campo_select = document.forms[0].subcategoria;
if (http.readyState == 4) {
campo_select.options.length = 0;
results = http.responseText.split(",");
for( i = 0; i < results.length; i++ )
{
string = results[i].split( "|" );
campo_select.options[i] = new Option( string[0], string[1] );
}
}
}
function handleHttpResponse2()
{
campo_select2 = document.forms[0].categoriafinal;
if (http.readyState == 4) {
campo_select2.options.length = 0;
results2 = http.responseText.split(",");
for( i = 0; i < results2.length; i++ )
{
string2 = results2[i].split( "|" );
campo_select2.options[i] = new Option( string2[0], string2[1] );
}
}
}
function getHTTPObject() {
var req;
try {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
if (req.readyState == null) {
req.readyState = 1;
req.addEventListener("load", function () {
req.readyState = 4;

if (typeof req.onreadystatechange == "function")
req.onreadystatechange();
}, false);
}
return req;
}

if (window.ActiveXObject) {

var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];

for (var i = 0; i < prefixes.length; i++) {
try {
req = new ActiveXObject(prefixes[i] + ".XmlHttp");
return req;
} catch (ex) {};

}
}
} catch (ex) {}
alert("XmlHttp Objects not supported by client browser");
}
var http = getHTTPObject();
// Logo após fazer a verificação, é chamada a função e passada
// o valor à variável global http.


/* Busca do segundo para o terceiro select */
function list_dados2( valor )
{
http.open("GET", "categorias_busca_sub.php?id=" + valor, true);
http.onreadystatechange = handleHttpResponse2;
http.send(null);
}



#1012728 Mailer Error: Language String Failed To Load: Instantiate

Posted by Henderson on 15/08/2011, 15:38 in PHP

ixi cara
difícil enviar email localmente, vce tem que instalar um server.
usando o easyphp difícil.
joga isso aí em um server que provavelmente vai funcionar.



#1012727 Problema Com Loop

Posted by Henderson on 15/08/2011, 15:36 in Javascript / DOM / AJAX / ECMAScript

hauihaui, tá vendo! se tivesse testado quando falei a primeira vez tinha evitado tudo isso, haihauihauihaui

só lê o que eu postei aí, do problema que vai surgir.
se por exemplo você colocar "teste:" vai dar pau eu acho.



#1012725 Busca / Adição Carrinho De Compras

Posted by Henderson on 15/08/2011, 15:33 in PHP

você precisa colocar seu form pra mandar como GET porque seu código tá recebendo os dados por GET
troque isso
  <form action="carrinho.php?cod=".$cod."&acao=incluir'">
  <label for="codBar">Passe o leitor pelo c&oacute;digo de barras
  <input type="text" id="codBar" name="cod" />
  </label>
  <button type="submit">OK </button>
  </form>
por isso
  <form action="carrinho.php" method="get">
  <label for="codBar">Passe o leitor pelo c&oacute;digo de barras
  <input type="text" id="codBar" name="cod" />
  </label>
  <input type="hidden" id="acaoHidden" name="acaoHidden" value="incluir" />
  <button type="submit">OK </button>
  </form>



#1012722 Problema Com Loop

Posted by Henderson on 15/08/2011, 15:06 in Javascript / DOM / AJAX / ECMAScript

cara, to testando aqui
seguinte.. pra que tu quer esse code? porque ó, esse código, funciona quando tem ponto à esquerda, ele não seleciona
HTMLTextAreaElement.prototype.wordSelect = function()
{
        if(this.selectionstart !== this.selectionend){
                this.focus();
                return; //sai da função e não retorna nada				
        }

        var startCursor = this.selectionStart;
        var endCursor = this.selectionEnd;
        var txt = this.value;
		alert(startCursor);
		alert(endCursor);
		alert(txt);
        
        while (startCursor-1 >= 0 && txt.charAt(startCursor-1) != ' ' && txt.charAt(startCursor-1) != '\n' && !txt.charAt(startCursor-1).isPoint())
        {
                startCursor--;
        }

        while (endCursor < txt.length && txt.charAt(endCursor) != ' ' && txt.charAt(endCursor) != '\n' && !txt.charAt(endCursor).isPoint())
                endCursor++;
        //alert(startCursor);
        this.selectionstart = startCursor;
        this.selectionend = endCursor;
        this.focus();
		
		alert(startCursor);
		alert(endCursor);
		alert(txt);
};

mas se tu colocar um ponto à direita, ele não vai selecionar nada da palavra, porque logo de começo ele vai achar um ponto e vai parar de mover pra esquerda, tendeu?
acho que vce vai ter que fazer outra abordagem pra isso aí. partir do meio da palavra pras pontas talvez.



#1012718 Problema Com Loop

Posted by Henderson on 15/08/2011, 14:41 in Javascript / DOM / AJAX / ECMAScript

não, vce não tá fazendo isso.
vce tá verificando, depois decrementando. vce já tem que verificar o anterior.
veja nesse exemplo

:teste
nesse caso, vamos supor que seu while está analisando o "t"
ele vai analisar o T, o T vai passar nos testes das condições, porque é uma letra e então o código ira decrementar o cursor. decrementando o cursor, o ":" será incluído na seleção
no próximo loop o while será finalizado porque aí sim ele irá analizar o ":"
por isso que você tem que analisar o startCursor-1 na condição do while e não somente startCursor
tente assim:
while (startCursor-1 >= 0 && txt.charAt(startCursor-1) != ' ' && txt.charAt(startCursor-1) != '\n' && !txt.charAt(startCursor-1).isPoint())
        {
               startCursor--;
        }

eu não sei se essas operação "-1" são aceitas dentro do while
se não forem, vce vai ter que criar uma variável auxiliar pra fazer isso.

teste aí.



#1012710 Problema Com Loop

Posted by Henderson on 15/08/2011, 13:37 in Javascript / DOM / AJAX / ECMAScript

ah tá, entendi
bom, vce tá comparando sempre o caracter atual, sendo que vce tem que comparar o caracter anterior, pra ver se realmente tem que andar pra esquerda.
então, troque seus startCursor no primeiro while, por startCursor-1
veja se dá!

não to com tempo de ficar testando agora, to só dando uma sugestão que parece que vai funcionar, mas nem sempre é assim né!
mas quem sabe da certo!



#1012705 Problema Com Loop

Posted by Henderson on 15/08/2011, 11:49 in Javascript / DOM / AJAX / ECMAScript

pqe vce comentou aquela parte no código? ela não funcionava?
tá certa a lógica acho, mas aqela parte comentada é qe reposicionaria o cursor para a direita do ponto.
Mas não precisa daquele break ali não. Tira ele, deixa o código seguir normal.



#1012704 Atualizar Página

Posted by Henderson on 15/08/2011, 11:35 in PHP

Fala galera,

Seguinte, to com um sistema de chat e que tá atualizando o texto do chat usando setInterval.
Tá de 1 em 1 segundo, final, é um chat, tem que ser rápido o negócio.
Mas é MUITA requisição no servidor. Ainda mais que tem um "O usuário está digitando"
Não é possível que só possa ser feito assim. Eu abro o painel do desenvolvedor no chrome e vejo lá, aquele monte de requisição.
Eu entrei em sites como o www.omegle.com, na versão Text (só pra vces entrarem se quiserem ver do que estou falando) e lá não tem esse monte de requisição, somente uma requisição quando uma digitação é iniciada e outra requisição quando a mensagem é enviada ou recebida.

Como fazer para que seja desse jeito?
O servidor, e pelo jeito até o navegador, não dá conta direito de tanta requisição. Sem contar que a página fica sempre "carregando".

Abraço.



#1012702 Não Consigo Definir Dimensões Como Quero

Posted by Henderson on 15/08/2011, 10:25 in HTML, CSS e Metodologias

Olá.

Estou tentando definir algumas dimensões, de modo que a página ocupe a página inteira.
Coloquei uma figura aqui em anexo pra explicar, o HTML+CSS segue abaixo.
As áreas vermelhas tem tamanho fixo (largura e altura em px)
As áreas verdes, eu quero que adaptem suas dimensões de forma que toda a janela do browser, não importe o tamanho, fique preenchida.
A verde de cima tem largura 100% e altura que deve se ajustar.
A verde de baixo tem altura fixa e largura que deve se ajustar, sem sobrepor a vermelha à direita e sem deixar espaço em branco.

Tenderam?
Não to conseguindo fazer esse ajuste com o html e css que montei.
Alguém pode me dar uma luz?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
html, body {
	padding: 0;
	margin: 0;
	height: 100%;
	width: 100%;
}
.class-you {
	color:#3895BF;
	font-weight:bold;
}
.class-partner {
	color:#2E900D;
	font-weight:bold;
}
#container {
	width: 100%;
	height: 100%;
}
#content {	
	width: 100%;
	height: 100%;
}
#topbar {
	padding-top: 10px;
	height: 50px;
	width: 100%;
}
#buttons {
	padding-bottom:5px;
	width:170px;
	float:left;
}
.buttonFont {
	font-size:10px;
}
#info {
	font-family:Verdana, Geneva, sans-serif;
	font-size:12px;
	float:left;
	padding-top:5px;
}
.label {
	font-family:Verdana, Geneva, sans-serif;
	font-size:11px;
	color:#3895BF;
}
#externalPanel {
	clear:both;
	margin: 0 5px 0 5px;
	height:70%;
	width:99%;
}
#panel {
	overflow:auto;
	padding:3px;
	font-family:Verdana, Geneva, sans-serif;
	font-size:12px;
	height: 100%;
	width: 100%;
}
#typing {
	padding-top: 5px;
	margin-left: 4px;
	width: 95%;
	height: 25px;
	clear: both;
}
#sendMessage {
	padding-top:5px;
	margin-left:0px;
	width: 100%;
	height: 62px;
}
#message {
	float: left;
	width: 89%;
	height: 60px;
}
#submit {
	float: right;
	font-size:13px;
	width: 10%;
	height: 62px;
}
#ads {
	clear: both;
	margin-top: 10px;	
	height: 90px;
	width: 100%;
}
</style>
</head>
<body>
<div id="container">
<div id="content">
<div id="topbar">
	<div id="buttons" class="buttonFont">
		<input type="button" id="logout" name="logout" value="close" />
		<input type="button" id="status" name="status" value="searching..." />	
	</div>
	<div id="info">
	you are a ...
	</div>
</div>
<div id="externalPanel" class="ui-corner-all ui-widget-content">
	<div id="panel">
	</div>
</div>
<div id="typing"></div>
<div id="sendMessage">
	<div id="messageBox">
		<textarea id="message" name="message" class="ui-corner-all ui-widget-content"></textarea>
	</div>
	<div id="submitBox">
		<input type="button" id="submit" value="send" />
	</div>
</div>
<div id="ads">
</div>
</div>
</div>
</body>
</html>

Valeu!!

Attached Thumbnails

  • lay.JPG




IPB Skin By Virteq