Commit:    bdbad3ce56b58bbcac8812519dfb1b71af75e1c9
Author:    Javier Infante <[email protected]>         Fri, 12 Feb 2016 21:09:43 
+0100
Parents:   df52d48b164c816305ddc50e88ae757b1770970b
Branches:  master

Link:       
http://git.php.net/?p=web/bugs.git;a=commitdiff;h=bdbad3ce56b58bbcac8812519dfb1b71af75e1c9

Log:
Follow Meta->Link->Next on github jsonp in order to fetch all PHP repos.
per_page param added when fetching PHP repos

Changed paths:
  M  templates/addghpull.php


Diff:
diff --git a/templates/addghpull.php b/templates/addghpull.php
index 89becb6..e848816 100644
--- a/templates/addghpull.php
+++ b/templates/addghpull.php
@@ -71,21 +71,42 @@ if (typeof($) != "function") {
 $(document).ready(function() {
   var org = "php";
   var baseurl = "https://api.github.com/";;
-  var url = baseurl+'orgs/'+org+'/repos';
+  var url = baseurl+'orgs/'+org+'/repos?per_page=100';
   converter = new Markdown.getSanitizingConverter();
   $("#pull_id_field").empty().hide();
   $('#pull_details').empty();
-  $.ajax({ dataType: 'jsonp', url: url, success: function(d) {
-    var repos = new Array();
-    for (var i in d.data) {
-      repos.push(d.data[i].name);
-    }
+
+  var repos = new Array();
+  
+  function loadGHRepos(url) {
+    $.ajax({ dataType: 'jsonp', url: url, success: function(d) {
+      for (var i in d.data) {
+        repos.push(d.data[i].name);
+      }
+      // Follow pagination if exists next
+      if (d.meta && d.meta.Link) {
+        for(var l in d.meta.Link) {
+          if (d.meta.Link[l][1] && d.meta.Link[l][1].rel && 
d.meta.Link[l][1].rel == 'next') {
+            loadGHRepos(d.meta.Link[l][0]);
+            return;
+          }
+        }
+      }
+      // No more next Links, draw them!
+      drawRepos();
+      }
+    });
+  }
+
+  function drawRepos() {
     repos.sort();
     for (var i in repos) {
       $("#repository_field").append("<option>"+repos[i]+"</option>");
     }
     $("#loading").hide();
-  } });
+  }
+  loadGHRepos(url);
+
 });
 
 $("#repository_field").change(function() {


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to