Affichage des articles dont le libellé est Active questions tagged html - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged html - Stack Overflow. Afficher tous les articles

mercredi 5 août 2015

Tornado - why does static files without StaticFileHandler donot work?


I am new to Tornado. I am trying to link a CSS file to the html template. I am using jinja2 with Tornado. But due to some unknown reasons the CSS file is not loading up.

EDIT: I have created my custom render_template function which is working fine.

Here is my Request Handler's Class:

class Index(RequestHandler):
def get(self):
    path = os.path.join('static/css/', 'custom.css')
    return self.write(render_template('index.html', path = path))

and here is my index.html template:

<!Doctype html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="{{path}}"/>
  </head>
  <body>
    <div>
      <div class="header">
         asdasdasd
      </div>
    </div><!--wrapper-->
  </body>

</html>

but the browser is returning the 404-NotFound error for the css file with the correct url, that is http://localhost/static/css/custom.css



via Chebli Mohamed

How to make div in grid view be of 90% height of page


I want to create grid view, where header contains 10% height of the page and body 90%.

I have tried to adjust this, but body part does not grow when element section on right hand scales.

I want to add elements in right panel in responsive manner.

Is there any good way to organize this?

fiddle: http://ift.tt/1W1eZGO

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12" style="background-color:lavender;">
            <div class="header">Header Height should be 10% of the page</div>
        </div>  
    </div>

    <div class="row" >
        <div class="col-xs-8" style="background-color:lavenderblush; height:100%">Body, Height should be 90% of th page
        </div>
        <div class="col-xs-4" style="background-color:lavender;">
            <!-- 12 repeated rows as below, height should fit in 90% region in responsive manner -->
            <div class="row" >
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item1</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item2</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item3</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item4</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item5</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item6</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item7</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item8</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item9</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item10</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">Item11</div>
                </div>
                <div class="col-xs-6" style="background-color:lavender;">
                    <div class="element-box">item12</div>
                </div>
         </div>
     </div>
</div>

</body>



via Chebli Mohamed

How to add video to html using flash player


I want to add video which is of format (mp4) to my page using flash player (not html5). I have tried this using Flowplayer but I am not able to do this:

<html>
    <head></head>
    <body>
        <div class="flowplayer is-splash"
            data-engine="flash"
            data-swf="../dist/flowplayer.swf">
            <video src="http://ift.tt/1MNeWKX" preload="none"></video>
        </div>
    </body>
</html>

Can someone please explain this? I searched a lot experimented a lot but didn't get results.



via Chebli Mohamed

Accepting and displaying HTML tags in Spring MVC Blog application


I am building a custom Blog using Spring MVC. This will have an administration module, where the Blog owner can manage articles.

The owner should be able to add HTML tags, which should then later on be displayed on the articles when a user looks at them. I.e. the owner should be able to build up the article by inputting something like:

<p>This is displayed as a paragraph <b>and this in bold</b></p>

Which should then be later on be placed as "real" html code in the article placed by Thymeleaf.

So basically, I want to be able to display actual HTML tags using thymeleaf.

What are things I should take into consideration and does Spring MVC already offer something to mitigate any security implications (for example, against XSS in case my owner's account is hijacked)?



via Chebli Mohamed

Submit datepicker with ajax


i'm having issues with submiting my datepicker.

I use the code below to load my datepicker page and other 2 pages in the page i want.

in the below html i load 3 external pages and one of those is my datepicker. every time i submit the datepicker nothing happens.

if i don't load the page via ajax, when i click on submit the data is send successfully to the database.

What do i need to change in my javascript file so i can make this working.

Thanks

$(document).ready(function() {
    //initial
    $('#content').load('content/index.php');


    //handle menu click
    $('ul#nav li a').on('click', function() {
        var page = $(this).attr('href');
        //$('#content').load('content/'+ page +'.php');

        $.ajax({
            url: 'content/'+ page +'.php',
            context: document.body,
            success: function(response){
                $('#content').html(response);   
                console.log(response);      
            }
        });

        return false;
    });
});

<html>
    <head>
        <link rel="stylesheet" href="css/style.css" />
        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

        <script src="http://ift.tt/1E2nZQG"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
        <script src="js/general.js"></script>
    </head>
    <body>
        <div class="selector">
            <ul id="nav">
                <li><a href="index">Profil</a></li>
                <li><a href="planner">Planificare concediu</a></li>
                <li><a href="data">Usefull data</a></li>
                <li></li>
                <a href="logout.php">Logout</a>
            </ul>
            <div id="content"></div>    
        </div>

    </body>
<html>



via Chebli Mohamed

Detect if a textbox does not contain certain words


I want to know how to detect if a textbox does not contain certain words. For example if the textbox did not contain 'who', 'what', 'why', 'when' or 'where' some sort of function would run.

JavaScript:

function command() {
    var srchVar = document.getElementById("srch");
    var srch = srchVar.value;
    var t = srch;
    if (srch == '') {
        alert('Please do not leave the field empty!');
    }
    else if (srch.indexOf('time') != -1) {
        alert('The current time according to your computer is' + ShowTime(new Date()));
    }
    else if (srch.indexOf('old are you') != -1) {
        alert("I am as old as you want me to be.");
    }
    else {
        if (confirm('I am sorry but I do not understand that command. Would you like to search Google for that command?') == true) {
            window.open('http://ift.tt/1IMorZb' + srch, '_blank');
        }
        else { /* Nothing */ }
    }
}

HTML:

<!DOCTYPE html>
<html>
<head>
    <script src="script.js" type="text/javascript"></script>
    <link href="http://ift.tt/1f1Mm3V" rel="stylesheet">
    <script src="http://ift.tt/1dLCJcb"></script>
    <script src="http://ift.tt/1fJwIAs"></script>
</head>
<body>
    <div class="ui-widget">
        <input class="search-field" id="srch" onkeypress="searchKeyPress(event);" placeholder="ask me anything" spellcheck="false">
    </div>
</body>
</html>



via Chebli Mohamed

Trigger event on new line in contentediable div


I am trying to listen for an event that indicates a new line has been created in a contenteditable div. The purpose is to eventually show a user some options each time a new empty line is created and the caret is on that line, or if the user clicks the caret position to a currently empty line.

In my book there seem to be three events that would lead to the user being on a new line within a contentediable div:

  • pressing enter
  • pasting content that has a empty new line at the end
  • clicking the caret position to an empty line

of course in a contentediable div a new line means different things to different browsers, in chrome it seems to create <p></p> tags, but having browsed around SO enough it seems that other browsers might create <div></div> or perhaps another tag - <br/>

I've now tried to figure this out a couple of times and just have to get it done. Is it really the best way to listen for new elements being added under that div, and/or check if the caret position is currently within empty 'new line' tags. checking each time the caret moves seems highly inefficient - is there a better way to do this?

To summarise for tldr; people

  • is there a better way to check for new lines in contenteditable divs
  • how would i trigger an event based upon that efficiently

Just fyi this is within an Angular context and I have jQuery also.



via Chebli Mohamed

how to keep php output lines in one line


I just made a phone number to time zone converter and it displays result as:

Requested Phone No.: +1 732 78782722

Country: United States

Expected Region: Newark, New Brunswick

Timezone: America/New_York

Date: 2015-08-05

Time: 01:51:03 am

What I want to do is place all these outputs in a single line. Here's my output code

      if(!empty($record['country_name'])) {
            $this->display('<strong>Country:</strong> ' . $record['country_name']);
        }

        if(!empty($record['city'])) {
            $this->display('<strong>Expected Region:</strong> ' . $record['city']);
        }

        //echo json_encode($date); 

        if(!empty($record['zone_name'])) {
            $this->display('<strong>Timezone:</strong> ' . $record['zone_name']);
            $this->display('<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>');
            $this->display('<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>');
        }

Thanks for the help.



via Chebli Mohamed

Binding mouse events to dynamically created select


I have created select tag dynamically in jquery function. I want to bind the mouse events to it. I have dynamically created the selct tag

function loadValues()
{
var sel='<select id="flavor_slct'+index+'" class="popper" data-popbox="pop1"     

onclick="alert()">'+flavor_fetched_string+'</select>';
$("#attach").append(sel);

}

I have tried using the .on() jQuery function. Still events are not triggered.

$("body").on("hover","Select",function()
    alert("hovered");
)};

How should i bind events to dynamically created elements.?



via Chebli Mohamed

Copying a email will returns html [on hold]


I've created a list of different email links, however when i'm on the page trying to copy a email it will return email with the tags aswell is there any javascript code or something like this that can avoid this?



via Chebli Mohamed

Getting elements from table row within different tables with Javascript


i need help with returning some elements from tr with javascript(jquery)

Question 1. How can i reach td where is comment "i need to get to this item (based on question1)"? So i need to get last item with class "b" and first td that comes after it? Number of td's is not static. Classes b may not be in same table.

Question 2. Also if I want to select class "a" and give next 5 (for example) td's some class ("b" for example) how can i do it? Function nextAll can help but it will only get elements from single row.

Example is below:

<table>
<tr>
  <td></td>
  <td></td>
  <td class="a"></td>
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
</tr>
</table>

<table>
<tr>
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- i need to get to this item (based on question1) -->
  <td></td>
  <td></td> 
  <td></td>
</tr>
</table>

Thanks



via Chebli Mohamed

Javascript - Drag´n´Drop Script


At first here is my Fiddle:

So maybe it won´t work on Fiddle because the window size is too small. Here are the problems I have and I can´t solve after trying it for 8 days -.- . 1.Deactivate Drag option after once dropped: So once an item was dropped it shouldn´t be draggable anymore , so how is it possible to do this? 2.I can´t drop my items in the e.g. 6. or 7. row. 3.Everytime I try to add instead of a text in the header an image it won´t appear. 4.Also my footer doesn´t appear.

I hope someone can help me please, And sorry for my bad english :| Greetz



via Chebli Mohamed

Check if textbox contains a number


I'm currently working on a digital assistant website which is based around JavaScript and jQuery. The user can type in questions or tell the assistant things into the textbox and the assistant will respond with something relevant to the input. What I am planning to implement is to check if the textbox contains a number (intager) and if it does some sort of function will run. The concept sounds fairly simple and but I am having trouble. I have been searching around for a bit but I can't seem to find anything which will work with my code.

I will add my JavaScript and the nessacary parts of the HTML. But I am warning you, the code is messy.

JavaScript:

// JavaScript Document
function submitted() {
    var srch = document.getElementById("srch");
    command();
    getPlaceHolder();
    srch.value = "";
}

function searchKeyPress(e) {
    e = e || window.event;
    if (e.keyCode == 13) {
        //document.getElementById('btn').click();
        submitted();
    }
}

function goBtn() {
    submitted();
}

function refreshBtn() {
    getWelcome();
}

function stClock() {
    window.setTimeout("stClock()", 1000);
    today = new Date();
    self.status = today.toString();
}

function getWelcome() {
    var ar = new Array(20)
    ar[0] = "What's on your mind?";
    ar[1] = "How can I help?";
    ar[2] = "Anything you need help with?";
    ar[3] = "Ask me anything";
    ar[4] = "What can I help you with?";
    ar[5] = "What would you like me to do?";
    ar[6] = "What can I do for you?";
    ar[7] = "Need help with anything?";
    ar[8] = "Need someone to talk to?";
    ar[9] = "I'm here to help";
    ar[10] = "Anything you need to know?";
    ar[11] = "How else can I help?";
    ar[12] = "What can I do now?";
    ar[13] = "Need anything?";
    ar[14] = "Any problems you need solving?";
    ar[15] = "Hello, how do you do?";
    ar[16] = "Hi there";
    ar[17] = "Hi, I'm aurum";
    ar[18] = "Hello there";
    ar[19] = "How do you do?";
    var now = new Date();
    var sec = now.getSeconds();
    document.getElementById('output').innerHTML = ar[sec % 20];
}

function getPlaceHolder() {
    var ar = new Array(20)
    ar[0] = "What's on your mind?";
    ar[1] = "How can I help?";
    ar[2] = "Anything you need help with?";
    ar[3] = "Ask me anything";
    ar[4] = "What can I help you with?";
    ar[5] = "What would you like me to do?";
    ar[6] = "What can I do for you?";
    ar[7] = "Need help with anything?";
    ar[8] = "Need someone to talk to?";
    ar[9] = "I'm here to help";
    ar[10] = "Anything you need to know?";
    ar[11] = "How else can I help?";
    ar[12] = "What can I do now?";
    ar[13] = "Need anything?";
    ar[14] = "Any problems you need solving?";
    ar[15] = "Hello, how do you do?";
    ar[16] = "Hi there";
    ar[17] = "Hi, I'm aurum";
    ar[18] = "Hello there";
    ar[19] = "How do you do?";
    var now = new Date();
    var sec = now.getSeconds();
    document.getElementsByName('srch')[0].placeholder=ar[sec % 20];
}

function command() {
        var srchVar = document.getElementById("srch");
        var srch = srchVar.value;
        var t = srch;
        var outputElement = document.getElementById('output');
        if (srch == '') {
            outputElement.innerHTML = "How can I help you, if you don't say anything?";
        }
        else if (srch.indexOf('about') != -1) {
            outputElement.innerHTML = "Hello, I'm Aurum. I was designed by Omar Latreche to help people answer their questions. However, I also like to talk to people aswell as answer their questions.";
        }
        else if (srch.indexOf('time') != -1) {
            outputElement.innerHTML = 'The current time according to your computer is' + ShowTime(new Date());
        }
        else {
            if (confirm("I am sorry but for some reason I don't understand. You could either repeat that or would you like to search Google for that instead?") == true) {
                window.open('http://ift.tt/1ANNWBe' + srch, '_blank');
            }
            else { /* Nothing */ }
        }
    }
    //Show time in 12hour format
var ShowTime = (function() {
    function addZero(num) {
        return (num >= 0 && num < 10) ? "0" + num : num + "";
    }
    return function(dt) {
        var formatted = '';
        if (dt) {
            var hours24 = dt.getHours();
            var hours = ((hours24 + 11) % 12) + 1;
            formatted = [formatted, [addZero(hours), addZero(dt.getMinutes())].join(":"), hours24 > 11 ? "PM" : "AM"].join(" ");
        }
        return formatted;
    };
})();

And the HTML:

<!DOCTYPE html>
<html>
<body onload="getWelcome(); getPlaceHolder();">
    <div class="output" id="output">
        An error has occoured. Please make sure you have JavaScript enabled in your browser.
    </div>
    <div class="cont">
        <div class="ui-widget">
            <div class="search-cont">
                <input class="search-field" id="srch" name="srch" onkeypress="searchKeyPress(event);" placeholder="ask me anything" spellcheck="false"> <input class="refresh" onclick="refreshBtn()" title="Refresh the conversation" type="button"> <input class="go" onclick="goBtn()" type="button">
            </div>
        </div><br>
    </div>
</body>
</html>

I really appreciate any help provided. Thanks, Omar.

PS. I apologies for the long paragraph but that is the only way I could think to explain what I need.

PPS. If you need any more information on my project just incase, the URL is http://ift.tt/1InGUrg



via Chebli Mohamed

Will page automation with PhantomJS be lost after a page redesign?


I'm quite new to PhantomJS. I want to do page automation with PhantomJS to a web site by manipulating the HTML elements (for example: taking buttons/links by their IDs and triggering clicks) and going from one page to another and doing the same things.

What I was wondering is: This is actually a web system that is created and belongs to some company, so in the future if they decided to make a complete redesign to their system my whole work will be lost, since they will have completely new design with new HTML structure and new IDs of elements. Is that correct? Is there a way to handle this problem?



via Chebli Mohamed

Active menu Changer on Sticky Bar


I have designed a Parallax Page with Sticky Menu bar. I need to change the active menu on scrolling. I have made it to change the active class on Click event. But I need it to do for the scroll event.

Here is my HTML Code

<div class="main-menu">

    <ul>             
        <li><a class="active" href="#" data-delay="2000" data-appear="false" data-scrollto="#intro-slideshow">Home</a></li>
        <li><a href="#" data-delay="2000" data-appear="false" data-scrollto="#overview">Features</a></li>
        <li><a href="#" data-delay="2000" data-appear="false" data-scrollto="#categories">Categories</a></li>
        <li><a href="#" data-delay="2000" data-appear="false" data-scrollto="#contact">Contact Us</a></li>
    </ul>

</div>

Here is my JQuery Code for Onclick Active Menu Changer

$('*[data-scrollto]').click(function(){

        $( "a" ).removeClass( "active" );
        $(this).addClass("active");

        var dest = $(this).data('scrollto');                
        var pixels = $(dest).offset().top - 70;         
        var ms = Math.round(1000 + pixels/5);

        $('html, body').animate({               
            scrollTop: pixels
        }, ms, 'easeOutQuint');

    }); 

How do I change the active class on Scroll Event with the Data-Scrollto attribute ?



via Chebli Mohamed

Edit and Save Pivot Table in Database in ASP.NET


I want to create an ASP.Net web page which will have one DropDownList control and upon changing the selection of it. Pivot table should be created. The Column Headers and Row Headers of this table should come from Database. The values shown in this table will also be retrieved from Database with respect to the corresponding Column Header and Row Header. This table values should be editable and upon "SAVE" button click the Data in values should be saved in database for corresponding Column Header and Row Header. example:

           |   Lot1   |   Lot2  |   Lot3 |  ...
---------------------------------------------
Product1   |    100   |  2000   |   3000 |  ...
---------------------------------------------
Product2   |    1000  |  3000   |   4000 |  ...
---------------------------------------------
Product3   |    3500  |  6000   |   4500 |  ...
---------------------------------------------

. . These values should be editable and upon save button click these should save in database with respect to Lot number and Product.



via Chebli Mohamed

Change style of element which appears directly before another element on the same level


My issue is as follows: I've got a navigation bar with main navigation and some of these links have additional drop down menus. I'm trying to change the styling of the main link, whenever I hover over the drop down menu. I can't use classes as it will change the style of all the main nav links. Which means I can't use the following method

.dropdown:hover ~ .main{
    change css here
}

I also can't use individual IDs for the linked drop down and main nav as it appears on too many pages already.

The format of the HTML is as follows

<a class="main-link">Main Link</a>
<div class="drop-down"></div>

My question is; is there a way to change the style of an element which appears directly before an element within a HTML document?



via Chebli Mohamed

How to remove � sign from whole site in wordpress


I have uploaded wordpress site on live , then the one "�" sign is being appearing in between content , but it is fine in local. How to remove please suggest me ? I am not able fix the problem.

Example - Frédèric becomes Fr�d�ric.



via Chebli Mohamed

How to automatically sum input value boxes on each row in a HTML table


I have an HTML table with columns of input boxes(Quantity, Price, Discount and Total). I made a JS function for adding as many rows as I need. I would like to make the Total column, for each row, to display automatically the value of this formula:

(Quantity * Price) - ( Quantity * Price * (Discount/100)) .

I tried numerous JavaScript code, but I have been unable to get anything to correctly work.

HTML:

<table id="myTable">
<tr>
<th width="65%"></th>
<th align="center" width="5%">Q<br>-ty</th>
<th align="center" width="10%">Price,</br>$</th>
<th align="center" width="5%">Discount,<br>%</th>
<th align="center" width="15%">Total, $<br>(Without tax)</th>
</tr>
<tr>
<td width="65%"><input class="Left" size="100" type="text" name="Description"></td>
<td align="center" width="5%"><input type="number" name="quantity" min="1" max="99"></td>
<td align="center" width="10%"><input type="number" name="summ" min="0" max="999999"></td>
<td align="center" width="5%"><input type="number" name="rate" min="0" max="100"></td>
<td align="center" width="15%"><input align="center" type="number" name="total" min="0" max="99999999"></td>
</tr>
</table>
<button onclick="addRow()">Add Row</button>

Javascript:

function addRow() {
    var table = document.getElementById("myTable");
    var row = table.insertRow();
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    var cell3 = row.insertCell(2);
    var cell4 = row.insertCell(3);
    var cell5 = row.insertCell(4);
    cell1.innerHTML = "<input class=\"Left\" size=\"100\" type=\"text\" name=\"Description\">";
    cell2.innerHTML = "<div align=\"center\"><input type=\"number\" name=\"quantity\" min=\"1\" max=\"99\"></div>";
    cell3.innerHTML = "<div align=\"center\"><input type=\"number\" name=\"summ\"  min=\"0\" max=\"999999\"></div>";
    cell4.innerHTML = "<div align=\"center\"><input type=\"number\" name=\"rate\"  min=\"0\" max=\"100\"></div>";
    cell5.innerHTML = "<div align=\"center\"><input type=\"number\" name=\"total\" min=\"0\" max=\"99999999\"></div>";
}

My code on FIDDLE.



via Chebli Mohamed

How to prevent an iframe to display external websites?


Let's say I display an iFrame on iframe.domain.com. I want this iframe to be able to display content from iframe.domain.com or sub.domain.com. But those websites contain link to external websites, for example google.com. If the users clicks on a link redirecting him to google.com, I want the iFrame to be redirected to sub.domain.com

How can I do that?



via Chebli Mohamed