I have no idea why this happens. Whenever it processes the characters of a string
, and it string
has vowels with accents or ñ
transforms them and does not display properly.
I have a textarea
where the messages put by user1 and user2 are placed , what I want is that every so often, for example 5 seconds, div
only the user is updated.
For this I have found several examples where they use load
passing a page to load.
$(document).ready(function() {
var refreshId = setInterval(function() {
$("#feedback-bg-info").load("url a cargar")
.error(function() { alert("Error"); });
}, 1000);
$.ajaxSetup({ cache: false });
});
In this part $("#feedback-bg-info").load("url a cargar")
, in the method load
, what I am looking for is that only the is updated div
without passing it a different route.
I have this code that has turned into a little maze. I have a dynamic array made of a BASE class called MazePlace and I have two DERIVED classes that are wall and OpenSpace
Basically what I want is to read a text file with a maze that can have variable dimensions and read the file character by character and recreate the maze inside an array of pointers
LugarLaberinto*** lugares;
but the derived class OpenSpace has methods that allow me to change the Open space with for example the person inside the maze.
So my question is how to access a method of the OpenSpace class through a pointer of a MazePlace class ?
and here I leave the code with the comments. (I tried to make the code as small as possible to show the doubt, but I couldn't reduce it more than this. Thanks)
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//####################################
//clase BASE lugar del laberinto
class LugarLaberinto
{
public:
virtual char mostrarCaracter()=0;
protected:
char caracter;
};
//####################################
//clase muro DERIVADA de lugar del laberinto
class muro : public LugarLaberinto
{
public:
muro();
~muro();
char mostrarCaracter();
};
muro::muro()
{
caracter = '#';
}
char muro::mostrarCaracter()
{
return caracter;
}
//####################################
//clase espacioAbierto DERIVADA de lugar del laberinto
class EspacioAbierto : public LugarLaberinto
{
public:
EspacioAbierto();
~EspacioAbierto();
char mostrarCaracter();
// funcion de la clase derivada
void hayAlguien(bool);
};
EspacioAbierto::EspacioAbierto()
{
caracter=' ';
}
char EspacioAbierto::mostrarCaracter()
{
return caracter;
}
void EspacioAbierto::hayAlguien(bool)
{
caracter='@';
}
//####################################
//clase laberinto
class laberinto
{
public:
//constructor que toma de un stream los valores del laberinto
laberinto (std::ifstream&, int, int);
~laberinto();
LugarLaberinto*** lugares;
LugarLaberinto* obtenerLugar(int, int);
};
laberinto::laberinto(ifstream& fin, int alto, int ancho)
{
char bloque;
string auxiliar;
lugares = new LugarLaberinto**[alto];
//fin.ignore();
for (int i=0; i< alto ; i++)
{
lugares[i] = new LugarLaberinto*[ancho];
// leo una linea completa del archivo laberinto
// y la guardo en auxiliar
getline(fin,auxiliar);
//cout << auxiliar;
for (int j=0; j< ancho; j++)
{
//leo cada uno de los caracteres y los almaceno en la variable bloque
bloque = auxiliar [j];
// Basado en si es un # o si es un espacio basio creo el puntero
//hacia lugar de laberinto
if (bloque=='#')
this->lugares[i][j] = new muro();
else
{
this->lugares[i][j] = new EspacioAbierto();
//########################
//aqui esta mi duda
// me gustaría acceder al metodo
// void hayAlguien(bool)
// a traves del puntero lugares
// sin embargo no se si sea posible
// o no se como hacerlo
/*
// aqui dice que la clase lugar laberinto no tiene
//un miembro llamado hayAlguien y bueno eso lo sé
// pero no quiero crear una funcion virtual para cada miembro
// de esta clase derivada
if (bloque=='@')
this->lugares[i][j]->hayAlguien(true);
*/
// encontré esta manera de hacerlo pero no se si es la única
// que es creando un nuevo objeto modificandolo y luego
// asignándolo, sin embargo no me siento totalmente cómodo
// pensando que tengo que crear objetos a cada instante que
// quiera modificar el objeto.
if (bloque=='@')
{
EspacioAbierto *aux= new EspacioAbierto();
aux->hayAlguien(true);
lugares[i][j]=aux;
}
}
//########################
cout << this->lugares[i][j]->mostrarCaracter();
}
cout << endl;
}
}
int main(int argc, char** argv) {
ifstream fin;
fin.open("laberinto.txt");
int alto = 10;
int ancho =10;
laberinto *nivel = new laberinto(fin, alto, ancho);
return 0;
}
to finish I attach the file labyrinth.txt
##########
#@# #
# ##### #
# #
###### #
# #
# #######
# # #
# e#
##########
I have the following html component to which I pass a Json:
<a href="javascript:abreModal('{ 'name':'John', 'age':'30', 'city':'New York'}');">
Pulsador
</a>
And the Javascript function:
function abreModal(text) {
//var text = '{ "name":"John", "age":"function () {return 30;}", "city":"New York"}';
obj = JSON.parse(text);
alert(obj.name);
}
The error firebug throws me is:
SyntaxError: missing ) after argument list
I suspect that the error is in the quotes abreModal(...)
I have tried to change the quotes without result.
Any suggestion?
Since I updated Android Studio to 2.3 I'm having problems that don't influence when using the application on my mobile, but if it shows me errors from Android Studio and I don't know if I'll have problems in the future, that's why I want to solve them.
The first is in the gradle
and is as follows:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.1.0, 25.0.2. Examples include com.android.support:animated-vector-drawable:25.1.0 and com.android.support:renderscript:25.0.2
This is my gradle
, compile 'com.android.support:appcompat-v7:25.1.0'
where I get the above message.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "otrointento.dos"
minSdkVersion 19
targetSdkVersion 25
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/circleimageview/gradle/wrapper/gradle-wrapper.jar')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.android.support:design:25.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}
And the other problem is in thisxml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/base_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f4f4f4">
<ListView
android:id="@+id/listViewPersonas"
android:layout_width="match_parent"
android:divider="#f4f4f4"
android:dividerHeight="7dp"
android:layout_height="match_parent" />
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/icon_btn_flo_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
fab:menu_animationDelayPerItem="55"
fab:menu_backgroundColor="@android:color/transparent"
fab:menu_buttonSpacing="0dp"
fab:menu_colorNormal="#46b1bb"
fab:menu_colorPressed="#3d979f"
fab:menu_colorRipple="#99d4d4d4"
fab:menu_fab_size="normal"
fab:menu_icon="@drawable/fab_add"
fab:menu_labels_colorNormal="#46b1bb"
fab:menu_labels_colorPressed="#3d979f"
fab:menu_labels_colorRipple="#66efecec"
fab:menu_labels_cornerRadius="3dp"
fab:menu_labels_ellipsize="none"
fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
fab:menu_labels_margin="0dp"
fab:menu_labels_maxLines="-1"
fab:menu_labels_padding="8dp"
fab:menu_labels_position="left"
fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
fab:menu_labels_showShadow="true"
fab:menu_labels_singleLine="false"
fab:menu_labels_textColor="#f2f1f1"
fab:menu_labels_textSize="15sp"
fab:menu_openDirection="up"
fab:menu_shadowColor="#45baba"
fab:menu_shadowRadius="4dp"
fab:menu_shadowXOffset="1dp"
fab:menu_shadowYOffset="4dp"
fab:menu_showShadow="true">
<com.github.clans.fab.FloatingActionButton
android:id="@+id/icon_btn_flo_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_btn_flo_1"
fab:fab_label="@string/btn_flo_1"
fab:fab_size="mini"
android:clickable="false" />
</com.github.clans.fab.FloatingActionMenu>
</AbsoluteLayout>
Failed to instantiate one or more classes
The following classes could not be instantiated: