Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Signed-off-by: timur prokopiev <pojitonov@gmail.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
pojitonov committed Nov 19, 2011
1 parent 48259a4 commit f89093c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 0 deletions.
Binary file modified development/Wheel (Date Picker).graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions development/Wheel (Date Picker).jsf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//==================================================================// iPhone Wheel (Date Picker)// Timur Prokopiev 2011//==================================================================// Global VariablesIPH_MONTHS = [1,2,3,4,5,6,7,8,9,10,11,12];IPH_DATE = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];get_index_of_array = function(array, value){ for(var i = 0; i < array.length; i++){ if (value === array[i]){ return i; } } return null;}get_month_from_array_with_shift = function(array, index, shift){ var new_index = index + shift; if (new_index < 0) new_index = array.length + new_index; if (new_index > array.length - 1) new_index = new_index - array.length; return array[new_index];}get_date_from_array_with_shift = function(array, index, shift){ var i = get_month_from_array_with_shift(array, index, shift); return normalize(i);}normalize = function(date){ return (date < 10 ? ("0" + date.toString()) : date.toString());}//==================================================================function setDefaultValues() { var values = new Array(); // Enable Current values.push({ name:"Current", type:"Boolean", value:"true" });// Month values.push({ name:"Month", type:"ComboBox", value:("12," + IPH_MONTHS.join(",")) });// Date values.push({ name:"Date", type:"ComboBox", value:("30," + IPH_DATE.join(",")) });// Year values.push({ name:"Year", type:"text", value:"2012"});Widget.elem.customData["currentValues"] = values;}function applyCurrentValues() { var values = Widget.elem.customData["currentValues"]; var current = (values[0].value.toString()=="true"); var month = parseInt(values[1].value.split(",")[0]); var date = parseInt(values[2].value.split(",")[0]); var year = values[3].value; var d = new Date(); var curr_month = d.getMonth() + 1; var curr_date = d.getDate(); var curr_year = d.getFullYear(); if (current){ month = curr_month; date = curr_date; year = curr_year; } var month_index = get_index_of_array(IPH_MONTHS, month); var date_index = get_index_of_array(IPH_DATE, date);var m_names = { January: "1", February: "2", March: "3", April: "4", May: "5", June: "6", July: "7", August: "8", September: "9", October: "10", November: "11", December: "12", }var m_count = { 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December", }if (year <= 1001 || year >= 9998 || typeof(year) === "string"){year=curr_year;}//================================================================== Widget.GetObjectByName("1 (active)").textChars = m_count[month.toString()];Widget.GetObjectByName("2 (active)").textChars = normalize(date.toString());Widget.GetObjectByName("3 (active)").textChars = year;Widget.GetObjectByName("1 (column1)").textChars = m_count[get_month_from_array_with_shift(IPH_MONTHS, month_index, -2)];Widget.GetObjectByName("2 (column1)").textChars = m_count[get_month_from_array_with_shift(IPH_MONTHS, month_index, -1)];Widget.GetObjectByName("3 (column1)").textChars = m_count[get_month_from_array_with_shift(IPH_MONTHS, month_index, 1)];Widget.GetObjectByName("4 (column1)").textChars = m_count[get_month_from_array_with_shift(IPH_MONTHS, month_index, 2)];Widget.GetObjectByName("1 (column2)").textChars = get_date_from_array_with_shift(IPH_DATE, date_index, -2);Widget.GetObjectByName("2 (column2)").textChars = get_date_from_array_with_shift(IPH_DATE, date_index, -1);Widget.GetObjectByName("3 (column2)").textChars = get_date_from_array_with_shift(IPH_DATE, date_index, 1);Widget.GetObjectByName("4 (column2)").textChars = get_date_from_array_with_shift(IPH_DATE, date_index, 2);Widget.GetObjectByName("1 (column3)").textChars = parseInt(year)-2;Widget.GetObjectByName("2 (column3)").textChars = parseInt(year)-1;Widget.GetObjectByName("3 (column3)").textChars = parseInt(year)+1;Widget.GetObjectByName("4 (column3)").textChars = parseInt(year)+2;}switch (Widget.opCode){ case 1: setDefaultValues(); break; case 2: applyCurrentValues(); break;}
Expand Down

0 comments on commit f89093c

Please sign in to comment.