Search the Community
Showing results for tags 'atualizar'.
Found 11 results
-
[Resolvido] Atualizar tabela com data "curdate()"
Kefatif posted a question in Perguntas e respostas rápidas
Prezados, boa tarde! Estou tentando fazer com que meu sistema grave num campo chamado "ULTIMO_ACESSO" a data após o login do usuário. Para isso estou tentando com o seguinte código: $sqlultimoacesso = "UPDATE USUARIOS set ULTIMO_ACESSO = curdate() WHERE ID_USUARIO = ".$row["ID_USUARIO"]; Mas não estou conseguindo, alguém poderia me auxiliar? Agradeço desde já pela ajuda! -
tenho um while onde a div se atualiza automaticamente a cada 10 segundos, e gostaria que quando tivesse uma alteração na quantidade de linhas tocasse um bip, o bip tudo bem, sei como executar ele, por ex: as 9:00 tinha 3 o.s para o técnico, ai apareceu um encaixe, e foi direcionada para esse técnico, então são 4 o.s, quando a div atualizar automaticamente e ver que o resultado de agora é maior que o anterior emitir um bip mas a parte para comparar com a quantidade anterior não consegui, trecho do código onde pretendo colocar o bip: <?php $hoje = date("Y-m-d"); $mi = '08:00:00'; $mf = '13:00:00'; $ti = '13:00:01'; $tf = '18:00:00'; $result_os_tard = "SELECT * FROM sis_suporte WHERE tecnico = '$func' AND visita BETWEEN '$hoje $ti' AND '$hoje $tf' LIMIT 5"; $resultado_os_tard = mysqli_query($mysqli, $result_os_tard); while($dados = mysqli_fetch_assoc($resultado_os_tard)){ ?> <tr> <td><a href="os.php?os=<?php echo $dados['chamado']; ?>"> <?php if ($dados['status'] == 'aberto'){ echo '<span class="label label-danger">Aberto</button>'; } if ($dados['status'] == 'fechado'){ echo '<button class="label label-success">Fechado</button>'; } ?> </a></td> <td><a href="os.php?os=<?php echo $dados['chamado']; ?>"><?php echo mb_strimwidth(utf8_encode($dados['nome']), 0, 15, "..."); ?></a></td> <td><a href="os.php?os=<?php echo $dados['chamado']; ?>"><?php echo strtoupper(mb_strimwidth(utf8_encode($dados['assunto']), 0, 4)); ?></a></td> <td><a href="os.php?os=<?php echo $dados['chamado']; ?>"><?php echo mb_strimwidth(utf8_encode($dados['chamado']), 0, 15, "..."); ?></a></td> </tr> <?php } ?>
-
Boa Noite senhores(as), tenho uma missão na minha empresa e estou sem saída ainda no momento. A TI disponibilizou alguns endereços para criação no WordPress, bom com isso tenho que fazer que uma planilha que fica na rede apareça nessa pagina e se atualize a cada X seg/min bom até ai entendi, tudo certo. Porem a questão é como vou colocar uma planilha que está na rede interna dentro da pagina. Não consigo pensar em nada sem ter que ficar fazendo Upload, preciso de algo automático, o arquivo deve ser carregado constantemente. Qualquer dica será bem vinda! Desde de já agradeço a atenção de todos. att, Fabrício Martins
-
Galera, criei um código para atualizar meus dados no banco, ele não esta funcionado. Editar.php <?php include 'conexao.php'; session_start(); setcookie("ck_authorized", "true", 0, "/"); if(!isset($_SESSION['usuario'])): header("location: index.php"); else: $login = $_SESSION['usuario']; endif; ?> <!DOCTYPE HTML> <html> <head> <title>Edição de Registros</title> <style type="text/css"> #divCenter { left: 35%; margin: -130px 0 0 530px; padding:0 px; position: static; } </style> <meta charset="utf-8"/> <link rel="icon" type="imagem/png" href="ame_icon.png" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <script src="js/jquery.min.js"></script> <script src="js/skel.min.js"></script> <script src="js/skel-layers.min.js"></script> <script src="js/init.js"></script> <script type="text/javascript"></script> <noscript> <link rel="stylesheet" href="css/skel.css" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style-xlarge.css" /> </noscript> </head> <body id="top"> <!-- Header --> <header id="header" class="skel-layers-fixed"> <h1><a href="home.php">ASSOCIAÇÃO DOS ESTUDANTES</a></h1> <nav id="nav"> <ul> <li><a href="home.php">Home</a></li> <li><a href="consultarcarteirinha_p.php">Consultar Carteirinha</a></li> <li><a href="#" class="button special" id="clicar"><?php echo ($_SESSION['usuario']) ?></a></li> </ul> </nav> <!-- Menu --> <section> <div class="login-form" align="center"> <form action= method="POST"> <label></label> <font size=4 >Painel de Controle</font> <label></label> <div> <a href="registros.php" class="button alt" style="width: 250px; height: 40px">Registros</a> </div> <div> <label></label> <a href="dados.php" class="button alt" style="width: 250px; height: 40px">Dados</a> </div> <div> <label></label> <a href="logout.php" class="button" style="width: 250px; height: 40px">Sair</a> </div> <br> </form> </div> </section> </header> <!-- Main --> <section id="main" class="wrapper style1"> <header class="major"> <h2>Edição de Registros</h2> <p>Edite os Registros lançados</p> </header> </section> <?php $cod = $_GET['cod']; $SESSION['cod'] = $cod; $busca = mysqli_query($conexao, "SELECT * FROM form WHERE cod = $cod"); $row = mysqli_fetch_array($busca); ?> <br> <!-- Formulário --> <div id="divCenter"> <form method="POST" action="update.php" class="formulario"> <div class="row uniform"> <!-- Nome --> <div class="6u 12u$(xsmall)"> <input type="text" name="fname" size= "200" placeholder="Nome" value="<?php echo $row['nome']?>" /> </div> <br> <br> <br> <!-- Data Nascimento --> <div class="6u 12u$(xsmall)"> <input type="date" name="fdatanasc" placeholder="Data" value="<?php echo $row['data_nasc']?>" /> </div> <br> <br> <br> <!-- Instituição de Ensino--> <div class="6u 12u$(xsmall)"> <input type="text" name="finstituicao" placeholder="Instituição de Ensino" value="<?php echo $row['instituicao']?>" /> </div> <br> <br> <br> <!-- Curso --> <div class="6u 12u$(xsmall)"> <input type="text" name="fcurso" placeholder="Curso" value="<?php echo $row['curso']?>" /> </div> <br> <br> <br> <!-- Período --> <div class="12u$"> <div class="select-wrapper"> <select name="fperiodo" > <option value="">- Período -</option> <option value="Matutino">Matutino</option> <option value="Vespertino">Vespertino</option> <option value="Noturno">Noturno</option> <option value="Integral">Integral</option> </select> </div> </div> <br> <br> <br> <!-- Número Matrícula --> <div class="6u 12u$(xsmall)"> <input type="int" name="fnummatricula" placeholder="Número da Matrícula" value="<?php echo $row['num_matricula']?>" /> </div> <br> <br> <br> <!-- Validade da Carteirinha --> <div class="6u 12u$(xsmall)"> <input type="date" name="fvalidade" placeholder="Validade" value="<?php echo $row['validade_cart']?>" /> </div> <br> <br> <br> <!-- Botões --> <div class="12u$"> <ul class="actions"> <li><input type="submit" value="Atualizar" /></li> <li><input type="reset" value="Cancelar" class="alt" /></li> </ul> </div> </div> </form> </div> <br> <br> <br> <br> <br> <!-- Script Animação Menu--> <script type="text/javascript"> $(document).ready(function(){ var form = $(".login-form"); var status = false; $("#clicar").click(function(event){ event.preventDefault(); if (status == false){ form.fadeIn(); status = true; }else{ form.fadeOut(); status = false; } }) }) </script> <!-- Footer --> <footer id="footer"> <div class="container"> <div class="row double"> <div class="6u"> <h2>Entre em contato com a gente</h2> <p>Endereço: Av. Cuiabá, n° 3098, em frente a Facimed (anexo a WebCópias). <br> Telefone: 3443-4001 <br> Whatsapp: (69) 9 9958-3178 / (69) 9 9385-6070 </p> <ul class="icons"> <li><a href="https://www.facebook.com/amecarteirinhas" class="icon fa-facebook"><span class="label">Facebook</span></a></li> </ul> </div> </div> <ul class="copyright"> <li>© Untitled. All rights reserved.</li> </ul> </div> </footer> </body> </html> update.php <?php include ("conexao.php"); session_start (); $cod = $SESSION['cod']; $num_matricula = $_POST['fnum_matricula']; $nome = $_POST['fnome']; $data_nasc = $_POST['fdata_nasc']; $instituicao = $_POST['finstituicao']; $curso = $_POST['fcurso']; $periodo = $_POST['fperido']; $validade_cart = $_POST['fvalidade_cart']; //Executa a atualização no banco de dados $update = mysqli_query($conexao, "UPDATE form SET num_matricula = '$num_matricula', nome='$nome', data_nasc='$data_nasc', instituicao='$instituicao', curso='$curso', periodo='$periodo', validade_cart='$validade_cart' WHERE cod='$cod' "); //Se não deu certo, redireciona pra exibe.php com alteracao igual a false if( !$update ){ header("Location: editar.php"); exit; } //se tudo deu certo, redireciona pra exibe.php com alteracao igual a true header("Location: dados.php"); mysqli_close($conexao); ?>
-
Boa tarde galera. Gostaria de saber como faço para mostrar um aviso caso o usuário esteja digitando em uma textarea e ele actualize ou saia da página. Exemplo do aviso: Você está digitando em uma textarea, tem certeza que deseja sair? Com dois botões SAIR OU FICAR. Forte abraço!
-
Boa Noite, tenho um sistema de carrinho de compra, mais ajustei para um sistema de vendas/estoque, pega normal, seleciona o produto, tem como atualizar a qtd e excluir, mais o cliente pediu para adicionar um campo q chama valor adicional, q pode ser usado para coloca um valor de frete por exemplo ou taxa (%), ate blz ta certo, mais quando seleciono dois produto, e coloco um valor adicional em 1 dos produtos, ele acaba atualizando os 2 produto, e ele só funciona se coloca o valor no produto em ordem decrescente, se o produto q adiciono primeiro, coloca um valor adicional, ele não funciona, fica como 0, ai se coloca o valor no 2 produto adicionado, ai ele adiciona só q nos dois 2 produto, certo seria mostra o valor adicional no produto desejável, segue o código: cogido em php que faz todo o funcionamento, foca apenas no " if(isset($_POST['adicional'])){ " q é aonde atuliza o valor adicional <?php session_start(); if(!isset($_SESSION['carrinho'])){ $_SESSION['carrinho'] = array(); } //adiciona produto //ADICIONAR CARRINHO if($_GET['acao'] == 'add'){ $id = intval($_GET['id']); if(!isset($_SESSION['carrinho'][$id])){ $_SESSION['carrinho'][$id] = 1; }else{ $_SESSION['carrinho'][$id] += 1; } } //REMOVER CARRINHO if($_GET['acao'] == 'del'){ $id = intval($_GET['id']); if(isset($_SESSION['carrinho'][$id])){ unset($_SESSION['carrinho'][$id]); } } //ALTERAR QUANTIDADE if(isset($_POST['up'])){ if(is_array($_POST['prod'])){ foreach($_POST['prod'] as $id => $qtd){ $id = intval($id); $qtd = intval($qtd); if(!empty($qtd) || $qtd <> 0){ $_SESSION['carrinho'][$id] = $qtd; }else{ unset($_SESSION['carrinho'][$id]); } } } } //ALTERAR VALOR ADICIONAL if(isset($_POST['adicional'])){ if(is_array($_POST['prods'])){ foreach($_POST['prods'] as $id => $p_valor_adicional){ $id = intval($id); $p_valor_adicional = intval($p_valor_adicional); if(!empty($p_valor_adicional) || $p_valor_adicional <> 0){ $_SESSION['carrinho'][$id] = $p_valor_adicional; }else{ unset($_SESSION['carrinho'][$id]); } } } } ?> codigo do html e php, com o select listando os produtos: <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-block"> <h4 class="card-title">Resumo do Pedido</h4> <div class="table-responsive m-t-20"> <table class="table stylish-table color-table muted-table"> <thead> <tr> <th>Produto</th> <th class="text-center">Quantidade</th> <th class="text-center">Preço</th> <th class="text-center">Preço Adicional</th> <th class="text-center">Total</th> <th> </th> </tr> </thead> <form action="?id_cliente=<?php echo $_GET['id_cliente']; ?>" method="post"> <tbody> <?php if(count($_SESSION['carrinho']) == 0){ echo '<tr> <td class="center top-20 bottom-40" style="text-align: center; padding: 20px;" colspan="5"><img src="assets/images/icon_cart.fw.png"><br/>Não há produto no carrinho</td> </tr>'; }else{ foreach($_SESSION['carrinho'] as $id => $qtd){ $Seleciona_Produtos = $pdo->prepare("SELECT * FROM tb_sys_produtos WHERE p_id = :id"); $Seleciona_Produtos->bindValue(":id", $id); $Seleciona_Produtos->execute(); if($Seleciona_Produtos->rowCount() > 0){ foreach($Seleciona_Produtos->fetchAll() as $ResAssoc){ $Total += $ResAssoc['p_valor_venda'] * $qtd + $p_valor_adicional; echo '<tr>'; echo '<td class="">'.$ResAssoc['p_nome'].'</td>'; echo '<td class="text-center"><input type="text" size="3" class="text-center" name="prod['.$id.']" value="'.$qtd.'" /></td>'; echo '<td class="text-center">R$ '.number_format($ResAssoc['p_valor_venda'],2,",",".").'</td>'; echo '<td class="text-center"><input type="text" size="10" class="text-center" name="prods['.$id.']" value="'.$p_valor_adicional.'" /></td>'; echo '<td class="text-center">R$ '.number_format($ResAssoc['p_valor_venda'] * $qtd + $p_valor_adicional,2,",",".").'</td>'; echo '<td class="text-center"><a href="?id_cliente='.$_GET['id_cliente'].'&acao=del&id='.$id.'" class="text-inverse btn btn-danger btn-xs" title="" data-toggle="tooltip" data-original-title="Dar Baixa"><i class="ti-trash" style="color:#fff;"></i></a></td>'; echo '</tr>'; } } } ?> <tr> <td><button type"submit" name="up[]" class="btn btn-primary ladda-button" data-style="zoom-out"> <span class="ladda-label fa fa-refresh"></span> Atualizar Quantidade </button> </td> <td><button type"submit" name="adicional[]" class="btn btn-success ladda-button" data-style="zoom-out"> <span class="ladda-label fa fa-refresh"></span> Atualizar Adicional </button> </td> <td></td> <td></td> <td class="text-center"><h5>Subtotal</h5></td> <td class="text-center"><h5><strong>R$<?php echo number_format($Total,2,",","."); ?></strong></h5></td> </tr> <tr> <td> </td> <td> </td> <td></td> <td></td> <td class="text-center"><h3>Total</h3></td> <td class="text-center"><h3><strong>R$<?php echo number_format($Total + $taxa,2,",","."); ?></strong></h3></td> </tr> <tr> <td> </td> <td> </td> <td></td> <td></td> <td class="text-center"> <a href="fatura_novo_busca.php?id_cliente=<?php echo $_GET['id_cliente']; ?>"><button type="button" class="btn btn-default ladda-button" data-style="zoom-out"> <span class="ladda-label fa fa-search"></span> Nova Busca </button></a></td> <td class="text-center"> <?php if(isset($_POST['enviar'])){ $v_data = date('Y-m-d :H:i:s'); $cliente = $_GET['id_cliente']; $SqlInserirVenda = $pdo->prepare("INSERT INTO tb_sys_vendas (v_codigo, v_cliente, v_valor_total, v_data) VALUES (:v_codigo, :v_cliente, :v_valor_total, :v_data)"); $SqlInserirVenda->bindValue(":v_codigo", $chave_key2); $SqlInserirVenda->bindValue(":v_cliente", $cliente); $SqlInserirVenda->bindValue(":v_valor_total", $Total); $SqlInserirVenda->bindValue(":v_data", $v_data); $SqlInserirVenda->execute(); $vi_id_venda = $pdo->lastInsertId(); foreach($_SESSION['carrinho'] as $ProdInsert => $qtd): $SqlInserirItens = $pdo->prepare("INSERT INTO tb_sys_vendas_itens (vi_id_venda, vi_id_produto, vi_id_cliente, vi_qtd) VALUES (:vi_id_venda, :vi_id_produto, :vi_id_cliente, :vi_qtd)"); $SqlInserirItens->bindValue(":vi_id_venda", $vi_id_venda); $SqlInserirItens->bindValue(":vi_id_produto", $ProdInsert); $SqlInserirItens->bindValue(":vi_id_cliente", $cliente); $SqlInserirItens->bindValue(":vi_qtd", $qtd); $SqlInserirItens->execute(); $calcular = $id; $UpProduto = $pdo->prepare("UPDATE tb_sys_produtos SET p_disponivel_estoque = p_disponivel_estoque - :qtd WHERE p_id = :ProdInsert"); $UpProduto->bindValue(":qtd", $qtd); $UpProduto->bindValue(":ProdInsert", $ProdInsert); $UpProduto->execute(); endforeach; $pagina = 'visualizar_fatura.php?id_fatura='.$vi_id_venda.''; echo "<script>parent.location = '$pagina';</script>"; unset($_SESSION['carrinho']); } ?> <form action="" enctype="multipart/form-data" method="post"> <input type="submit" name="enviar" class="btn btn-danger ladda-button" data-style="zoom-out" value="Finalizar Pedido"> </form></td> </tr> <?php } ?> </tbody> </form> </table> </div> </div> </div> </div> </div>
-
Olá pessoal, estou precisando de uma ajudinha.... estou fazendo um script para importar produtos para o banco de dados a partir do xml... só que.... alguns produtos já estão cadastrados. o que eu queria fazer era o seguinte... quando o usuario for cadastrar o xml e os produts que já estiverem cadastrado cm o mesmo código de barras seja apenas atualizado! como faç isso já tentei de várias maneiras.... ajudem ai por favor! segue abaixo o código que recebe e faz as gravações! Detalhe, grava perfeitamente, só não consegui colocar uma condição que fizesse essa lógica! <?php session_start(); require '../../includes/connect.php'; //$sql = "INSERT INTO produtos (cProd, nProd, un, estoque, vlVenda, ncm, vlCompra, pICMS, perc_ipi) VALUES "; $grava = "INSERT INTO produtos (cProd, cBarras, nProd, un, estoque, vlVenda, ncm, vlCompra, pICMS, perc_ipi) VALUES "; $verifica = ""; $atualiza = ""; for( $i=0; $i<count($_POST['item']); $i++ ) { $codigo = $_POST['codigo'][$i]; $cBarras = $_POST['cEAN'][$i]; $nProd = $_POST['xProd'][$i]; $ncm = $_POST['NCM'][$i]; $un = $_POST['uCom'][$i]; $esto = $_POST['qCom'][$i]; $estoque = str_replace(",", ".", $esto); $vlC = $_POST['vUnCom'][$i]; $vlCompra = str_replace(",", ".", $vlC); $vlV = $_POST['vVenda'][$i]; $vlVenda = str_replace(",", ".", $vlV); $pICMS = $_POST['pICMS'][$i]; $perc_ipi = $_POST['perc_ipi'][$i]; $verifica .= "SELECT * FROM `produtos` WHERE `cBarras` = '$cBarras'; "; $atualiza .= "UPDATE `produtos` SET `estoque` = `estoque` + '$estoque', `vlVenda` = '$vlVenda', `vlCompra` = '$vlCompra' WHERE `cBarras` = '$cBarras';"; $grava .= "('$codigo', '$cBarras', '$nProd', '$un', '$estoque', '$vlVenda', '$ncm', '$vlCompra', '$pICMS', '$perc_ipi'),"; } //Remove a última vírgula da string SQL $grava = substr($grava, 0, -1); //echo $sql."<br/><br/>"; // $execute = mysqli_query($LOCAL, $sql); // if ($execute !=0) { // echo "deu"; // }else{ // echo "não deu"; // } ?>
-
Contador regressivo sem resetar ao dar refresh na página
ggbelgamo posted a question in Perguntas e respostas rápidas
Pessoal, estou usando o Flipclock para fazer um contador regressivo para um site EM CONSTRUÇÃO. Deu tudo certo, mas ao atualizar a página o contador regressivo reseta. <html> <head> <link rel="stylesheet" href="compiled/flipclock.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="compiled/flipclock.js"></script> </head> <body> <div class="clock"></div> <div class="message"></div> <script type="text/javascript"> var clock; $(document).ready(function() { var clock; clock = $('.clock').FlipClock({ clockFace: 'DailyCounter', autoStart: false, callbacks: { reset: function() { } } }); clock.setTime(3974400); clock.setCountdown(true); clock.start(); }); </script> </body> </html> /* Base.js, version 1.1a Copyright 2006-2010, Dean Edwards License: http://www.opensource.org/licenses/mit-license.php */ var Base = function() { // dummy }; Base.extend = function(_instance, _static) { // subclass "use strict"; var extend = Base.prototype.extend; // build the prototype Base._prototyping = true; var proto = new this(); extend.call(proto, _instance); proto.base = function() { // call this method from any other method to invoke that method's ancestor }; delete Base._prototyping; // create the wrapper for the constructor function //var constructor = proto.constructor.valueOf(); //-dean var constructor = proto.constructor; var klass = proto.constructor = function() { if (!Base._prototyping) { if (this._constructing || this.constructor == klass) { // instantiation this._constructing = true; constructor.apply(this, arguments); delete this._constructing; } else if (arguments[0] !== null) { // casting return (arguments[0].extend || extend).call(arguments[0], proto); } } }; // build the class interface klass.ancestor = this; klass.extend = this.extend; klass.forEach = this.forEach; klass.implement = this.implement; klass.prototype = proto; klass.toString = this.toString; klass.valueOf = function(type) { //return (type == "object") ? klass : constructor; //-dean return (type == "object") ? klass : constructor.valueOf(); }; extend.call(klass, _static); // class initialisation if (typeof klass.init == "function") klass.init(); return klass; }; Base.prototype = { extend: function(source, value) { if (arguments.length > 1) { // extending with a name/value pair var ancestor = this[source]; if (ancestor && (typeof value == "function") && // overriding a method? // the valueOf() comparison is to avoid circular references (!ancestor.valueOf || ancestor.valueOf() != value.valueOf()) && /\bbase\b/.test(value)) { // get the underlying method var method = value.valueOf(); // override value = function() { var previous = this.base || Base.prototype.base; this.base = ancestor; var returnValue = method.apply(this, arguments); this.base = previous; return returnValue; }; // point to the underlying method value.valueOf = function(type) { return (type == "object") ? value : method; }; value.toString = Base.toString; } this[source] = value; } else if (source) { // extending with an object literal var extend = Base.prototype.extend; // if this object has a customised extend method then use it if (!Base._prototyping && typeof this != "function") { extend = this.extend || extend; } var proto = {toSource: null}; // do the "toString" and other methods manually var hidden = ["constructor", "toString", "valueOf"]; // if we are prototyping then include the constructor var i = Base._prototyping ? 0 : 1; while (key = hidden[i++]) { if (source[key] != proto[key]) { extend.call(this, key, source[key]); } } // copy each of the source object's properties to this object for (var key in source) { if (!proto[key]) extend.call(this, key, source[key]); } } return this; } }; // initialise Base = Base.extend({ constructor: function() { this.extend(arguments[0]); } }, { ancestor: Object, version: "1.1", forEach: function(object, block, context) { for (var key in object) { if (this.prototype[key] === undefined) { block.call(context, object[key], key, object); } } }, implement: function() { for (var i = 0; i < arguments.length; i++) { if (typeof arguments[i] == "function") { // if it's a function, call it arguments[i](this.prototype); } else { // add the interface using the extend method this.prototype.extend(arguments[i]); } } return this; }, toString: function() { return String(this.valueOf()); } }); /*jshint smarttabs:true */ var FlipClock; /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * FlipFlock Helper * * @param object A jQuery object or CSS select * @param int An integer used to start the clock (no. seconds) * @param object An object of properties to override the default */ FlipClock = function(obj, digit, options) { if(digit instanceof Object && digit instanceof Date === false) { options = digit; digit = 0; } return new FlipClock.Factory(obj, digit, options); }; /** * The global FlipClock.Lang object */ FlipClock.Lang = {}; /** * The Base FlipClock class is used to extend all other FlipFlock * classes. It handles the callbacks and the basic setters/getters * * @param object An object of the default properties * @param object An object of properties to override the default */ FlipClock.Base = Base.extend({ /** * Build Date */ buildDate: '2014-12-12', /** * Version */ version: '0.7.7', /** * Sets the default options * * @param object The default options * @param object The override options */ constructor: function(_default, options) { if(typeof _default !== "object") { _default = {}; } if(typeof options !== "object") { options = {}; } this.setOptions($.extend(true, {}, _default, options)); }, /** * Delegates the callback to the defined method * * @param object The default options * @param object The override options */ callback: function(method) { if(typeof method === "function") { var args = []; for(var x = 1; x <= arguments.length; x++) { if(arguments[x]) { args.push(arguments[x]); } } method.apply(this, args); } }, /** * Log a string into the console if it exists * * @param string The name of the option * @return mixed */ log: function(str) { if(window.console && console.log) { console.log(str); } }, /** * Get an single option value. Returns false if option does not exist * * @param string The name of the option * @return mixed */ getOption: function(index) { if(this[index]) { return this[index]; } return false; }, /** * Get all options * * @return bool */ getOptions: function() { return this; }, /** * Set a single option value * * @param string The name of the option * @param mixed The value of the option */ setOption: function(index, value) { this[index] = value; }, /** * Set a multiple options by passing a JSON object * * @param object The object with the options * @param mixed The value of the option */ setOptions: function(options) { for(var key in options) { if(typeof options[key] !== "undefined") { this.setOption(key, options[key]); } } } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock Face class is the base class in which to extend * all other FlockClock.Face classes. * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.Face = FlipClock.Base.extend({ /** * Sets whether or not the clock should start upon instantiation */ autoStart: true, /** * An array of jQuery objects used for the dividers (the colons) */ dividers: [], /** * An array of FlipClock.List objects */ factory: false, /** * An array of FlipClock.List objects */ lists: [], /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.dividers = []; this.lists = []; this.base(options); this.factory = factory; }, /** * Build the clock face */ build: function() { if(this.autoStart) { this.start(); } }, /** * Creates a jQuery object used for the digit divider * * @param mixed The divider label text * @param mixed Set true to exclude the dots in the divider. * If not set, is false. */ createDivider: function(label, css, excludeDots) { if(typeof css == "boolean" || !css) { excludeDots = css; css = label; } var dots = [ '<span class="'+this.factory.classes.dot+' top"></span>', '<span class="'+this.factory.classes.dot+' bottom"></span>' ].join(''); if(excludeDots) { dots = ''; } label = this.factory.localize(label); var html = [ '<span class="'+this.factory.classes.divider+' '+(css ? css : '').toLowerCase()+'">', '<span class="'+this.factory.classes.label+'">'+(label ? label : '')+'</span>', dots, '</span>' ]; var $html = $(html.join('')); this.dividers.push($html); return $html; }, /** * Creates a FlipClock.List object and appends it to the DOM * * @param mixed The digit to select in the list * @param object An object to override the default properties */ createList: function(digit, options) { if(typeof digit === "object") { options = digit; digit = 0; } var obj = new FlipClock.List(this.factory, digit, options); this.lists.push(obj); return obj; }, /** * Triggers when the clock is reset */ reset: function() { this.factory.time = new FlipClock.Time( this.factory, this.factory.original ? Math.round(this.factory.original) : 0, { minimumDigits: this.factory.minimumDigits } ); this.flip(this.factory.original, false); }, /** * Append a newly created list to the clock */ appendDigitToClock: function(obj) { obj.$el.append(false); }, /** * Add a digit to the clock face */ addDigit: function(digit) { var obj = this.createList(digit, { classes: { active: this.factory.classes.active, before: this.factory.classes.before, flip: this.factory.classes.flip } }); this.appendDigitToClock(obj); }, /** * Triggers when the clock is started */ start: function() {}, /** * Triggers when the time on the clock stops */ stop: function() {}, /** * Auto increments/decrements the value of the clock face */ autoIncrement: function() { if(!this.factory.countdown) { this.increment(); } else { this.decrement(); } }, /** * Increments the value of the clock face */ increment: function() { this.factory.time.addSecond(); }, /** * Decrements the value of the clock face */ decrement: function() { if(this.factory.time.getTimeSeconds() == 0) { this.factory.stop() } else { this.factory.time.subSecond(); } }, /** * Triggers when the numbers on the clock flip */ flip: function(time, doNotAddPlayClass) { var t = this; $.each(time, function(i, digit) { var list = t.lists[i]; if(list) { if(!doNotAddPlayClass && digit != list.digit) { list.play(); } list.select(digit); } else { t.addDigit(digit); } }); } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock Factory class is used to build the clock and manage * all the public methods. * * @param object A jQuery object or CSS selector used to fetch the wrapping DOM nodes * @param mixed This is the digit used to set the clock. If an object is passed, 0 will be used. * @param object An object of properties to override the default */ FlipClock.Factory = FlipClock.Base.extend({ /** * The clock's animation rate. * * Note, currently this property doesn't do anything. * This property is here to be used in the future to * programmaticaly set the clock's animation speed */ animationRate: 1000, /** * Auto start the clock on page load (True|False) */ autoStart: true, /** * The callback methods */ callbacks: { destroy: false, create: false, init: false, interval: false, start: false, stop: false, reset: false }, /** * The CSS classes */ classes: { active: 'flip-clock-active', before: 'flip-clock-before', divider: 'flip-clock-divider', dot: 'flip-clock-dot', label: 'flip-clock-label', flip: 'flip', play: 'play', wrapper: 'flip-clock-wrapper' }, /** * The name of the clock face class in use */ clockFace: 'HourlyCounter', /** * The name of the clock face class in use */ countdown: false, /** * The name of the default clock face class to use if the defined * clockFace variable is not a valid FlipClock.Face object */ defaultClockFace: 'HourlyCounter', /** * The default language */ defaultLanguage: 'english', /** * The jQuery object */ $el: false, /** * The FlipClock.Face object */ face: true, /** * The language object after it has been loaded */ lang: false, /** * The language being used to display labels (string) */ language: 'english', /** * The minimum digits the clock must have */ minimumDigits: 0, /** * The original starting value of the clock. Used for the reset method. */ original: false, /** * Is the clock running? (True|False) */ running: false, /** * The FlipClock.Time object */ time: false, /** * The FlipClock.Timer object */ timer: false, /** * The jQuery object (depcrecated) */ $wrapper: false, /** * Constructor * * @param object The wrapping jQuery object * @param object Number of seconds used to start the clock * @param object An object override options */ constructor: function(obj, digit, options) { if(!options) { options = {}; } this.lists = []; this.running = false; this.base(options); this.$el = $(obj).addClass(this.classes.wrapper); // Depcrated support of the $wrapper property. this.$wrapper = this.$el; this.original = (digit instanceof Date) ? digit : (digit ? Math.round(digit) : 0); this.time = new FlipClock.Time(this, this.original, { minimumDigits: this.minimumDigits, animationRate: this.animationRate }); this.timer = new FlipClock.Timer(this, options); this.loadLanguage(this.language); this.loadClockFace(this.clockFace, options); if(this.autoStart) { this.start(); } }, /** * Load the FlipClock.Face object * * @param object The name of the FlickClock.Face class * @param object An object override options */ loadClockFace: function(name, options) { var face, suffix = 'Face', hasStopped = false; name = name.ucfirst()+suffix; if(this.face.stop) { this.stop(); hasStopped = true; } this.$el.html(''); this.time.minimumDigits = this.minimumDigits; if(FlipClock[name]) { face = new FlipClock[name](this, options); } else { face = new FlipClock[this.defaultClockFace+suffix](this, options); } face.build(); this.face = face if(hasStopped) { this.start(); } return this.face; }, /** * Load the FlipClock.Lang object * * @param object The name of the language to load */ loadLanguage: function(name) { var lang; if(FlipClock.Lang[name.ucfirst()]) { lang = FlipClock.Lang[name.ucfirst()]; } else if(FlipClock.Lang[name]) { lang = FlipClock.Lang[name]; } else { lang = FlipClock.Lang[this.defaultLanguage]; } return this.lang = lang; }, /** * Localize strings into various languages * * @param string The index of the localized string * @param object Optionally pass a lang object */ localize: function(index, obj) { var lang = this.lang; if(!index) { return null; } var lindex = index.toLowerCase(); if(typeof obj == "object") { lang = obj; } if(lang && lang[lindex]) { return lang[lindex]; } return index; }, /** * Starts the clock */ start: function(callback) { var t = this; if(!t.running && (!t.countdown || t.countdown && t.time.time > 0)) { t.face.start(t.time); t.timer.start(function() { t.flip(); if(typeof callback === "function") { callback(); } }); } else { t.log('Trying to start timer when countdown already at 0'); } }, /** * Stops the clock */ stop: function(callback) { this.face.stop(); this.timer.stop(callback); for(var x in this.lists) { if (this.lists.hasOwnProperty(x)) { this.lists[x].stop(); } } }, /** * Reset the clock */ reset: function(callback) { this.timer.reset(callback); this.face.reset(); }, /** * Sets the clock time */ setTime: function(time) { this.time.time = time; this.flip(true); }, /** * Get the clock time * * @return object Returns a FlipClock.Time object */ getTime: function(time) { return this.time; }, /** * Changes the increment of time to up or down (add/sub) */ setCountdown: function(value) { var running = this.running; this.countdown = value ? true : false; if(running) { this.stop(); this.start(); } }, /** * Flip the digits on the clock * * @param array An array of digits */ flip: function(doNotAddPlayClass) { this.face.flip(false, doNotAddPlayClass); } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock List class is used to build the list used to create * the card flip effect. This object fascilates selecting the correct * node by passing a specific digit. * * @param object A FlipClock.Factory object * @param mixed This is the digit used to set the clock. If an * object is passed, 0 will be used. * @param object An object of properties to override the default */ FlipClock.List = FlipClock.Base.extend({ /** * The digit (0-9) */ digit: 0, /** * The CSS classes */ classes: { active: 'flip-clock-active', before: 'flip-clock-before', flip: 'flip' }, /** * The parent FlipClock.Factory object */ factory: false, /** * The jQuery object */ $el: false, /** * The jQuery object (deprecated) */ $obj: false, /** * The items in the list */ items: [], /** * The last digit */ lastDigit: 0, /** * Constructor * * @param object A FlipClock.Factory object * @param int An integer use to select the correct digit * @param object An object to override the default properties */ constructor: function(factory, digit, options) { this.factory = factory; this.digit = digit; this.lastDigit = digit; this.$el = this.createList(); // Depcrated support of the $obj property. this.$obj = this.$el; if(digit > 0) { this.select(digit); } this.factory.$el.append(this.$el); }, /** * Select the digit in the list * * @param int A digit 0-9 */ select: function(digit) { if(typeof digit === "undefined") { digit = this.digit; } else { this.digit = digit; } if(this.digit != this.lastDigit) { var $delete = this.$el.find('.'+this.classes.before).removeClass(this.classes.before); this.$el.find('.'+this.classes.active).removeClass(this.classes.active) .addClass(this.classes.before); this.appendListItem(this.classes.active, this.digit); $delete.remove(); this.lastDigit = this.digit; } }, /** * Adds the play class to the DOM object */ play: function() { this.$el.addClass(this.factory.classes.play); }, /** * Removes the play class to the DOM object */ stop: function() { var t = this; setTimeout(function() { t.$el.removeClass(t.factory.classes.play); }, this.factory.timer.interval); }, /** * Creates the list item HTML and returns as a string */ createListItem: function(css, value) { return [ '<li class="'+(css ? css : '')+'">', '<a href="#">', '<div class="up">', '<div class="shadow"></div>', '<div class="inn">'+(value ? value : '')+'</div>', '</div>', '<div class="down">', '<div class="shadow"></div>', '<div class="inn">'+(value ? value : '')+'</div>', '</div>', '</a>', '</li>' ].join(''); }, /** * Append the list item to the parent DOM node */ appendListItem: function(css, value) { var html = this.createListItem(css, value); this.$el.append(html); }, /** * Create the list of digits and appends it to the DOM object */ createList: function() { var lastDigit = this.getPrevDigit() ? this.getPrevDigit() : this.digit; var html = $([ '<ul class="'+this.classes.flip+' '+(this.factory.running ? this.factory.classes.play : '')+'">', this.createListItem(this.classes.before, lastDigit), this.createListItem(this.classes.active, this.digit), '</ul>' ].join('')); return html; }, getNextDigit: function() { return this.digit == 9 ? 0 : this.digit + 1; }, getPrevDigit: function() { return this.digit == 0 ? 9 : this.digit - 1; } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * Capitalize the first letter in a string * * @return string */ String.prototype.ucfirst = function() { return this.substr(0, 1).toUpperCase() + this.substr(1); }; /** * jQuery helper method * * @param int An integer used to start the clock (no. seconds) * @param object An object of properties to override the default */ $.fn.FlipClock = function(digit, options) { return new FlipClock($(this), digit, options); }; /** * jQuery helper method * * @param int An integer used to start the clock (no. seconds) * @param object An object of properties to override the default */ $.fn.flipClock = function(digit, options) { return $.fn.FlipClock(digit, options); }; }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock Time class is used to manage all the time * calculations. * * @param object A FlipClock.Factory object * @param mixed This is the digit used to set the clock. If an * object is passed, 0 will be used. * @param object An object of properties to override the default */ FlipClock.Time = FlipClock.Base.extend({ /** * The time (in seconds) or a date object */ time: 0, /** * The parent FlipClock.Factory object */ factory: false, /** * The minimum number of digits the clock face must have */ minimumDigits: 0, /** * Constructor * * @param object A FlipClock.Factory object * @param int An integer use to select the correct digit * @param object An object to override the default properties */ constructor: function(factory, time, options) { if(typeof options != "object") { options = {}; } if(!options.minimumDigits) { options.minimumDigits = factory.minimumDigits; } this.base(options); this.factory = factory; if(time) { this.time = time; } }, /** * Convert a string or integer to an array of digits * * @param mixed String or Integer of digits * @return array An array of digits */ convertDigitsToArray: function(str) { var data = []; str = str.toString(); for(var x = 0;x < str.length; x++) { if(str[x].match(/^\d*$/g)) { data.push(str[x]); } } return data; }, /** * Get a specific digit from the time integer * * @param int The specific digit to select from the time * @return mixed Returns FALSE if no digit is found, otherwise * the method returns the defined digit */ digit: function(i) { var timeStr = this.toString(); var length = timeStr.length; if(timeStr[length - i]) { return timeStr[length - i]; } return false; }, /** * Formats any array of digits into a valid array of digits * * @param mixed An array of digits * @return array An array of digits */ digitize: function(obj) { var data = []; $.each(obj, function(i, value) { value = value.toString(); if(value.length == 1) { value = '0'+value; } for(var x = 0; x < value.length; x++) { data.push(value.charAt(x)); } }); if(data.length > this.minimumDigits) { this.minimumDigits = data.length; } if(this.minimumDigits > data.length) { for(var x = data.length; x < this.minimumDigits; x++) { data.unshift('0'); } } return data; }, /** * Gets a new Date object for the current time * * @return array Returns a Date object */ getDateObject: function() { if(this.time instanceof Date) { return this.time; } return new Date((new Date()).getTime() + this.getTimeSeconds() * 1000); }, /** * Gets a digitized daily counter * * @return object Returns a digitized object */ getDayCounter: function(includeSeconds) { var digits = [ this.getDays(), this.getHours(true), this.getMinutes(true) ]; if(includeSeconds) { digits.push(this.getSeconds(true)); } return this.digitize(digits); }, /** * Gets number of days * * @param bool Should perform a modulus? If not sent, then no. * @return int Retuns a floored integer */ getDays: function(mod) { var days = this.getTimeSeconds() / 60 / 60 / 24; if(mod) { days = days % 7; } return Math.floor(days); }, /** * Gets an hourly breakdown * * @return object Returns a digitized object */ getHourCounter: function() { var obj = this.digitize([ this.getHours(), this.getMinutes(true), this.getSeconds(true) ]); return obj; }, /** * Gets an hourly breakdown * * @return object Returns a digitized object */ getHourly: function() { return this.getHourCounter(); }, /** * Gets number of hours * * @param bool Should perform a modulus? If not sent, then no. * @return int Retuns a floored integer */ getHours: function(mod) { var hours = this.getTimeSeconds() / 60 / 60; if(mod) { hours = hours % 24; } return Math.floor(hours); }, /** * Gets the twenty-four hour time * * @return object returns a digitized object */ getMilitaryTime: function(date, showSeconds) { if(typeof showSeconds === "undefined") { showSeconds = true; } if(!date) { date = this.getDateObject(); } var data = [ date.getHours(), date.getMinutes() ]; if(showSeconds === true) { data.push(date.getSeconds()); } return this.digitize(data); }, /** * Gets number of minutes * * @param bool Should perform a modulus? If not sent, then no. * @return int Retuns a floored integer */ getMinutes: function(mod) { var minutes = this.getTimeSeconds() / 60; if(mod) { minutes = minutes % 60; } return Math.floor(minutes); }, /** * Gets a minute breakdown */ getMinuteCounter: function() { var obj = this.digitize([ this.getMinutes(), this.getSeconds(true) ]); return obj; }, /** * Gets time count in seconds regardless of if targetting date or not. * * @return int Returns a floored integer */ getTimeSeconds: function(date) { if(!date) { date = new Date(); } if (this.time instanceof Date) { if (this.factory.countdown) { return Math.max(this.time.getTime()/1000 - date.getTime()/1000,0); } else { return date.getTime()/1000 - this.time.getTime()/1000 ; } } else { return this.time; } }, /** * Gets the current twelve hour time * * @return object Returns a digitized object */ getTime: function(date, showSeconds) { if(typeof showSeconds === "undefined") { showSeconds = true; } if(!date) { date = this.getDateObject(); } console.log(date); var hours = date.getHours(); var merid = hours > 12 ? 'PM' : 'AM'; var data = [ hours > 12 ? hours - 12 : (hours === 0 ? 12 : hours), date.getMinutes() ]; if(showSeconds === true) { data.push(date.getSeconds()); } return this.digitize(data); }, /** * Gets number of seconds * * @param bool Should perform a modulus? If not sent, then no. * @return int Retuns a ceiled integer */ getSeconds: function(mod) { var seconds = this.getTimeSeconds(); if(mod) { if(seconds == 60) { seconds = 0; } else { seconds = seconds % 60; } } return Math.ceil(seconds); }, /** * Gets number of weeks * * @param bool Should perform a modulus? If not sent, then no. * @return int Retuns a floored integer */ getWeeks: function(mod) { var weeks = this.getTimeSeconds() / 60 / 60 / 24 / 7; if(mod) { weeks = weeks % 52; } return Math.floor(weeks); }, /** * Removes a specific number of leading zeros from the array. * This method prevents you from removing too many digits, even * if you try. * * @param int Total number of digits to remove * @return array An array of digits */ removeLeadingZeros: function(totalDigits, digits) { var total = 0; var newArray = []; $.each(digits, function(i, digit) { if(i < totalDigits) { total += parseInt(digits[i], 10); } else { newArray.push(digits[i]); } }); if(total === 0) { return newArray; } return digits; }, /** * Adds X second to the current time */ addSeconds: function(x) { if(this.time instanceof Date) { this.time.setSeconds(this.time.getSeconds() + x); } else { this.time += x; } }, /** * Adds 1 second to the current time */ addSecond: function() { this.addSeconds(1); }, /** * Substracts X seconds from the current time */ subSeconds: function(x) { if(this.time instanceof Date) { this.time.setSeconds(this.time.getSeconds() - x); } else { this.time -= x; } }, /** * Substracts 1 second from the current time */ subSecond: function() { this.subSeconds(1); }, /** * Converts the object to a human readable string */ toString: function() { return this.getTimeSeconds().toString(); } /* getYears: function() { return Math.floor(this.time / 60 / 60 / 24 / 7 / 52); }, getDecades: function() { return Math.floor(this.getWeeks() / 10); }*/ }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock.Timer object managers the JS timers * * @param object The parent FlipClock.Factory object * @param object Override the default options */ FlipClock.Timer = FlipClock.Base.extend({ /** * Callbacks */ callbacks: { destroy: false, create: false, init: false, interval: false, start: false, stop: false, reset: false }, /** * FlipClock timer count (how many intervals have passed) */ count: 0, /** * The parent FlipClock.Factory object */ factory: false, /** * Timer interval (1 second by default) */ interval: 1000, /** * The rate of the animation in milliseconds (not currently in use) */ animationRate: 1000, /** * Constructor * * @return void */ constructor: function(factory, options) { this.base(options); this.factory = factory; this.callback(this.callbacks.init); this.callback(this.callbacks.create); }, /** * This method gets the elapsed the time as an interger * * @return void */ getElapsed: function() { return this.count * this.interval; }, /** * This method gets the elapsed the time as a Date object * * @return void */ getElapsedTime: function() { return new Date(this.time + this.getElapsed()); }, /** * This method is resets the timer * * @param callback This method resets the timer back to 0 * @return void */ reset: function(callback) { clearInterval(this.timer); this.count = 0; this._setInterval(callback); this.callback(this.callbacks.reset); }, /** * This method is starts the timer * * @param callback A function that is called once the timer is destroyed * @return void */ start: function(callback) { this.factory.running = true; this._createTimer(callback); this.callback(this.callbacks.start); }, /** * This method is stops the timer * * @param callback A function that is called once the timer is destroyed * @return void */ stop: function(callback) { this.factory.running = false; this._clearInterval(callback); this.callback(this.callbacks.stop); this.callback(callback); }, /** * Clear the timer interval * * @return void */ _clearInterval: function() { clearInterval(this.timer); }, /** * Create the timer object * * @param callback A function that is called once the timer is created * @return void */ _createTimer: function(callback) { this._setInterval(callback); }, /** * Destroy the timer object * * @param callback A function that is called once the timer is destroyed * @return void */ _destroyTimer: function(callback) { this._clearInterval(); this.timer = false; this.callback(callback); this.callback(this.callbacks.destroy); }, /** * This method is called each time the timer interval is ran * * @param callback A function that is called once the timer is destroyed * @return void */ _interval: function(callback) { this.callback(this.callbacks.interval); this.callback(callback); this.count++; }, /** * This sets the timer interval * * @param callback A function that is called once the timer is destroyed * @return void */ _setInterval: function(callback) { var t = this; t._interval(callback); t.timer = setInterval(function() { t._interval(callback); }, this.interval); } }); }(jQuery)); (function($) { /** * Twenty-Four Hour Clock Face * * This class will generate a twenty-four our clock for FlipClock.js * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.TwentyFourHourClockFace = FlipClock.Face.extend({ /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.base(factory, options); }, /** * Build the clock face * * @param object Pass the time that should be used to display on the clock. */ build: function(time) { var t = this; var children = this.factory.$el.find('ul'); if(!this.factory.time.time) { this.factory.original = new Date(); this.factory.time = new FlipClock.Time(this.factory, this.factory.original); } var time = time ? time : this.factory.time.getMilitaryTime(false, this.showSeconds); if(time.length > children.length) { $.each(time, function(i, digit) { t.createList(digit); }); } this.createDivider(); this.createDivider(); $(this.dividers[0]).insertBefore(this.lists[this.lists.length - 2].$el); $(this.dividers[1]).insertBefore(this.lists[this.lists.length - 4].$el); this.base(); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { this.autoIncrement(); time = time ? time : this.factory.time.getMilitaryTime(false, this.showSeconds); this.base(time, doNotAddPlayClass); } }); }(jQuery)); (function($) { /** * Counter Clock Face * * This class will generate a generice flip counter. The timer has been * disabled. clock.increment() and clock.decrement() have been added. * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.CounterFace = FlipClock.Face.extend({ /** * Tells the counter clock face if it should auto-increment */ shouldAutoIncrement: false, /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { if(typeof options != "object") { options = {}; } factory.autoStart = options.autoStart ? true : false; if(options.autoStart) { this.shouldAutoIncrement = true; } factory.increment = function() { factory.countdown = false; factory.setTime(factory.getTime().getTimeSeconds() + 1); }; factory.decrement = function() { factory.countdown = true; var time = factory.getTime().getTimeSeconds(); if(time > 0) { factory.setTime(time - 1); } }; factory.setValue = function(digits) { factory.setTime(digits); }; factory.setCounter = function(digits) { factory.setTime(digits); }; this.base(factory, options); }, /** * Build the clock face */ build: function() { var t = this; var children = this.factory.$el.find('ul'); var time = this.factory.getTime().digitize([this.factory.getTime().time]); if(time.length > children.length) { $.each(time, function(i, digit) { var list = t.createList(digit); list.select(digit); }); } $.each(this.lists, function(i, list) { list.play(); }); this.base(); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { if(this.shouldAutoIncrement) { this.autoIncrement(); } if(!time) { time = this.factory.getTime().digitize([this.factory.getTime().time]); } this.base(time, doNotAddPlayClass); }, /** * Reset the clock face */ reset: function() { this.factory.time = new FlipClock.Time( this.factory, this.factory.original ? Math.round(this.factory.original) : 0 ); this.flip(); } }); }(jQuery)); (function($) { /** * Daily Counter Clock Face * * This class will generate a daily counter for FlipClock.js. A * daily counter will track days, hours, minutes, and seconds. If * the number of available digits is exceeded in the count, a new * digit will be created. * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.DailyCounterFace = FlipClock.Face.extend({ showSeconds: true, /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.base(factory, options); }, /** * Build the clock face */ build: function(time) { var t = this; var children = this.factory.$el.find('ul'); var offset = 0; time = time ? time : this.factory.time.getDayCounter(this.showSeconds); if(time.length > children.length) { $.each(time, function(i, digit) { t.createList(digit); }); } if(this.showSeconds) { $(this.createDivider('SEGUNDOS')).insertBefore(this.lists[this.lists.length - 2].$el); } else { offset = 2; } $(this.createDivider('MINUTOS')).insertBefore(this.lists[this.lists.length - 4 + offset].$el); $(this.createDivider('HORAS')).insertBefore(this.lists[this.lists.length - 6 + offset].$el); $(this.createDivider('DIAS', true)).insertBefore(this.lists[0].$el); this.base(); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { if(!time) { time = this.factory.time.getDayCounter(this.showSeconds); } this.autoIncrement(); this.base(time, doNotAddPlayClass); } }); }(jQuery)); (function($) { /** * Hourly Counter Clock Face * * This class will generate an hourly counter for FlipClock.js. An * hour counter will track hours, minutes, and seconds. If number of * available digits is exceeded in the count, a new digit will be * created. * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.HourlyCounterFace = FlipClock.Face.extend({ // clearExcessDigits: true, /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.base(factory, options); }, /** * Build the clock face */ build: function(excludeHours, time) { var t = this; var children = this.factory.$el.find('ul'); time = time ? time : this.factory.time.getHourCounter(); if(time.length > children.length) { $.each(time, function(i, digit) { t.createList(digit); }); } $(this.createDivider('Seconds')).insertBefore(this.lists[this.lists.length - 2].$el); $(this.createDivider('Minutes')).insertBefore(this.lists[this.lists.length - 4].$el); if(!excludeHours) { $(this.createDivider('Hours', true)).insertBefore(this.lists[0].$el); } this.base(); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { if(!time) { time = this.factory.time.getHourCounter(); } this.autoIncrement(); this.base(time, doNotAddPlayClass); }, /** * Append a newly created list to the clock */ appendDigitToClock: function(obj) { this.base(obj); this.dividers[0].insertAfter(this.dividers[0].next()); } }); }(jQuery)); (function($) { /** * Minute Counter Clock Face * * This class will generate a minute counter for FlipClock.js. A * minute counter will track minutes and seconds. If an hour is * reached, the counter will reset back to 0. (4 digits max) * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.MinuteCounterFace = FlipClock.HourlyCounterFace.extend({ clearExcessDigits: false, /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.base(factory, options); }, /** * Build the clock face */ build: function() { this.base(true, this.factory.time.getMinuteCounter()); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { if(!time) { time = this.factory.time.getMinuteCounter(); } this.base(time, doNotAddPlayClass); } }); }(jQuery)); (function($) { /** * Twelve Hour Clock Face * * This class will generate a twelve hour clock for FlipClock.js * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.TwelveHourClockFace = FlipClock.TwentyFourHourClockFace.extend({ /** * The meridium jQuery DOM object */ meridium: false, /** * The meridium text as string for easy access */ meridiumText: 'AM', /** * Build the clock face * * @param object Pass the time that should be used to display on the clock. */ build: function() { var t = this; var time = this.factory.time.getTime(false, this.showSeconds); this.base(time); this.meridiumText = this.getMeridium(); this.meridium = $([ '<ul class="flip-clock-meridium">', '<li>', '<a href="#">'+this.meridiumText+'</a>', '</li>', '</ul>' ].join('')); this.meridium.insertAfter(this.lists[this.lists.length-1].$el); }, /** * Flip the clock face */ flip: function(time, doNotAddPlayClass) { if(this.meridiumText != this.getMeridium()) { this.meridiumText = this.getMeridium(); this.meridium.find('a').html(this.meridiumText); } this.base(this.factory.time.getTime(false, this.showSeconds), doNotAddPlayClass); }, /** * Get the current meridium * * @return string Returns the meridium (AM|PM) */ getMeridium: function() { return new Date().getHours() >= 12 ? 'PM' : 'AM'; }, /** * Is it currently in the post-medirium? * * @return bool Returns true or false */ isPM: function() { return this.getMeridium() == 'PM' ? true : false; }, /** * Is it currently before the post-medirium? * * @return bool Returns true or false */ isAM: function() { return this.getMeridium() == 'AM' ? true : false; } }); }(jQuery)); (function($) { /** * FlipClock Arabic Language Pack * * This class will be used to translate tokens into the Arabic language. * */ FlipClock.Lang.Arabic = { 'years' : 'سنوات', 'months' : 'شهور', 'days' : 'أيام', 'hours' : 'ساعات', 'minutes' : 'دقائق', 'seconds' : 'ثواني' }; /* Create various aliases for convenience */ FlipClock.Lang['ar'] = FlipClock.Lang.Arabic; FlipClock.Lang['ar-ar'] = FlipClock.Lang.Arabic; FlipClock.Lang['arabic'] = FlipClock.Lang.Arabic; }(jQuery)); (function($) { /** * FlipClock Danish Language Pack * * This class will used to translate tokens into the Danish language. * */ FlipClock.Lang.Danish = { 'years' : 'År', 'months' : 'Måneder', 'days' : 'Dage', 'hours' : 'Timer', 'minutes' : 'Minutter', 'seconds' : 'Sekunder' }; /* Create various aliases for convenience */ FlipClock.Lang['da'] = FlipClock.Lang.Danish; FlipClock.Lang['da-dk'] = FlipClock.Lang.Danish; FlipClock.Lang['danish'] = FlipClock.Lang.Danish; }(jQuery)); (function($) { /** * FlipClock German Language Pack * * This class will used to translate tokens into the German language. * */ FlipClock.Lang.German = { 'years' : 'Jahre', 'months' : 'Monate', 'days' : 'Tage', 'hours' : 'Stunden', 'minutes' : 'Minuten', 'seconds' : 'Sekunden' }; /* Create various aliases for convenience */ FlipClock.Lang['de'] = FlipClock.Lang.German; FlipClock.Lang['de-de'] = FlipClock.Lang.German; FlipClock.Lang['german'] = FlipClock.Lang.German; }(jQuery)); (function($) { /** * FlipClock English Language Pack * * This class will used to translate tokens into the English language. * */ FlipClock.Lang.English = { 'years' : 'Years', 'months' : 'Months', 'days' : 'Days', 'hours' : 'Hours', 'minutes' : 'Minutes', 'seconds' : 'Seconds' }; /* Create various aliases for convenience */ FlipClock.Lang['en'] = FlipClock.Lang.English; FlipClock.Lang['en-us'] = FlipClock.Lang.English; FlipClock.Lang['english'] = FlipClock.Lang.English; }(jQuery)); (function($) { /** * FlipClock Spanish Language Pack * * This class will used to translate tokens into the Spanish language. * */ FlipClock.Lang.Spanish = { 'years' : 'Años', 'months' : 'Meses', 'days' : 'Días', 'hours' : 'Horas', 'minutes' : 'Minutos', 'seconds' : 'Segundos' }; /* Create various aliases for convenience */ FlipClock.Lang['es'] = FlipClock.Lang.Spanish; FlipClock.Lang['es-es'] = FlipClock.Lang.Spanish; FlipClock.Lang['spanish'] = FlipClock.Lang.Spanish; }(jQuery)); (function($) { /** * FlipClock Finnish Language Pack * * This class will used to translate tokens into the Finnish language. * */ FlipClock.Lang.Finnish = { 'years' : 'Vuotta', 'months' : 'Kuukautta', 'days' : 'Päivää', 'hours' : 'Tuntia', 'minutes' : 'Minuuttia', 'seconds' : 'Sekuntia' }; /* Create various aliases for convenience */ FlipClock.Lang['fi'] = FlipClock.Lang.Finnish; FlipClock.Lang['fi-fi'] = FlipClock.Lang.Finnish; FlipClock.Lang['finnish'] = FlipClock.Lang.Finnish; }(jQuery)); (function($) { /** * FlipClock Canadian French Language Pack * * This class will used to translate tokens into the Canadian French language. * */ FlipClock.Lang.French = { 'years' : 'Ans', 'months' : 'Mois', 'days' : 'Jours', 'hours' : 'Heures', 'minutes' : 'Minutes', 'seconds' : 'Secondes' }; /* Create various aliases for convenience */ FlipClock.Lang['fr'] = FlipClock.Lang.French; FlipClock.Lang['fr-ca'] = FlipClock.Lang.French; FlipClock.Lang['french'] = FlipClock.Lang.French; }(jQuery)); (function($) { /** * FlipClock Italian Language Pack * * This class will used to translate tokens into the Italian language. * */ FlipClock.Lang.Italian = { 'years' : 'Anni', 'months' : 'Mesi', 'days' : 'Giorni', 'hours' : 'Ore', 'minutes' : 'Minuti', 'seconds' : 'Secondi' }; /* Create various aliases for convenience */ FlipClock.Lang['it'] = FlipClock.Lang.Italian; FlipClock.Lang['it-it'] = FlipClock.Lang.Italian; FlipClock.Lang['italian'] = FlipClock.Lang.Italian; }(jQuery)); (function($) { /** * FlipClock Latvian Language Pack * * This class will used to translate tokens into the Latvian language. * */ FlipClock.Lang.Latvian = { 'years' : 'Gadi', 'months' : 'Mēneši', 'days' : 'Dienas', 'hours' : 'Stundas', 'minutes' : 'Minūtes', 'seconds' : 'Sekundes' }; /* Create various aliases for convenience */ FlipClock.Lang['lv'] = FlipClock.Lang.Latvian; FlipClock.Lang['lv-lv'] = FlipClock.Lang.Latvian; FlipClock.Lang['latvian'] = FlipClock.Lang.Latvian; }(jQuery)); (function($) { /** * FlipClock Dutch Language Pack * * This class will used to translate tokens into the Dutch language. */ FlipClock.Lang.Dutch = { 'years' : 'Jaren', 'months' : 'Maanden', 'days' : 'Dagen', 'hours' : 'Uren', 'minutes' : 'Minuten', 'seconds' : 'Seconden' }; /* Create various aliases for convenience */ FlipClock.Lang['nl'] = FlipClock.Lang.Dutch; FlipClock.Lang['nl-be'] = FlipClock.Lang.Dutch; FlipClock.Lang['dutch'] = FlipClock.Lang.Dutch; }(jQuery)); (function($) { /** * FlipClock Norwegian-Bokmål Language Pack * * This class will used to translate tokens into the Norwegian language. * */ FlipClock.Lang.Norwegian = { 'years' : 'År', 'months' : 'Måneder', 'days' : 'Dager', 'hours' : 'Timer', 'minutes' : 'Minutter', 'seconds' : 'Sekunder' }; /* Create various aliases for convenience */ FlipClock.Lang['no'] = FlipClock.Lang.Norwegian; FlipClock.Lang['nb'] = FlipClock.Lang.Norwegian; FlipClock.Lang['no-nb'] = FlipClock.Lang.Norwegian; FlipClock.Lang['norwegian'] = FlipClock.Lang.Norwegian; }(jQuery)); (function($) { /** * FlipClock Portuguese Language Pack * * This class will used to translate tokens into the Portuguese language. * */ FlipClock.Lang.Portuguese = { 'years' : 'Anos', 'months' : 'Meses', 'days' : 'Dias', 'hours' : 'Horas', 'minutes' : 'Minutos', 'seconds' : 'Segundos' }; /* Create various aliases for convenience */ FlipClock.Lang['pt'] = FlipClock.Lang.Portuguese; FlipClock.Lang['pt-br'] = FlipClock.Lang.Portuguese; FlipClock.Lang['portuguese'] = FlipClock.Lang.Portuguese; }(jQuery)); (function($) { /** * FlipClock Russian Language Pack * * This class will used to translate tokens into the Russian language. * */ FlipClock.Lang.Russian = { 'years' : 'лет', 'months' : 'месяцев', 'days' : 'дней', 'hours' : 'часов', 'minutes' : 'минут', 'seconds' : 'секунд' }; /* Create various aliases for convenience */ FlipClock.Lang['ru'] = FlipClock.Lang.Russian; FlipClock.Lang['ru-ru'] = FlipClock.Lang.Russian; FlipClock.Lang['russian'] = FlipClock.Lang.Russian; }(jQuery)); (function($) { /** * FlipClock Swedish Language Pack * * This class will used to translate tokens into the Swedish language. * */ FlipClock.Lang.Swedish = { 'years' : 'År', 'months' : 'Månader', 'days' : 'Dagar', 'hours' : 'Timmar', 'minutes' : 'Minuter', 'seconds' : 'Sekunder' }; /* Create various aliases for convenience */ FlipClock.Lang['sv'] = FlipClock.Lang.Swedish; FlipClock.Lang['sv-se'] = FlipClock.Lang.Swedish; FlipClock.Lang['swedish'] = FlipClock.Lang.Swedish; }(jQuery)); (function($) { /** * FlipClock Chinese Language Pack * * This class will used to translate tokens into the Chinese language. * */ FlipClock.Lang.Chinese = { 'years' : '年', 'months' : '月', 'days' : '日', 'hours' : '时', 'minutes' : '分', 'seconds' : '秒' }; /* Create various aliases for convenience */ FlipClock.Lang['zh'] = FlipClock.Lang.Chinese; FlipClock.Lang['zh-cn'] = FlipClock.Lang.Chinese; FlipClock.Lang['chinese'] = FlipClock.Lang.Chinese; }(jQuery)); -
Atualizar uma tabela puxando dados de outra tabela com condição
alnasciment posted a topic in Visual Basic
Pessoal, estou tentando atualizar o campo class_fiscal da tabela custitem onde tento fazer uma busca na tabela import e trazer apenas o campo clas_datas. Preciso puxar da tabela import o campo clas_datas para a tabela custitem, porem na tabela custitem ja tenho cadastrado o codigo e descrição preciso buscar na tabela import e trazer a classificação referente a este codigo ja cadastrado, porem conforme abaixo ele executa apenas o primeiro registro, e não atualiza os demais. o que esta errado ? Set Custitem = vgDb(QualDb("DADOS")).OpenRecordSet("Custitem", dbOpenTable) Set Import = vgDb(QualDb("DADOS")).OpenRecordSet("Import", dbOpenTable) 'Processos pré-definidos Set Custitem = vgDb(QualDb("DADOS")).OpenRecordSet("SELECT * FROM Custitem WHERE Coditem = '" & Import!Cod_import & "' ORDER BY Coditem", dbOpenDynaset) If Custitem.RecordCount > 0 Then Custitem.MoveFirst vgNVez = 0 Do While Not Custitem.EOF If Not PTab(Import, "DADOS.Cod_import", Custitem!Coditem) Then MsgBox "Import não cadastrado", vbCritical, vgAtencao Error 65524 End If Custitem.Edit Custitem!Class_fiscal = (Import!Clas_datas) Custitem.Update Custitem.BookMark = Custitem.LastModified Custitem.MoveNext Loop End If CommitTrans GoTo SaiDaSub -
Saudações desenvolvedores, Estou precisando da ajuda de vocês em uma questão: Tenho uma pagina onde dentro de um laço while gero a consulta ao banco, mostrando um resultado por linha, sendo que em uma das colunas preciso que seja atualizada a cada 10 minutos apenas a coluna. Ja tentei com Ajax, mas aí atualiza apenas o primeiro resultado do while. Não posso dar refresh em toda a pagina pois tenho um MODAL que as vezes é chamado e se der refresh em toda a página perco as informações do modal. Alguém me daria uma dica de como fazer? a parte do código a qual me refiro é esta aqui: <!-- Inicio Modal --> <div class="modal fade" id="myModalcad" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" style="width: 1500px; margin: 0 auto; height: 100%;" role="document"> <!-- botao Cadastrar --> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title text-center" id="myModalLabel">Cadastrar Receita</h4> </div> <!-- botao Cadastrar --> <div class="modal-body " > <form method="POST" action="processa.php" enctype="multipart/form-data"> <div class="form-group"> <label for="recipient-name" class="control-label">Nome:</label> <input name="nome" type="text" class="form-control"> </div> <!--nao e do alterar --> <div class="form-group"> <label for="message-text" class="control-label">ConsultaXXXXX:</label> <textarea style="width:100%;height:630px" name="detalhes" class="form-control"></textarea> </div> <div class="modal-footer"> <button type="submit" class="btn btn-success">Cadastrar</button> </div> </form> </div> <!-- botao Cadastrar --> </div> </div> </div> <!-- Fim Modal --> <!-- botao Cadastrar --> <? while($colunas_prontuario = mysqli_fetch_assoc($preenche)) { $Descricao=['Descricao']; ?> <div id="lista"> <!-- TABELA --> <div class="row"> <div class="col-lg-12"> <table class="table table-striped" > <thead> <tr> <th>Hora</th> <th>Dra</th> <th>CodPac</th> <th>Paciente</th> <th>Convenio</th> <th>Contato</th> <th>Alergico</th> <th>Ação</th> </tr> </thead> <tbody> <?php while($rows_cursos = mysqli_fetch_assoc($resultado_cursos)) { ?> <tr> <td><?php echo $rows_cursos['hora'];?></td> <td><?php echo $rows_cursos['nomden'];?></td> <td><?php echo $rows_cursos['codpac']; ?></td> <td><?php echo $rows_cursos['nompac'];?></td> <td><?php echo $rows_cursos['nomefantasia'];?></td> <td><?php echo $rows_cursos['celpac'];?></td> <td><?php echo $rows_cursos['alergias'];?></td> <td><?php echo $rows_cursos['status_a'];?></td>
-
Olá, sou novo aqui e estou criando um contador e calcular de preço por minutos. Funciona basicamente como um cronômetro que faz um calculo por minuto, está tudo funcionando normalmente... o problema é quando atualiza a página e o cronômetro reinicia, existe algum modo de guardar essa função numa sessão ou em cookies? (vou colocar o código aqui mesmo e tbm anexei no post). var segundos = new Number(); var segundos = 0; var minutos = new Number(); var minutos = 0; var horas = new Number(); var horas = 0; var minutos_inf = new Number(); var minutos_inf = 0; var valor_por_minuto = 0.10; function start() { segundos = segundos + 1; if (segundos >= 60) { minutos = minutos + 1; minutos_inf = minutos_inf + 1; segundos = 0; if (minutos >= 60) { horas = horas + 1; minutos = 0; } } if (segundos < 10) { var m_segundos = "0" + segundos; } else { var m_segundos = segundos; } if (minutos < 10) { var m_minutos = "0" + minutos; } else { var m_minutos = minutos; } if (horas < 10) { var m_horas = "0" + horas; } else { var m_horas = horas; } sessionStorage.setItem('tempo', m_horas + ":" + m_minutos + ":" + m_segundos); tempo.innerText = sessionStorage.getItem('tempo'); var valor_total = (valor_por_minuto * minutos_inf).toFixed(2); valor.innerText = "R$ " + valor_total; setTimeout('start();', 1000); } config.js
- 2 replies
-
- cronometro
- page
- (and 19 more)