Tuesday, 1 October 2013

How to check the valid Youtube URL ?

// Here, The simple way to valid YouTube url in Appcelerator.

// Typically, the thing that most people want is the youtube video ID valid or not. 

// Some one also check that front part youtube.com/ that one very easy in appcelerator.

Here , some code

 var _videoUrl = "youtube.com/watch?v=FhnMNwiGg5M";
 var _videoUrlNotValid = "go.com/watch?v=FhnMNwiGg5M";

var matches = _videoUrl.match(/((http|https):\/\/)?(www\.)?(youtube\.com)(\/)?([a-zA-Z0-9\-\.]+\/?/);

var matches = _videoUrlNotValid.match(/((http|https):\/\/)?(www\.)?(youtube\.com)(\/)?([a-zA-Z0-9\-\.]+)\/?/);

  if (matches) {
        alert('valid youtube URL');
    }else{
        alert('Not valid');
    }

Output :)

1) _videoUrl is valid
2) _videoUrlNotValid not valid

Hope it helps you , i use this in Appcelerator and it works for me.

Monday, 30 September 2013

Very Simple use to MATH function in javascript

// This one is very simple blog to understand littlebit about MATH function in appcelerator.

// This one is very to easy but i want to share it because today i waste my 3 hour in one simple line code

// I just want to do one simple this like if i get value
3.5 it would be 4 same as,
4.1 it would be 4 same as,
4.9 it would be 5 same as.

It means simple ROUND .

But i didnt think about MATH function at that time . I just try it my own way that one is successful but here one simple mathod ROUND in MATH with the use of this function i easily get may goal.

Example : 
  1. var ratingInfo = Math.round(2.5);
  2. var ratingInfo = Math.round(3.9);
  3. var ratingInfo = Math.round(4.1);
  4. var ratingInfo = Math.round(2.7);
Output :)
  1. 3
  2. 4
  3. 4
  4. 3
This one is very easy in Appcelerator i use this function for Rating Functionality in my Application.

There are lots of other part method is available in MATH .

Like

1 ) Math.random() :  It return a random number between 0 and 1.

2 ) Math.max(15,10) : It return the number with the highest value of two specified numbers.

3) Math.min(25,40) : It return the number with the lowest value of two specified numbers.

That one really helpful me its very easy but it help me a lot so i share it with you.

I hope it helps to all.



 

Monday, 16 September 2013

Text To Speech Available in Appcelerator MarketPlace

// Text To Speech is very good thing and i already create blog on that and many people like it.

// One day i decide to share that product with Appcelerator. i just send that to appcelerator that accept that and that product is now in marketplace.

// That product is available in Open Marketplace and that created in alloy. 

// Best thing of that code is that work fine in both platform .

// Same code works for both (iOS , android)

// Most Important Point in Text TO Speech  :)

"Google now requires an API Key to use Google Translate on your website and charges $20 USD per million characters. Question: Where do you add the key within the above URL in order not to get a 404 message from Google"

Here, i share with you marketplace link with the help of this link you can directly download that sample code and i hope that it will help you a lot.

Download Link :)  https://marketplace.appcelerator.com/apps/6518?837327809

Slider widget In Appcelerator Marketplace

// The slider like facebook is now available in appcelerator Open Marketplace. 

// And the best thing is that product is accepeted by appcelerator i really happy about this.

// That product is available in Open Marketplace and that created in alloy. 

// Best thing of that widget is that work fine in both platform .

// There is not difference in that widget look and feel and also in their how is works.

// Same code works for both (iOS , android)

Here, i share with you marketplace link with the help of this link you can directly download that sample widget and i hope that it will help you a lot.

Download Link :)  https://marketplace.appcelerator.com/apps/6373?2033952617

Friday, 30 August 2013

How-to-use i18n(Internationalization) folder in Appcelerator

//  How-to-use i18n(Internationalization) folder

// Rather than hard-coding strings into your project, you can use localized strings. Localized strings are replaced at runtime with values appropriate to the user's language. Titanium relies on resources files and string placeholders to accomplish this task.

Example :)

 // Titanium provides two functions for obtaining a localized string from your resource files. Both take the key of the string requested as their first parameter. The L() macro is a short form for Ti.Locale.getString():


Helpful LINK :  https://wiki.appcelerator.org/display/guides/Internationalization

LIKE

var str1 = L('welcome_message');
var str2 = Ti.Locale.getString('welcome_message');
// str1 === str2

Sample code is available on GIT :) 
https://github.com/dharmik/How-to-use-i18n-folder--

Thursday, 15 August 2013

How to use paint module and save that image in local . .

// In this blog we learn that how to use paint module in appcelerator

// This module is very easy to use.

// This paint module is available on appcelerator market place.

//Sample code is available here. :)

You can get module using this link

https://dl.dropboxusercontent.com/u/72783403/paint.zip


var Paint = require('ti.paint');

var win = Ti.UI.createWindow({
    backgroundColor : '#fff'
});
var paintView = Paint.createPaintView({
    top : 0,
    right : 0,
    bottom : 80,
    left : 0,
    strokeColor : 'black',
    strokeAlpha : 255,
    strokeWidth : 5,
    eraseMode : false
});
win.add(paintView);

var clear = Ti.UI.createButton({
    bottom : 40,
    right : 50,
    width : 75,
    height : 30,
    title : 'Clear'
});
clear.addEventListener('click', function() {
    paintView.clear();
});
win.add(clear);
var save = Ti.UI.createButton({
    bottom : 40,
    left : 50,
    width : 75,
    height : 30,
    title : 'Save'
});
save.addEventListener('click', function() {
    var filename = "sample.png";
    var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);

    if (file.exists()) {
        file.deleteFile();
    }

    file.write(paintView.toImage());
    var path = file.nativePath;
    Ti.API.info('path of image' + path);
    alert('Image Save');
});
win.add(save);

win.open();




Sunday, 11 August 2013

Different project structure

// Today we simply discuss some project structure.

// How to display menu in appcelerator in different style.


// Sample code is available on GIT :)

https://github.com/dharmik/MenuStructure


Pic :)