Advertisement
terorama

mvcnew / index.php

Apr 30th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 13.28 KB | None | 0 0
  1. <?php
  2.    if (isset($_GET['mktabs'])) {
  3.       mktabs();
  4.       exit();
  5.    }
  6.    
  7.  
  8.    function mktabs() {
  9.    
  10.        $sqls = array(
  11.    
  12.       //-----------------------------
  13.       'drop table if exists digests',
  14.           'drop table if exists digests_elements',
  15.            
  16.           //-----------------------------
  17.           'create table digests (
  18.              digest_id int(11) not null auto_increment,
  19.                
  20.                  digest_title varchar(50),
  21.                  digest_text varchar(500),
  22.                  digest_schedule_type int(11),
  23.                  digest_date datetime,
  24.              primary key(`digest_id`)) ',
  25.                  
  26.           //-----------------------------
  27.           'create table digests_elements (
  28.              element_id int(11) not null auto_increment,
  29.                  digest_id int(11),
  30.                  element_rss_name varchar(20),
  31.                  element_page_order int(11),
  32.                  element_output_type int(11),
  33.                  
  34.              primary key(`element_id`))');
  35.              
  36.    $db = new mysqli('','','','');
  37.    foreach ($sqls as $sql) {
  38.       $db->query($sql);
  39.    }
  40.  
  41.  }
  42.    
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml">
  46. <head>
  47. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  48. <meta name="description" content="JQuery tests" />
  49.  
  50. <title>JQuery tests</title>
  51. <?php $cur_url = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']); ?>
  52.  
  53. <style type="text/css">
  54.   * {
  55.              margin: 0;
  56.                  padding: 0;
  57.                  border: none;
  58.                  outline: none;
  59.                  
  60.           }
  61.          
  62.           body {
  63.              font-family: verdana, sans-serif;
  64.                  font-size:100%;
  65.           }
  66.          
  67.       #container {
  68.          
  69.              width:1000px;
  70.                  margin:0 auto;
  71.           }
  72.          
  73.           #questions {
  74.              margin-bottom: 10px;
  75.           }
  76.          
  77.           .header {
  78.              height:100px;
  79.                  color:#333;
  80.                  font-size:1.5em;
  81.                  line-height:1.5em;
  82.                  text-align:center;
  83.                  letter-spacing:3px;
  84.                  
  85.                  background: #eee;
  86.                  
  87.                  border-radius: 100px 60px 50px 10px;
  88.                  -moz-border-radius: 100px 60px 50px 10px;
  89.                  -webkit-border-radius: 100px 60px 50px 10px;
  90.                  
  91.                  display: none;
  92.                  
  93.           }
  94.           .content {
  95.              float:left;
  96.                  width:1000px;
  97.                  margin-bottom: 5px;
  98.                  margin-top: 20px;
  99.           }
  100.          
  101.           .page {
  102.              float:left;
  103.           }
  104.          
  105.           .page>div {
  106.              float:left;
  107.              margin-top:0;
  108.              margin-right:0;
  109.              margin-bottom:0;
  110.              height: 30px;
  111.              width: 130px;
  112.              padding: 4px 10px;
  113.              border-right: solid 1px #aaa;
  114.              border-top: solid 1px #aaa;
  115.              font-size: 12px;
  116.           }
  117.          
  118.           div.entrytitle {
  119.              margin-top: 0;
  120.              font-size:1.2em;
  121.                  font-weight:bold;
  122.                  
  123.                  height:30px;
  124.                  line-height:30px;
  125.                  text-align:center;
  126.                  
  127.                  background: #eee;
  128.                  
  129.                  
  130.                  border-radius:10px;
  131.                  -moz-border-radius:10px;
  132.                  -webkit-border-radius:10px;
  133.                  
  134.                  float: left;
  135.                  padding: 4px 50px;
  136.                  clear:left;
  137.                  width:200px;
  138.           }
  139.           .entrytitle a {
  140.              color:#999;
  141.                  text-decoration: none;
  142.                  
  143.           }
  144.           .entrytitle a:hover {
  145.              color:#555;
  146.           }
  147.           .entrycontent {
  148.              padding: 4px 20px 5px 10px;
  149.              border-bottom: solid 1px #999;
  150.                  
  151.           }
  152.           .entrycategory {
  153.          
  154.              height:30px;
  155.                  background: #eee;
  156.           }
  157.           .entryuser {
  158.              font-family:georgia, serif;
  159.              font-size:0.75em;
  160.           }
  161.           .entrydate {
  162.              font-size:0.75em;
  163.                  font-style: italic;
  164.           }
  165.          
  166.           .entryeditpanel {      
  167.              margin-top:10px;
  168.              overflow:hidden;
  169.           }
  170.            .editpanel {
  171.               overflow:hidden;
  172.              
  173.           }
  174.           .editbutton, .deletebutton, .addbutton, .backtolistbutton {
  175.          
  176.              background:#ff9;
  177.      
  178.                  font-weight:bold;
  179.                  font-size: 12px;
  180.                  text-align:center;
  181.                  padding:4px 10px;
  182.                  margin-right:5px;
  183.                  
  184.                  border: solid 2px #800;
  185.                  -moz-border-radius: 8px;
  186.                  -webkit-border-radius: 8px;
  187.                  border-radius: 8px;
  188.                  
  189.                  float:left;
  190.           }
  191.          
  192.           .editbutton a, .deletebutton a, .addbutton a, .backtolistbutton a{
  193.          
  194.              color:#c00;
  195.                  text-decoration: none;
  196.           }
  197.           div.editbutton {
  198.            
  199.            
  200.           }
  201.           div.deletebutton {
  202.            
  203.           }
  204.          
  205.           .addbutton {
  206.           }
  207.           .backtolistbutton {
  208.           }      
  209.          
  210.           .sidebar {
  211.              float:right;
  212.                  width:190px;
  213.                  margin-top:10px;
  214.                  background: #f5f5f5;
  215.                  display:none;
  216.           }
  217.          
  218.           .footer {
  219.              clear:both;              
  220.                  background: #f0f0f0;
  221.                  padding:0;
  222.                  margin-bottom:20px;
  223.                
  224.                  
  225.           }
  226.  
  227.          
  228.           .navigation {
  229.              margin-top:4px;
  230.              overflow: hidden;
  231.           }
  232.          
  233.           .navigation ul {
  234.              list-style-type:none;
  235.           }
  236.           .navigation li {
  237.              float:left;
  238.                  margin-right: 5px;
  239.                  text-align:center;
  240.                  height:40px;
  241.                  line-height:40px;
  242.                  background: white;
  243.                  font-weight: bold;
  244.                  width: 40px;
  245.                  border: solid 1px #555;
  246.                  -moz-border-radius:4px;
  247.                  -webkit-border-radius:4px;
  248.           }
  249.           .navigation li a, .navigation li a:visited {
  250.              text-decoration:none;
  251.                  color: #800;
  252.           }
  253.           .navigation li a:hover {
  254.              text-decoration: underline;
  255.           }
  256.          
  257.           form {
  258.              
  259.                  padding:20px 40px 10px 20px;
  260.           }
  261.          
  262.           fieldset {
  263.              padding-top:10px;
  264.           }
  265.          
  266.           legend {
  267.              border:solid 1px #aaa;
  268.                  border-radius:4px;
  269.                  -moz-border-radius:4px;
  270.                  -webkit-border-radius:4px;
  271.                  padding:4px 20px;
  272.                  display: none;
  273.           }
  274.           label {
  275.              display:block;
  276.                  float:left;
  277.                  clear:left;
  278.                  width:200px;
  279.                  margin-right:10px;
  280.                  margin-top: 5px;
  281.           }
  282.           input, select {
  283.              display: block;
  284.                  
  285.                  border: solid 1px #aaa;
  286.                  border-radius: 4px;
  287.                  -moz-border-radius: 4px;
  288.                  -webkit-border-radius: 4px;
  289.                  padding:2px 5px;
  290.                  margin-top:5px;
  291.           }
  292.          
  293.           input[type=text] {
  294.              width:400px;
  295.           }
  296.          
  297.           input[type=submit], input[type=button] {
  298.          
  299.              background:#ffa;
  300.                  float:left;
  301.                  border:solid 2px #a00;
  302.                  border-radius 8px;
  303.                  -moz-border-radius 8px;
  304.                  -webkit-border-radius 8px;
  305.                  color:#b00;
  306.                  cursor:pointer;
  307.                  padding:4px 20px;
  308.                  
  309.                  font-size:1em;
  310.                  margin-right:10px;
  311.                  margin-top:10px;
  312.                  
  313.           }
  314.          
  315.           #all_ajax_status {
  316.          
  317.              display: none;
  318.           }
  319.          
  320.          
  321. </style>
  322.  
  323. <script src="<?php echo $cur_url;?>/jquery.min.js"></script>
  324.  
  325. <script type="text/javascript">
  326.  
  327.    var gl_current_digest = 0;
  328.    
  329.    //-----------------------------------------
  330.    function init() {
  331.       $('#all_ajax_status').ajaxStart( function() {
  332.          
  333.          $(this).html('Request started, Please wait...');
  334.       });
  335.       //--------------------
  336.       $('#all_ajax_status').ajaxStop( function() {
  337.          $(this).html('Request finished.');
  338.       });
  339.       //--------------------
  340.       $('#all_ajax_status').ajaxSend( function (ev, xhr, options) {
  341.      
  342.          $(this).html('Request sent, status:'+xhr.status);
  343.          
  344.          
  345.       });
  346.       //--------------------
  347.       $('#all_ajax_status').ajaxSuccess (function( ev, xhr, options) {
  348.      
  349.          $(this).html('Request success, status:'+xhr.status+', readystate:'+xhr.readyState);
  350.          
  351.          $(options.statusblock).html('');
  352.  
  353.          
  354.       });
  355.       //--------------------
  356.       $('#all_ajax_status').ajaxError( function( ev, xhr, options, err) {
  357.      
  358.          $(this).html('Error occured: '+err+', status:'+xhr.status);
  359.          
  360.          $(options.statusblock).html('error occured :'+err);     
  361.          $(options.targetblock).html('response: '+xhr.responseText+'<br/>'+
  362.          ' xhr status:'+xhr.status+'<br/>xhr ready state:'+xhr.readyState+'<br/>');
  363.          
  364.       });
  365.       //--------------------
  366.       $('#all_ajax_status').ajaxComplete( function( ev, xhr, options) {
  367.       });  
  368.    }
  369.    
  370.    //-----------------------------------------
  371.    function ajaxBeforeSend (xhr, options) {
  372.    
  373.       $(options.statusblock).html('request started, please wait...');
  374.    }
  375.  
  376.    //-----------------------------------------
  377.    function ajaxSuccess (target_block) {
  378.    
  379.       return function(inf, status, xhr) {
  380.          $(target_block).html(inf);
  381.          
  382.          redir_links(target_block);
  383.          
  384.          if (target_block=='#digests_ajax')
  385.             master_detail_events(target_block);
  386.            
  387.          
  388.       }
  389.    }
  390.    
  391.    //-----------------------------------------
  392.    function ajaxError (xhr, status, err) {
  393.    }
  394.    
  395.    //-----------------------------------------
  396.    function ajaxComplete (xhr, status) {
  397.    }
  398.    //-----------------------------------------
  399.    function master_detail_events(target_block) {
  400.    
  401.       $('.entrytitle a',$(target_block)).unbind('click').click(
  402.          function() {
  403.             var re = /digest_id=(\d+)/;
  404.             var zid = re.exec(this.href);
  405.             gl_current_digest = zid[1];
  406.            
  407.             ajax_request('#digests_details_ajax_info',
  408.             '#digests_details_ajax', "<?=$cur_url?>/ajax_ind.php?controller=digestelements&filterdigestelements="+
  409.             encodeURIComponent('digest_id='+gl_current_digest));
  410.            
  411.             return false;
  412.          }
  413.       )
  414.      
  415.       $('.entrytitle a',$(target_block)).eq(0).trigger('click');
  416.    
  417.      
  418.    }
  419.    //-----------------------------------------
  420.    function redir_links(target_block) {
  421.      
  422.       $('a',target_block).click( function() {
  423.          ajax_request(target_block+'_info', target_block, $(this).attr('href'));
  424.          return false;
  425.       });
  426.      
  427.       $('input:hidden[name=digest_id]').attr('value', gl_current_digest);
  428.      
  429.       $('form',target_block).submit( function() {
  430.          var data = {};
  431.          $(this).find('input[name],select[name]').each(
  432.             function(ind, el4) {
  433.                data[el4.name] = el4.value;
  434.             })
  435.          
  436.          ajax_request(target_block+'_info', target_block, this.action, 'POST', data);
  437.          return false;
  438.       });
  439.      
  440.       $('input:button[name="cancel"]',target_block).attr('onclick','').click( function() {
  441.        
  442.          ajax_request(target_block+'_info', target_block,
  443.                $(this).parent().find('input:hidden[name="cancelroute"]').attr('value'));
  444.          return false;
  445.       });
  446.      
  447.       /*var re = /back_to_list.*?/;
  448.      
  449.       if (tx!==undefined) {
  450.             res = re.exec(tx);
  451.             console.log(res);
  452.          }
  453.        
  454.       var re = /(\w+)\s(\w+)/;
  455.       var str = "John Smith";
  456.       var newstr = str.replace(re, "$2, $1");
  457.       alert(newstr); // "Smith, John"
  458.          */
  459.      
  460.       /*for (var i in document.scripts) {
  461.          var tx = document.scripts[i].text;  
  462.       }*/
  463.      
  464.    }
  465.    //-----------------------------------------
  466.    function ajax_request(status_block, target_block, inurl, intype, indata) {
  467.    
  468.       var intype = intype || 'GET';
  469.       var indata = indata || {};
  470.      
  471.       $.ajax ( {
  472.      
  473.          url: inurl,
  474.          type: intype,
  475.          data: indata,
  476.          dataType: 'html',
  477.          
  478.          statusblock: status_block,
  479.          targetblock: target_block,
  480.          
  481.          beforeSend: ajaxBeforeSend,
  482.          success: ajaxSuccess(target_block),
  483.          error: ajaxError,
  484.          complete: ajaxComplete
  485.       })
  486.    }
  487.    //-----------------------------------------
  488.    $(document).ready ( function() {
  489.       init();
  490.      
  491.       ajax_request('#digests_ajax_info', '#digests_ajax', "<?=$cur_url?>/ajax_ind.php?controller=digests");
  492.    });
  493. </script>
  494.  
  495. </head>
  496.  
  497. <body>
  498. <h3>List of Digests</h3>
  499. <div id="all_ajax_status"></div>
  500. <div id="digests_ajax_info"></div>
  501. <div id="digests_ajax"></div>
  502.  
  503. <h3 id="current_digest">Digest details</h3>
  504. <div id="digests_details_ajax_info"></div>
  505. <div id="digests_details_ajax"></div>
  506.  
  507.  
  508. </body>
  509.  
  510. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement