jomsocial force status refresh - joomla2.5

I am getting crazy to make jomsocial 2.6.2 with joomla 2.5.7 to works.
The problem is that when a user change the status the message is not reflecting in the wall.
Only if you refresh the page or switch view all to me and Friends view.
There no js error in the console and i get:
Jax.submitTask ajax_1.3.js:1
Jax.call ajax_1.3.js:1
joms.extend.activities.getLatestContent script-1.2.js:226
reloadActivities myaccount:1129
(anonymous function)
But no refresh anybody know how to force the wall so i can add a line after:
Status.submit
in
status.form.php
any tip welcome 2 days already trying...
Thanks a lot

I can believe that it is working
I add this line at the status.forum.php forcing to load all status
line 255
complete: function()
{
CreatorLoadingIndicator.hide();
joms.ajax.call('frontpage,ajaxGetActivities', [ 'all' ])
Status.reset();
Status.submitting = false;
}

Related

'Content-Length: 0', Javascript, XMLHttpRequest, Django REST API

I wish I can find some assistance with my code.
I have set up a Database on mySQL, and connected it to Django REST. Those both work as expected, and I can access the REST with Firefox REST Client with it returning the correct tables from the database.
I have started working for user interface with html and javascript and I have encountered a problem I am unable to solve. I am a student, and this is part of my school work, but unfortunately my teachers are unavailable at the moment due summer vacations and I am eager to continue my project. Hence I am askin for Your assistance.
As I have tested the Django REST through Firefox REST Client, I am sure the database and REST service is not at fault so here we come to my code.
I seem to be able to get connection to the REST Service, giving me code 200 and state 4 (pictures linked underneath)
ReadyStateChange + ReadyState console.logs
Picture 2 shows that my GET request gets stuck on OPTIONS, instead of executing the correct request.
200 OPTIONS
However I am unable to pull data out, giving me 'Content-Length: 0'.
Originally I thought the issue would be cross-domain request problem until my fellow student said he does not think it is, however he was unable to find solution for my code either.
I am trying to find reason and workaround for this error, and if you guys do have idea why this is happening I would deeply appriciate your help!
Here is my code:
<div id="demo"></div>
<script>
loadData() //function kutsu
function loadData(){
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "http://127.0.0.1:8000/vamkrs/";
xmlhttp.open("GET", url, true);
xmlhttp.withCredentials = true;
xmlhttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
xmlhttp.send();
setTimeout(xmlhttp.onreadystatechange = function() {
console.log(this.status);
console.log(this.readyState);
if (this.readyState == 4 && this.status == 200) {
var myData = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myData.responseText(); }
},1500);
/*
xmlhttp.onreadystatechange = function(){
console.log(this.status);
if (this.readyState == 4 && this.status == 200) {
var myData = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myData.responseText();}
}; */
}
</script>
Ps. Sorry, English is not my native language so some spelling mistakes might have been made
Pss. First time posting here, I apologize if mistakes were made on the post

How to get current page from Navigation in ionic 2

I am new to Ionic2, and I am trying to build dynamic tabs based on current menu selection. I am just wondering how can I get current page using navigation controller.
...
export class TabsPage {
constructor(navParams: NavParams,navCtrl:NavController) {
//here I want to get current page
}
}
...
From api documentation I feel getActiveChildNav() or getActive() will give me the current page, but I have no knowledge on ViewController/Nav.
Any help will be appreciated. Thanks in advance.
Full example:
import { NavController } from 'ionic-angular';
export class Page {
constructor(public navCtrl:NavController) {
}
(...)
getActivePage(): string {
return this.navCtrl.getActive().name;
}
}
Method to get current page name:
this.navCtrl.getActive().name
More details here
OMG! This Really Helped mate, Tons of Thanks! #Deivide
I have been stuck for 1 Month, Your answer saved me. :)
Thanks!
if(navCtrl.getActive().component === DashboardPage){
this.showAlert();
}
else
{
this.navCtrl.pop();
}
My team had to build a separate custom shared menu bar, that would be shared and displayed with most pages. From inside of this menu component.ts calling this.navCtrl.getActive().name returns the previous page name. We were able to get the current page name in this case using:
ngAfterViewInit() {
let currentPage = this.app.getActiveNav().getViews()[0].name;
console.log('current page is: ', currentPage);
}
this.navCtrl.getActive().name != TheComponent.name
or
this.navCtrl.getActive().component !== TheComponent
is also possible
navCtrl.getActive() seems to be buggy in certain circumstances, because it returns the wrong ViewController if .setRoot was just used or if .pop was just used, whereas navCtrl.getActive() seems to return the correct ViewController if .push was used.
Use the viewController emitted by the viewDidEnter Observable instead of using navCtrl.getActive() to get the correct active ViewController, like so:
navCtrl.viewDidEnter.subscribe(item=> {
const viewController = item as ViewController;
const n = viewController.name;
console.log('active page: ' + n);
});
I have tested this inside the viewDidEnter subscription, don't know about other lifecycle events ..
Old post. But this is how I get current page name both in dev and prod
this.appCtrl.getActiveNav().getActive().id
Instead of
...
...
//In debug mode alert value is 'HomePage'
//In production/ signed apk alert value is 'n'
alert(activeView.component.name);
if (activeView.component.name === 'HomePage') {
...
...
Use this
...
...
//In debug mode alert value is 'HomePage'
//In production/ signed apk alert value is 'HomePage'
alert(activeView.id);
if (activeView.id === 'HomePage') {
...
...
Source Link
You can use getActive to get active ViewController. The ViewController has component and its the instance of current view. The issue is the comparsion method. I've came up to solution with settings some field like id:string for all my Page components and then compare them. Unfortunately simple checking function name so getActive().component.name will break after minification.

Redirect user to modal popup after registration confirmation using Devise on Rails 4.x webapp

On a Rails 4.x app I'm using Devise to register users. What I want to do is redirect a user after confirmation to the usual user_path(resource) but having a modal appear to prompt for a few things. I don't know how to solve this without using cookies and javascript. Anyone solved this before or know to do it using the standard after_confirmation_path_for way in Devise? If not, what do you think is the best approach to solve it?
Many thanks in advance.
Ok, so if anyone else runs into this problem. I only found one way to solve it, this is it:
confirmations_controller.rb
class ConfirmationsController < Devise::ConfirmationsController
private
def after_confirmation_path_for(resource_name, resource)
sign_in(resource)
user_path(resource[:id], cp: true)
end
end
Then in the view which I want to popup the modal, I used this fairly popular javascript answer (How can I get query string values in JavaScript?) show.html.erb:
<%= javascript_tag do -%>
window.onload = function() {
var doCP = getParameterByName('cp');
if (doCP) {
$("#modal").html("<%= escape_javascript(render 'confirm_prompt_form') %>");
$("#modal").modal("show");
}
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

Facebook PHP SDK fatal error occures Facebook:: throwAPIException

try {
$return = $facebook->api("/" . $userFromDB["username"] . "/feed",
"post", array(
message => "",
picture => "http://blabla.net/blabla1/img/autopost/" . $blabla2 . ".png",
link => "http://apps.facebook.com/blabla1/?var2=" . $encryptedUserIds[$userFromDB["id"]], //$appPageURL
caption => "Tikla, begen.",
description => $var3,
access_token => $auth["auth_code"],
));
$usersPosted++;
} catch (FacebookApiException $e) {
$userProcessError++;
write_log("blabla");
}
Hello, this is the part of the code where i send posts to users' wall. If there is no exception, the code works flawlessly. Whenever an exception occures, I get this annoying fatal error.
I have tried many things to correct but the script is the same where I make calls to facebook api in other parts of my code.
I searched google and stackoverflow. Noone seems to have this error. Am i the only one? Thanks in advance.
This is the error:
Fatal error: Call to undefined method Facebook::throwAPIException() in facebook-php-sdk/src/base_facebook.php on line 870
Facebook sdk version i use: 3.2
Php version: 5.3
EDIT: this is how i get access_token for user. I store it into db:
if(isset($code) && $state==$authState){
$accessTokenInformation=file_get_contents($accessTokenURL . $code);
$tmpResult=explode("&", $accessTokenInformation);
if(sizeof($tmpResult)==2){
$tmpAT=explode("=", $tmpResult[0]);
$tmpExp=explode("=", $tmpResult[1]);
if(sizeof($tmpAT)==2 && sizeof($tmpExp)==2){
$tmpDBUserAuth=check_db_for_authcode_for_user(...);
if(empty($tmpDBUserAuth)){
insert_authcode_indb(...);
write_log(...);
}else{
update_authcode_indb(...)
write_log(...);
}
}else{
write_log(...);
echo(' top.location.href="'. $OAuthURL .'"; ');
}
}else{
write_log(...);
echo(' top.location.href="'. $OAuthURL .'"; ');
}
}
EDIT on 2012/11/06: Problem still persists. Please help.
Please check you FB API secrete keys are proper set or not ... I also faced this problem , but i have corrected secrete keys after that it was working perfect.
Try to use the following script
http://www.9lessons.info/2011/09/update-login-with-facebook-and-twitter.html
Fatal error: Call to undefined method Facebook::throwAPIException() in facebook-php-sdk/src/base_facebook.php on line 870
That error message does not make sense.
If I go to line 870 in that file in my IDE, and follow the method name to its declaration, it’s in the same file on line 1237 (all for current version 3.2.0).
So there is no plausible reason for a undefined method error there.
Could you please check if the SDK files got uploaded correctly to your server, or just re-download and re-upload them, to make sure its not a problem with mangled/truncated file contents?

Using jsPlumb in an Ember.js Application

I am trying to learn how to use jsPlumb in my Ember.js application so I put a minimal jsFiddle together to demonstrate how they could work together.
In this example so far I just insert the nodes and add them to jsPlumb. I have not added any links between them yet. At this stage the nodes should be draggable but they are not.
Error I get in the browser console:
TypeError: myOffset is null
Which points to this part of the code in jsPlumb:
for (var i = 0; i < inputs.length; i++) {
var _el = _getElementObject(inputs[i]), id = _getId(_el);
p.source = _el;
_updateOffset({ elId : id });
var e = _newEndpoint(p);
_addToList(endpointsByElement, id, e);
var myOffset = offsets[id], myWH = sizes[id];
var anchorLoc = e.anchor.compute( { xy : [ myOffset.left, myOffset.top ], wh : myWH, element : e });
e.paint({ anchorLoc : anchorLoc });
results.push(e);
}
You can see that a simple example without integration with Ember.js works as expected. I know that this version of jsPlumb I have uses jquery-ui to clone elements and support drag and drop. A post here shows there is an issue with jquery-ui draggable functionality in Ember. However, I am not sure if I am hitting the same problem. If that is the same issue I am having, I would appreciate some help in how to implement the solution suggested there in my application. I am new to both Ember and jsPlumb, so I would appreciate clear guidance about what is going on here and what path to take.
How can I make this example work?
Luckily my suspicion was wrong and the issue was not with metamorph. jsPlumb and Ember work just fine together, without any hacks. I put a little example in this jsFiddle that demonstrates how they could work together.
Credit goes to Simon Porritt who helped me at jsPlumb user group to identify the problem. What I was missing was a simple call to jsPlumb.draggable element. However, the above error persisted after this fix.
The particular error message above was result of Ember calling didInsertElement an extra time with an element which did not make it to the DOM. I have reported this issue. One workaround is to check the element makes it into the DOM before calling jsPlumb. As you can see in the jsFiddle I have added this code in the didInsertElement hook to get rid of the error.
elementId = this.get 'elementId'
element = $("#"+elementId)
if element.size() > 0
console.log "added element", element
jsPlumb.addEndpoint element, endpoint
jsPlumb.draggable element
else
console.log "bad element"
Hope this helps someone.