Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var d = document;
- var config = {
- num_quest:3,
- max_time_to_response:300000,
- cookie_name:'resps'
- }
- cookie = {
- clear:function(){
- document.cookie = config.cookie_name + '=';
- },
- set:function(x){
- x = cookie.get() + x;
- document.cookie = config.cookie_name + '=' + x;
- },
- get:function(){
- try {
- return (document.cookie.toString().split(config.cookie_name)[1].split('=')[1].split(';')[0]);
- }catch(e){
- return '';
- }
- }
- };
- function show(param){
- try{
- $('#q_'+param).show(2200);
- param--;
- $('#q_'+(eval(param))).hide(900);
- if(param >= config.num_quest) {
- alert('Pronto!');
- config.finish = true;
- check_result();
- }
- }catch(e){
- alert(e);
- }
- }
- function form_send(pragma){
- try{
- var p = pragma;
- if(p[0].checked){
- resp_from_form = 'a';
- } else if(p[1].checked){
- resp_from_form = 'b';
- } else if(p[2].checked){
- resp_from_form = 'c';
- } else {
- alert('Marque alguma questão antes de prosseguir');
- return false;
- };
- cookie.set(resp_from_form);
- atual = p.name.toString().split('_')[1];
- atual++;
- show(atual);
- return (!1);
- }catch(e){
- alert(e);
- return false;
- }
- }
- function check_result(){
- var gabarito = ['b','b','a'];
- var resp_c = (cookie.get()).split('');
- var alert_req = '';
- if(!resp_c){ return (alert('Erro'));};
- for(i=0;i<gabarito.length;i++){
- q = i + 1;
- if(gabarito[i]==resp_c[i]) {
- alert_req += 'Você acertou a questão '+q+'\n';
- } else {
- alert_req += 'Você errou a questão '+q+'\n';
- }
- }
- alert(alert_req);
- // cookie.clear();
- }
- function start_time(){
- config.prototype.counter_var = setTimeout(function(){
- if(!config.finish){
- alert('Você atingiu o máximo de tempo para responder as '+config.num_quest+' questão(es)');
- $('input').attr('disabled','disabled');
- cookie.clear();
- setTimeout(function(){
- location.reload();
- },3000);
- }
- },config.max_time_to_response);
- }
- $(function(){
- /*
- $.getScript('http://pastebin.com/raw.php?i=FB3YNQ5a',function(){
- Overlay.show('Carregando...');
- */
- var cssObj = {
- 'height' : '400px',
- 'width' : '700px'
- };
- $('#q').css(cssObj).tabs().show(3000,function(){
- d.title = 'Questionário';
- // Overlay.hide();
- }
- );
- $('button').button().first().click(function(p){
- show('1');
- start_time();
- });
- $('input:submit').button();
- /*
- });
- */
- });
Advertisement
Add Comment
Please, Sign In to add comment