Search This Blog

Friday, 6 October 2017

Useful Development Resources...

 

 Useful> Development> Resources >

I debated how to set up this section of the site. On the one hand, I could gather each and every helpful link that’s out there, and compile them into one giant list right here on this page. While that would be nice, it would also be labor intensive, not to mention many people already have such link lists. Rather than re-invent the wheel, I will point you in the right direction…

 

Tuesday, 28 March 2017

మీకు మీ కుటుంబసభ్యులకు హేవిళంబి నామ ఉగాది శుభాకాంక్షలు!

🍋మామిడి పువ్వుకి మాట వచ్చింది🍋

🐦కోకిల గొంతుకు కుత వచ్చింది🐦

🌿వేప కొమ్మకు పూత వచ్చింది🌿

🍯పసిడి బెల్లం తోడు వచ్చింది🍯

🌿🌾గుమ్మానికి పచ్చని తోరణము వచ్చింది🌾🌿

🌾🍒పండగ మన ముందరికి వచ్చింది🍒🌾

🌾మీకు మీ కుటుంబసభ్యులకు హేవిళంబి నామ ఉగాది శుభాకాంక్షలు!🌾

Friday, 10 March 2017

Javascript::Check Type of JS Object

Check Type of JS Object

function objIs(type, obj) {
    var clas = Object.prototype.toString.call(obj).slice(8, -1);
    return obj !== undefined && obj !== null && clas === type;
}
 
objIs('String', 'test'); // true

objIs('String', new String('test')); // true

JavaScript::JavaScript ‘Back’ Button

JavaScript ‘Back’ Button

<a href="javascript:history.back(1)">Previous Page</a>

JavaScript::Get URL Parameter

Get URL Parameter
function getUrlParam(name) {
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return (results && results[1]) || undefined;

}

JavaScript::Browser Window Dimensions

Browser Window Dimensions

function report() { 
  document.getElementsByTagName('output')[0].innerHTML = 'screen.width:'+screen.width+'<br>screen.height:'+screen.height+'<br>window.innerWidth:'+window.innerWidth+'<br>window.innerHeight:'+window.innerHeight+'<br>window.outerWidth:'+window.outerWidth+'<br>window.outerHeight:'+window.outerHeight+'<br>document.documentElement.<br clientHeight:'+document.documentElement.clientHeight+'<br>window.devicePixelRatio:'+window.devicePixelRatio; 
}
window.addEventListener('load', report, false);
window.addEventListener('resize', report, false);
window.addEventListener('orientationchange', report, false);
window.addEventListener('deviceorientation', report, false);

window.addEventListener('MozOrientation', report, false);

JavaScript::Detecting Mobile Devices

Detecting Mobile Devices
var isMobile = {
  Android: function() {
    return navigator.userAgent.match(/Android/i);
  },
  BlackBerry: function() {
    return navigator.userAgent.match(/BlackBerry/i);
  },
  iOS: function() {
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
  Opera: function() {
    return navigator.userAgent.match(/Opera Mini/i);
  },
  Windows: function() {
    return navigator.userAgent.match(/IEMobile/i);
  },
  any: function() {
    return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  }
};
 
// Examples
if( isMobile.any() ) alert('Mobile');

if( isMobile.iOS() ) alert('iOS Device');

JavaScript::Detecting the Operating System

Detecting the Operating System

var system = navigator.appVersion;
if (navigator.appVersion.indexOf("Mac") != -1 ) OS = "Mac";
else if (navigator.appVersion.indexOf("PowerPC") != -1 ) OS = "Mac";
else if (navigator.appVersion.indexOf("Win") != -1 ) OS = "Win";
else if (navigator.appVersion.indexOf("SunOS") != -1 ) OS = "Solaris";
else  OS = "Linux";
 
//Determine Browser Version
bName = navigator.appName;
bVer  = parseInt(navigator.appVersion);
 
if (OS == "Mac" && bName=="Netscape") { 
  // your code here
}
else if (OS =="Mac" && bName=="Microsoft Internet Explorer") { 
  // your code here
}
else if (OS =="Win" || OS == "Linux" && bName == "Netscape") {
  // your code here
}
else if (OS =="Solaris" && bName=="Netscape") {
  // your code here
}
else if (OS =="Win" || OS == "Linux" && bName=="Microsoft Internet Explorer") {
  // your code here
}

JavaScript::JavaScript Cookies

JavaScript Cookies
function setCookie(name, value) {
  if(name != '')
    document.cookie = name + '=' + value;
}
 
function getCookie(name) {
  if(name == '')
    return('');
 
  name_index = document.cookie.indexOf(name + '=');
 
  if(name_index == -1)
    return('');
 
  cookie_value =  document.cookie.substr(name_index + name.length + 1, document.cookie.length);
 
  //All cookie name-value pairs end with a semi-colon, except the last one.
  end_of_cookie = cookie_value.indexOf(';');
  if(end_of_cookie != -1)
    cookie_value = cookie_value.substr(0, end_of_cookie);
 
  //Restores all the blank spaces.
  space = cookie_value.indexOf('+');
  while(space != -1) { 
    cookie_value = cookie_value.substr(0, space) + ' ' + 
    cookie_value.substr(space + 1, cookie_value.length);
 
    space = cookie_value.indexOf('+');
  }
 
  return(cookie_value);
}

JavaScript::Browser Detection

Browser Detection
// Internet Explorer
var ie  = document.all != null;  //ie4 and above
var ie5 = document.getElementById && document.all;
var ie6 = document.getElementById && document.all&&(navigator.appVersion.indexOf("MSIE>=0);
 
// Netscape
var ns4 = document.layers != null;
var ns6 = document.getElementById && !document.all;
var ns  = ns4 || ns6;
 
// Firefox
var ff  = !document.layers && !document.all;
 
// Opera
var op  = navigator.userAgent.indexOf("opera")>0;
var op7 = op && operaVersion() <= 7;
var op8 = op && operaVersion() >= 8;
 
// Detects the Opera version
function operaVersion() {
          agent = navigator.userAgent;
          idx = agent.indexOf("opera");       
          if (idx>-1) {
                    return parseInt(agent.subString(idx+6,idx+7));
          }

}

JavaScript::Obtain Select Input Value

Obtain Select Input Value
<select id="menulist">
  <option value="1">test1</option>
  <option value="2" selected="selected">test2</option>
  <option value="3">test3</option>
</select>
 
<script>
var e = document.getElementById("menulist");
var optvalue = e.options[e.selectedIndex].value; // the option value attribute
var opttext  = e.options[e.selectedIndex].text; // internal text inside option element
</script>

JavaScript::Detect When Browser is Closed

Detect When Browser is Closed
function checkBrowser() {
  // triggers on clicking the close button, Alt+F4 , File->Close 
  if(window.event.clientX < 0 && window.event.clientY < 0) {
    window.open("somefile.htmllosewindow",'left=12000,top=1200,width=120,height=50');
  }

}

JavaScript::JavaScript Cookies

JavaScript Cookies

<script type="text/javascript">
/**
* Sets a Cookie with the given name and value.
*
* name       Name of the cookie
* value      Value of the cookie
* [expires]  Expiration date of the cookie (default: end of current session)
* [path]     Path where the cookie is valid (default: path of calling document)
* [domain]   Domain where the cookie is valid
*              (default: domain of calling document)
* [secure]   Boolean value indicating if the cookie transmission requires a
*              secure transmission
*/                        
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
</script>

<script type="text/javascript">
/**
* Gets the value of the specified cookie.
*
* name  Name of the desired cookie.
*
* Returns a string containing value of specified cookie,
*   or null if cookie does not exist.
*/
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
</script>

<script type="text/javascript">
/**
* Deletes the specified cookie.
*
* name      name of the cookie
* [path]    path of the cookie (must be same as path used to create cookie)
* [domain]  domain of the cookie (must be same as domain used to create cookie)
*/
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
</script>

It  will allow your site to store information on the viewer’s computer then read it at another point in time. This snippet can be used in many different ways to accomplish different tasks.

JavaScript::E-mail Validation

E-mail Validation

Head:
<script type="text/javascript">
function validateEmail(theForm) {
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(theForm.email-id.value)){
return(true);
}
alert("Invalid e-mail address! Please enter again carefully!.");
return(false);
}
</script>
Body:
<form onSubmit="return validateEmail(this);" action="">
E-mail Address:
<input type="text" name="emailid" />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>

This snippet will validate that a properly formatted E-mail address is entered in a form, it cannot guarantee that the E-mail address is real, there is no way to check for that with JavaScript.

JavaScript::No Right-Click

No Right-Click

<script type="text/javascript">
function f1() {
  if(document.all) { return false; }
}
function f2(e) {
  if(document.layers || (document.getElementById &! document.all)) {
    if(e.which==2 || e.which==3) { return false; }
  }
}
if(document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown = f1;
}
else {
  document.onmouseup = f2;
  document.oncontextmenu = f1;
}
document.oncontextmenu = new function("return false");
</script>

This snippet will prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.