Advertisement
terorama

twit / index.php

Dec 27th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 10.28 KB | None | 0 0
  1. <?php
  2.  
  3.    require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'twit.inc.php');
  4.  
  5.    $action= (isset($_GET['action'])) ? $_GET['action'] : '';
  6.    $line_name =(isset($_GET['line_name'])) ? $_GET['line_name'] : '';
  7.    
  8.    $twit = new Twit;
  9.  
  10.    if ($action) {
  11.       echo $twit->$action($line_name);
  12.       exit();
  13.       }
  14.    
  15. ?>
  16.  
  17.  
  18. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  19. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  20.  
  21. <head>
  22. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  23. <title>twit lines</title>
  24.    <script type="text/javascript" src="jquery.min.js"></script>
  25.    
  26.    
  27.    <script type="text/javascript">
  28.    
  29.       $(document).ready(init);
  30.      
  31.        ajax_get='';
  32.        ajax_post='';
  33.        
  34.       //------------------------------------------
  35.       function init() {
  36.      
  37.        
  38.          //-------------------
  39.          $('a[rel^="_"], input:button[rel^="_"]').unbind('click').click ( function(ev) {
  40.            
  41.             var ev = ev || event;
  42.            
  43.             if ($(this).get(0).tagName=='A')
  44.                if  ($(this).get(0).hasAttribute("rel")) {
  45.                   $(this).prev().attr('checked','checked');
  46.                }
  47.                        
  48.             //--------------------------------
  49.             if (this.hasAttribute('lnname'))
  50.                var line_name = this.getAttribute('lnname');
  51.             else
  52.                var line_name = '';
  53.             //--------------------------------
  54.             if (this.hasAttribute('pg'))
  55.                var page_id = this.getAttribute('pg');
  56.             else
  57.                var page_id = 'z';
  58.             //--------------------------------
  59.             if (!ajax_get)
  60.                ajax_get = new Ajax_get();
  61.        
  62.             ajax_get.query($(this).attr('rel').slice(1), line_name, page_id);
  63.            
  64.             if (ev.preventDefault)
  65.                ev.preventDefault();
  66.             else
  67.                ev.returnValue = false;
  68.              
  69.          });
  70.          //-------------------
  71.          $('form').filter(
  72.             function(index) {
  73.                return (this.hasAttribute('rel')) && ($(this).attr('rel').substr(0,1)=='_');})
  74.                .unbind('submit')
  75.                .submit( function(ev) {
  76.                  
  77.                   var ev = ev || event;
  78.                  
  79.                   if (!ajax_post)
  80.                      ajax_post = new Ajax_post();
  81.                    
  82.                   var data8 = {};
  83.                   $(this).find('input[name]').each (
  84.                      function(i) {
  85.                         data8[this.name]=this.value;
  86.                      }
  87.                   );
  88.                  
  89.                   $.when (ajax_post.query($(this).attr('rel').slice(1), data8))
  90.                   .done(function(){updateState();});
  91.                  
  92.                  
  93.                  
  94.                   if (ev.preventDefault)
  95.                      ev.preventDefault();
  96.                   else
  97.                      ev.returnValue = false;
  98.                      
  99.                });
  100.                
  101.          //-------------------     
  102.          $('.controls a[rel="refill_twitline"]').unbind('click').click (
  103.             function() {
  104.              
  105.                $('#ajaxblock').empty().append(
  106.                   $('<iframe/>', {id:'ziframe', width:'700', height: '400', scrolling: 'no'}));
  107.                  
  108.                $('#ziframe').css('border','solid 1px #888');
  109.                $('#ziframe').attr('src',
  110.                   location.protocol+'//'+location.hostname+location.pathname+
  111.                   '?action=refill_twitline&line_name='+
  112.                   $('#lineform input:radio:checked').val());
  113.             }
  114.          );
  115.          
  116.          //----------------------------------
  117.          $('#contentheader').unbind().ajaxStart(
  118.             function() {
  119.                $(this).html('ajax request started...');
  120.             }
  121.          );
  122.          //----------------------------------
  123.          $('#contentheader').unbind().ajaxStop(
  124.             function() {
  125.                $(this).html('ajax request finished');
  126.             }
  127.          );
  128.          //----------------------------------
  129.                  
  130.       };
  131.  
  132.       //------------------------------------------
  133.       Ajax_get = function () {
  134.      
  135.          var _self = this;
  136.          
  137.          //----------------------
  138.          this.onSuccess = function(inf, status, xhr) {
  139.            
  140.             $('#ajaxblock').empty().html(inf);
  141.             init();
  142.          }
  143.      
  144.          //----------------------
  145.          this.onError = function(xhr, status, exception) {
  146.            
  147.             var inf = [];
  148.             inf.push ('ajaxResponse: <pre>'+xhr.responseText+'</pre>');
  149.             inf.push ('status: '+xhr.status);
  150.             inf.push ('ready state: '+xhr.readyState);
  151.             inf.push ('text status: '+status);
  152.             inf.push ('exception: '+exception);
  153.            
  154.             s = inf.join('<br/>');
  155.            
  156.             $('#ajaxblock').empty().html(s);
  157.          }
  158.          
  159.          //----------------------
  160.          this.query = function (action, line_name, page_id) {
  161.          
  162.             var line_name = line_name || $('#lineform input:radio:checked').val();
  163.            
  164.             var data = {
  165.                   action: action,
  166.                   line_name: line_name
  167.                };
  168.    
  169.             if (!isNaN(page_id)) {
  170.            
  171.                data['page'] = page_id
  172.             }
  173.              
  174.  
  175.             return $.ajax ( {        
  176.                type: 'GET',
  177.                url: location.protocol + '//' +
  178.                     location.hostname + location.pathname,
  179.                    
  180.                data: data,
  181.                success: _self.onSuccess,
  182.                error: _self.onError
  183.             })
  184.          }
  185.       };
  186.      
  187.       //------------------------------------------
  188.       Ajax_post = function () {
  189.      
  190.          var _self = this;
  191.          
  192.          //----------------------
  193.          this.onSuccess = function (inf, status, xhr) {
  194.          
  195.             $('#ajaxblock').empty().html(inf);
  196.          }
  197.          
  198.          //----------------------
  199.          this.onError = function (xhr, status, exception) {
  200.          
  201.             var inf = [];
  202.             inf.push ('ajaxResponse: <pre>'+xhr.responseText+'</pre>');
  203.             inf.push ('exception: '+exception);
  204.            
  205.             s = inf.join('<br/>');
  206.            
  207.             $('#ajaxblock').empty().html(s);
  208.            
  209.          }
  210.          
  211.          //----------------------
  212.          this.query = function (action, data) {
  213.          
  214.             return $.ajax ( {
  215.                type: 'POST',
  216.                
  217.                url: location.protocol+'//'+ location.hostname +
  218.                location.pathname +'?action='+action,
  219.                
  220.                data : data,
  221.                success: _self.onSuccess,
  222.                error: _self.onError
  223.             });
  224.          }
  225.          
  226.       }
  227.      
  228.       //-------------------------------------------------
  229.       function updateState() {
  230.      
  231.          var addr = location.protocol+'//'+location.hostname+location.pathname;
  232.          
  233.          $.when ($.get( addr, {action: 'loginstatus'})).done(
  234.             function(tx) {
  235.                $('#loginblock').empty().html(tx);  
  236.                init();             
  237.             }
  238.          );
  239.          $.when ($.get( addr, {action: 'show_twitlines'})).done(
  240.             function(tx) {
  241.                $('#twitlines').empty().html(tx);
  242.                init();             
  243.             }
  244.          )
  245.          
  246.          
  247.            
  248.       }
  249.    </script>
  250.    
  251.    
  252.    <style type="text/css">
  253.       * {
  254.          margin: 0;
  255.          padding: 0;
  256.          font-size: inherit;
  257.       }
  258.      
  259.       ul {
  260.          list-style-type: none;
  261.       }
  262.      
  263.       a {
  264.          color:inherit;      
  265.       }
  266.      
  267.       body {
  268.          font-family: verdana, helvetica, sans-serif;
  269.          font-size: 1em;
  270.       }
  271.      
  272.       #container {
  273.          width: 90%;
  274.        
  275.          margin: 0 auto;
  276.       }
  277.      
  278.       #header {
  279.          height: 100px;
  280.          background: #800;
  281.          color: white;
  282.          position:relative;
  283.       }
  284.      
  285.       #loginblock {
  286.          position: absolute;
  287.          left:50px;
  288.          top: 20px;
  289.          border: solid 1px #eee;
  290.          padding: 20px 50px 15px 50px;
  291.       }
  292.        
  293.      
  294.       #sidebar {
  295.          float:left;
  296.          width: 300px;
  297.          padding: 20px 0 0 0;
  298.       }
  299.      
  300.      
  301.      
  302.       #twitlines li {
  303.          height: 1.5em;
  304.          line-height:1.5em;
  305.          border-bottom: dotted 1px;
  306.       }
  307.      
  308.       #twitlines input[type=radio] {
  309.          width:50px;
  310.       }
  311.      
  312.       #twitlines li a {
  313.          text-decoration: none;
  314.       }
  315.      
  316.       .controls {
  317.          overflow: auto;
  318.          margin: 10px 0 0 0;
  319.          padding: 0 0 20px 0;
  320.  
  321.       }
  322.      
  323.       .controls li {
  324.          float:left;
  325.          margin-top: 5px;
  326.          margin-right:10px;
  327.          border: solid 1px #500;
  328.          border-radius: 10px;
  329.          background: #ffe;
  330.          padding: 5px 10px;
  331.          font-size: 0.75em;
  332.       }
  333.      
  334.       .controls li a {
  335.      
  336.          text-decoration: none;
  337.       }
  338.      
  339.       .controls li a:hover {
  340.      
  341.          text-decoration: underline;
  342.       }
  343.      
  344.       #content {
  345.          margin-left: 320px;
  346.          
  347.       }
  348.      
  349.       #contentheader {
  350.          height: 30px;
  351.          background: #400;
  352.          color: white;
  353.       }
  354.      
  355.       #ajaxblock {
  356.  
  357.          border: dotted 1px #888;
  358.       }
  359.      
  360.       #footer {
  361.      
  362.          height: 50px;
  363.          background: #444;
  364.          clear:left;
  365.       }
  366.      
  367.       /*-------------------------*/
  368.       .twitfeed {
  369.          font-size: 0.75em;
  370.       }  
  371.      
  372.       .twitfeed li {
  373.          position: relative;
  374.          border-bottom: dotted 1px #888;
  375.          padding-bottom: 3px;
  376.          padding-right: 160px;
  377.       }
  378.      
  379.       .twitid {
  380.          display:none;
  381.       }
  382.       .twittitle {
  383.          line-height:1.5;
  384.       }
  385.       .twitdesc {
  386.          display:none;
  387.       }
  388.       .twitlink {
  389.          display: none;
  390.       }
  391.       .twitpubdate {
  392.        
  393.         position:absolute; 
  394.         right:0;
  395.         bottom:0;
  396.         background: #ffe;
  397.         border: solid 1px #f5f5f5;
  398.         color: #555;   
  399.         padding: 0 10px;
  400.         width: 130px;
  401.        
  402.         border-radius: 5px;
  403.         -moz-border-radius: 5px;
  404.         -webkit-border-radius: 5px;
  405.       }
  406.      
  407.       .pager {
  408.          overflow: auto;
  409.          padding: 10px 0 15px 0;
  410.       }
  411.       .pager li {
  412.          
  413.          float:left;
  414.          margin: 0 5px 4px 0;
  415.          border: solid 1px #500;
  416.          
  417.          border-radius: 10px;
  418.          -moz-border-radius: 10px;
  419.          -webkit-border-radius: 10px;
  420.          
  421.          background: #ffe;
  422.          font-size:0.75em;
  423.          overflow:hidden;
  424.          
  425.       }
  426.       .pager li a {
  427.          
  428.          display:block;
  429.        
  430.          height: 100%;
  431.          padding: 0.5em 10px;
  432.          text-decoration: none;
  433.          
  434.       }
  435.       .pager li a:hover {
  436.      
  437.          background: #444;
  438.          color: white;
  439.       }
  440.       /*-------------------------*/
  441.       form {
  442.          overflow: auto;
  443.          padding: 5px;
  444.          margin:5px;
  445.          
  446.       }
  447.      
  448.       form p {
  449.        
  450.       }
  451.      
  452.       form input[type=text] {
  453.          margin-left:20px;
  454.       }
  455.      
  456.       form input[type=button],
  457.       form input[type=submit],
  458.       form input[type=reset] {
  459.      
  460.          display:block;
  461.          float: left;
  462.          margin: 5px 5px 0 0;
  463.          padding: 5px 8px;
  464.          background: #f0f0f0;
  465.          cursor:pointer;
  466.          border: solid 1px #444;
  467.          
  468.          border-radius: 10px;
  469.          -moz-border-radius: 10px;
  470.          -webkit-border-radius: 10px;
  471.       }
  472.      
  473.       form input[type=submit] {
  474.          clear: left;
  475.       }
  476.      
  477.      
  478.    </style>
  479. </head>
  480.  
  481. <body>
  482.  
  483. <div id="container">
  484.    <div id="header">
  485.       <div id="loginblock">
  486.          <?php echo $twit->loginstatus(); ?>
  487.       </div>
  488.    </div>
  489.  
  490.    <div id="sidebar">      
  491.       <div id="twitlines">
  492.          <?php try {echo $twit->show_twitlines();} catch (Exception $e) {echo $e->getMessage();} ?>
  493.       </div>
  494.       <div id="controls">
  495.          <?php try {echo $twit->show_controls();} catch( Exception $e) {echo $e->getMessage();} ?>
  496.       </div>
  497.    </div>
  498.    
  499.    <div id="content">
  500.       <div id="contentheader">
  501.       </div>
  502.      
  503.       <div id="ajaxblock">
  504.       </div>
  505.    </div>
  506.    
  507.    <div id="footer">
  508.    </div>
  509. </div>
  510.  
  511.  
  512. </body>
  513. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement