This commit is contained in:
Hannes Mannerheim 2015-11-05 13:27:23 +01:00
parent 4a4c2aff0d
commit 8fd44ec71e

View File

@ -63,17 +63,24 @@ function timeNow() {
function getDoc(doc, actionOnSuccess) { function getDoc(doc, actionOnSuccess) {
var timeNow = new Date().getTime(); var timeNow = new Date().getTime();
$.get(window.fullUrlToThisQvitterApp + 'doc/' + window.selectedLanguage + '/' + doc + '.html?t=' + timeNow, function(data){
if(data) { $.ajax({ url: window.fullUrlToThisQvitterApp + 'doc/' + window.selectedLanguage + '/' + doc + '.html',
cache: false,
type: "GET",
success: function(data) {
actionOnSuccess(renderDoc(data)); actionOnSuccess(renderDoc(data));
} },
}).fail(function() { // default to english if we can't find the doc in selected language error: function() {
$.get(window.fullUrlToThisQvitterApp + 'doc/en/' + doc + '.html?t=' + timeNow, function(data){ // default to english if we can't find the doc in selected language
if(data) { $.ajax({ url: window.fullUrlToThisQvitterApp + 'doc/en/' + doc + '.html',
cache: false,
type: "GET",
success: function(data) {
actionOnSuccess(renderDoc(data)); actionOnSuccess(renderDoc(data));
} }
}); });
}); }
});
} }
function renderDoc(docHtml) { function renderDoc(docHtml) {
docHtml = docHtml.replace(/{instance-name}/g,window.siteTitle); docHtml = docHtml.replace(/{instance-name}/g,window.siteTitle);
@ -98,7 +105,8 @@ function renderDoc(docHtml) {
function checkLogin(username,password,actionOnSuccess) { function checkLogin(username,password,actionOnSuccess) {
$.ajax({ url: window.apiRoot + 'qvitter/checklogin.json', $.ajax({ url: window.apiRoot + 'qvitter/checklogin.json',
type: 'POST', cache: false,
type: 'POST',
data: { data: {
username: username, username: username,
password: password password: password
@ -129,8 +137,9 @@ function checkLogin(username,password,actionOnSuccess) {
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function getFromAPI(stream, actionOnSuccess) { function getFromAPI(stream, actionOnSuccess) {
var url = window.apiRoot + stream + qOrAmp(stream) + 't=' + timeNow(); var url = window.apiRoot + stream;
$.ajax({ url: url, $.ajax({ url: url,
cache: false,
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
statusCode: { statusCode: {
@ -234,7 +243,8 @@ function getNicknameByGroupIdFromAPI(id, callback) {
function postUpdateBookmarks(newBookmarks) { function postUpdateBookmarks(newBookmarks) {
var bookmarksString = JSON.stringify(newBookmarks); var bookmarksString = JSON.stringify(newBookmarks);
$.ajax({ url: window.apiRoot + 'qvitter/update_bookmarks.json?t=' + timeNow(), $.ajax({ url: window.apiRoot + 'qvitter/update_bookmarks.json',
cache: false,
type: "POST", type: "POST",
data: { data: {
bookmarks: bookmarksString bookmarks: bookmarksString
@ -257,7 +267,8 @@ function postUpdateBookmarks(newBookmarks) {
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function postNewLinkColor(newLinkColor) { function postNewLinkColor(newLinkColor) {
$.ajax({ url: window.apiRoot + 'qvitter/update_link_color.json?t=' + timeNow(), $.ajax({ url: window.apiRoot + 'qvitter/update_link_color.json',
cache: false,
type: "POST", type: "POST",
data: { data: {
linkcolor: newLinkColor linkcolor: newLinkColor
@ -281,7 +292,8 @@ function postNewLinkColor(newLinkColor) {
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function postNewBackgroundColor(newBackgroundColor) { function postNewBackgroundColor(newBackgroundColor) {
$.ajax({ url: window.apiRoot + 'qvitter/update_background_color.json?t=' + timeNow(), $.ajax({ url: window.apiRoot + 'qvitter/update_background_color.json',
cache: false,
type: "POST", type: "POST",
data: { data: {
backgroundcolor: newBackgroundColor backgroundcolor: newBackgroundColor
@ -311,13 +323,14 @@ function postNewBackgroundColor(newBackgroundColor) {
function APIFollowOrUnfollowUser(followOrUnfollow,user_id,this_element,actionOnSuccess) { function APIFollowOrUnfollowUser(followOrUnfollow,user_id,this_element,actionOnSuccess) {
if(followOrUnfollow == 'follow') { if(followOrUnfollow == 'follow') {
var postRequest = 'friendships/create.json?t=' + timeNow(); var postRequest = 'friendships/create.json';
} }
else if (followOrUnfollow == 'unfollow') { else if (followOrUnfollow == 'unfollow') {
var postRequest = 'friendships/destroy.json?t=' + timeNow(); var postRequest = 'friendships/destroy.json';
} }
$.ajax({ url: window.apiRoot + postRequest, $.ajax({ url: window.apiRoot + postRequest,
cache: false,
type: "POST", type: "POST",
data: { data: {
user_id: user_id user_id: user_id
@ -345,7 +358,8 @@ function APIFollowOrUnfollowUser(followOrUnfollow,user_id,this_element,actionOnS
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function APIJoinOrLeaveGroup(joinOrLeave,group_id,this_element,actionOnSuccess) { function APIJoinOrLeaveGroup(joinOrLeave,group_id,this_element,actionOnSuccess) {
$.ajax({ url: window.apiRoot + 'statusnet/groups/' + joinOrLeave + '.json?t=' + timeNow(), $.ajax({ url: window.apiRoot + 'statusnet/groups/' + joinOrLeave + '.json',
cache: false,
type: "POST", type: "POST",
data: { data: {
id: group_id id: group_id
@ -374,7 +388,8 @@ function APIJoinOrLeaveGroup(joinOrLeave,group_id,this_element,actionOnSuccess)
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function postQueetToAPI(queetText_txt, in_reply_to_status_id, postToGroups, actionOnSuccess) { function postQueetToAPI(queetText_txt, in_reply_to_status_id, postToGroups, actionOnSuccess) {
$.ajax({ url: window.apiRoot + 'statuses/update.json?t=' + timeNow(), $.ajax({ url: window.apiRoot + 'statuses/update.json',
cache: false,
type: "POST", type: "POST",
data: { data: {
status: queetText_txt, status: queetText_txt,
@ -406,7 +421,8 @@ function postQueetToAPI(queetText_txt, in_reply_to_status_id, postToGroups, acti
· · · · · · · · · · · · · */ · · · · · · · · · · · · · */
function postActionToAPI(action, actionOnSuccess) { function postActionToAPI(action, actionOnSuccess) {
$.ajax({ url: window.apiRoot + action + qOrAmp(action) + 't=' + timeNow(), $.ajax({ url: window.apiRoot + action,
cache: false,
type: "POST", type: "POST",
data: { data: {
source: 'Qvitter' source: 'Qvitter'
@ -477,7 +493,8 @@ function getFavsAndRequeetsForQueet(q,qid) {
showFavsAndRequeetsInQueet(q, cacheData); showFavsAndRequeetsInQueet(q, cacheData);
} }
$.ajax({ url: window.apiRoot + "qvitter/favs_and_repeats/" + qid + ".json?t=" + timeNow(), $.ajax({ url: window.apiRoot + "qvitter/favs_and_repeats/" + qid + ".json",
cache: false,
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {