Last active
December 16, 2015 06:49
-
-
Save kensei/5394686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/App.js b/js/App.js | |
index 4593686..faf7cfc 100644 | |
--- a/js/App.js | |
+++ b/js/App.js | |
@@ -71,3 +71,12 @@ $(function(){ | |
$.ajaxSettings.complete = function(){ $('loading').hide(); }; | |
}); | |
+window.is_jsonp = true; | |
+window.base_url = 'your_redmine_url' | |
+function generate_url(url){ | |
+ if(is_jsonp == true){ | |
+ return window.base_url + url + "&callback=?"; | |
+ }else{ | |
+ return url; | |
+ } | |
+} | |
diff --git a/js/NamedRoutes.js b/js/NamedRoutes.js | |
index 893167f..6ff306e 100644 | |
--- a/js/NamedRoutes.js | |
+++ b/js/NamedRoutes.js | |
@@ -16,4 +16,4 @@ function issues_path(options){ | |
function issue_path(options){ | |
return "issue/" + options.id; | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/js/collections/Issues.js b/js/collections/Issues.js | |
index f39f420..0163af7 100644 | |
--- a/js/collections/Issues.js | |
+++ b/js/collections/Issues.js | |
@@ -4,7 +4,8 @@ window.Issues = Backbone.Collection.extend({ | |
var issues = this; | |
var results = []; | |
var project = this.project; | |
- $.getJSON("/issues.json?key=" + user.get("key") + "&project_id=" + project.id, function(data){ | |
+ var url = generate_url("/issues.json?key=" + user.get("key") + "&project_id=" + project.id); | |
+ $.getJSON(url, function(data){ | |
$.each(data.issues, function(index, issue){ | |
var model = new Issue(issue); | |
results.push(model); | |
@@ -13,4 +14,4 @@ window.Issues = Backbone.Collection.extend({ | |
if(typeof(callback)=='function'){ callback(); } | |
}); | |
} | |
-}); | |
\ No newline at end of file | |
+}); | |
diff --git a/js/collections/Projects.js b/js/collections/Projects.js | |
index 7a4d9ba..54f5178 100644 | |
--- a/js/collections/Projects.js | |
+++ b/js/collections/Projects.js | |
@@ -3,7 +3,8 @@ window.Projects = Backbone.Collection.extend({ | |
populate: function(callback){ | |
var projects = this; | |
var results = []; | |
- $.getJSON("/projects.json?key=" + user.get("key"), function(data){ | |
+ var url = generate_url("/projects.json?key=" + user.get("key")); | |
+ $.getJSON(url, function(data){ | |
$.each(data.projects, function(index, project){ | |
var model = new Project(project); | |
results.push(model); | |
@@ -12,4 +13,4 @@ window.Projects = Backbone.Collection.extend({ | |
if(typeof(callback)=='function'){ callback(); } | |
}); | |
} | |
-}); | |
\ No newline at end of file | |
+}); | |
diff --git a/js/models/Issue.js b/js/models/Issue.js | |
index 4ff2286..383051f 100644 | |
--- a/js/models/Issue.js | |
+++ b/js/models/Issue.js | |
@@ -1,10 +1,10 @@ | |
window.Issue = Backbone.Model.extend({ | |
populate_by_id: function(id,callback){ | |
- var url = "/issues/" + id + ".json?key=" + user.get("key"); | |
+ var url = generate_url("/issues/" + id + ".json?key=" + user.get("key")); | |
var model = this; | |
$.getJSON(url, function(data){ | |
model.set(data.issue); | |
if(typeof(callback)=='function'){ callback(); } | |
}); | |
} | |
-}); | |
\ No newline at end of file | |
+}); | |
diff --git a/js/models/User.js b/js/models/User.js | |
index 8964846..7303314 100644 | |
--- a/js/models/User.js | |
+++ b/js/models/User.js | |
@@ -1,7 +1,8 @@ | |
window.User = Backbone.Model.extend({ | |
populate: function(callback){ | |
var model = this; | |
- $.getJSON("/users/current.json?key=" + model.get("key"), function(data){ | |
+ var url = generate_url("/users/current.json?key=" + model.get("key")); | |
+ $.getJSON(url, function(data){ | |
model.set(data.user); | |
if(typeof(callback)=='function'){ callback(); } | |
}); | |
@@ -15,4 +16,4 @@ window.User = Backbone.Model.extend({ | |
gravatar: function(){ | |
return $.gravatar(this.get("mail"), {size: 40}); | |
} | |
-}); | |
\ No newline at end of file | |
+}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment