Mobile and Tablet Devices Review

Cyber Living posts the specifications or details of the latest mobile phones and tablets with some thought comments on the device You can find them by clicking the MOBILE?TSBLET DEV on the menu bar above. Or you can click this link Mobile and Tablet Devices

Computer Problems Solutions

For personal computer/notebook problems and tips, refer to PC PROB from the menu or click this link Personal Computer Problem Solutions.

What's in the world with Philippine ISPs

Discussions about Philippine Internet Service Providers (ISPs) particularly problems users are encountering but are not getting any solutions.

  • Tips or work around to these problems to improve browsing experience.
  • Do you have any problems too? Give your comments below each of the posts to be heard.
  • Or better yet, send me a message on our contact form if you want a dedicated article to your problem on this site.
  • Bloggers and Webmasters tips/tricks

    Looking for something to implement to your site? Our Bloggers' tips/tricks have what you need. If you do not find it there, notify us through our contact form.

    SEO Tips

    Tips to improve your rankings on Search Engine Resuts Pages (SERPs).

    Showing posts with label All Blogger. Show all posts
    Showing posts with label All Blogger. Show all posts

    Monday, August 12, 2013

    What are light boxes and how can you make one?

    Ever wondered what are those square floating boxes that appear in front of the contents of a page when it is loaded or when you click a link like a thumbnail of a photo or a small window inside the current window?  It is called a lightbox.

    A lightbox is very handy when you want to show the content of a link but you do not want them leaving a page. One reason why you might not want your reader to leave a page is because many find it troublesome to go back to a page when they are taken somewhere else even if it is on a different tab or a new window.

    Lightbox is also very useful if a page mostly contains links like in the case of a stock photo page where a user will be looking for many different pictures from the displayed list. Imagine how combersome it would be to be going back from tab to tab or window to window on every sample photo.

    What makes a lightbox
    Basically, a lightbox is only a div element that is positioned above everything else within a page. It is styled in a way that it would look like a new, smaller window inside the browsing window.

    How to make one?
    I want to create one and put it in my site, how can I do it? I hear you say. Below I will describe how it is done.

    Like what was already said earlier, a lightbox is only a div element with the proper styling applied to it. So go ahead, define a div element and give it an id as you wish or you can simply call it lightbox like this:

    <div id="lightbox"></div>

    This of course will not show anything in your screen. Next, define some format to it using CSS like boder width, color, width and height of the box like this:

    <style type="text/CSS">
    #lightbox{
     border: 10px solid yellow;
     width: 400px;
     height: 250px;
    }
    </style>

    #lightbox means these formats will be applied only to the element with an id of lightbox. All the formatting is enclosed with these { }. border: 10px solid yellow; means the border will have a width of 10 pixels, it is solid (not dashed, double or any other type) and it is color yellow. width: 400px; means the width of the window is 400 px and height: 250px; means the window will have a height of 250 px. It would then look like this:


    Let us add a close button
    If you have been observing the internet some uses a circle with an X in it to indicate the close button or a solid square box with also the X on it and some simply uses the word close. All are on the upper right hand corner. I am in the mood for the circle close button so let us do that.

    First create a circle, on how to create one, refer to the guide on creating lines. Fill this circle with the same color as the adjacent element's background (later we will be adding a title bar with orange background so we will fill our close button with orange) but instead of an X, let us place the word close instead. It will look like this:

    close

    The code is this:
    html part:

    <div id="circlecontainer" style="width: 40px; height: 40px; position: absolute; top: 15px; left: 412px;"><div id="close_button"><div style="font-size: 9px; position: absolute; top: 14px; left: 11px;">close</div></div>

    </div>


    CSS Part:

    #close_button{
     width: 20px;
     height: 20px;
     background-color: orange;
     border: 10px solid yellow;
     border-radius: 20px;
    }

    The div with id="circlecontainer" is to group both the circle as well as the word close so it is easier to handle it later in case a javascript is used to on it. The CSS part is mainly for the circle. There are also in-line CSS in the HTML part mostly for aligning the elements together.

    Now put them together in a way that the circle is on top of the lightbox window. We will also make the corners of the lightbox rounded and add a title bar with an orange background color. The following lines will be added:

    First position the circle to the upper right corner of the box by using position: absolute then top: xxpx and left xxpx placed in the CSS for the close_button. The xx are values that will line-up the close-button best to the box.

    Next round the corners of the box by adding corner-radius: 15px. Then to add the title bar, add another div element within the div of the box. Give it a height of 30px and background color of orange. In here we will use again in-line CSS (remember to round the upper corners a bit to match the rounded corners of the box):

    <div style="background-color: orange; height: 30px; border-radius: 5 5 0 0px;"><b>Title Here</b></div>
    So it will look like this:
    Title Here
    close

















    Our lightbox is completed. My color selection may not be the best to use for a lightbox. Do some research by looking at what others are using the change it to that color that makes you happy. Also ad content to the box by placing them between the closing div (</div>) of the title bar and the closing div of the main box.

    The last thing we need to do is to make the close button function as it should (close the window). To do this we will use javascript to hide the entire box using the display: none property. By using display : none, it is not actually being closed but only being hidden from view. First group it all by containing it in a single div element then refer to its id when in javascript to hide it. Below is the final code:



    <script type="text/javascript">
    function closeIt(){
    document.getElementById("main_container").style.display = "none";
    }
    </script>

    <style type="text/CSS">
    #lightbox{
     position: absolute;
     top: 40px;
     border: 10px solid yellow;
     width: 400px;
     height: 250px;
     border-radius: 15px;
    }

    #close_button{
     width: 20px;
     height: 20px;
     background-color: orange;
     border: 10px solid yellow;
     border-radius: 20px;
    }
    </style>

    <div id="main_container" style="display: block;">
    <div id="lightbox">
     <div id="title_bar" style="background-color: orange; height: 30px; border-radius: 5 5 0 0px;"><b>Title Here</b></div>
    </div>
    <div id="circlecontainer" style="width: 40px; height: 40px; position: absolute; top: 15px; left: 412px;">
    <div id="close_button"><div style="font-size: 9px; position: absolute; top: 14px; left: 11px; cursor: pointer;" onclick="closeIt()">close</div></div>
    </div>
    </div>

    There you have it. Make your adjustment as necessary.

    Back to CyberLiving home page

    Other Posts

    Thursday, August 8, 2013

    How to draw lines using CSS

    Do you want some simple lines (vertical, horizontal,diagonal or slanting) but without using images?

    It is quite simple really. By using CSS, you can create the above listed lines as well as circle.

    Let us start with the simpler ones, that is horizontal and vertical lines. To do so, simply create a div element and define the border on one side and you already have a line then define its position so you can place it at the exact location you wish the line be displayed by using a combination of the top, left, bottom, right properties together with the position: absolute, position: relative or position: fixed.

    Vertical line example:
    <style>
    #vertical
    {
     height: 200px;
     border-left: 1px solid blue;
     position: absolute;
     top: 50px;
     left: 250px;
    }
    </style>

    <div id="vertical"></div>

    *You may also use border-right with the same values and it will have the exact same result. The bigger height it is the longer the vertical line.

    Horizontal line example:
    <style>
    #horizontal
    {
     width: 200px;
     border-top: 1px solid blue;
     position: absolute;
     top: 50px;
     left: 250px;
    }
    </style>

    <div id="horizonal"></div>

    *You may also use border-bottom.

    For a diagonal line first create a vertical or horizontal line then add the rotate property.

    Diagonal line example:
    <style>
    #diagonal
    {
     width: 200px;
     border-top: 1px solid blue;
     -webkit-transform: rotate(36deg);
     -moz-transform: rotate(36deg);
     -o-transform: rotate(36deg);
     -ms-transform: rotate(36deg);
     transform: rotate(36deg);
     position: absolute;
     top: 50px;
     left: 250px;
    }
    </style>

    <div id="diagonal"></div>
    *A diagonal line is a horizontal or vertical line that is rotated at an angle.
    **The -webkit-transform: rotate(xxdeg), -moz-transform: rotate(xxdeg), -o-transform: rotate(xxdeg), -ms-transform: rotate(xxdeg) and transform: rotate(xxdeg) all do the same thing. But each only works for a specific browser.
    ***Always supply the same angle to all, otherwise it will be displayed differently on different browsers.

    For a circle, it is still a div element with rounded corners.
    Circle Example:
    <style>
    #circle
    {
     height: 200px;
     width: 200px;
     border-radius: 100px;
     border: 1px solid blue;
     position: absolute;
     top: 50px;
     left: 250px;
    }
    </style>

    <div id="circle"></div>
    *To create a circle, the div element has to be a square thus height and width must be equal.
    **The value of the border-radius must be half that of the side (or half of the height or width value).

    Now let us use a combination of these to draw a very big stickman.


    <!DOCTYPE html>
    <html>
    <head>
    <style>
    #stick_head
    {
    height: 100px;
    width: 100px;
    border: 1px solid blue;
    border-radius: 50px;
    position: absolute;
    top: 200;
    left: 400px;
    }

    #body
    {
    height: 240px;
    border-left: 1px solid blue;
    position: absolute;
    top: 120px;
    left: 450px;
    }

    #left_arm
    {
    height: 130px;
    border-right: 1px solid blue;
    -webkit-transform: rotate(50deg);
    -moz-transform: rotate(50deg);
    -o-transform: rotate(50deg);
    -ms-transform: rotate(50deg);
    transform: rotate(50deg);
    position: absolute;
    top: 140px;
    left: 400px;
    }

    #right_arm
    {
    height: 130px;
    border-right: 1px solid blue;
    -webkit-transform: rotate(130deg);
    -moz-transform: rotate(130deg);
    -o-transform: rotate(130deg);
    -ms-transform: rotate(130deg);
    transform: rotate(130deg);
    position: absolute;
    top: 140px;
    left: 500px;
    }

    #left_leg
    {
    width: 180px;
    border-bottom: 1px solid blue;
    -webkit-transform: rotate(100deg);
    -moz-transform: rotate(100deg);
    -o-transform: rotate(100deg);
    -ms-transform: rotate(100deg);
    transform: rotate(100deg);
    position: absolute;
    top: 448px;
    left: 345px;
    }

    #right_leg
    {
    width: 180px;
    border-bottom: 1px solid blue;
    -webkit-transform: rotate(80deg);
    -moz-transform: rotate(80deg);
    -o-transform: rotate(80deg);
    -ms-transform: rotate(80deg);
    transform: rotate(80deg);
    position: absolute;
    top: 448px;
    left: 376px;
    }
    </style>
    </head>
    <body>
    <div id="stick_head"></div>
    <div id="body"></div>
    <div id="left_arm"></div>
    <div id="right_arm"></div>
    <div id="left_leg"></div>
    <div id="right_leg"></div>
    </body>
    </html>


    Of course this is not how you would use a line to style your page but just to give you an idea as to what extent you can do with it and what has just been demonstrated is the very basic. There are more that you can do with it specially when used together with javascript or similar language.
    Back to CyberLiving home page

    Other Posts
    Back to home page

    How to customize a Google Visualization Table to best fit your page

    If you are using Google Visualization Table to show your data like when making Google Spreadsheet as a database, you may have learned that customizing it is not simply declaring an ID to the containing element.

    The declaration google.visualization.table in itself contains its own CSS styles which defines what you see when the table gets drawn like background color, font size, font face and so on. There are readily available options that you can turn on or off like alternating background color per row but sometimes that is not enough as what is readily available may not be suited on how your page looks like.

    How to override the default styles
    For this to work the option allowHtml must be set to true. Also, there should not be any formatting on the source spreadsheet.

    For the purpose of this post, let us go back to a previous article that illustrates how to use your google spreadsheet as a database. Let us make this table transparent so that it will match and adopt your page's background color.


    • Define the CSS styles for the table elements - create a css class for the following: headerRow, tableRow, oddTableRow, .selectedTableRow, headerCell and tableCell. Set the the background color to transparent and since by default there is no border define one for it as well. Also, since all will be having the same styles, just lump them up in a single declaration within the <style> </style> tag. Here is an example:
    Example: 
    .hrowclass, .trowclass, .otrowclass, .strowclass, .hcellclass, .tcellclass
    {
     background-color: transparent;
     border: 1px solid #c8c8c8;
    }


    • Use declared classes in the table.draw using the cssClassName property - locate the javascript function containing the actual code that displays the table. In this case it is table.draw(data, {'allowHtml': true, 'alternatingRowStyle': true, 'page': 'enable', 'pageSize': 10, 'sort': 'enable', 'sortAscending': false, 'sortColumn': 0}); and add this 'cssClassNames': {'tableRow': 'trowclass', 'headerRow': 'hrowclass', 'oddTableRow': 'otrowclass', 'selectedTableRow': 'strowclass', 'headerCell': 'hcellclass', 'tableCell': 'tcellclass'}. The final result will be this:
    table.draw(data, {'allowHtml': true, 'alternatingRowStyle': true, 'page': 'enable', 'pageSize': 10, 'sort': 'enable', 'sortAscending': false, 'sortColumn': 0, 'cssClassNames': {'tableRow': 'trowclass', 'headerRow': 'hrowclass', 'oddTableRow': 'otrowclass', 'selectedTableRow': 'strowclass', 'headerCell': 'hcellclass', 'tableCell': 'tcellclass'}});

    Now save your work and you will have a transparent table with a gray background. You can even change the color of the border or make it thicker, add more styles as you see fit. Try playing on it to give you what you wanted.


    Back to CyberLiving home page

    Other Posts
    Back to home page

    Thursday, July 25, 2013

    Use custom CSS fonts to enrich your page

    How to add stylish and curvy fonts to your blog post/page using CSS?

    You may have observed while visiting other sites that they have very nice looking fonts specially with their qoutes. But however you hard you try to find what font they used, you can not duplicate it. How was that possible? It is by using custom CSS fonts.

    Today many are already offering such fonts like fonts.com and face-fonts. But most of these needed that you upload them to your server and access it from there. There is one alternative though that does not require uploading to your server. It is Google Web Fonts or simply Google Fonts.

    To give a sample of the fonts, here is a famous line from Confucius:

    Chose a job you love, and you will never have to work a day in your life.
    -Confucius
    The custom font used above is cursive Bilbo from Google Web Fonts. The texts affected by the custom font are the quote

    Here is how it is done:
    Using custom fonts with CSS. Here is the code for the above quote:

    <blockquote style="font-family: 'Bilbo', cursive http://fonts.googleapis.com/css?family=Bilbo stylesheet text/css; font-size: 18px; font-style: italic; line-height: 1.45; margin: 0.25em 0; padding: 0.25em 40px; position: relative; width: 500px;">
    <span style="color: lightgrey; font-size: 130px; left: -30px; position: absolute; top: -50px;">“</span><span style="font-family: Georgia, serif;">Chose a job you love, and you will never have to work a day in your life.</span><br />
    <span style="color: lightgrey; font-family: 'Bilbo', cursive http://fonts.googleapis.com/css?family=Bilbo stylesheet text/css; font-size: 15px;">-Confucius</span></blockquote>

    Google Fonts' instructions in using their fonts is to include a code into your website. For blogger users, you will have to include it into your template. By doing so, the said font will be available anytime you want to use it. The downside to it is that, the more fonts you add into your template, the slower it is for your site to load. And since you are forced not to add as much custom fonts as you want, you don't have that much flexibility in using all these custom fonts.

    Fortunately there is another way of coding it that will only require to add a code into your browser. What I will describe below  does not require you to add anything in your template. But this will still add into the loading time for the page/blog post you will apply it with but not on your whole site.


    • Follow the basic format for the code as shown below. Just include the code as inline CSS to the element you wish to place it. In the case that there is already an existing inline CSS in the said element, just copy the texts inside the double quotes and insert it inside the CSS.
    style="font-family: 'Bilbo', cursive http://fonts.googleapis.com/css?family=Bilbo stylesheet text/css;"
    Note the different colors of the texts. The red ones represent the URL for the font and the blue ones represent the name of the font.
    • Get the font URL for the custom font.
      1. Go to http://www.google.com/fonts/ and browse through the list then choose the font that you wish.
      2. When you have chosen, click on the quick use button at the lower right for each font.
      3. You will be redirected to another set of selections. If the font you selected had more than one style, you will need to choose for the style that you want. Choose only one. Actually it is possible to choose all but that is if you will be placing your code on your template.
      4. You will also need to choose a character set in case there are more than one. Again just choose one for the same reason as above.
      5. Finally, you will see some code similar to this:
    <link href='http://fonts.googleapis.com/css?family=Roboto+Slab&subset=cyrillic-ext' rel='stylesheet' type='text/css'>
    Copy all the text inside the single quote after href= and then in the basic format mentioned above replace the red texts with this. In the example above, replace http://fonts.googleapis.com/css?family=Bilbo with http://fonts.googleapis.com/css?family=Roboto+Slab&subset=cyrillic-ext.


    • Get the font name for your chosen font
      1. Just below the link code is another code that looks like this:
    font-family: 'Roboto Slab', serif;rel='stylesheet' type='text/css'>
    Copy the font-family until the first semi-colon (semicolon not included) and go back to your inline CSS to replace the existing font-family similar to the way you did with the URL. In the example above, replace font-family: 'Bilbo', cursive with font-family: 'Roboto Slab', serif.

    That is it, you now have custom fonts inside your content and you can use different font type for different page and still not affecting the loading time of your site.

    It is up to you know how big yo want it. What color and the positioning of the texts to make it even look better.







    Tuesday, July 16, 2013

    Meta tag generator

    Here is a free meta tag generator/builder for blogger users and non-blogger users that include facebook and twitter meta tags.

    Simply input the page title, description and keywords (if you wish not to include it leave it blank) and the post URL and click the Generate Meta tags button. To include facebook and twitter meta tags, just click on the option list that you wish included.

    Copy the code (that appears after the button) applicable for you and paste it on your page. It is important to copy including all leading spaces so it will align properly when you paste it on blogger template, If you are a blogger user look for the <b:include data:='blog' name='all-head-content'/> and paste the code just below it. For non-blogger users, paste the code within the <HEAD> and </HEAD> tags.





    You have 160 characters left.





    You have 160 characters left.





    You have 160 characters left.





    Tell Robots to:
    Index this page and follow the links on the page
    Index this page but do not follow the links on the page
    Do not index this page and follow the links on the page
    Do not index this page and do not follow the links on the page

    Facebook Meta tags
    Include Facebook Meta title tag (og:title)
    Include Facebook Meta URL tag/Canonical URL (It will use the same URL as the one supplied above) (og:URL)
    Include Facebook Meta description tag (og:description)
    Include the type

    Select Type



    Include Facebook Meta image tag (og:image)



    Include Facebook User IDs (fb:admins)



    Twitter Meta tags
    Include Twitter Meta URL tag (twitter:url)
    Include Twitter Meta Title tag (twitter:title)
    Include Twitter Meta Description tag (twitter:description)
    Include Twitter Meta image tag (twitter:image)
    Include the type

    Select Twitter Card Type






    For Blogger Users copy this
    For others use this



    Back to CyberLiving home page

    Other Posts
    How to change your Smart Bro DNS server to Google Public DNS or OpenDNS
    Add your profile photo in search results


    Monday, July 15, 2013

    Add your profile photo in search results

    Google Authorship Markup: How to add your photo into SERPs

    So you wanted to add your profile photo into the results page of major search sites like Google, Yahoo and Bing.

    The short answer is by using Authorship Markup and it is called rich snippet. And in Google it is done without having to write a single code.

    Why bother with Authorship Markup
    Aside from the obvious that it is quite cool, it also standouts out among the other results. And if it stands out you get more attention, thus you get more advantage against the competition. It also gives the impression that that search result is more credible since Google has given you authorship on that particular subject or with the article.

    Many believes that with the authorship, click through rates have increased for their site. I mean, just look at this result:

    Here is what it looked without the Authorship Markup

    An here is with Authorship Markup
    And so how did they do it?

    Here is how

    • You need to have a Google+ account - If you don't have one yet or even if you don't intend on using it just create one since it will be used to link your site/content and your bio/profile. If you are on Blogger, I suggest that you take time to write your Tagline and Introduction.
    • Link your profile to Google+
      1. Go to your site and click your about or profile page, the one that contains your personal profile.
      2. Copy the URL of that (profile) page from the address bar.
      3. Go back to your Google+ profile and click on About.
      4. Scroll down until you see the links box.
      5. Click Edit and under Contributor to click Add custom link and on Label put something like +Your Name Blog. On URL put the copied profile address. Make sure that Current contributor is selected on the drop down menu.
      6. If you don't see your site listed under Contributor to add it as well by following step 5.
        • Note to Blogger users - To connect your blogs to Google+, go to your dashboard and click on Google+ then on the right side will be the Get Started button. From there, just follow the instructions or you can still manually do them by following step 5.
    • Link Google+ profile to your site's content
      1. Add the 'rel=author' on the link of your author box (the <a href="http://example.com/profile.html/" of written by Blog Author at the bottom of the page)
      2. If you have a profile page, ad the 'rel=me' on the link.
      3. For Blogger users (or even if you are not) you can link your Google+ profile directly by adding '?rel=author' at the end of the URL link like https://plus.google.com/14790572345602544?rel=author.
    • Test and see the result using Google's Structured Data Testing Tool. Just type in your site URL and click on the PREVIEW button.

    Back to CyberLiving home page

    Other Posts
    Meta tag generator
    Put the Loading... text with animated dots

    Saturday, July 13, 2013

    Put the Loading... text with animated dots

    There are times where you navigate to a page and you see the "Loading..." text with moving three or so dots like this
    Loading
    and you wonder how they did it.

    Here is how
    Copy and paste the following code to where you wish for it to appear inside you page
    <span id="wait">Loading</span>
    <script>
    var dots = window.setInterval( function() {
        var wait = document.getElementById("wait");
        if ( wait.innerHTML.length > 12 )
            wait.innerHTML = "Loading";
        else
            wait.innerHTML += " .";
        }, 300);
    </script>

    You may replace the value 300 (in red text) to a value you wish. 300 means 300 millisecond or 0.3 second interval between each appearance of the dot so naturally the higher value you put in, the longer it will take for each dot to appear and vice versa.

    You may also wish to add some format to the text like making the font size 40px and color gray. You can put an inline CSS at the span tag like this:
    <span style="color:gray;font-size:40px;" id="wait">Loading</span>
    <script>
    var dots = window.setInterval( function() {
        var wait = document.getElementById("wait");
        if ( wait.innerHTML.length > 12 )
            wait.innerHTML = "Loading";
        else
            wait.innerHTML += " .";
        }, 300);
    </script>

    And the result will be like this:
    Loading


    Back to CyberLiving home page

    Other Posts
    Add your profile photo in search results
    Using Google Spreadsheet as a query-able table using Javascript

    Thursday, July 11, 2013

    Using Google Spreadsheet as a query-able table using Javascript

    Add more functionality (like sort, search string, limit result per page and page navigation) to your query using Javascript that a query in the data source URL would be tedious do.

    In a previous post (Using Google Spreadsheet as a database for your site) it was shown that a Google Spreadsheet could function as a database and that it was possible to make queries as opposed to just publishing the entire content into one very long table (in a case where the table contains lots of data).

    But in my desire to give more functionality (like searching a certain text, limiting to 10 result per page and a navigation button for the next or previous 10 results) to the page, I thought it would be much simpler to do the query in Javascript rather than to do it in the data source URL. Fortunately I found one in Google code playground.

    Here is how
    By using the setquery method to put your query string within the Javascript code. Here is what it would basically look like:

    var query = new google.visualization.Query(DATA_SOURCE_URL);
    query.setQuery('select A,B,C group by A order by B desc');
    query.send(handleQueryResponse);

    With the query in Javascript it turned my display result page from this:

    into this:

    The Javascript code for this is found just below. Feel free to use it. Just copy and paste the code into your page replacing the source spreadsheet and the query string as best fits your requirement.

    <style>
    .post h3 {display:none !important;}
    </style>


    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
     
        <title>
          Google Visualization API Sample
        </title>
        <script src="http://www.google.com/jsapi" type="text/javascript"></script>
        <script type="text/javascript">
          google.load('visualization', '1', {packages: ['table']});
        </script>
        <script type="text/javascript">

        var isFirstTime = true;
        var data;
        var queryInput;
        var credits = '<br /><p style="font-size: 8px;">Courtesy of <a href="http://cyberliving.blogspot.com">http://cyberliving.blogspot.com</a></p>';
         
        var query = new google.visualization.Query(
            'https://spreadsheets.google.com/tq?key=YOUR_SPREADSHEET_ID_HERE');
     
        function sendAndDraw() {
          // Send the query with a callback function.
          query.send(handleQueryResponse);
        }
     
        function handleQueryResponse(response) {
          if (response.isError()) {
            alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
            return;
          }
          data = response.getDataTable();
          var table = new google.visualization.Table(document.getElementById('querytable'));
          table.draw(data, {'allowHtml': true, 'alternatingRowStyle': true, 'page': 'enable', 'pageSize': 10, 'sort': 'enable', 'sortAscending': false, 'sortColumn': 0});
          if (isFirstTime) {
          init();
          }
        }
     
        function setQuery(queryString) {
          // Query language examples configured with the UI
          query.setQuery(queryString);
          sendAndDraw();
          queryInput.value = queryString;
        }
     
     

        google.setOnLoadCallback(sendAndDraw);

        function init() {
          isFirstTime = false;
          queryInput = document.getElementById('display-query');
        }

        function setQueryFromUser() {
          var queryInput1 = "Select * where C contains " + "'" + queryInput.value + "'" + " or D contains " + "'" + queryInput.value + "'" + " or E contains " + "'" + queryInput.value + "'" + " or F contains " + "'" + queryInput.value + "'" + " or G contains " + "'" + queryInput.value + "'"
          setQuery(queryInput1);
        }
     
        </script>
      </head>
    <body style="border: 0 none; font-family: Arial;">
    <div style="background-color: buttonface; border: 1px solid gray; margin-bottom: 10px; padding: 5px;">
    <span> Refine your search</span>
    <form action="">
    <table style="font-size: 12px;">
    <tr>
        <td>Select Category</td>
        <td><select id="query-1" onchange="setQuery(this.value)">
          <option value="">None</option>
          <option value="where B = 'Real Estate'">Real Estate</option>
          <option value="where B = 'Automobile/Vehicle'">Automobile/Vehicle</option>
          <option value="where B = 'Computers/Electronics'">Computers/Consumer Electronics</option>
          <option value="where B = 'Job Opportunity'">Job Opportunity</option>
          <option value="where B = 'Others'">Others</option>
        </select></td>
        <td>Search iSari-Sari Store</td>
        <td><input id="display-query" type="text" />
          <input onclick="setQueryFromUser()" type="button" value="Search" />
        </td>
    </tr>
    </table>
    </form>
    </div>
    <br />
    <div id="querytable">Loading...</div>
      <script>document.write(credits);</script>
    </body></html>​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    The following things you need to do after pasting the code in your page:

    1. Replace the YOUR_SPREADSHEET_ID_HERE with the correct ID.
    2. There are also other red texts in the handleQueryResponse function. Edit it as you wish or you may remove an option:
      • 'allowHtml': true this is to allow some formatting from the table to be carried out in the query output.
      • 'alternatingRowStyle': true when set to true alternating rows will get different tone (gray for odd rows and white for evenrows).
      • 'page': 'enable' when set to enable, paging is turned on meaning you can set the maximum result to be displayed per page by using the pageSize option.
      • 'pageSize': 10 the number is the maximum limit of displayed result per page. A navigation button (previous and next buttons) is placed at the buttom of the result table.
      • 'sort': 'enable' seems self-explanatory. When enabled, you can sort any column.
      • 'sortAscending': false when set to true, data is sorted in ascending manner. When false, data are sorted in descending manner.
      • 'sortColumn': 0 Tells the query language which column to sort automatically before publishing the result on the page. 0 is for column A, 1 for B and so on.
    3. The blue and purple texts makes up the "Refine your search" user interface. The blue texts is for the drop down menu while the purple makes the search input field.


    Back to CyberLiving home page

    Other Posts
    Put the Loading... text with animated dots
    Make your static page look cleaner by removing the page title

    Tuesday, July 9, 2013

    Make your static page look cleaner by removing the page title

    How to remove the page title on your blog pages?

    There are times when you wanted to remove the page title on your blog's static pages just to make it cleaner and appear more professional.

    I mean look at the sample screen capture of a form page below:
    An Ad submit page with the page title.
    Examine the photo above and you will see the redundancy. Submit your Ad is the page title (encircled in red). You will see, however just above is the navigation bar showing the current page selection (pointed by the red arrow) which says exactly the same as the page title.

    Removing Submit your Ad on the navigation bar is not advisable since it is used to navigate to the form. The one appearing on the actual page, however, is not necessary so it should be removed.

    Here is how
    The solution is quite simple, by placing a 3 line code at the top of your page's code.

    • Edit your page in HTML
      1. In your dashboard, click pages.
      2. Select the page and click on edit.
      3. On the edit/compose window, click on HTML so you can edit the html code of the page.
    • Copy and Paste the following code at the top of your page's code
    <style>
    .post h3 {display:none !important;}
    </style>

    • Publish the page
      1. Click on the Upate button.
      2. Check the page you just edited and it should no longer be showing the page title on the page.

    Done!

    Back to CyberLiving home page

    Other Posts
    Using Google Spreadsheet as a query-able table using Javascript
    Using Google Spreadsheet as a database for your site

    Sunday, July 7, 2013

    Using Google Spreadsheet as a database for your site

    Turn Google spreadsheet into a query able database that you can publish on your web page.

    In a previous post (Create your own form and display all response real time using Google Drive) I have mentioned that you can post the results of your Google Form that updates real time. It is good because it is an active result by that I mean it updates data real time.

    But the output result will also include everything like the menu bar and tool bars which is basically anything when you open a spreadsheet in Google Drive. It therefore looks and feel more like a work space than a web page. Refer to below image for the output.
    Output on your website using the link share address of the spreadsheet.
    But what if you wanted a better output without the distracting menu and tool bars, column and row headings and just wanted it to look like any other table you see around the internet?

    Use the Data Source URL instead of the link share address
    Fortunately, there is a better way of showing your response table and that is using the data source URL. It looks like this:

    https://spreadsheets.google.com/tq?tqx=out:html&key=YOUR_SPREADSHEET_ID_HERE

    To find your spreadsheet ID, open your spreadsheet in Google Drive and on the address bar should look like this:

    https://docs.google.com/spreadsheet/ccc?key=SPREADSHEET_ID#gid=0

    Just copy the spreadsheet ID and paste it on your data source URL. To post this in your website, use the iframe tag just like when you made the link share address. It therefore should look something like:

    <iframe frameborder="0" height="1100" marginheight="0" marginwidth="0" width="1000" src="https://spreadsheets.google.com/tq?tqx=out:html&key=YOUR_SPREADSHEET_ID_HERE"></iframe>

    Please note also that I have highlighted in bold and blue the text tqx=out:html that is because there are three possible output in using the data source URL (json, html and csv). Without specifying the output, it will automatically assume a json output (default). The tqx=out:html text will ensure that it gives an html output which is more readable to us common folk. Using csv will download the table to your hard drive.

    Supposing your iframe options were set properly, you will not see any evidence of the iframe on your page and should look like this:
    Using the data source URL gives a cleaner look.
    Add Query on your data source URL for better interactivity with your table
    Now looking better! How about if you wanted some interactivity with the table like showing responses only on a certain category. Like this:
    Sort by:
    Real Estate                     Automobile or Vehicle
    Job Opportunity              Computers and Electronics
    Others

    From the above table, you can see that you can sort the data by clicking on any of the choices on how to sort it.

    To do this include a query in the data source URL. The query has the following syntax:

    &tq=QUERY_STRING_HERE

    The entire data source URL then would look like this:

    https://spreadsheets.google.com/tq?tqx=out:html&key=YOUR_SPREADSHEET_ID_HERE&tq=QUERY_STRING_HERE

    Replace that into your iframe source and it will display any data that meets the query requirement.

    But what to put on the query string? Instead of discussing the details, I will give you the code for the above example as it is beyond the scope of this article to discuss in detail about the query language.

    Here is the code. Feel free to use it. Just copy and paste it to a blank page and it should work fine.
    <b>Sort by:</b><br />
    <a href="https://spreadsheets.google.com/tq?tqx=out:html&amp;tq=select * where (B='Real Estate' or B='Category') order by A desc&key=YOUR_SPREADSHEET_ID_HERE" target="pakita">Real Estate</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="https://spreadsheets.google.com/tq?tqx=out:html&amp;tq=select * where (B='Automobile/Vehicle' or B='Category') order by A desc&key=YOUR_SPREADSHEET_ID_HERE" target="pakita">Automobile or Vehicle</a><br />
    <a href="https://spreadsheets.google.com/tq?tqx=out:html&tq=select * where (B='Job Opportunity' or B='Category') order by A desc&key=YOUR_SPREADSHEET_ID_HERE" target="pakita">Job Opportunity</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<a href="https://spreadsheets.google.com/tq?tqx=out:html&tq=select * where (B='Computers/Electronics' or B='Category') order by A desc&key=YOUR_SPREADSHEET_ID_HERE" target="pakita">Computers and Electronics</a><br />
    <a href="https://spreadsheets.google.com/tq?tqx=out:html&tq=select * where (B='Others' or B='Category') order by A desc&amp;key=YOUR_SPREADSHEET_ID_HERE" target="pakita">Others</a>
    <br />
    <iframe frameborder="0" height="900" marginheight="0" marginwidth="0" name="pakita" src="https://spreadsheets.google.com/tq?tqx=out:html&amp;tq=select * order by A desc&key=YOUR_SPREADSHEET_ID_HERE" width="1000"></iframe><br /><p style="font-size: 8px;">Courtesy of <a href="http://cyberliving.blogspot.com">http://cyberliving.blogspot.com</a></p>
    A little explanation for the code
    In order to make an interaction with the table, I made use of an achor text (<a href="source URL>) in order to make the query using the data source URL then targeted the frame (iframe) as my output.

    You might have also noticed the blue and red texts. These are what composed the query string, except for the key=YOUR_SPREADSHEET_ID_HERE which we have already explained earlier. The blue texts are called clauses while the red texts are the conditions you set for each clause.

    For the select I gave it the * to mean select all columns in the table. You may also select only certain columns. Do it by specifying its column letter. Ex. select A,B,C or select A,C,D,E or select B,E,F

    The where clause tells your query which among the data is to be displayed. In my example I used where (B='Real Estate' or B='Category') on my first anchor text (Real Estate) because I just wanted to display all responses under the category Real Estate. I included or B='Category' so that it will still display the column title. Without it, the displayed data will not have any column title.

    Then there is the order by A desc. This serves to arrange the data according to the content of column A. Since I wanted it to display the data from the latest entry from the form down to the earliest I choose column a to sort because it contains the time stamp data as to when each data has been created and since I wanted the latest entry to be on top I choose "desc" for descending order.

    That is it. I hope I helped you solved your problem. If you wish for any clarification, leave your comments below.

    Back to CyberLiving home page

    Other Posts
    Turn blogger blog into a static web page
    Make your static page look cleaner by removing the page title

    Thursday, July 4, 2013

    Turn blogger blog into a static web page

    Turn blogger blog into a static web page

    Create a static web page in blogger.

    Tired of looking at your blog and wanted a static web page but do not want to work hard into setting-up one? Or you just wanted a more professional look for your page and not look like a blog?

    Let us face it, a lot of us find it a bit difficult to set-up a page or just do not have much time to learn it while here is Google offering us Blogger where in just several steps you can have your own page (albeit a blog) not to mention that it is free.

    Now, you can have both a static as well as a blog page in Blogger.


    Here is how
    Note: If you just wanted to convert your existing blog into a static page skip the first step.



    1. Create a blog following the normal process.
      • You can choose any template you wish but in my case I prefer getting the simple template.
      • For the Layout, I choose only a single column with no side bar this way I can have free range in styling it later.
      • I also adjusted the width to fit the entire blog area, I have only 1 column any way and no side bars.
    2. Make a static landing page
      • First thing is to create a page. Log-in to blogger then go to your blog's dashboard. Under Pages, click New Page then Blank page. Name this Home Page (under Page title). Publish the page.
      • Create a custom redirect. Let us create a redirect to the static page you just created so that it will effectively become the landing page of your site instead of the blog page. Click Settings on the dashboard then click Search preferences. Scroll down until you see Custom Redirect under Errors and redirections. Click Custom Redirects and on the From input field, input "/" (forward slash, without the quotes). On the To field, input "/p/home-page.html. Lastly, click on the Permanent check box to check it. Click on save then Save changes.
      • Hide the default Home blog page. After creating the custom redirect, when you go to your blog, it will automatically redirect you to the blank static page and no longer at the blog page. But notice your navigation bar that both Home and Home Page is present. Home is the default blog home page while the Home Page is the static one you have created. Notice also that it is the Home Page that is selected (meaning active) and not Home. We need then to hide Home as it is redundant and it does not hold much purpose. Click Layout on your dashboard then click edit under Pages gadget. On the pop-up window, uncheck Home under Pages to show. This action hides Home.
      • Rename Home Page to Home. After hiding Home, you are now left with just the Home Page on the navigation bar. But for me, Home Page do not sound too nice so I will rename it to just Home. Click back on Pages in the dashboard. Notice that Home is now under Hidden. Click Edit under Home Page and edit the Page title to whatever name you wish to name this page. For me I called it Home because it basically is now the effective home page of this site.
      • Bring back blog page. If you wish to still have the blog page (but just not as a landing page), create another page by clicking on New page (in Pages) but instead of a blank page, click Web address. Input any desired Page title, ex. Blog Posts. Under Web address (URL) input your blog URL and add the following texts "/index.html" without the quotes, ex. http://yourblog.blogspot.com/index.html. This page will have the same content as the original blog's home page including its formatting.
    3. Create content for your new static landing page. Congratulations! You have just reformatted you blog into a static site. Next step is to put content into the blank page. Format it as you wish.


    Back to CyberLiving home page

    Other Posts
    Using Google Spreadsheet as a database for your site
    Is facebook down?