Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
associação pythonbrasil[9] django zope/plone planet Logado como (Entrar) Procurar: Veja também: PythonBrasil MudançasRecentes ÍndiceDeTítulos DocumentacaoPython CookBook OutrasSecoes Estrutura Sequencial Planet PythonBrasil Mais... EstruturaSequencial Voltar para a ListaDeExercicios Faça um Programa que mostre a mensagem "Alo mundo" na tela. Faça um Programa que peça um número e então mostre a mensagem O número informado foi [número]. Faça um Programa que peça dois números e imprima a soma. Faça um Programa que peça as 4 notas bimestrais e mostre a média. Faça um Programa que converta metros para centímetros. Faça um Programa que peça o raio de um círculo, calcule e mostre sua área. Faça um Programa que calcule a área de um quadrado, em seguida mostre o dobro desta área para o usuário. Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês. Faça um Programa que peça a temperatura em graus Farenheit, transforme e mostre a temperatura em graus Celsius. C = (5 * (F-32) / 9). Faça um Programa que peça a temperatura em graus Celsius, transforme e mostre em graus Farenheit. Faça um Programa que peça 2 números inteiros e um número real. Calcule e mostre: o produto do dobro do primeiro com metade do segundo . a soma do triplo do primeiro com o terceiro. o terceiro elevado ao cubo. Tendo como dados de entrada a altura de uma pessoa, construa um algoritmo que calcule seu peso ideal, usando a seguinte fórmula: (72.7*altura) - 58 Tendo como dados de entrada a altura e o sexo de uma pessoa, construa um algoritmo que calcule seu peso ideal, utilizando as seguintes fórmulas: Para homens: (72.7*h) - 58 Para mulheres: (62.1*h) - 44.7 (h = altura) Peça o peso da pessoa e informe se ela está dentro, acima ou abaixo do peso. João Papo-de-Pescador, homem de bem, comprou um microcomputador para controlar o rendimento diário de seu trabalho. Toda vez que ele traz um peso de peixes maior que o estabelecido pelo regulamento de pesca do estado de São Paulo (50 quilos) deve pagar uma multa de R$ 4,00 por quilo excedente. João precisa que você faça um programa que leia a variável peso (peso de peixes) e verifique se há excesso. Se houver, gravar na variável excesso e na variável multa o valor da multa que João deverá pagar. Caso contrário mostrar tais variáveis com o conteúdo ZERO. Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% para o sindicato, faça um programa que nos dê: salário bruto. quanto pagou ao INSS. quanto pagou ao sindicato. o salário líquido. calcule os descontos e o salário líquido, conforme a tabela abaixo: + Salário Bruto : R$ - IR (11%) : R$ - INSS (8%) : R$ - Sindicato ( 5%) : R$ = Salário Liquido : R$ Obs.: Salário Bruto - Descontos = Salário Líquido. Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00. Informe ao usuário a quantidades de latas de tinta a serem compradas e o preço total. Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00 ou em galões de 3,6 litros, que custam R$ 25,00. Informe ao usuário as quantidades de tinta a serem compradas e os respectivos preços em 3 situações: comprar apenas latas de 18 litros; comprar apenas galões de 3,6 litros; misturar latas e galões, de forma que o preço seja o menor. Acrescente 10% de folga e sempre arredonde os valores para cima, isto é, considere latas cheias. Faça um programa que peça o tamanho de um arquivo para download (em MB) e a velocidade de um link de Internet (em Mbps), calcule e informe o tempo aproximado de download do arquivo usando este link (em minutos). Voltar para a ListaDeExercicios Sobre esta página EstruturaSequencial (editada pela última vez em 2011-06-20 13:57:34 por MarcoAndreLopesMendes) Visualizar Texto | Visualizar Impressão | Information | Fazer Usuário Acompanhar | Anexos "Python" e os logos de Python são marcas registradas da Python Software Foundation, usadas aqui mediante permissão da mesma. O conteúdo deste site está disponível sob os termos da Creative Commons Attribution 2.5 exceto quando explicitamente especificado outra licença. a.www::before { margin: 0px 0.2em; content: url(../img/moin-www.png); } a.http::before { margin: 0px 0.2em; content: url(../img/moin-www.png); } a.https::before { margin: 0px 0.2em; content: url(../img/moin-www.png); } a.file::before { margin: 0px 0.2em; content: url(../img/moin-ftp.png); } a.ftp::before { margin: 0px 0.2em; content: url(../img/moin-ftp.png); } a.nntp::before { margin: 0px 0.2em; content: url(../img/moin-news.png); } a.news::before { margin: 0px 0.2em; content: url(../img/moin-news.png); } a.telnet::before { margin: 0px 0.2em; content: url(../img/moin-telnet.png); } a.irc::before { margin: 0px 0.2em; content: url(../img/moin-telnet.png); } a.mailto::before { margin: 0px 0.2em; content: url(../img/moin-email.png); } a.attachment::before { margin: 0px 0.2em; content: url(../img/moin-attach.png); } a.badinterwiki::before { margin: 0px 0.2em; content: url(../img/moin-inter.png); } a.interwiki::before { margin: 0px 0.2em; content: url(../img/moin-inter.png); } * html a.www { background: url("../img/moin-www.png") no-repeat left; padding-left: 14px; } * html a.http { background: url("../img/moin-www.png") no-repeat left; padding-left: 14px; } * html a.https { background: url("../img/moin-www.png") no-repeat left; padding-left: 14px; } * html a.file { background: url("../img/moin-ftp.png") no-repeat left; padding-left: 14px; } * html a.ftp { background: url("../img/moin-ftp.png") no-repeat left; padding-left: 14px; } * html a.nntp { background: url("../img/moin-news.png") no-repeat left; padding-left: 14px; } * html a.news { background: url("../img/moin-news.png") no-repeat left; padding-left: 14px; } * html a.telnet { background: url("../img/moin-telnet.png") no-repeat left; padding-left: 14px; } * html a.irc { background: url("../img/moin-telnet.png") no-repeat left; padding-left: 14px; } * html a.mailto { background: url("../img/moin-email.png") no-repeat left; padding-left: 14px; } * html a.attachment { background: url("../img/moin-attach.png") no-repeat left; padding-left: 14px; } * html a.badinterwiki { background: url("../img/moin-inter.png") no-repeat left; padding-left: 14px; } * html a.interwiki { background: url("../img/moin-inter.png") no-repeat left; padding-left: 14px; } body { margin: 0px; } #head_bar { margin: 0px 0px 2em; padding: 1em 150px; color: rgb(51, 51, 51); font-family: sans-serif; font-size: 8pt; border-bottom-color: black; border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(240, 240, 240); } #head_bar img { border: 0px currentColor; border-image: none; } #head_bar a.user_preference { color: rgb(51, 51, 51); font-weight: bold; } #head_bar .partners { width: 400px; text-align: right; word-spacing: 1em; float: right; display: block; } #head_bar .partners a { color: rgb(51, 51, 51); } #core { margin-right: 150px; margin-left: 150px; } #optional_header { margin: 1em -150px; color: black; padding-right: 150px; padding-left: 150px; font-family: sans-serif; font-size: 9pt; background-color: rgb(226, 242, 254); } #optional_header a { margin: 0pt; color: black; text-decoration: none; } #optional_header a strong { font-size: 12pt; } td { behavior: url(../pybr/css/IEFixes.htc); } #optional_header a:hover { color: white; background-color: rgb(0, 120, 192); } #optional_header td:hover { color: white; background-color: rgb(0, 120, 192); } #optional_header td.hover { color: white; background-color: rgb(0, 120, 192); } #optional_header a { color: inherit; } #optional_header td { padding: 10px; width: 25%; height: 11em; } #logo { border: 0px currentColor; border-image: none; margin-top: 50px; } #searchform { border: 0px currentColor; border-image: none; width: 340px; font-family: sans-serif; font-size: 8pt; float: right; max-height: 45px; } #sidebar { width: 160px; right: 150px; font-family: sans-serif; font-size: 9pt; margin-top: 3em; position: absolute; } #sidebar h1 { padding: 3px; font-family: sans-serif; font-size: 9pt; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 2px; border-bottom-style: dotted; } #sidebar img { border: 0px currentColor; border-image: none; } #sidebar ul { padding-left: 1.5em; } #sidebar p.ad { margin-top: 2em; } #page { color: rgb(51, 51, 51); line-height: 150%; font-family: sans-serif; font-size: 9pt; margin-top: 3em; margin-right: 200px; min-height: 1000px; _height: 1000px; } #page img { border: 0px currentColor; border-image: none; } #page h1 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 18pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #page h1 a { color: black; text-decoration: none; } #page h2 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 12pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #footer { background-position: top; padding: 1em 150px; clear: both; margin-top: 2em; background-image: url("../img/footer_bar.png"); background-repeat: repeat-x; background-color: rgb(244, 244, 247); } #footer p { margin: 0px; color: rgb(51, 51, 51); font-family: sans-serif; font-size: 8pt; } #footer a { color: rgb(51, 51, 51); } #footer .partners { word-spacing: 1em; float: right; } #footer img { border: 0px currentColor; border-image: none; } a img { border: 0px currentColor; border-image: none; } #message { margin: 1em; padding: 1em; border: 1px solid red; border-image: none; color: red; font-weight: bolder; } #message p { margin: 0px; } #message a { background: red; padding: 2px; color: white; text-decoration: none; margin-right: 1em; } #content .table-of-contents-heading { margin: 0px; font-weight: bold; } #content .table-of-contents { padding: 1em; border: 1px dashed rgb(96, 96, 255); border-image: none; } #content li p { margin: 0.5em; } #content h1 { padding: 3px; font-size: 16pt; } #content h2 { padding: 2px; font-size: 14pt; } #content h3 { font-size: 12pt; } #content h4 { font-size: 10pt; } #content { text-align: justify; } #content td { padding: 3px; border: 1px solid rgb(240, 240, 240); border-image: none; text-align: left; } #content td p { margin: 0px; } #content hr { border: 1px solid black; border-image: none; } tr.rcdaybreak { background-color: rgb(240, 240, 240); } .recentchanges td { padding: 5px; } #page-history td { border: 1px solid rgb(240, 240, 240); border-image: none; } .diff-removed { background-color: rgb(255, 128, 128); } .diff-added { background-color: rgb(128, 255, 128); } .diff-title { background-color: rgb(255, 255, 128); } table.diff { width: 100%; } pre { background: rgb(240, 240, 240); clear: both; font-family: courier, monospace; white-space: pre-wrap; -ms-word-wrap: break-word; } #editor { text-align: left; } #editor-textarea { width: 100%; clear: right; margin-top: 2em; } #editor-comment { width: 100%; } #preview { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } #previewbelow { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } div.codearea pre span.LineNumber { color: gray; } div.codearea pre span.ID { color: rgb(0, 0, 0); } div.codearea pre span.Operator { color: rgb(0, 0, 192); } div.codearea pre span.Char { color: rgb(0, 64, 128); } div.codearea pre span.Comment { color: rgb(0, 128, 0); } div.codearea pre span.Number { color: rgb(0, 128, 192); } div.codearea pre span.String { color: rgb(0, 64, 128); } div.codearea pre span.SPChar { color: rgb(0, 0, 192); } div.codearea pre span.ResWord { color: rgb(160, 0, 0); } div.codearea pre span.ConsWord { color: rgb(0, 128, 128); font-weight: bold; } div.codearea pre span.Error { border: 1.5pt solid rgb(255, 0, 0); border-image: none; color: rgb(255, 128, 128); } div.codearea pre span.ResWord2 { color: rgb(0, 128, 255); font-weight: bold; } div.codearea pre span.Special { color: rgb(0, 0, 255); } div.codearea pre span.Preprc { color: rgb(128, 57, 153); } .content_ad { padding-top: 1em; margin-top: 2em; margin-right: 4em; margin-bottom: 2em; border-top-color: black; border-top-width: 1px; border-top-style: solid; float: left; } #special_page .attachment { margin-right: 2em; margin-bottom: 1em; float: left; } #special_page .image { margin-right: 2em; margin-bottom: 1em; float: left; } #special_page br { clear: both; margin-top: 2em; } h1 { clear: both; margin-top: 2em; } h2 { clear: both; margin-top: 2em; } h3 { clear: both; margin-top: 2em; } h4 { clear: both; margin-top: 2em; } #figure { text-align: center; } #figure .attachment { float: none; } #head_bar { display: none; } #core { margin: 0px; } #optional_header { display: none; } #logo { border: 0px currentColor; border-image: none; } #search { display: none; } #sidebar { display: none; } #page { color: rgb(51, 51, 51); font-family: sans-serif; font-size: 9pt; } #page img { border: 0px currentColor; border-image: none; } #page h1 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 18pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #page h1 a { color: black; text-decoration: none; } #page h2 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 12pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #footer p { margin: 0.5em; color: rgb(51, 51, 51); font-family: sans-serif; font-size: 8pt; } #footer a { color: rgb(51, 51, 51); } #footer .partners { word-spacing: 1em; float: right; } #footer img { border: 0px currentColor; border-image: none; } a img { border: 0px currentColor; border-image: none; } #message { display: none; } #content .table-of-contents { display: none; } #content li p { margin: 0.5em; } #content h1 { padding: 3px; font-size: 16pt; } #content h2 { padding: 2px; font-size: 14pt; } #content h3 { font-size: 12pt; } #content h4 { font-size: 10pt; } #content { text-align: justify; } #content td { padding: 3px; border: 1px solid rgb(240, 240, 240); border-image: none; text-align: left; } #content td p { margin: 0px; } #content hr { border: 1px solid black; border-image: none; } tr.rcdaybreak { background-color: rgb(240, 240, 240); } .recentchanges td { padding: 5px; } #page-history td { border: 1px solid rgb(240, 240, 240); border-image: none; } .diff-removed { background-color: rgb(255, 128, 128); } .diff-added { background-color: rgb(128, 255, 128); } .diff-title { background-color: rgb(255, 255, 128); } table.diff { width: 100%; } pre { background: rgb(240, 236, 230); padding: 0.5em; border: 1pt solid rgb(192, 192, 192); border-image: none; font-family: courier, monospace; white-space: pre-wrap; -ms-word-wrap: break-word; } #editor { text-align: left; } #editor-textarea { width: 100%; clear: right; margin-top: 2em; } #editor-comment { width: 100%; } #preview { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } #previewbelow { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } body { margin: 0px; } #head_bar { margin: 0px 0px 2em; padding: 1em 150px; color: rgb(51, 51, 51); font-family: sans-serif; font-size: 8pt; border-bottom-color: black; border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(240, 240, 240); } #head_bar img { border: 0px currentColor; border-image: none; } #head_bar a.user_preference { color: rgb(51, 51, 51); font-weight: bold; } #head_bar .partners { width: 400px; text-align: right; word-spacing: 1em; float: right; display: block; } #head_bar .partners a { color: rgb(51, 51, 51); } #core { margin-right: 150px; margin-left: 150px; } #optional_header { margin: 1em -150px; color: black; padding-right: 150px; padding-left: 150px; font-family: sans-serif; font-size: 9pt; background-color: rgb(226, 242, 254); } #optional_header a { margin: 0pt; color: black; text-decoration: none; } #optional_header a strong { font-size: 12pt; } td { behavior: url(../pybr/css/IEFixes.htc); } #optional_header a:hover { color: white; background-color: rgb(0, 120, 192); } #optional_header td:hover { color: white; background-color: rgb(0, 120, 192); } #optional_header td.hover { color: white; background-color: rgb(0, 120, 192); } #optional_header a { color: inherit; } #optional_header td { padding: 10px; width: 25%; height: 11em; } #logo { border: 0px currentColor; border-image: none; margin-top: 50px; } #searchform { border: 0px currentColor; border-image: none; width: 340px; font-family: sans-serif; font-size: 8pt; float: right; max-height: 45px; } #sidebar { width: 160px; right: 150px; font-family: sans-serif; font-size: 9pt; margin-top: 3em; position: absolute; } #sidebar h1 { padding: 3px; font-family: sans-serif; font-size: 9pt; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 2px; border-bottom-style: dotted; } #sidebar img { border: 0px currentColor; border-image: none; } #sidebar ul { padding-left: 1.5em; } #sidebar p.ad { margin-top: 2em; } #page { color: rgb(51, 51, 51); line-height: 150%; font-family: sans-serif; font-size: 9pt; margin-top: 3em; margin-right: 200px; min-height: 1000px; _height: 1000px; } #page img { border: 0px currentColor; border-image: none; } #page h1 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 18pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #page h1 a { color: black; text-decoration: none; } #page h2 { padding-bottom: 0.5em; padding-left: 10px; font-family: sans-serif; font-size: 12pt; font-weight: bold; border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: solid; } #footer { background-position: top; padding: 1em 150px; clear: both; margin-top: 2em; background-image: url("../img/footer_bar.png"); background-repeat: repeat-x; background-color: rgb(244, 244, 247); } #footer p { margin: 0px; color: rgb(51, 51, 51); font-family: sans-serif; font-size: 8pt; } #footer a { color: rgb(51, 51, 51); } #footer .partners { word-spacing: 1em; float: right; } #footer img { border: 0px currentColor; border-image: none; } a img { border: 0px currentColor; border-image: none; } #message { margin: 1em; padding: 1em; border: 1px solid red; border-image: none; color: red; font-weight: bolder; } #message p { margin: 0px; } #message a { background: red; padding: 2px; color: white; text-decoration: none; margin-right: 1em; } #content .table-of-contents-heading { margin: 0px; font-weight: bold; } #content .table-of-contents { padding: 1em; border: 1px dashed rgb(96, 96, 255); border-image: none; } #content li p { margin: 0.5em; } #content h1 { padding: 3px; font-size: 16pt; } #content h2 { padding: 2px; font-size: 14pt; } #content h3 { font-size: 12pt; } #content h4 { font-size: 10pt; } #content { text-align: justify; } #content td { padding: 3px; border: 1px solid rgb(240, 240, 240); border-image: none; text-align: left; } #content td p { margin: 0px; } #content hr { border: 1px solid black; border-image: none; } tr.rcdaybreak { background-color: rgb(240, 240, 240); } .recentchanges td { padding: 5px; } #page-history td { border: 1px solid rgb(240, 240, 240); border-image: none; } .diff-removed { background-color: rgb(255, 128, 128); } .diff-added { background-color: rgb(128, 255, 128); } .diff-title { background-color: rgb(255, 255, 128); } table.diff { width: 100%; } pre { background: rgb(240, 240, 240); clear: both; font-family: courier, monospace; white-space: pre-wrap; -ms-word-wrap: break-word; } #editor { text-align: left; } #editor-textarea { width: 100%; clear: right; margin-top: 2em; } #editor-comment { width: 100%; } #preview { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } #previewbelow { background: url("../img/draft.png"); padding: 1em; border: 1px dashed red; border-image: none; margin-top: 3em; margin-bottom: 3em; } div.codearea pre span.LineNumber { color: gray; } div.codearea pre span.ID { color: rgb(0, 0, 0); } div.codearea pre span.Operator { color: rgb(0, 0, 192); } div.codearea pre span.Char { color: rgb(0, 64, 128); } div.codearea pre span.Comment { color: rgb(0, 128, 0); } div.codearea pre span.Number { color: rgb(0, 128, 192); } div.codearea pre span.String { color: rgb(0, 64, 128); } div.codearea pre span.SPChar { color: rgb(0, 0, 192); } div.codearea pre span.ResWord { color: rgb(160, 0, 0); } div.codearea pre span.ConsWord { color: rgb(0, 128, 128); font-weight: bold; } div.codearea pre span.Error { border: 1.5pt solid rgb(255, 0, 0); border-image: none; color: rgb(255, 128, 128); } div.codearea pre span.ResWord2 { color: rgb(0, 128, 255); font-weight: bold; } div.codearea pre span.Special { color: rgb(0, 0, 255); } div.codearea pre span.Preprc { color: rgb(128, 57, 153); } .content_ad { padding-top: 1em; margin-top: 2em; margin-right: 4em; margin-bottom: 2em; border-top-color: black; border-top-width: 1px; border-top-style: solid; float: left; } #special_page .attachment { margin-right: 2em; margin-bottom: 1em; float: left; } #special_page .image { margin-right: 2em; margin-bottom: 1em; float: left; } #special_page br { clear: both; margin-top: 2em; } h1 { clear: both; margin-top: 2em; } h2 { clear: both; margin-top: 2em; } h3 { clear: both; margin-top: 2em; } h4 { clear: both; margin-top: 2em; } #figure { text-align: center; } #figure .attachment { float: none; } @import url( screen.css ); html { line-height: 1.8em; } body { font-size: 18pt; } b { font-size: 18pt; } em { font-size: 18pt; } a { font-size: 18pt; } span { font-size: 18pt; } div { font-size: 18pt; } p { font-size: 18pt; } td { font-size: 18pt; } h1 { font-size: 26pt; } h2 { font-size: 22pt; } h3 { font-size: 20pt; } h4 { font-size: 18pt; } h5 { font-size: 16pt; } h6 { font-size: 14pt; } tt { font-size: 16pt; } pre { font-size: 16pt; } sup { font-size: 12pt; } sub { font-size: 12pt; } table.navigation { margin: 2px; float: right; } .navigation td { padding: 2px; font-size: 10pt; } .navigation a { padding: 2px; font-size: 10pt; } #interwiki { display: none; } #pagelocation { display: none; } #pageinfo { display: none; } // // MoinMoin commonly used JavaScript functions // // We keep here the state of the search box searchIsDisabled = false; function searchChange(e) { // Update search buttons status according to search box content. // Ignore empty or whitespace search term. var value = e.value.replace(/\s+/, ''); if (value == '' || searchIsDisabled) { searchSetDisabled(true); } else { searchSetDisabled(false); } } function searchSetDisabled(flag) { // Enable or disable search document.getElementById('fullsearch').disabled = flag; document.getElementById('titlesearch').disabled = flag; } function searchFocus(e) { // Update search input content on focus if (e.value == search_hint) { e.value = ''; e.className = ''; searchIsDisabled = false; } } function searchBlur(e) { // Update search input content on blur if (e.value == '') { e.value = search_hint; e.className = 'disabled'; searchIsDisabled = true; } } function actionsMenuInit(title) { // Initialize action menu for (i = 0; i < document.forms.length; i++) { var form = document.forms[i]; if (form.className == 'actionsmenu') { // Check if this form needs update var div = form.getElementsByTagName('div')[0]; var label = div.getElementsByTagName('label')[0]; if (label) { // This is the first time: remove label and do buton. div.removeChild(label); var dobutton = div.getElementsByTagName('input')[0]; div.removeChild(dobutton); // and add menu title var select = div.getElementsByTagName('select')[0]; var item = document.createElement('option'); item.appendChild(document.createTextNode(title)); item.value = 'show'; select.insertBefore(item, select.options[0]); select.selectedIndex = 0; } } } } // use this instead of assigning to window.onload directly: function addLoadEvent(func) { // alert("addLoadEvent " + func) var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } // copy from fckeditor browser check code (fckeditor.js:298, function : FCKeditor_IsCompatibleBrowser) function can_use_gui_editor() { var sAgent = navigator.userAgent.toLowerCase() ; // Internet Explorer 5.5+ if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 ) { var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ; return ( sBrowserVersion >= 5.5 ) ; } // Gecko (Opera 9 tries to behave like Gecko at this point). if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) ) return true ; // Opera 9.50+ if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 ) return true ; /* // disable safari : until fck devteam fix http://dev.fckeditor.net/ticket/2333 // Adobe AIR // Checked before Safari because AIR have the WebKit rich text editor // features from Safari 3.0.4, but the version reported is 420. if ( sAgent.indexOf( ' adobeair/' ) != -1 ) return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ; // Build must be at least v1 // Safari 3+ if ( sAgent.indexOf( ' applewebkit/' ) != -1 ) return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ; // Build must be at least 522 (v3) */ return false ; } function update_edit_links() { // Update editlink according if if the browser is compatible if (can_use_gui_editor() == false){ //alert("update_edit_links: can't use gui editor"); return; } var editlinks = document.getElementsByName("editlink"); for (i = 0; i < editlinks.length; i++) { var link = editlinks[i]; href = link.href.replace('editor=textonly','editor=guipossible'); link.href = href; //alert("update_edit_links: modified to guipossible"); } } function add_gui_editor_links() { // Add gui editor link after the text editor link // If the variable is not set or browser is not compatible, exit try {gui_editor_link_href} catch (e) { //alert("add_gui_editor_links: gui_editor_link_href not here"); return } if (can_use_gui_editor() == false){ //alert("add_gui_editor_links: can't use gui_editor"); return; } var all = document.getElementsByName('texteditlink'); for (i = 0; i < all.length; i++) { var textEditorLink = all[i]; // Create a list item with a link var guiEditorLink = document.createElement('a'); guiEditorLink.href = gui_editor_link_href; var text = document.createTextNode(gui_editor_link_text); guiEditorLink.appendChild(text); var listItem = document.createElement('li') listItem.appendChild(guiEditorLink); // Insert in the editbar var editbar = textEditorLink.parentNode.parentNode var nextListItem = textEditorLink.parentNode.nextSibling; editbar.insertBefore(listItem, nextListItem); //alert("add_gui_editor_links: added gui editor link"); } } function show_switch2gui() { // Show switch to gui editor link if the browser is compatible if (can_use_gui_editor() == false) return; var switch2gui = document.getElementById('switch2gui') if (switch2gui) { switch2gui.style.display = 'inline'; } } function toggleComments() { // Toggle visibility of every tag with class == *comment* var all = document.getElementsByTagName('*'); for (i = 0; i < all.length; i++){ el = all[i]; if ( el.className.indexOf('comment') >= 0 ){ if ( el.style.display != 'none' ) { el.style.display = 'none'; } else { el.style.display = ''; } } } } function show_toggleComments() { // Show edit bar item "ToggleComments" if inline comments exist on this page var all = document.getElementsByTagName('*'); var count = 0; for (i = 0; i < all.length; i++){ el = all[i]; if ( el.className.indexOf('comment') >= 0 ){ count++; } } if (count > 0) { for (i = 0; i < all.length; i++){ el = all[i]; if ( el.className == 'toggleCommentsButton' ){ el.style.display = 'inline'; } } } } function load() { // Do not name this "onload", it does not work with IE :-) // TODO: create separate onload for each type of view and set the // correct function name in the html. // e.g <body onlod='editor_onload()'> // login focus if (document.forms['loginform']) { document.forms['loginform'].elements['name'].focus(); } // Page view stuff update_edit_links(); add_gui_editor_links(); // Editor stuff show_switch2gui(); // Enable menu item "ToggleComments" if inline comments exist show_toggleComments(); // data browser widget dbw_hide_buttons(); } function before_unload(evt) { // TODO: Better to set this in the editor html, as it does not make // sense elsehwere. // confirmleaving is available when editing try {return confirmleaving();} catch (e) {} } // Initialize after loading the page addLoadEvent(load) // Catch before unloading the page window.onbeforeunload = before_unload function dbw_update_search(dbw_id) { var table = document.getElementById(dbw_id+'table'); var cell; var shown; var i var cols = table.rows[0].cells.length; var filter = new Array(); var dofilter = new Array(); var form = document.forms[dbw_id+'form']; for (i = 0; i < cols; i++) { dofilter[i] = false; if (form[dbw_id+'filter'+i]) { dofilter[i] = true; filter[i] = form[dbw_id+'filter'+i].value; if (filter[i] == '[all]') dofilter[i] = false; if (filter[i] == '[empty]') filter[i] = ''; } } for (i = 1; i < table.rows.length; i++) { var show = true; for (col = 0; col < cols; col++) { if (!dofilter[col]) continue; cell = table.rows[i].cells[col]; if (filter[col] == '[notempty]') { if (cell.abbr == '') { show = false; break; } } else if (filter[col] != cell.abbr) { show = false; break; } } if (show) table.rows[i].style.display = ''; else table.rows[i].style.display = 'none'; } } function dbw_hide_buttons() { var form; var elem; for (var fidx = 0; fidx < document.forms.length; fidx++) { form = document.forms[fidx]; for (var eidx = 0; eidx < form.elements.length; eidx++) { elem = form.elements[eidx]; name = elem.name; if (name) { if (name.substr(0,4) == 'dbw.' && name.substr(-7) == '.submit') elem.style.display = 'none'; } } } }
Compartilhar