c() function in javascript, meaning? - javascript

I was looking through the source code of a web page, and I came across this JavaScript:
function fsb329142055() {
var b=new Array(57,50,102,50,52,99,50,53,52,56,102,98,102,98,101,102,101,49,53,61,101,99,110,57,111,78,109,54,114,111,56,48,102,38,100,53,100,53,48,50,55,52,49,55,57,50,52,51,98,53,56,61,100,99,100,55,73,116,97,53,53,115,105,108,100,55,116,105,104,38,53,116,104,38,103,104,105,102,61,61,98,110,111,105,116,99,97,38,112,50,51,104,112,46,116,50,104,99,103,105,56,102,51,61,98,50,53,51,49,56,97,101,57,116,54,49,63,100,52,97,100,112,104,97,112,46,116,115,102,56,51,105,108,98,52,116,52,53,105,104,100,97,47,101,98,98,52,100,97,57,99,99,54);
var p=new Array(0,0,1,1,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,0,1,0,1,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,1,1,0,1,1,1,1,0,0,0,1,1,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0);
window.location = c(b,p);
return false;
}
This function is called here:
<a href="/hitlist.php?tab=fight.php&action=fight&hitlistId=329142055&formNonce=1eb542f92c248ffbfe59680dd774b58dc7a55d75&h=284e4fe4946e6fb8af3a662f4583454eebc8bd23" onclick="return fsb329142055();">
<div class="fightActionInner"><div class="fightActionInnerInner">Attack</div> </div>
</a>
Specifically, I'm wondering what the window.location = c(b,p); is.
People are saying it is a function, but I dont see it anywhere in the source code:
`
<link rel="stylesheet" type="text/css" href="http://static.storm8.com/im/css/global.css?v=330"/>
<script type="text/javascript" src="http://static.storm8.com/im/js/global.js?v=330"></script> <script type="text/javascript" src="http://static.storm8.com/im/js/equipment.js?v=330"></script> <title>Add the Hit List</title>
<script>
function s8Ajax(url) {
window.location.href = url;
}
</script>
</head>
<body style="; width: 100%;" class="portrait" data-promo-button="">
<div id="fb-root"></div>
<div id="contentParent">
<div id="contentChild" style="">
<div id="SCROLL_CONTENT"><div id="scrollContentChild"><div>
<div id="overlay" class="dialogOverlay"></div>
<script type="text/javascript">
window.isAndroid = false;
window.isFacebook = false;
</script>
<div id="topBar" class="topBar"><div class="topBarBg"></div><div id="inner-topbar"><a href="/bank.php?formNonce=81668c46988c486ed2d1d0b1f7e31f16d41c093c&setTab1Badge=&h=da793b290e598f2e0823e93dbab769b0736a7557"><div class="cashTopArea">
<span class="topBarCash">$<span id="cashCurrent" style="white-space:nowrap">138,136,907</span></span>
</div>
<div id="cashTimerDiv" class="cashBottomArea"><span style="font-size: 11px; font-weight: normal;"><span>+<span style="white-space: nowrap;">255,350</span></span> in </span><span id="cashType" style="font-size:11px;font-weight:normal;">59:05</span></div></a><div class="levelTopArea">
<div class="levelBgTopArea"></div>
<div class="levelFrontTopArea"><a style="text-decoration:none" href="/profile.php?formNonce=81668c46988c486ed2d1d0b1f7e31f16d41c093c&setTab1Badge=&h=dc3aa8ea9e33fff4ea763e4556ad5e0ca2718a3b">31</a></div>
</div>
<div class="levelBottomArea">
Level
</div><div class="levelBarTopArea">
<div class="levelBar" style="width:90px">
<div class="bgLevelBar" style="width:90px"><div id="expBar" class="frontLevelBar" style="width:36px"> </div>
</div>
</div>
</div>
<div class="levelBarBottomArea">
Exp: <span id="expText">5793/5993</span>
</div>
<a href="/favor.php?"><div class="energyAreaContainer"><table class="statTable"><tr><td class="statTableIcon"><div></div></td>
<td class="statTableInBetween"></td>
<td class="statTableInfo">
<div class="statTopArea">
<span id="energyCurrent" class="statEmphasis">75</span> / <span id="energyMax">75</span></div>
<div id="energyTimerDiv" class="statBottomArea"><span id="energyType" style="font-size:11px;font-weight:normal;">Energy</span></div></td></tr></table></div></a>
<a href="/hospital.php?"><div class="healthAreaContainer"><table class="statTable"><tr><td class="statTableIcon"><div></div></td>
<td class="statTableInBetween"></td>
<td class="statTableInfo">
<div class="statTopArea">
<span id="healthCurrent" class="statEmphasis">100</span> / <span id="healthMax">100</span></div>
<div id="healthTimerDiv" class="statBottomArea"><span id="healthType" style="font-size:11px;font-weight:normal;">Health</span></div></td></tr></table></div></a>
<a href="/favor.php?"><div class="staminaAreaContainer"><table class="statTable"><tr><td class="statTableIcon"><div></div></td>
<td class="statTableInBetween"></td>
<td class="statTableInfo">
<div class="statTopArea">
<span id="staminaCurrent" class="statEmphasis">5</span> / <span id="staminaMax">5</span></div>
<div id="staminaTimerDiv" class="statBottomArea"><span id="staminaType" style="font-size:11px;font-weight:normal;">Stamina</span></div></td></tr></table></div></a></div><script>
setTopBarTimerData({"cash":{"page":"\/bank.php?","text":"Cash","timeLeft":3545,"value":138136907,"maxValue":999999999999,"rate":3600,"update":255350},"energy":{"page":"\/favor.php?","text":"Energy","timeLeft":-1,"value":75,"maxValue":"75","rate":240,"update":1},"health":{"page":"\/hospital.php?","text":"Health","timeLeft":-1,"value":100,"maxValue":"100","rate":180,"update":1},"stamina":{"page":"\/favor.php?","text":"Stamina","timeLeft":-1,"value":5,"maxValue":"5","rate":120,"update":1},"experience":{"width":90,"value":"5793","previousLevelValue":5658,"nextLevelValue":5993}});
createTopBarTimer();
</script></div></div><link rel="stylesheet" type="text/css" href="http://static.storm8.com/im/css/bounty.css?v=330"/>
<div class="section">
<div class="sectionHeader">
Add "Raͭgͪnͤa͠rok" to the Hit List</div>
<div class="sectionBar"></div><div class="sectionContent">
<script>
function fsb10213841(x) {
var b=new Array(49,100,50,100,100,48,98,101,54,49,102,56,55,101,52,99,56,56,57,51,54,52,49,99,56,102,49,54,100,54,54,52,49,49,56,99,61,101,99,110,48,111,78,57,51,99,38,109,104,61,114,50,50,51,111,102,38,57,52,49,52,51,57,102,56,51,49,98,51,50,50,51,57,48,49,61,51,48,48,54,100,105,95,53,57,116,51,97,57,99,97,115,56,57,54,105,54,108,51,116,105,51,49,49,101,48,99,104,54,100,63,112,104,112,46,121,116,110,117,111,98);
var p=new Array(1,1,1,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1,0,1,1,0,0,0,0,1,1,0,1,0,1,0,1,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,0,0,1,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1);
var bountyForm = document.getElementById('bountyForm');
bountyForm.action = c(b,p) + x;
return true;
}
</script>
<form id="bountyForm" method="post" onsubmit="return fsb10213841('373');" action="/bounty.php?hitlist_id=10213841&formNonce=81668c46988c486ed2d1d0b1f7e31f16d41c093c&h=284e4fe4946e6fb8af3a662f4583454eebc8bd23">
<ul>
<li>The minimum bounty amount is <span style="white-space: nowrap;">$10,000</span>.</li>
<li>A 15% fee will be charged to safeguard the bounty.</li>
</ul>
<br/>
<table>
<tr>
<td class="bountyLabel">Bounty Amount:</td>
<td>
<input type="text" name="bountyValue" size=25 class="medTextField"> <br/>
<div style="height:6px"> </div>
<input type="submit" value="Place Bounty" name="action" class="btnMed btnBroadcast">
</td>
</tr>
</table>
</form>
</div>
</div>
</div></div><br/><br/><script> window.onload = function() { window.location.href = "#&setTab0Badge=&changeApplicationBadge=0&setTab4Badge=1";}</script></div></body></html>

In the HTML you provided, you'll see the following tag:
<script type="text/javascript" src="http://static.storm8.com/im/js/global.js?v=330"></script>
Go to http://static.storm8.com/im/js/global.js?v=330 and you'll find the following function definition:
function c(b,p) {
a='';s=String.fromCharCode;
for(i=0;i<b.length;i++) {if(p[i])a=s(b[i])+a;else a+=s(b[i]);}
return a;
}

This function is located in the included javascript files in head
http://static.storm8.com/im/js/global.js?v=330
line no: 411 and function code is as follow:
function c(b,p) {
a='';s=String.fromCharCode;
for(i=0;i<b.length;i++) {if(p[i])a=s(b[i])+a;else a+=s(b[i]);}
return a;
}

Related

URL display:none;

I have this code, for some reason when I try to access it with a link (http://127.0.0.1:5501/111.html?textarea=2&p=2) the textarea part remains the same, I'm probably doing something wrong, but I'm not sure how to fix it.
When I open the link I want to see textarea 2 and p 2 visible, the rest should be hidden.
Here is the code in case someone from the forum can help:
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="stylechat.css">
<meta charset="UTF-8">
<title>Support</title>
<meta http-equiv="Content-Type">
</head>
<body data-new-gr-c-s-check-loaded="14.1022.0" data-gr-ext-installed="">
<!-- nav -->
<div class="navbar">
<div class="container">
<a class="logo" href="./index.html">Ho<span>me</span></a>
</div>
</div>
<!-- nav -->
<!-- info -->
<div class="textinfo">
<p class="menus" id="dsk1"><span>AAA:</span><br>
One:<br><br>
1. test<br>
2. test<br></p>
</div>
<div class="textinfo">
<p class="menus" id="dsk2"><span>AAA:</span><br>
Two:<br><br>
1. test<br>
2. test<br></p>
</div>
<!-- info -->
<!-- text -->
<div class="textniz">
<textarea id="myInput1" class="one" name="myInput1" readonly>
One
One
One</textarea>
</div>
<div class="textniz">
<textarea id="myInput2" class="two" name="myInput2" readonly>
Two
Two
Two</textarea>
</div>
<div class="textniz">
<textarea id="myInput3" class="three" name="myInput3" readonly>
Three
Three
Three</textarea>
</div>
<div class="textniz">
<textarea id="myInput4" class="four" name="myInput4" readonly>
Four
Four
Four</textarea>
</div>
<div class="textniz">
<textarea id="myInput5" class="five" name="myInput5" readonly>
Five
Five
Five</textarea>
</div>
<div class="textniz">
<textarea id="myInput6" class="six" name="myInput6" readonly>
Six
Six
Six</textarea>
</div>
<div class="textniz">
<textarea id="myInput7" class="seven" name="myInput7" readonly>
Seven
Seven
Seven</textarea>
</div>
<div class="textniz">
<textarea id="myInput8" class="eight" name="myInput8" readonly>
Eight
Eight
Eight</textarea>
</div>
<!-- text -->
<!-- scr -->
<div class="scrn" id="scrn">
<img src="/Screenshot_1.png" alt="" class="image1"></img>
<img src="/Screenshot_2.png" alt="" class="image2"></img>
<img src="/Screenshot_3.png" alt="" class="image3"></img>
<img src="/Screenshot_5.png" alt="" class="image4"></img>
</div>
<!-- scr -->
<!-- button -->
<button onclick="showscr(1)" id="scr1" class="scron1"></button>
<button onclick="showscr(2)" id="scr2" class="scron2"></button>
<button onclick="Copytextfunction(1)" id="menucopy1" class="menucopy1"></button>
<button onclick="Copytextfunction(2)" id="menucopy2" class="menucopy2"></button>
<button onclick="Copytextfunction(3)" id="menucopy3" class="menucopy3"></button>
<button onclick="Copytextfunction(4)" id="menucopy4" class="menucopy4"></button>
<button onclick="Copytextfunction(5)" id="menucopy5" class="menucopy5"></button>
<button onclick="Copytextfunction(6)" id="menucopy6" class="menucopy6"></button>
<button onclick="Copytextfunction(7)" id="menucopy7" class="menucopy7"></button>
<button onclick="Copytextfunction(8)" id="menucopy8" class="menucopy8"></button>
</div>
<!-- button -->
<!-- script -->
<script>
// Get textarea from url parameters
const urlParams = new URLSearchParams(window.location.search);
let textarea = urlParams.get('textarea')
function show(textarea) {
for (let check = 1; check <= 8; check++) {
document.getElementById('myInput' + check).style.display = "none";
document.getElementById('menucopy' + check).style.display = "none";
}
document.getElementById('myInput' + textarea).style.display = "block";
document.getElementById('menucopy' + textarea).style.display = "block";
}
let p = urlParams.get('p')
function show(p) {
for (let check = 1; check <= 2; check++) {
document.getElementById('dsk' + check).style.display = "none";
document.getElementById('dsk' + check).style.display = "none";
}
document.getElementById('dsk' + p).style.display = "block";
document.getElementById('dsk' + p).style.display = "block";
}
function Copytextfunction(textarea) {
var value = document.getElementById('myInput' + textarea).value;
var copyText = document.createElement("textarea");
copyText.value = value;
copyText.style.position = "fixed";
copyText.style.top = "-1000vh";
document.body.append(copyText);
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
console.log(value);
copyText.remove();
}
// Run the hide function with the textarea number from parameters
if (textarea) {
show(textarea);
}
if (p) {
show(p);
}
</script>
<!-- script -->
</body>

Add span class according to url

I have a span attribute and need to insert a class to force hide it if it is inside a url, I want to do it in javascript entirely.
Code i'm doing
function exec()
{
url = window.location.href;
if(url == "https://www.myurl.com.br/product")
{
$("span .price").addClass("force-hide");
}
}
Html code
<div class="info-details">
<strong class="product name product-item-name">
<a class="product-item-link" href="https://www.myurl.com.br/product"> Long Drink Unicórnio Seja Você </a>
</strong>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="2293" data-price-box="product-id-2293">
<span class="price-container price-final_price tax weee">
<span id="product-price-2293" data-price-amount="13.9" data-price-type="finalPrice" class="price-wrapper ">
<span class="price">R$13,90</span>
</span>
</span>
</div></div>
I want to make sure that if it is in the indicated url, add a force-hide class in the span price attribute.
Note that className is a single string. If you're adding more than one class they need to be separated with spaces.
<html>
<body>
<div id="price">price</div>
<script type="text/javascript">
let url = window.location;
if( url == "https://your.domain.here"){
document.getElementById('price').className += 'hide';
}
</script>
</body>
</html>
I have added an event listener to wait for the DOM to be ready.
Hope this works now.
document.addEventListener('DOMContentLoaded', () => {
if(window.location.href === "https://www.myurl.com.br/product") {
document.querySelector('span.price').classList.add('force-hide');
}
});
.force-hide {
display:none;
}
<div class="info-details">
<strong class="product name product-item-name">
<a class="product-item-link" href="https://www.myurl.com.br/product"> Long Drink Unicórnio Seja Você </a>
</strong>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="2293" data-price-box="product-id-2293">
<span class="price-container price-final_price tax weee">
<span id="product-price-2293" data-price-amount="13.9" data-price-type="finalPrice" class="price-wrapper ">
<span class="price">R$13,90</span>
</span>
</span>
</div>
</div>
$(document).ready(function ()
{
exec();
function exec()
{
url = window.location.href;
if(url == "https://www.myurl.com.br/product")
{
$("span.price").addClass(" force-hide");
}
}
});
.force-hide{
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html lang="en">
<head></head>
<body>
<div class="info-details">
<strong class="product name product-item-name">
<a class="product-item-link" href="https://www.myurl.com.br/product"> Long Drink Unicórnio Seja Você </a>
</strong>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="2293" data-price-box="product-id-2293">
<span class="price-container price-final_price tax weee">
<span id="product-price-2293" data-price-amount="13.9" data-price-type="finalPrice" class="price-wrapper ">
<span class="price">R$13,90</span>
</span>
</span>
</div></div>
</body>
</html>
Basically you are missing a space inside addClass method, and the calling method exec().
<html lang="en">
<head>
<style type="text/css">
.force-hide{
display: none;
}
</style>
</head>
<body>
<div class="info-details">
<strong class="product name product-item-name">
<a class="product-item-link" href="https://www.myurl.com.br/product"> Long Drink Unicórnio Seja Você </a>
</strong>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="2293" data-price-box="product-id-2293">
<span class="price-container price-final_price tax weee">
<span id="product-price-2293" data-price-amount="13.9" data-price-type="finalPrice" class="price-wrapper ">
<span class="price">R$13,90</span>
</span>
</span>
</div></div>
<script type="text/javascript" src="jquery/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
exec();
function exec()
{
url = window.location.href;
if(url == "https://www.myurl.com.br/product")
{
$("span.price").addClass(" force-hide");
}
}
});
</script>
</body>
</html>

Variable incrementation is not working

I have a button in HTML, and I want to increase a JavaScript variable value when clicked:
<a id="right-btn" onclick="increasePokemon_ID()">
Here is the script:
var pokemon_ID = 1;
function increasePokemon_ID() {
pokemon_ID++;
}
I also tried this way, but none of them worked:
document.getElementById("right-btn").onclick = function() {
increasePokemon_ID();
}
The value is outputted in this div:
document.getElementById("id-number").innerHTML="no. 00" + pokemon_ID;
<div id="id-number"></div>
What is wrong in the code?
Full code:
<?php
require 'database.php';
$id = null;
if ( !empty($_GET['id'])) {
$id = $_REQUEST['id'];
}
if ( null==$id ) {
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM pokemons where id = ?";
$q = $pdo->prepare($sql);
$q->execute(array($id));
$data = $q->fetch(PDO::FETCH_ASSOC);
Database::disconnect();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="pokedex">
<div id="left">
<div id="top-left">
<div id="top-leds">
<div id="top-red-led"></div>
<div id="top-yellow-led"></div>
<div id="top-green-led"></div>
</div>
</div>
<div id="led"></div>
<div id="left-triangle"></div>
<div id="screen-border">
</div>
<div id="screen">
<div class="name"><?php echo $data['name'];?></div>
</div>
<div id="cross">
<div id="center">
<div id="cross-center">
<div id="center-circle"></div>
</div>
<div id="up-btn">
<div id="upAr"></div>
</div>
<a id="right-btn" onclick="increasePokemon_ID()">
<div id="rightAr"></div>
</a>
<div id="left-btn">
<div id="leftAr"></div>
</div>
<div id="down-btn">
<div id="downAr"></div>
</div>
</div>
</div>
<div id="id-number"></div>
<div id="blue-btn"></div>
</div>
<div id="middle">
<div id="charniere-haute"></div>
<div id="charniere-basse"></div>
</div>
<div id="right">
<div id="info-screen"></div>
<div id="right-triangle"></div>
<div id="left-arrow-button">
<div id="left-arrow"></div>
</div>
<div id="right-arrow-button">
<div id="right-arrow"></div>
</div>
<div id="keyboard">
<div class="top-key"></div>
<div class="top-key"></div>
<div class="top-key"></div>
<div class="top-key"></div>
<div class="top-key"></div>
<div class="bottom-key"></div>
<div class="bottom-key"></div>
<div class="bottom-key"></div>
<div class="bottom-key"></div>
<div class="bottom-key">Help</div>
</div>
<div id="type-display1"><?php echo $data['type'];?></div>
<div id="type-display2"></div>
</div>
</div>
<script>
var pokemon_ID = 0;
function increasePokemon_ID() {
pokemon_ID++;
document.getElementById("id-number").innerHTML="no. 00" + pokemon_ID;
}
document.getElementById("right-btn").onclick = function() {
increasePokemon_ID();
}
</script>
</body>
</html>
The value is actually being incremented, but you're not showing the updated value to the div.
Try this:
var pokemon_ID = 0;
var el = document.getElementById("id-number");
function increasePokemon_ID() {
pokemon_ID++;
el.innerHTML = "no. 00" + pokemon_ID;
}
<a id="right-btn" onclick="increasePokemon_ID()">
<div id="id-number">0</div>
This is because you are not updating the HTML on click, but just updating the value of a variable. You can add the document.getElementById("id-number").innerHTML="no. 00" + pokemon_ID; to your onclick function or to the increasePokemon_ID function.

How to delay page set Interval if the user still input text

I am trying to build a social network site and in order for post's to keep on updating I've set an interval time of 20 seconds so it refreshes the page and show's new comments and or post's.
My problem now is that when a user is trying to input a comment in my form, the page is running through the interval and as soon as it hit's 20 seconds the page refreshes and the text input deleted.
I want to set the interval function so that it will start counting if no one had typed anything anywhere in the page for about 10 seconds.
I can't give an input ID since the comment's are bound to post's and by that do not have a static ID for reference.
Is there a way to do what I just described?
that's the code of the page I want to stop the interval temporarily:
<?php
session_start();
if(!isset($_SESSION['login_user'])){ // check whether a session is set or not
header('Location: registrationPage.php'); // Redirecting To Registration Page
}
include 'connectDB.php';
$FN = $_SESSION['login_user'];
$result = mysqli_query($conn, "SELECT concat(U.firstName,' ',U.lastname) as fullName FROM tblUser U where U.userName='$FN'");
while($row = mysqli_fetch_array($result)){
$UN = $row['fullName'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Main page">
<meta name="author" content="Sorokina E. and Menaker T.">
<title>Main page</title>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<href='https://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../files/connection.json" type="text/jason"></script>
<script src="../files/positions.json" type="text/jason"></script>
<script src="../files/messages.json" type="text/jason"></script>
<link rel="stylesheet" type="text/css" href="../css/mystyle.css">
<script src="../js/typeahead.min.js"></script>
</head>
<body>
<div class="row alignT bg_color7">
<div class="col-sm-1">
<img class="img-responsive" src="../images/logo.gif" alt="">
</div>
<div class="col-sm-1">
<?php
if(isset($_SESSION['login_user'])){
echo '<span >Welcome ' . $UN. '! </span>';
}
?>
</div>
<div class="col-sm-1">
<span class="glyphicon glyphicon-home"></span>
</div>
<div class="col-sm-1">
<span class="glyphicon glyphicon-user"></span>
</div>
<div class="col-sm-1 " data-toggle="tooltip" title="My connections" >
<button id="NL" class="Tbutton " type="button">
<span class="glyphicon glyphicon-globe " style="vertical-align:middle; " ></span>
</button>
<div id="NC" class="notificationContainer">
<div id="NT" class="notificationTitle">My friends:</div>
<div id="NB" class="notificationsBody forConnection">
<?php include ('selectAllFriends.php');?></div>
<div id="NF" class="notificationFooter">See All</div>
</div>
</div>
<div class="col-sm-2 ">
<span > <input id="search" name="typehead" class="typeahead" data-provide="typeahead" placeholder="Search people" ></input></span>
</div>
<div class="col-sm-1 mm">
<span><input type="button" onclick="location.href = 'allUsersPage.php';" class="btn btn-info" value="All people" ></span>
</div>
<div class="col-sm-1 " data-toggle="tooltip" title="My messages" >
<button id="NL1" class="Tbutton " type="button">
<span class="glyphicon glyphicon-envelope" style="vertical-align:middle; " ></span>
</button>
<div id="NC1" class="notificationContainer">
<div id="NT1" class="notificationTitle">My Messages:</div>
<div id="NB1" class="notificationsBody forMessages">
<?php include ('selectAllMessages.php');?></div>
<div id="NF1" class="notificationFooter">See All</div>
</div>
</div>
<div class="col-sm-2 " data-toggle="tooltip" title="My notifications" >
<button id="NL2" class="Tbutton " type="button">
<span class="glyphicon glyphicon-flag" style="vertical-align:middle; " ></span>
</button>
<div id="NC2" class="notificationContainer">
<div id="NT2" class="notificationTitle">My Notifications:</div>
<div id="NB2" class="notificationsBody forNotifications"></div>
<div id="NF2" class="notificationFooter">See All</div>
</div>
</div>
<div class="col-sm-1">
<span class="glyphicon glyphicon-log-out"></span>
</div>
</div>
<div class="row">
<p class="alignW"><input class=" col-sm-5" type="text" name="mind" id="textField9" placeholder="Share your mind">
<span class=" col-sm-1"></span> <input type="button" id = "btn_submit" class="btn btn-info col-sm-1" value="Add post" ></p>
</div>
<div class="row" id="middle">
<div class="col-sm-8" id="left">
<?php include ('selectAllPosts.php'); ?>
</div>
<div class="col-sm-4" id="right">
<?php include ('select5Positions.php'); ?>
</div>
</div>
<!--Footer-->
<footer class="container-fluid text-center">
<p class="glyphicon glyphicon-copyright-mark"> Created by ... </p>
</footer>
<script>
$(document).ready(function(){
var timer = null;
function autoRefresh_div()
{
$('#left').load("selectAllPosts.php");// a function which will load data from other file after x seconds
}
$(document.body).keydown(function(event){
clearTimeout(timer);
timer = setTimeout(setInterval(function(){ autoRefresh_div() }, 20000), 5000);
});
$("#btn_submit").click(function(){
var userName='<?php echo $FN; ?>';
var content = $('#textField9').val();
var postData = '&uname='+userName+'&content='+content;
$.ajax({
url : "insertPost.php",
type: "POST",
data : postData,
success: function(data,status, xhr){
if(data==="You have successfully posted!"){
$('#textField9').val('');
}
if(data==="ERROR"){
$('#textField9').val('');
}
}
});
});
$('#search').typeahead( {
name:'typehead',
remote: 'selectAllUsers.php?query=%QUERY'
});
//search for all users and go to their pages
$('#search').on('typeahead:selected', function(evt, item){
window.location.href = "userPage.php?fullName="+item.value;
});
$.getJSON("../files/notifications.json",function(result){
$.each(result, function (index, value) {
$(".forNotifications").append("<div class=\"divStyle1\">" +value.Notification + "</div>");
});
});
$("#NL").click(function(){
$("#NC2").hide();
$("#NC1").hide();
$("#NC").fadeToggle(300);
return false;
});
$("#NL1").click(function(){
$("#NC").hide();
$("#NC2").hide();
$("#NC1").fadeToggle(300);
return false;
});
$("#NL2").click(function(){
$("#NC").hide();
$("#NC1").hide();
$("#NC2").fadeToggle(300);
return false;
});
$('#myButton').click(function (){
$(this).hide();
}
);
});
</script>
</body>
</html>
Thank you.
Tom
There are multiple ways you could do this either by making an AJAX Request to retrieve new data or even use Websockets (Which is the most efficient). However, the simplest approach to fixing your problem would be to create a timer via JS when the page loads.
<!-- Element -->
<input type="text" data-ui="post"/>
<!-- Script -->
<script>
$(document).ready(function(){
var timer = null;
function startTimer() {
timer = setInterval(function() {
window.location.reload();
}, 1000);
}
// Stop timer by clearing with interval when
// the user focuses on the element
$('[data-ui]').on('focus', function() {
clearInterval(timer);
});
// Start the timer once the user has blurred away from
// the element
$('[data-ui]').on('blur', function() {
startTimer();
});
// Start the timer as the page has finished loading
startTimer();
})
</script>
The basically stops the window location.reload timer once the user has focused an element that has a [data-ui] attribute tag attached to it. Another method would be to save your inputs content with LocalStorage and reinsert the content into the input box once the page has reloaded.
Let me know if you need a jQUERY'less version.

Capturing the output of a JavaScript function

Using C#, PowerShell and Jsoup I've tried to capturing the percentage that is displayed at the end, 99.96%. Using the DOM explorer in IE, this is what I see:
<!DOCTYPE html>
<html>
<body id="website#22;page">
<div id="wrap">
<script type="text/javascript">...</script>
<div class="topRow" id="iTopRow">...</div>
<div id="header">...</div>
<div id="content">
<div class="paddingfix">
<script type="text.javascript">...</script>
<div class="toppaddingfix"></div>
<div title="Summary Percentage"
class="overallPercentage">
<div>
<div style="padding-bottom: 12px;">
<div class="textRegionContainer" id="iTextRegion_D14">
<div class="position" style="display: none;"<>/div>
<div class="status" style="display: none;">loaded</div>
<div class="textRegionPlaceHolder">
<p class="textRegionTitle">
99.96 %
</p>
</div>
</div>
</div>
However, when programmatically trying to capture it I receive this:
<div id="iTextRegion_DR14" class="textRegionContainer">
<script type="text/javascript">
$(document).ready(function() {
var client = new wLive.Service.Client(false);
var textRegion = new wLive.Controls.TextRegion(
'Tools',
'AppServerOutDetails3',
'DR14',
'#iTextRegion_DR14',
{"id":"DR14","data":null,"paragraphs":["<bindingref
name=\"Reliability\" \/> %\u000d\u000a "],"style":0},
client);
wLive.Controls.DataBridge.registerDataRegion('#iDataBridge', textRegion);
});
</script>
</div>
How do I programmatically capture that percentage so I can then have another program evaluate it's value?

Categories

Resources