another way to open instagram in iframe tag without having API
You can always check any url(example.com) is allowed in IFrame or not for a specific Origin by following method:
function isAllowededByXFrameOption({ header, origin }) {
if (header["X-Frame-Options".toLowerCase()]) {
let options = header["X-Frame-Options".toLowerCase()].toLowerCase();
if (options === "SAMEORIGIN".toLowerCase()) {
return false;
} else if (options === "DENY".toLowerCase()) {
return false;
} else if (~options.indexOf("ALLOW-FROM".toLowerCase())) {
let allowedOrigins = options.split(" ").slice(1);
return allowedOrigins.find(
_o => url.parse(_o).host === url.parse(origin).host
);
}
}
if (header["Content-Security-Policy".toLowerCase()]) {
let _options = header["Content-Security-Policy".toLowerCase()];
let CheckOriginInSource = source_name => {
_options = _options.split(";");
_options = _options.find(_o => _o.indexOf(source_name) > -1);
_options = _options.split(" ").slice(1);
return _options.find(_o => url.parse(_o).host === url.parse(origin).host);
};
if (_options.indexOf("frame-src") > -1) {
return CheckOriginInSource("frame-src");
} else if (_options.indexOf("child-src")) {
return CheckOriginInSource("child-src");
} else if (_options.indexOf("default-src")) {
return CheckOriginInSource("default-src");
} else {
return true;
}
} else {
return true;
}
}
const got = require("got");
const metascraper = require("metascraper")([
require("metascraper-author")(),
require("metascraper-date")(),
require("metascraper-description")(),
require("metascraper-image")(),
require("metascraper-logo")(),
require("metascraper-clearbit-logo")(),
require("metascraper-publisher")(),
require("metascraper-title")(),
require("metascraper-url")()
]);
const Domain = "example.com";
(async () => {
const { body: html, url, headers } = await got(Domain);
const metadata = await metascraper({ html, url });
const isAllowed = isAllowededByXFrameOption({
header: headers,
origin: "www.app4pc.com"
})
})();
You can easily embed an Instagram post using the embed link they provide.
Source: https://www.instagram.com/developer/embedding/
Example:
<blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="https://www.instagram.com/p/B3w_PilgaOZ/?utm_source=ig_embed&utm_campaign=loading" data-instgrm-version="12" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div> <div style="display:block; height:50px; margin:0 auto 12px; width:50px;"><svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-511.000000, -20.000000)" fill="#000000"><g><path d="M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631"></path></g></g></g></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;"> View this post on Instagram</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <p style=" margin:8px 0 0 0; padding:0 4px;"> Today’s #WeeklyFluff is defying gravity. Meet Narcos (#narcos_cockerspaniel): He’s a happy, expressive and active dog who loves to fly. Photo by #narcos_cockerspaniel</p> <p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;">A post shared by Instagram (#instagram) on <time style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px;" datetime="2019-10-18T15:59:06+00:00">Oct 18, 2019 at 8:59am PDT</time></p></div></blockquote> <script async src="//www.instagram.com/embed.js"></script>
as you can see on my snippets, I could search only for the first name e.g. full name"ABDOL JABAR BAKARI" and the first name is "abdol" and only the name "abdol" is utilize in the filter function which it must all the string inside that data attribute named "data-fullname" will filtered. any ideas, clues, help, suggestions, recommendation to make it search the whole string inside the data attribute named "data-fullname" and search also from the string inside the data attribute named "data-job"?
$(document).ready(function(){
$('.search_employee').on('input', function() {
var value = this.value.toLowerCase();
$('.profile').hide().filter(function() {
var name = $(this).attr('data-fullname').toLowerCase();
return value.trim().length < 1 || name.indexOf(value) === 0;
}).show();
});
});
.profile{
width: 200px;
float: left;
display: block;
margin: 5px;
border: 1px solid #ccc;
padding: 10px 0px;
}
.profile h1{
font-size: 15px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
.profile p{
font-size: 13px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control search_employee" placeholder="Search here...">
<div id="profile_holder">
<div class="profile" data-fullname="Abdol Jabar Bakari" data-job="system developer">
<h1>Abdol Jabar Bakari</h1>
<p>System Developer</p>
</div>
<div class="profile" data-fullname="Jason Fang" data-job="database analysis">
<h1>Jason Fang</h1>
<p>Database Analysis</p>
</div>
<div class="profile" data-fullname="Mechelle Newyurk" data-job="sales officer">
<h1>Mechelle Newyurk</h1>
<p>Sales Officer</p>
</div>
<div class="profile" data-fullname="Juliver Galleto" data-job="ui/ux">
<h1>Juliver Galleto</h1>
<p>UI/UX</p>
</div>
</div>
A simple change required. Instead of checking for name.indexOf(value) !== -0;, you should check for name.indexOf(value) !== -1;
$(document).ready(function(){
$('.search_employee').on('input', function() {
var value = this.value.toLowerCase();
$('.profile').hide().filter(function() {
var name = $(this).attr('data-fullname').toLowerCase();
return value.trim().length < 1 || name.indexOf(value) !== -1;
}).show();
});
});
.profile{
width: 200px;
float: left;
display: block;
margin: 5px;
border: 1px solid #ccc;
padding: 10px 0px;
}
.profile h1{
font-size: 15px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
.profile p{
font-size: 13px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control search_employee" placeholder="Search here...">
<div id="profile_holder">
<div class="profile" data-fullname="Abdol Jabar Bakari" data-job="system developer">
<h1>Abdol Jabar Bakari</h1>
<p>System Developer</p>
</div>
<div class="profile" data-fullname="Jason Fang" data-job="database analysis">
<h1>Jason Fang</h1>
<p>Database Analysis</p>
</div>
<div class="profile" data-fullname="Mechelle Newyurk" data-job="sales officer">
<h1>Mechelle Newyurk</h1>
<p>Sales Officer</p>
</div>
<div class="profile" data-fullname="Juliver Galleto" data-job="ui/ux">
<h1>Juliver Galleto</h1>
<p>UI/UX</p>
</div>
</div>
The problem is the condition name.indexOf(value) === 0 which matches the search term to only the start of the string.
If the searched term is not found indexOf will retrn -1, so just check the returned value is > 1 to check whether the term is present in the string like name.indexOf(value) > -1;
$(document).ready(function() {
$('.search_employee').on('input', function() {
var value = this.value.toLowerCase().trim();
if (value) {
//do this only if a filter condition is present
$('.profile').hide().filter(function() {
var name = $(this).data('fullname').toLowerCase();
return name.indexOf(value) > -1 || $(this).data('job').toLowerCase().indexOf(value) > -1;
}).show();
} else {
$('.profile').show();
}
});
});
.profile {
width: 200px;
float: left;
display: block;
margin: 5px;
border: 1px solid #ccc;
padding: 10px 0px;
}
.profile h1 {
font-size: 15px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
.profile p {
font-size: 13px;
color: 555;
padding: 5px;
margin: 0px;
text-align: center;
text-transform: uppercase;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control search_employee" placeholder="Search here...">
<div id="profile_holder">
<div class="profile" data-fullname="Abdol Jabar Bakari" data-job="system developer">
<h1>Abdol Jabar Bakari</h1>
<p>System Developer</p>
</div>
<div class="profile" data-fullname="Jason Fang" data-job="database analysis">
<h1>Jason Fang</h1>
<p>Database Analysis</p>
</div>
<div class="profile" data-fullname="Mechelle Newyurk" data-job="sales officer">
<h1>Mechelle Newyurk</h1>
<p>Sales Officer</p>
</div>
<div class="profile" data-fullname="Juliver Galleto" data-job="ui/ux">
<h1>Juliver Galleto</h1>
<p>UI/UX</p>
</div>
</div>
I'm having a some trouble with a button, I'm using a DIV that has a POST method inside of it, however, this button in question doesn't need the POST method, so:
<div id="lightA" class="white_content" height="300">
<h1>Adivinar...</h1>
<h2>Que personaje escoges?:</h2>
<form type="post">
<input type="text" list="personajes">
<datalist id="personajes" style="display:block">
<?php
session_start();
include "config.php";
if(isset($_SESSION["user_name"]))
{
$select = "SELECT nombre_personaje FROM partida WHERE user_name =".$_SESSION["user_name"]."AND personaje_activo = 'T'";
$query = mysqli_query($con, $select);
$rows = mysqli_num_rows($query);
$cont = 0;
$tableval;
if($rows > 0)
{
while($row = mysqli_fetch_array($query))
{
if($row['personaje_activo'] = "T")
{
=$tableval."<option value=\"".$row['']."\">";
}
}
}
else
{
?>
<?
}
}
echo $tableval;
?>
</datalist>
<button type="submit" action="submit_character.php" name="select" style="display:inline">Elegir!</button>
</form>
<button onclick:"javascript:cerrarPop('lightA')">Cancelar</button>
</div>
Now this is the funny part, <button onclick:"javascript:cerrarPop('lightA')">Cancelar</button> isn't executing anything at all, I was thinking, well just put the button inside the post, however the page refresh itself and executes <body background="imagen.jpg" onload="javascript:mostrarPop('lightP')"> which I don't need, then I was looking how to set a cookie for that pop DIV, but I have a limited knowledge in AJAX.
Here's also my JS script:
<script type="text/javascript">
function mostrarPop(name) {
document.getElementById(name).style.display='block';
document.getElementById('fade').style.display='block';
}
function cerrarPop(name) {
document.getElementById(name).style.display='none';
document.getElementById('fade').style.display='none';
}
</script>
Any help is appreciated, AJAX would be awesome, I'm reading some code right however is a bit confusing.
Thanks in advance.
Update
Here's the entire code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Guess who? - Lobby</title>
<style type="text/css">
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.6;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
text-align: center;
display: none;
margin-top: 50px;
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
width: 35%;
height: 500px;
padding: 16px;
border: 16px solid orange;
background: rgba(0,0,0,.8);
z-index:1002;
overflow: auto;
}
input[type="text"]{
width:173px;
display:inline;
margin-left:5px;
}
body { width:960px; margin:0 auto;}
div.chatbox{
position:fixed;
display:table;
border-collapse: collapse;
width: 250px;
height: 350px;
border-radius: 9px;
padding: 0.5em;
background: rgba(0,0,0,.5);
margin-top:25px;
margin-bottom:100px;
margin-right:50px;
margin-left:705px;
}
div.gamebox{
position:fixed;
background: rgba(0,0,0,.5);
width: 630px;
height: 560px;
border-radius: 9px;
padding: 0.5em;
margin-top:25px;
margin-bottom:100px;
margin-right:50px;
margin-left:25px;
}
div.optionbox{
position:fixed;
border-collapse: collapse;
width: 235px;
height: 190px;
border-radius: 9px;
padding: 0.5em;
background: rgba(0,0,0,.5);
margin-top:395px;
margin-bottom:100px;
margin-right:50px;
margin-left:705px;
}
h1 {
margin-top: 10px;
font-family: "Times New Roman", Times, serif;
font-weight: bold;
text-align: center;
font-size: 30px;
color: #F00;
text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
}
h2 {
display: inline;
margin-top: 10px;
font-family: "Times New Roman", Times, serif;
font-weight: bold;
text-align: left;
font-size: 25px;
color: #FFF;
}
iframe {
background-color: #FFF;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 5px;
margin-right: 5px;
}
input[type="submit"]{
background-color: #FFF;
margin-top: 1px;
margin-left: 5px;
margin-right: 5px;
}
</style>
<script type="text/javascript">
mostrarPop = function(name) {
document.getElementById(name).style.display='block';
document.getElementById('fade').style.display='block';
}
cerrarPop = function(name) {
document.getElementById(name).style.display='none';
document.getElementById('fade').style.display='none';
}
</script>
</head>
<body background="imagen.jpg" onload="mostrarPop('lightP')">
<div id="lightP" class="white_content">
<h1>Tu personaje secreto es:</h1>
<?php
session_start();
include "config.php";
if(isset($_SESSION["user_name"]))
{
$selectcategoria = "SELECT DISTINCT id_partida, id_categoria FROM partida WHERE user_name =".$_SESSION["user_name"];
$querycategoria = mysqli_query($con, $selectcategoria);
$rowcategoria = mysqli_fetch_array($querycategoria);
$personajenum = rand(0,23);
$selectpersonaje = "SELECT nombre_personaje, foto_personaje FROM Categoria WHERE id_personaje =".$personajenum;
$querypersonaje = mysqli_query($selectpersonaje);
$rowpersonaje = mysqli_fetch_array($querypersonaje);
$selectturno = "SELECT user_name_retador, user_name_oponente FROM WHERE user_name =".$_SESSION["user_name"];
$queryturno = mysqli_query($con, $selectcategoria);
$rowturno = mysqli_fetch_array($query);
if($_SESSION["user_name"]=$rowturno["user_name_oponente"]){
$insertestado = "INSERT INTO estadojugador(id_partida, user_name, turno_activo, personaje_secreto) VALUES(".$row['id_partida'].", ".$_SESSION["user_name"].", "."false".", ".$rowpersonaje["nombre_personaje"].")";
$queryestado = mysqli_query($insertestado);
}
else
{
$insertestado = "INSERT INTO estadojugador(id_partida, user_name, turno_activo, personaje_secreto) VALUES(".$row['id_partida'].", ".$_SESSION["user_name"].", "."true".", ".$rowpersonaje["nombre_personaje"].")";
$queryestado = mysqli_query($insertestado);
}
echo "<img src=\"categorias/".$rowpersonaje["foto_personaje"]."\" width=\"240\" height=\"360\" style=\"display:block; margin: 0 auto;></img>";
}
?>
<button onclick="cerrarPop('lightP')" style="margin-top:10px; margin: 0 auto;">Continuar!</button>
</div>
<div id="lightA" class="white_content" height="300">
<h1>Adivinar...</h1>
<h2>Que personaje escoges?:</h2>
<form type="post">
<input type="text" list="personajes">
<datalist id="personajes" style="display:block">
<?php
session_start();
include "config.php";
if(isset($_SESSION["user_name"]))
{
$select = "SELECT nombre_personaje FROM partida WHERE user_name =".$_SESSION["user_name"]."AND personaje_activo = 'T'";
$query = mysqli_query($con, $select);
$rows = mysqli_num_rows($query);
$cont = 0;
$tableval;
if($rows > 0)
{
while($row = mysqli_fetch_array($query))
{
if($row['personaje_activo'] = "T")
{
=$tableval."<option value=\"".$row['']."\">";
}
}
}
else
{
?>
<?
}
}
echo $tableval;
?>
</datalist>
<button type="submit" action="submit_character.php" name="select" style="display:inline">Elegir!</button>
</form>
<button onclick:"cerrarPop('lightA')">Cancelar</button>
</div>
<div id="fade" class="black_overlay"></div>
<div class="chatbox">
<table width="240" height="250">
<form method="post" action="handler_partidas.php">
<tr>
<td><iframe src="messages_partidas.php" name="iframe" width="230" height="305"></iframe></td>
</tr>
<tr>
<td><input type="text" name="message"> <button type="submit" name="send">Enviar</button>
</tr>
</form>
</table>
</div>
<div class="gamebox">
<table width="240" height="250">
<form method="post" action="fill_table.php">
</form>
</table>
</div>
<div class="optionbox">
<h1>Opciones</h1>
<button onclick="">Rendirse</button>
<button onclick="javascript:mostrarPop('lightA')">Adivinar...</button></br>
<button type="submit" name="yes">Si</button>
<button type="submit" name="no">No</button>
</div>
</body>
</html>
There is 2 problem on your code first one is button onclick event. It should be like;
<button onclick="cerrarPop('lightA')">Cancelar</button>
Second problem is function defination. It is also be like;
cerrarPop = function (name) {
document.getElementById(name).style.display='none';
document.getElementById('fade').style.display='none';
}
jsfiddle link
In my Application Everything Work Fine add/edit but my main Problem is IF i am on a 'agendaWeek' of Fullcalendar and try to submit or cancel the form then it is going to Month View
Updated Code:
JAVASCRIPT:
<script>
var globalEvent = null;
$(document).ready(function() {
var count=0;
var liveDate=new Date();
var dat = new Date();
var d = dat.getDate();
var m = dat.getMonth();
var y = dat.getFullYear();
var calendar = $('#calendar').fullCalendar({
selectable: true,
selectHelper: true,
select: function(startDate, endDate, allDay, jsEvent, view) {
var startDate1=$.fullCalendar.formatDate(startDate, "yyyy-MM-dd HH:mm:ss");
var endDate1=$.fullCalendar.formatDate(endDate, "yyyy-MM-dd HH:mm:ss");
document.getElementById('mode').innerHTML = "ADD :"+"<img src='<?php echo base_url();?>/assets/images/close.png' style='float:right; height:35px; width:35px; margin-top:-7px;' id='closeimg' name='closeimg'>";
document.getElementById('starting').innerHTML = startDate1;
document.getElementById('ending').innerHTML = endDate1;
$("#ginger").show();
$("#closeimg").click(function(){
$("#ginger").hide();
});
$("#eventName").focus();
$("#submit").click(function(){
var title=$("#eventName").val();
calendar.fullCalendar('renderEvent',{
title: title,
start: startDate1,
end: endDate1,
allDay: false},
true // make the event "stick"
);
var dataString={};
dataString['eventName']=title;
dataString['startTime']=startDate1;
dataString['endTime']=endDate1;
$.ajax({
type : 'POST',
dataType : 'json',
url : '<?php echo base_url(); ?>data/insert',
data: dataString,
success: function(data) {
alert("data insert SuccessFully1");// I get this alert
var currentView = calendar.fullCalendar('getView');
calendar.fullCalendar('refetchEvents');
calendar.fullCalendar('changeView', currentView.name)
calendar.fullCalendar('unselect');
calendar.fullCalendar('refetchEvents');
$("#ginger").hide();
if(data.success){
alert("Data insert suceessfully 2");// i can't get this alert
}
}
});
});
},
});
});
</script>
CSS:
body {
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 70%;
margin: 0 auto;
}
#popup{
padding-left: 0%; padding-top:17%; display: block; top: 0; left: 37%; z-index:1007; opacity: 1; transform: scale(1);
height: auto;
overflow: auto;
position: absolute;
width:auto;
}
#data{
background-color: #ffffff;
color:#585858;
width:400px;
display:block;
z-index: 100;
padding:0px;
font-family: arial;
font-weight: bold;
border-radius: 7px 7px 0px 0px;
border:1px solid #C5C5C5;
}
#popup textarea{
width:200px;
height:60px;
border-radius: 5px;
vertical-align: top;
}
#detail{
/* display: none;*/
position:fixed;
top:0;
left:0;
z-index:1;
width:100%;
height:100%;
background-color:#000;
filter:alpha(opacity=50);
opacity:.5;
}
.mode{
width:99%;
background-color: #8DB3CC;
background-image:url("<?php echo base_url();?>assets/kendou/styles/textures/highlight.png");
background-position: 0 center;
background-repeat: repeat-x;
height:30px;
padding: 5px 0px 0px 5px;
font-size: 15px;
font-weight:normal;
border-bottom:1px solid #C5C5C5;
border-radius: 7px 7px 0px 0px;
}
.dropdown{
border-style: solid;
border-width: 1px;
padding: 2px 22px 2px 2px;
display: block;
cursor: default;
position: relative;
text-align: right;
line-height:1px;
border-radius: 2px 2px 2px 2px;
color: #2E2E2E;
border-color: #C5C5C5;
}
HTML :
<div class="wrapper">
<div id='calendar'></div>
<div style="display:none;" id="ginger">
<div id="detail"> </div>
<form name="addData" id="addData" action="" method="post">
<div id="popup">
<div id="data">
<div id="mode" value="" class="mode">
<!--<img src="<?php echo base_url();?>/assets/images/close.png" style="float:right;"/>-->
<img src="<?php echo base_url();?>/assets/images/logo.png">
</div><br>
<div style="padding:10px;">
<label for="timing">Timing: <span id="starting"></span> to <span id="ending"></span></label><br><br>
<label for="eventName">Description : </label>
<textarea name="eventName" id="eventName"type="text" value=""></textarea><br><br>
<label for="AgentName"><b>Agent Name*</b></label>
<input name="AgentName" id="AgentName"/>
<label for="UserName">UserName : </label>
<select name="UserName" id="UserName" value=""></select><br><br>
<input type="button"class="k-button" name="submit" id="submit" value="submit">//Changes here
<input type="reset" name="reset" class="k-button" id="reset" value="Reset">//changes here
<input type="button"class="k-button" name="cancel" id="cancel" value="Cancel">//changes here
</div>
</div>
</div>
</form>
</div>
</div>
You can combine getView and changeView:
//remember current view
var currentView = calendar.fullCalendar('getView');
calendar.fullCalendar('refetchEvents');
//set view type
calendar.fullCalendar('changeView', currentView.name)