Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

133 řádky
4.9 KiB

  1. <script language="javascript">
  2. /**
  3. * highlight current collection being viewed
  4. *
  5. * @param string name collection name
  6. */
  7. function highlightCollection(name, count) {
  8. var collections = $(".collections");
  9. collections.find("li").each(function () {
  10. var a = $(this).find("a");
  11. if (a.attr("cname") == name) {
  12. if (count != undefined) {
  13. $(this).find(".count").html(count);
  14. }
  15. a.css("font-weight", "bold");
  16. a.css("color", "blue");
  17. }
  18. else {
  19. a.css("font-weight", "normal");
  20. a.css("color", "");
  21. }
  22. });
  23. }
  24. $(function () {
  25. //dbs click
  26. $(".dbs .db-box .db-btn").click(function () {
  27. var box = $(this).parent();
  28. var collectionsBox = box.find(".collections");
  29. if (collectionsBox.is(":visible") && collectionsBox.find("li").length > 0) {
  30. box.find(".collections").slideUp(100);
  31. return false;
  32. }
  33. window.parent.frames["right"].location = $(this).attr("r-target-url");
  34. });
  35. //collections click
  36. var collections = $(".collections");
  37. collections.find("li").each(function () {
  38. var li = $(this);
  39. var a = $(this).find("a");
  40. var name = a.attr("cname");
  41. li.click(function () {
  42. window.location.hash = "#" + name;
  43. });
  44. //highlight current selected
  45. if (window.location.hash == "#" + name) {
  46. a.css("font-weight", "bold");
  47. a.css("color", "blue");
  48. }
  49. });
  50. // will be used to redirect to db by name
  51. var template = '<?php h(url("db.index",array("db"=>'__DB__')));?>';
  52. $('#selector').submit(function(e) {
  53. e.preventDefault();
  54. if($('#db').val()) {
  55. window.parent.frames['right'].location=template.replace('__DB__', $('#db').val());
  56. }
  57. });
  58. //search collection in box with keyword
  59. $(".r_search_box").keyup(function (event) {
  60. var value = $(this).val().trim()
  61. .replace(/[^\w\.]/g, "");
  62. var collectionNameRows = $(this).parents(".collections:first").find(".collection");
  63. if (event.which == 13) {
  64. if (collectionNameRows.length > 0) {
  65. var link = collections.find(".collection:visible .name_text").parent("a:first");
  66. if (link.length > 0) {
  67. highlightCollection(link.attr("cname"));
  68. link[0].click();
  69. }
  70. return;
  71. }
  72. }
  73. collectionNameRows.each(function (k, row) {
  74. var name = $(row).find("a:first").attr("cname");
  75. if (value.length == 0 || (new RegExp(value, "i")).test(name)) {
  76. $(row).show();
  77. var nameText = $(row).find(".name_text");
  78. nameText.html(name.replace(new RegExp("(" + value + ")", "i"), "<font color=\"red\">$1</font>"));
  79. }
  80. else {
  81. $(row).hide();
  82. }
  83. });
  84. });
  85. });
  86. </script>
  87. <div class="leftbar-page">
  88. <div class="server-btn"><img src="<?php render_theme_path() ?>/images/server.png" align="absmiddle" width="14"/> <a href="<?php h(url("server.index"));?>" target="right"><?php hm("server"); ?></a></div>
  89. <div class="world-btn"><img src="<?php render_theme_path() ?>/images/world.png" align="absmiddle" width="14"/> <a href="<?php h(url("server.databases"));?>" target="right"><?php hm("overview"); ?></a></div>
  90. <div class="line"></div>
  91. <ul class="dbs">
  92. <?php foreach ($dbs as $db) : ?>
  93. <li class="db-box">
  94. <a class="db-btn" href="<?php echo $baseUrl;?>&db=<?php h($db["name"]);?>" <?php if ($db["name"] == x("db")): ?>style="font-weight:bold"<?php endif;?> r-target-url="<?php h(url("db.index",array("db"=>$db["name"])));?>"><img src="<?php render_theme_path() ?>/images/database.png" align="absmiddle" width="14"/> <?php echo $db["name"];?></a><?php if($db["collectionCount"]>0):?> (<?php h($db["collectionCount"]); ?>)<?php endif;?>
  95. <ul class="collections">
  96. <?php if($db["name"] == x("db")): ?>
  97. <?php if (!empty($tables)):?>
  98. <li><input type="text" class="r_search_box" placeholder="keyword"/></li>
  99. <?php foreach ($tables as $table => $count) :?>
  100. <li class="collection"><a href="<?php h(url("collection.index", array( "db" => $db["name"], "collection" => $table ))); ?>" target="right" cname="<?php h($table);?>"><img src="<?php render_theme_path() ?>/images/<?php echo r_get_collection_icon($table) ?>.png" width="14" align="absmiddle"/> <span class="name_text"><?php h($table);?></span></a> (<span class="count"><?php h($count);?></span>)</li>
  101. <?php endforeach; ?>
  102. <?php else:?>
  103. <li><?php hm("nocollections2"); ?></li>
  104. <?php endif;?>
  105. <?php endif; ?>
  106. <?php if ($db["name"] == x("db")):?>
  107. <li><a href="<?php h(url("db.newCollection", array( "db" => $db["name"] ))); ?>" target="right" title="<?php hm("createnewcollection"); ?>"><img src="<?php render_theme_path() ?>/images/add.png" width="14" align="absmiddle"/> <?php hm("create"); ?> &raquo;</a></li>
  108. <?php endif;?>
  109. </ul>
  110. </li>
  111. <?php endforeach; ?>
  112. <?php if($showDbSelector): ?>
  113. <li>
  114. <img src="<?php render_theme_path() ?>/images/database.png" align="absmiddle" width="14"/>
  115. <form id="selector" action="#" style="display:inline">
  116. <input type="text" name="db" id="db" />
  117. <input type="submit" value="<?php hm("selectdb"); ?>">
  118. </form>
  119. </li>
  120. <?php endif;?>
  121. </ul>
  122. <div style="height:40px"></div>
  123. </div>