code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package API; import API.Model.SessieExpiredException; import java.rmi.Remote; import java.rmi.RemoteException; /** * Deze interface wordt geinstantieerd aan de client zijde. * * Zodoende kan de server methodes van de client aanroepen. De server kan de * client remote "uitloggen" en kan de client laten weten dat het saldo van de * rekening is gewijzigd. * */ public interface IClient extends Remote { /** * Methode om de client te melden dat de sessie is verlopen en dat hij uitgelogd wordt. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet deze exceptie afgevangen worden. * @throws SessieExpiredException */ public void uitloggen() throws RemoteException, SessieExpiredException; /** * Methode om een observable te zetten bij de client. * @param ob observable object. * @throws RemoteException Zodra er gebruik gemaakt wordt van Remote, moet deze exceptie afgevangen worden. */ public void setObservable(IObservable ob) throws RemoteException; }
1234banksysteem
trunk/api/src/API/IClient.java
Java
oos
1,083
package API; import java.rmi.Remote; import java.rmi.RemoteException; /** * Interface voor Observer-observable patroon. Ipv overerving worden interfaces geimplementeerd. */ public interface IObserver extends Remote { /** * Methode om aan het object die een ander object observeert, een update te geven van een nieuw object. * @param observable Een object dat observable object * @param arg Het geupdate object dat door de observable gebruikt wordt. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet deze exceptie afgevangen worden. */ void update(Object observable, Object arg) throws RemoteException; }
1234banksysteem
trunk/api/src/API/IObserver.java
Java
oos
701
package API; import API.Model.Klant; import API.Model.LoginAccount; import API.Model.Rekening; import API.Model.SessieExpiredException; import java.math.BigDecimal; import java.rmi.RemoteException; /** * Interface waarmee client een sessie kan starten en een client haar basis * gegevens kan opvragen Tevens verantwoordelijk voor bijhouden * clientRMIobjecten * */ public interface IAuth extends IObserver { /** * Deze methode is alleen bedoeld voor DEMO doeleinden. * @param sessieId sessieID van client. * @param bedrag Het bedrag. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public void stort(String sessieId, BigDecimal bedrag) throws RemoteException, SessieExpiredException; /** * Starten van een sessie. Mits succesvol wordt er een sessieId terug * gegeven, anders null * * @param username client username om in te loggen * @param password client password om in te loggen * @return String sessieId of null * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. */ public String startSessie(String username, String password) throws RemoteException, IllegalArgumentException; /** * Hiermee kan een ClientObj geregistreert worden bij de server. Zodoende * kan de server remote calls maken bij de client. * * @param sessieId sessieId van actieve sessie * @param clientObj IClient object om remote calls uit te voeren bij de * client. * @throws RemoteException wordt gegooid wanneer de sessie van de klant verlopen is. * @throws SessieExpiredException wordt gegooid wanneer er RMI problemen zijn. */ public void registreerClientObject(String sessieId, IClient clientObj) throws RemoteException, SessieExpiredException; /** * Hiermee kan een bestaande sessie worden beeindigd. Returned true als het * gelukt is, anders false. * * @param sessionId sessieId van bestaande sessie * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public void stopSessie(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om wachtwoord aan te passen. * * @param sessionId sessieId van bestaande sessie * @param username username van de client. * @param password nieuwe password van de client. * @return true wanneer succesvol. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public boolean resetWachtwoord(String sessionId, String username, String password) throws RemoteException, SessieExpiredException; /** * Methode om klant object (gegevens) van een actieve sessie te verkrijgen * * @param sessionId sessieID van actieve sessie * @return Klant object. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public Klant getKlant(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om rekening object bij een actieve sessie te verkrijgen. * * @param sessionId sessieId van actieve sessie * @return Rekening object bij actieve sessie. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public Rekening getRekening(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om loginaccount object bij een actieve sessie op te vragen. * @param sessionId sessieId van actieve sessie * @return LoginAccount object bij actieve sessie. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de klant verlopen is. */ public LoginAccount getLoginAccount(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om een nieuwe klant + loginaccount + rekening aan te maken. * @param klantnaam naam van de klant. * @param woonplaats woonplaats van de klant. * @param gebruikersnaam gebruikersnaam van de klant. * @param wachtwoord wachtwoord van de klant. * @return true als het gelukt is om een nieuwe klant te registreren, false als het niet gelukt is. * @throws RemoteException wordt gegooid wanneer er RMI problemen zijn. */ public boolean registreerNieuweKlant(String klantnaam, String woonplaats, String gebruikersnaam, String wachtwoord) throws NullPointerException, IllegalArgumentException, RemoteException; }
1234banksysteem
trunk/api/src/API/IAuth.java
Java
oos
5,135
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API.Model; /** * Custom exceptie klasse voor een verlopen sessie die overerft van exception. */ public class SessieExpiredException extends Exception { /** * Constructor voor SessieExpiredException zonder parameters */ public SessieExpiredException() { } /** * Constructor voor SessieExpiredException * @param message een bericht */ public SessieExpiredException(String message) { super(message); } /** * Constructor voor SessieExpiredException * @param cause Throwable object */ public SessieExpiredException(Throwable cause) { super(cause); } /** * Constructor voor SessieExpiredException * @param message een bericht * @param cause Throwable object */ public SessieExpiredException(String message, Throwable cause) { super(message, cause); } }
1234banksysteem
trunk/api/src/API/model/SessieExpiredException.java
Java
oos
1,037
package API.Model; /** * Enum klasse voor de statussen van een transactie. */ public enum TransactieStatus { /** Wanneer een transactie verwerkt is door de bank krijgt het de status voltooid. */ VOLTOOID, /** Wanneer een transactie nog niet verwerkt is door de bank krijgt het de status openstaand, * alleen tijdens deze status kan de transactie geannuleerd worden. */ OPENSTAAND, /** Wanneer een transactie tijdig geannuleerd wordt, zal het niet door de bank worden * verwerkt. */ GEANNULEERD, /** Wanneer een transactie niet verwerkt kon worden door de bank omdat er iets mis is gegaan * (bijvoorbeeld de connectie met de centrale instantie) wordt de transactie tijdelijk uitgesteld. */ UITGESTELD, /** * Wanneer een transactie geaccepteerd is door centrale instelling. */ GEACCEPTEERD, /** Wanneer de bank de transactie probeerde te verwerken, maar er geen bestaande tegenrekeningnummer * was, zal de transactie geweigerd worden. */ GEWEIGERD; }
1234banksysteem
trunk/api/src/API/model/TransactieStatus.java
Java
oos
1,125
package API.Model; import java.math.BigDecimal; import java.util.GregorianCalendar; import java.util.Locale; /** * De klasse transatie is verantwoordelijk voor het registreren van een * overboeking. Hierbij is het bedrag van belang, en het rekeningnummer waar het * vanaf geschreven moet worden en de tegenrekening waarbij het bedrag * bijgeboekt moet worden. */ public class Transactie extends BaseObservable { //transient zodat het tijdens het serializeren niet wordt opgeslagen (niet meegestuurd over RMI). //volatile zodat het automatisch gesynchronizeerd wordt en nextTransactieId blijft altijd beschikbaar. //volatile variablen kunnen niet locked raken. private transient static volatile int nextTransactieId; private final int transactieId; private final String eigenbankrekening; private final String tegenrekening; private final String commentaar; private final BigDecimal bedrag; private final GregorianCalendar transactieInvoerDatum; private TransactieStatus status; /** * De constructor van Transactie. Hierin wordt als transactieInvoerDatum de * datum van vandaag gepakt. De status van de transactie staat op OPENSTAAND * bij het aanmaken van een nieuwe transactie. * * @param eigenbankrekening de rekening waarvan het bedrag afgeschreven moet * worden. * @param tegenrekening de rekening waar het bedrag bij geschreven moet * worden. * @param bedrag het bedrag wat overgemaakt wordt. * @param comment bij elke overboeking kan er commentaar of een * betalingskenmerk ingevuld worden. */ public Transactie(String eigenbankrekening, String tegenrekening, BigDecimal bedrag, String comment) { this.eigenbankrekening = eigenbankrekening; this.tegenrekening = tegenrekening; this.bedrag = bedrag; this.commentaar = comment; this.status = TransactieStatus.OPENSTAAND; this.transactieInvoerDatum = new GregorianCalendar(Locale.GERMANY); this.transactieId = nextTransactieId; Transactie.nextTransactieId++; } /** * De status van een transactie kan veranderen in loop van tijd. * * @param status de status die de transactie moet krijgen. */ public void setStatus(TransactieStatus status) { this.status = status; this.setChanged(); this.notifyObservers(); } /** * Een get-methode voor het transactieID. * * @return Het transactieID. */ public int getTransactieId() { return transactieId; } /** * Een get-methode voor de rekening waarvan het bedrag afgeschren moet * worden. * * @return de rekening waar het bedrag van afgeschreven wordt. */ public String getEigenbankrekening() { return eigenbankrekening; } /** * Een get-methode voor de rekening waar het bedrag bij geschreven moet * worden. * * @return de tegenrekening */ public String getTegenrekening() { return tegenrekening; } /** * Een get-methode voor het bedrag * * @return het bedrag */ public BigDecimal getBedrag() { return bedrag; } /** * Een get-methode voor de transactiestatus * * @return de transactiestatus */ public TransactieStatus getStatus() { return status; } /** * Een get-methode voor de datum dat de transactie ingevoerd is. * * @return de datum dat de transactie ingevoerd is. */ public GregorianCalendar getTransactieInvoerDatum() { return transactieInvoerDatum; } /** * Bij een transactie kan commentaar toegevoegd worden. * @return de commentaar / beschrijving die toegevoegd is bij transactie. */ public String getCommentaar() { return commentaar; } }
1234banksysteem
trunk/api/src/API/model/Transactie.java
Java
oos
4,014
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API.Model; import java.math.BigDecimal; import java.math.RoundingMode; /** * De klasse Rekening heeft als verantwoordelijkheid om rekeninggegevens. zoals * het saldo en kredietlimiet bij te houden. */ public class Rekening extends BaseObservable { private final String rekeningnummer; private BigDecimal saldo = new BigDecimal(0.00); private final BigDecimal kredietlimiet = new BigDecimal(100.00); //transient zodat het tijdens het serializeren niet wordt opgeslagen (niet meegestuurd over RMI) private transient static volatile int nextrekeningnummer = 1000; /** * Deze constructor maakt een nieuw rekeningnummer. Bij een nieuwe Rekening * is het saldo altijd 0 en het kredietlimiet is 100. * @param bankinitialen De 4 letters die identiek zijn voor een bank, waarmee een rekening begint. */ public Rekening(String bankinitialen) { super(); this.rekeningnummer = bankinitialen + nextrekeningnummer; nextrekeningnummer++; } /** * Een get-methode voor het rekeningnummer. * @return het rekeningnummer. */ public synchronized String getRekeningnummer() { return rekeningnummer; } /** * Een get-methode voor het saldo. * @return het saldo. */ public synchronized BigDecimal getSaldo() { return saldo.setScale(2, RoundingMode.HALF_EVEN); } /** * Een get-methode voor het kredietlimiet. * * @return het kredietlimiet. */ public synchronized BigDecimal getKredietlimiet() { return kredietlimiet.setScale(2, RoundingMode.HALF_EVEN); } /** * Een methode die gebruikt wordt om een bedrag op te nemen van een rekening (wordt gebruikt aangesproken door het uitvoeren van een Transactie). * @param bedrag het op te nemen bedrag * @return true als het bedrag afgeschreven is, false als het niet afgeschreven kon worden. */ public synchronized boolean neemOp(BigDecimal bedrag) { if (bedrag.compareTo(new BigDecimal(0)) == 1) { BigDecimal saldoTotaal = new BigDecimal(0.00); saldoTotaal = saldoTotaal.add(this.saldo); saldoTotaal = saldoTotaal.add(this.kredietlimiet); if (saldoTotaal.compareTo(bedrag) == 1 | saldoTotaal.compareTo(bedrag)== 0) { this.saldo = this.saldo.subtract(bedrag); setChanged(); notifyObservers(); return true; } } return false; } /** * methode om geld op een rekening te storten (aangeroepen bij het uitvoeren van een transactie). * @param bedrag het te storten bedrag */ public synchronized void stort(BigDecimal bedrag) { if (bedrag.compareTo(new BigDecimal(0)) == 1) { this.saldo = this.saldo.add(bedrag); } setChanged(); notifyObservers(); } /** * Een toString methode voor Rekening die de toString methode van Object * overschrijft. * @return het rekeningnummer. */ @Override public String toString() { return this.rekeningnummer; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof Rekening)) { return false; } Rekening r = (Rekening) obj; return rekeningnummer.equals(r.getRekeningnummer()); } }
1234banksysteem
trunk/api/src/API/model/Rekening.java
Java
oos
3,756
package API.Model; import API.IObservable; import API.IObserver; import java.io.Serializable; import java.rmi.RemoteException; import java.util.Observable; import java.util.Observer; /** * Base klasse voor observer/observable mechanisme. De observer klasses zijn * naast observers tevens Remote objecten, hierdoor is dubbele overerving * vereist. Om dit mogelijk te maken gebruiken we IObserver en IObservable. * Observable model klasse kunnen van deze klasse overerven om dubbele code te * vermijden. * */ public class BaseObservable extends Observable implements IObservable, Serializable { //transient zodat het niet geserialiseerd wordt meegestuurd. private transient static volatile int nextObservableId = 0; private final int observableId; /** * Nested klasse zodat de implementatie van observer/observable niet * opnieuw hoeft te worden geimplementeerd. */ private class WrappedObserver implements Observer, Serializable { private IObserver ro = null; public WrappedObserver(IObserver ro) { this.ro = ro; } @Override public void update(Observable o, Object arg) { try { ro.update(o, arg); } catch (RemoteException e) { System.out.println("Remote exception removing observer:" + this); o.deleteObserver(this); } } } /** * Methode om Iobserver te wrappen in een "echte" observer * @param o Iobserver */ @Override public synchronized void addObserver(IObserver o) { WrappedObserver mo = new WrappedObserver(o); addObserver(mo); } /** * Contructor voor observable. Zet gelijk het observableid. */ public BaseObservable() { this.observableId = nextObservableId; nextObservableId++; } /** * Get methode voor observablie ID * @return het observable ID */ @Override public int getObservableId() { return this.observableId; } }
1234banksysteem
trunk/api/src/API/model/BaseObservable.java
Java
oos
2,130
package API.Model; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * De verantwoordelijkheid van de Klasse klant, is het bijhouden van de naam en * woonplaats van de klant. De combinatie van naam, woonplaats en loginaccount * moeten uniek zijn wil de klant zich registreren bij een bank. */ public class Klant extends BaseObservable { private static Pattern karakterPattern; private static Pattern plaatsPattern; private final int klantNr; private String klantnaam; private String klantwoonplaats; //nog uit te breiden met postcode etc. private transient static volatile int nextklantnummer = 1; /** * De constructor voor Klant. * * @param klantnaam de naam van de klant. * @param klantwoonplaats de woonplaats van de klant. */ public Klant(String klantnaam, String klantwoonplaats) { //wanneer klant zijn gegevens heeft ingevoerd zonder hoofdletter(s) // zal de eerste letter een hoofdletter moeten zijn. this.klantnaam = capitaliseerWoord(klantnaam); this.klantwoonplaats = capitaliseerWoord(klantwoonplaats); this.klantNr = nextklantnummer; nextklantnummer++; } /** * Wanneer een klant een naamswijziging doorgeeft kan dat met onderstaande * methode verwerkt worden. * * @param klantnaam de nieuwe naam van de klant. */ public void setKlantnaam(String klantnaam) { this.klantnaam = klantnaam; } /** * Wanneer een klant een nieuwe woonplaats doorgeeft, kan dat met * onderstaande methode worden verwerkt. * * @param klantwoonplaats de nieuwe woonplaats van de klant. */ public void setKlantwoonplaats(String klantwoonplaats) { this.klantwoonplaats = klantwoonplaats; } /** * Een get-methode voor de klantnaam. * * @return de naam van de klant. */ public String getKlantnaam() { return klantnaam; } /** * Een get-methode voor de woonplaats van de klant. * * @return de woonplaats van de klant. */ public String getKlantwoonplaats() { return klantwoonplaats; } /** * Een get-methode voor het klantnummer van de klant. * * @return het klantnummer van de klant. */ public int getKlantNr() { return klantNr; } /** * Methode om te zorgen dat bepaalde gegevens van de klant altijd starten * met een hoofdletter en de rest kleine letters. * * @param string de tekst die omgezet moet worden. * @return de tekst die omgezet is. */ private String capitaliseerWoord(String string) { String[] token = string.split(" "); StringBuilder stringbuilder = new StringBuilder(); for (int i = 0; i < token.length; ++i) { String naam = token[i].toLowerCase(); naam = naam.substring(0, 1).toUpperCase() + naam.substring(1); stringbuilder.append(naam).append(" "); } //laatste spatie er uit halen die automatisch toegevoegd wordt aan de stringbuilder. return stringbuilder.toString().substring(0, stringbuilder.length() - 1); } /** * Een toString methode voor Klant die de toString methode van Object * overschrijft. * * @return de naam van de klant. */ @Override public String toString() { return this.klantnaam; } /** * Methode om te controleren of een string alleen uit letters bestaat. * * @param toCompare String om te controleren * @return true wanneer voldoet, anders false */ public static boolean isAlphabetical(String toCompare) { if (karakterPattern == null) { karakterPattern = Pattern.compile("[a-zA-Z]+"); } Matcher matcher = karakterPattern.matcher(toCompare); return matcher.matches(); } /** * Methode om te controleren of een string een plaatsnaam bevat. Nederlandse plaatsnamen mogen gebruik maken van verschillende karakters als - of '. * Deze methode controleert op karakters en composities van alle plaatsnamen uit onderstaande lijst: * http://nl.wikipedia.org/wiki/Lijst_van_Nederlandse_plaatsen * * @param toCompare De te vergelijken string. * @return True wannneer de string voldoet aan de eisen van een plaatsnaam, anders false */ public static boolean isPlaatsnaam(String toCompare) { if (plaatsPattern == null) { plaatsPattern = Pattern.compile("^(([2][e][[:space:]]|['][ts][-[:space:]]))?[ëéÉËa-zA-Z]{2,}((\\s|[-](\\s)?)[ëéÉËa-zA-Z]{2,})*$"); } Matcher matcher = plaatsPattern.matcher(toCompare); return matcher.matches(); //"^(([2][e][[:space:]]|['][ts][-[:space:]]))?[ëéÉËa-zA-Z]{2,}((\\s|[-](\\s)?)[ëéÉËa-zA-Z]{2,})*$" } }
1234banksysteem
trunk/api/src/API/model/Klant.java
Java
oos
5,027
package API.Model; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * De verantwoordelijkheid van de klasse LoginAccount is het bijhouden van een * inlognaam en een wachtwoord. Een inlognaam mag niet vaker voorkomen bij een * bank (een wachtwoord wel). */ public class LoginAccount extends BaseObservable { private String loginnaam; private transient String loginwachtwoord; private final int klantNr; private final String rekeningNr; private static Pattern karakterPattern; /** * De constructor van LoginAccount * * @param loginnaam de loginnaam van de klant * @param loginwachtwoord het loginwachtwoord van de klant * @param klantNr klantnummer van de klant. * @param rekeningNr rekeningnummer van de klant. */ public LoginAccount(String loginnaam, String loginwachtwoord, int klantNr, String rekeningNr) { this.loginnaam = loginnaam; this.loginwachtwoord = loginwachtwoord; this.klantNr = klantNr; this.rekeningNr = rekeningNr; } /** * Een get-methode voor de loginnaam * * @return de loginnaam */ public String getLoginNaam() { return this.loginnaam; } /** * Een get methode om klantnummer op te vragen. * * @return het klantnummer */ public int getKlantNr() { return klantNr; } /** * Een get methode om wachtwoord te verkrijgen bij loginaccount * * @return het wachtwoord. */ public String getLoginwachtwoord() { return loginwachtwoord; } /** * Een get methode voor het rekeningnummer die gekoppeld is aan het * loginaccount * * @return het rekeningnummer */ public String getRekeningNr() { return rekeningNr; } /** * Wanneer een klant bij het inloggen zijn wachtwoord is vergeten, moet het * mogelijk zijn (of worden) om het wachtwoord te wijzigen. * * @param nieuwwachtwoord het nieuwe wachtwoord */ public void setWachtwoord(String nieuwwachtwoord) { this.loginwachtwoord = nieuwwachtwoord; } /** * Een toString methode voor LoginAccount die de toString methode van Object * overschrijft. * * @return de loginnaam. */ @Override public String toString() { return this.loginnaam; } /** * Methode om te controleren of de gebruikersnaam voldoet aan de * voorwaarden. Gebruikersnaam mag letters en cijfers bevatten * * @param toCompare String om te controleren * @return true wanneer voldoet, anders false */ public static boolean isAlphanumeric(String toCompare) { if (karakterPattern == null) { karakterPattern = Pattern.compile("\\w+"); } Matcher matcher = karakterPattern.matcher(toCompare); return matcher.matches(); } }
1234banksysteem
trunk/api/src/API/model/LoginAccount.java
Java
oos
3,013
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API.Model; /** * Gebruiken om transacties op te zoeken. * */ public enum TransactieType { /** Wanneer er geld op een rekening gestort wordt, zal dit debet zijn. */ DEBET, /** Wanneer er geld van een bankrekening afgehaald wordt, zal dit credit zijn. */ CREDIT, /** Wanneer er geld van een bankrekening wordt gehaald of wordt gestort. */ ALLE; }
1234banksysteem
trunk/api/src/API/model/TransactieType.java
Java
oos
529
package api; import java.math.BigDecimal; import java.rmi.Remote; import java.rmi.RemoteException; /** * Remote interface waarmee de banken kunnen communiceren met de centrale instelling. * Via deze interface kan er bijv. een cross-bank transactie worden aangevraagd. */ public interface ICiServer extends Remote { /** * Methode om ICiClient bekend te maken bij de centrale instelling. * @param prefix rekeningnummer prefix van bank * @param key authentificatie sleutel * @param clientObj ICiClient van bank * @return String waarde met status codes. * @throws RemoteException */ public String setClient(String prefix, String key, ICiClient clientObj) throws RemoteException; /** * Methode om een cross-bank transactie aan te vragen. * @param prefix rekeningnummer prefix van aanvragende bank * @param key authenticatiesleutel * @param vanRekening Rekeningnummer van de aanvrager. * @param naarRekening Tegenrekening * @param bedrag het over te maken bedrag * @param comment Commentaar bij de transactie * @return String waarde met status codes. * @throws RemoteException * @throws IllegalArgumentException */ public String requestTransaction(String prefix, String key, String vanRekening, String naarRekening, BigDecimal bedrag, String comment) throws RemoteException, IllegalArgumentException; }
1234banksysteem
trunk/CiApi/src/api/ICiServer.java
Java
oos
1,460
package api; import java.math.BigDecimal; import java.rmi.Remote; import java.rmi.RemoteException; /** * Client interface voor banken. Hiermee kan de centrale instelling communiceren met de betreffende bank. */ public interface ICiClient extends Remote { /** * Methode waarmee de centrale instelling een transactie aan kan vragen bij een bank. Benodigd voor cross-bank transacties * Dit is verder niet uitgewerkt. Hier missen bijv. nog verschillende referenties van de verschillende banken. * @param vanRekening Aanvragende rekening * @param naarRekening Tegen rekening * @param bedrag bedrag van de transacti e * @param comment opmerkingen e.d. geplaatst bij de transactie. * @return String retourneert een bericht om aan te geven of dit gelukt is. * @throws RemoteException */ public String transactionRequested(String vanRekening, String naarRekening, BigDecimal bedrag, String comment) throws RemoteException; }
1234banksysteem
trunk/CiApi/src/api/ICiClient.java
Java
oos
997
package CiClient; import api.ICiClient; import java.math.BigDecimal; import java.rmi.RemoteException; /** * Klasse binnen bank die als client voor centrale instelling dient. * Deze klasse implementeert ICiClient en kan berichten sturen naar de centrale instelling. */ public class CiClient implements ICiClient { /** * * @param vanRekening * @param naarRekening * @param bedrag * @param comment * @return * @throws RemoteException */ @Override public String transactionRequested(String vanRekening, String naarRekening, BigDecimal bedrag, String comment) throws RemoteException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }
1234banksysteem
trunk/Bank/src/CiClient/CiClient.java
Java
oos
816
package CiClient; import api.ICiServer; import java.math.BigDecimal; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; /** * Klasse om de bankclient te verbinden met Centrale Instelling. */ public class CiConnector { private final String ciServerURL = "127.0.0.1"; private static String prefix; private static String key; private static ICiServer ciStub; private static Registry registry; /** * Constructor voor CiConnector die een aanroep doet naar setRegistry(). * @throws RemoteException moet afgevangen worden als er gebruik gemaakt wordt van RMI * @throws NotBoundException moet afgevangen worden wanneer centrale instelling offline is. */ public CiConnector() throws RemoteException, NotBoundException { setRegistry(); } /** * Constructor met 2 overloads * @param prefix unieke bankinitialen van de bank. * @param key validatiesleutel van de bank * @throws RemoteException moet afgevangen worden als er gebruik gemaakt wordt van RMI * @throws NotBoundException moet afgevangen worden wanneer centrale instelling offline is. */ public CiConnector(String prefix, String key) throws RemoteException, NotBoundException { this.prefix = prefix; this.key = key; setRegistry(); } /** * Methode die de registry zet. In deze methode wordt een referentie op gevraagd bij RMI Registry op de gespecificeerde host en port. * @throws RemoteException moet afgevangen worden als er gebruik gemaakt wordt van RMI */ private synchronized void setRegistry() throws RemoteException { if (registry == null) { if (System.getSecurityManager() == null) { SecurityManager securM = new SecurityManager(); System.setSecurityManager(securM); } registry = LocateRegistry.getRegistry(this.ciServerURL, 1100); } } /** * Methode die de stub van centrale instelling opzoekt. * Daarbij wordt de remote referentie die gebonden is aan de gespecificeerde naam in de registry opgevraagd. * @throws NotBoundException moet afgevangen worden wanneer centrale instelling offline is. * @throws RemoteException moet afgevangen worden als er gebruik gemaakt wordt van RMI */ private synchronized void lookupCiStub() throws NotBoundException, RemoteException { if (ciStub == null) { ciStub = (ICiServer) registry.lookup("ci"); } } /** * * @param vanRekening * @param naarRekening * @param bedrag * @param comment * @return * @throws RemoteException * @throws NotBoundException */ public synchronized String requestTransaction(String vanRekening, String naarRekening, BigDecimal bedrag, String comment) throws RemoteException, NotBoundException { lookupCiStub(); if (ciStub != null) { return ciStub.requestTransaction(prefix, key, vanRekening, naarRekening, bedrag, comment); } return null; } }
1234banksysteem
trunk/Bank/src/CiClient/CiConnector.java
Java
oos
3,217
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package managers; import API.Model.Klant; import java.util.HashMap; /** * De klantmanager klasse houdt een hashmap waar klanten te zoeken zijn op * klantnr */ public class KlantManager { private HashMap<Integer, Klant> klanten; //klantNr, KlantObject /** * */ private static class Loader { private static final KlantManager instance = new KlantManager(); } /** * Constructor voor klantmanager */ private KlantManager() { this.klanten = new HashMap<>(); } /** * Klantmanager wordt eenmalig opgestart en met deze methode kan de huidige klantmanager opgevraagd worden. * @return Actieve KlantManager object */ public static KlantManager getInstance() { return Loader.instance; } /** * deze methode voegt een klant toe aan de klantmanager * @param klant Klant object * @return true indien het toevoegen gelukt is, anders false */ public boolean addKlant(Klant klant) { synchronized (this.klanten) { if (this.klanten.get(klant.getKlantNr()) == null) { this.klanten.put(klant.getKlantNr(), klant); return true; } } return false; } /** * deze methode stuurt de klant terug met het gekozen klantnr * @param klantNr het klantnr van de klant * @return gekozen klant */ public Klant getKlant(int klantNr) { synchronized (this.klanten) { return this.klanten.get(klantNr); } } /** * Methode die kijkt of een klant al bekend is in het systeem wanneer * hij/zij zich registreert. Dan kan het bestaande klantnummer meegegeven * worden. * * @param naam * @param woonplaats * @return */ public int getBestaandeKlantNummer(String naam, String woonplaats) { String klantnaam = capitaliseerWoord(naam); String klantwoonplaats = capitaliseerWoord(woonplaats); for (Klant klant : this.klanten.values()) { if (klant.getKlantnaam().equals(klantnaam) && klant.getKlantwoonplaats().equals(klantwoonplaats)) { return klant.getKlantNr(); } } return 0; } /** * deze functie zet de eerste letter van een string in hoofdletter en de * rest van de string in kleine letters. * * @param string de string die aangepast moet worden * @return string */ private String capitaliseerWoord(String string) { String[] token = string.split(" "); StringBuilder stringbuilder = new StringBuilder(); for (int i = 0; i < token.length; ++i) { String naam = token[i].toLowerCase(); naam = naam.substring(0, 1).toUpperCase() + naam.substring(1); stringbuilder.append(naam).append(" "); } //laatste spatie er uit halen die automatisch toegevoegd wordt aan de stringbuilder. return stringbuilder.toString().substring(0, stringbuilder.length() - 1); } }
1234banksysteem
trunk/Bank/src/managers/KlantManager.java
Java
oos
3,251
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package managers; import java.util.TimerTask; /** * SessieTask om een sessie te kunnen beindigen na inactiviteit. Kan gebruikt * worden i.c.m. java.util.Timer. * */ public class SessieTask extends TimerTask { /** * constructor voor SessieTask. */ public SessieTask() { } /** * Run methode voor Sessietask waarin gekeken wordt of er sessie verlopen zijn binnen * de SessieManager. */ @Override public void run() { SessieManager sm = SessieManager.getInstance(); sm.expireCheck(); } }
1234banksysteem
trunk/Bank/src/managers/SessieTask.java
Java
oos
682
package managers; import API.IClient; import API.Model.LoginAccount; import controller.Sessie; import API.Model.SessieExpiredException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Map; import java.util.Timer; import java.util.logging.Level; import java.util.logging.Logger; /** * de SessieManager klasse houdt een hashmap bij waarin alle sessies worden bijgehouden. * Deze zijn te zoeken op SessieID. */ public class SessieManager { //Hashmap zodat we met O(1) op sessieId kunnen zoeken. //zoeken op Sessie referentie is gelijk aan ArrayList O(n); private HashMap<String, Sessie> sessies; private Timer timer; private long timerInterval = 1000; private SessieTask sessieTask; /** * Methode om een loginaccount bij een sessie op te vragen zonder dat de laatste activiteit geupdate wordt. * Vanuit de gui wordt er elke keer een callback gedaan om de transactielijst te verversen. Hierbij mag de * lastActivity niet veranderd worden bij de betreffende sessie. * @param sessieId SessieID behorende bij client die zijn loginaccount opvraagd. * @return LoginAccount object * @throws SessieExpiredException moet afgevangen worden om te kijken of sessie verlopen is. */ public LoginAccount getAccountFromSessieNoActivityChange(String sessieId) throws SessieExpiredException { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); if (sessie != null) { return sessie.getLoginNoActivityChange(); } else { throw new SessieExpiredException("Sessie verlopen"); } } } return null; } /** * Klasse loader wordt aangeroepen in de getInstance methode binnen SessieManager. * En zorgt dat er een nieuwe SessieManager opgestart wordt wanneer dit nog niet gedaan is. * Lazy-loaded singleton pattern */ private static class Loader { private static final SessieManager instance = new SessieManager(); } /** * Private constructor voor SessieManager die alleen in klasse Loader wordt aangeroepen. * */ private SessieManager() { this.sessies = new HashMap<>(); scheduleExpireCheck(); } /** * Methode om SessieManager op te vragen. * @return actieve SessieManager. */ public static SessieManager getInstance() { return Loader.instance; } /** * voegt een sessie toe aan de SessieManager * @param sessie de toe te voegen sessie * @return true indien de sessie is toegevoegd, anders false */ public boolean addSessie(Sessie sessie) { if (sessie != null) { synchronized (this.sessies) { if (this.sessies.get(sessie.getSessieId()) == null) { this.sessies.put(sessie.getSessieId(), sessie); return true; } } } return false; } /** * stuurt sessie terug met het opgegeven sessieId * @param sessieId sessieId van de terug te sturen sessie * @return sessie indien deze in de SessieManager voorkomt, anders null */ private Sessie getSessie(String sessieId) { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); return sessie; } } return null; } /** * stuurt een loginaccount terug waarbij de sessie het opgegeven sessieId heeft * @param sessieId het sessieId van de sessie * @return loginaccount van het gekozen sessieId indien deze is gevonden, anders null * @throws SessieExpiredException moet afgevangen worden om te kijken of sessie verlopen is. */ public LoginAccount getAccountFromSessie(String sessieId) throws SessieExpiredException { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); if (sessie != null) { return sessie.getLogin(); } else { throw new SessieExpiredException("Sessie verlopen"); } } } return null; } /** * Methode die zorgt dat sessietask om de zoveel tijd wordt uitgevoerd. */ private void scheduleExpireCheck() { try { if (timer != null) { timer.cancel(); } } catch (IllegalStateException e) { } finally { timer = new Timer(); sessieTask = new SessieTask(); timer.schedule(sessieTask, timerInterval); } } /** * Methode die kijkt of sessies 10 minuten ongebruikt zijn, logt ze dan uit. */ public void expireCheck() { java.util.Date date = new java.util.Date(); synchronized (this.sessies) { for (Map.Entry pair : this.sessies.entrySet()) { Sessie sessie = (Sessie) pair.getValue(); long verschil = date.getTime() - sessie.getLastActivity().getTime(); //Check of tijd toeneemt bij een sessieID wanneer daarbij geen activiteit heeft plaatsgevonden. //System.out.println("Sessie ID: " + sessie.getSessieId() + " Verschil: " + verschil ); if (verschil > 600000) { IClient clientOb = sessie.getClient(); try { clientOb.uitloggen(); } catch (RemoteException ex) { Logger.getLogger(SessieManager.class.getName()).log(Level.SEVERE, null, ex); } catch (SessieExpiredException ex) { Logger.getLogger(SessieManager.class.getName()).log(Level.SEVERE, null, ex); } finally { this.sessies.remove(sessie.getSessieId()); } } } } scheduleExpireCheck(); } /** * Methode om clientobject aan een sessieID te koppelen. * @param sessieId sessieID van clientobject. * @param clientObject behorende bij het sessieID. * @throws SessieExpiredException moet afgevangen worden om te kijken of de sessie verlopen is. */ public void bindClientObjecToSessie(String sessieId, IClient clientObject) throws SessieExpiredException { synchronized (this.sessies) { Sessie sessie = this.sessies.get(sessieId); if (sessie != null) { sessie.setClient(clientObject); } else { throw new SessieExpiredException("Sessie verlopen"); } } } /** * Methode om IClient op te vragen. * @param sessieId die gekoppeld is aan de gevraagde IClient object. * @return IClient object. * @throws SessieExpiredException moet afgevangen worden om te kijken of de sessie verlopen is. */ public synchronized IClient getClient(String sessieId) throws SessieExpiredException { if (sessieId != null && sessies.get(sessieId) != null) { Sessie sessie = sessies.get(sessieId); return sessie.getClient(); } return null; } /** * Methode die de sessie verwijderd. * @param sessieId sessieId van de te verwijderen Sessie */ public void stopSessie(String sessieId) { if (sessieId != null || sessieId.isEmpty()) { synchronized (sessies) { if (sessies.containsKey(sessieId)) { sessies.remove(sessieId); } } } } }
1234banksysteem
trunk/Bank/src/managers/SessieManager.java
Java
oos
7,975
package managers; import API.Model.Rekening; import java.util.HashMap; /** * de RekeningManager klasse houdt een hashmap met rekeningen waarbij op * rekeningnummer gezocht kan worden. */ public class RekeningManager { private HashMap<String, Rekening> rekeningen; private String bankinitialen; /** * Klasse loader wordt aangeroepen in de getInstance methode binnen SessieManager. * En zorgt dat er een nieuwe SessieManager opgestart wordt wanneer dit nog niet gedaan is. * Lazy-loaded singleton pattern */ private static class Loader { final static RekeningManager instance = new RekeningManager(); } /** * Constructor voor Rekeningmanager */ private RekeningManager() { this.rekeningen = new HashMap<>(); } /** * Methode om actieve rekeningmanager op te vragen. * * @return RekeningManager object. */ public static RekeningManager getInstance() { return Loader.instance; } /** * voegt een rekening toe aan de rekeningmanager * * @param rekening de toe te voegen rekening * @return true indien de rekening is toegevoegd, anders false */ public boolean addRekening(Rekening rekening) { if (rekening != null) { synchronized (this.rekeningen) { if (this.rekeningen.get(rekening.getRekeningnummer()) == null) { this.rekeningen.put(rekening.getRekeningnummer(), rekening); return true; } } } return false; } /** * stuurt rekeningobject terug met gekozen rekeningnr * * @param rekeningNr het rekeningnummer van het terug te sturen * rekeningobject. * @return gekozen Rekening */ public Rekening getRekening(String rekeningNr) { synchronized (this.rekeningen) { return this.rekeningen.get(rekeningNr); } } /** * Methode om bij een bank elk rekeningnummer te starten met de initialen van de betreffende bank. * @param banknaam naam van de bank. */ public void setBankInitialen(String banknaam) { String banknaamHoofdletters = banknaam.toUpperCase(); StringBuilder sb = new StringBuilder(); for (int i=0; i < 4; i++) { sb.append(banknaamHoofdletters.charAt(i)); } this.bankinitialen = sb.toString(); } /** * Get methode om bankinitialen op te vragen om deze in een rekening te zetten. * @return */ public String getBankInitialen() { return this.bankinitialen; } }
1234banksysteem
trunk/Bank/src/managers/RekeningManager.java
Java
oos
2,751
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package managers; import API.Model.LoginAccount; import java.util.HashMap; /** * De loginmanager klasse houdt een hashmap bij waarin loginaccounts te vinden zijn op loginnr */ public class LoginManager { private HashMap<String, LoginAccount> logins; //loginNr, loginObject; /** * Deze klasse wordt aangeroepen in de getInstance methode binnen LoginManager. * Dit is een vorm van Good Practice. */ private static class Loader { private static final LoginManager instance = new LoginManager(); } /** * private constructor voor LoginManager die alleen in Loader klasse wordt aangeroepen. */ private LoginManager() { this.logins = new HashMap<>(); } /** * Methode om de instantie van LoginManager op te vragen. * @return Actieve LoginManager object */ public static LoginManager getInstance() { return Loader.instance; } /** * voegt een loginaccount toe aan de loginmanager * @param login het toe te voegen loginaccount * @return true indien het toevoegen is gelukt, false indien dit niet is gelukt. */ public boolean addLogin(LoginAccount login) { if (login != null) { synchronized (this.logins) { if (this.logins.get(login.getLoginNaam()) == null) { this.logins.put(login.getLoginNaam(), login); return true; } } } return false; } /** * deze methode stuurt het loginaccount terug indien het opgegeven naam * en wachtwoord correct zijn. * Indien de loginnaam niet bestaat of het wachtwoord niet klopt zal dit * door middel van een exception door worden gegeven. * @param loginNaam de loginnaam van het op te vragen loginaccount * @param password het wachtwoord van het op te vragen loginaccount * @return LoginAccount indien naam en wachtwoord correct * @throws IllegalArgumentException */ public LoginAccount getLoginAccount(String loginNaam, String password) throws IllegalArgumentException { synchronized (this.logins) { LoginAccount login = this.logins.get(loginNaam); if (login == null) { throw new IllegalArgumentException("Onbekende gebruikersnaam"); } if (login.getLoginwachtwoord().equals(password)) { return login; } else { throw new IllegalArgumentException("Foutief wachtwoord"); } } } /** * checkt indien de opgegeven loginNaam al bestaat. * @param loginNaam de te checken naam van het inlogaccount * @return false indien de loginnaam niet bestaat */ public boolean bestaatLoginNaam(String loginNaam) { synchronized(this.logins) { LoginAccount login = this.logins.get(loginNaam); if (login == null) { return false; } else { throw new IllegalArgumentException("Loginnaam is al in gebruik"); } } } }
1234banksysteem
trunk/Bank/src/managers/LoginManager.java
Java
oos
3,305
package managers; import API.Model.Rekening; import API.Model.Transactie; import API.Model.TransactieStatus; import API.Model.TransactieType; import CiClient.CiConnector; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /** * Klasse TransactieManager wordt eenmalig geinstantieerd en houdt een lijst bij van alle transacties. */ public class TransactieManager { private static volatile TransactieManager instance = null; private HashMap<Integer, Transactie> transacties; private CiConnector ciConnector; /** * Klasse loader wordt aangeroepen in de getInstance methode binnen TransactieManager. * En zorgt dat er een nieuwe SessieManager opgestart wordt wanneer dit nog niet gedaan is. * Lazy-loaded singleton pattern */ private static class Loader { private static final TransactieManager instance = new TransactieManager(); } /** * Private constructor voor TransactieManager die alleen in klasse Loader wordt aangeroepen. * */ private TransactieManager() { this.transacties = new HashMap<>(); } /** * Methode om Transactiemanager op te vragen. * @return actieve Transactiemanager. */ public static TransactieManager getInstance() { return Loader.instance; } /** * Methode om een transactie toe te voegen aan de hashmap. * @param trans Transactie object. */ public void addTransactie(Transactie trans) { if (trans != null) { synchronized (transacties) { if (transacties.get(trans.getTransactieId()) == null) { if (trans.getStatus() == TransactieStatus.OPENSTAAND) { Rekening creditRekeningNr = RekeningManager.getInstance().getRekening(trans.getEigenbankrekening()); if (creditRekeningNr == null) { trans.setStatus(TransactieStatus.GEWEIGERD); } } transacties.put(trans.getTransactieId(), trans); executeTransactions(); } }; } } /** * Methode om een transactie uit te voeren (dus te verwerken). */ //uitvoeren van transacties kan beter in aparte threads worden gedaan. Voor nu zo gelaten. private void executeTransactions() { synchronized (transacties) { for (Map.Entry pair : this.transacties.entrySet()) { Transactie trans = (Transactie) pair.getValue(); if (RekeningManager.getInstance().getRekening(trans.getTegenrekening()) == null) { executeForeignBankTransaction(trans); } else { executeTransaction(trans); } } }; } /** * Methode die aangeroepen wordt wanneer een transactie wordt geplaatst waarbij tegenrekeningnummer van een andere bank is. * @param trans Transactie object. */ private void executeForeignBankTransaction(Transactie trans) { if (trans != null) { if (trans.getStatus() == TransactieStatus.OPENSTAAND) { Rekening creditRekeningNr = RekeningManager.getInstance().getRekening(trans.getEigenbankrekening()); if (creditRekeningNr.neemOp(trans.getBedrag())) { if (this.ciConnector == null) { try { this.ciConnector = new CiConnector(); } catch (RemoteException | NotBoundException ex) { creditRekeningNr.stort(trans.getBedrag()); Logger.getLogger(TransactieManager.class.getName()).log(Level.SEVERE, null, ex); } } try { String requestResult = this.ciConnector.requestTransaction(trans.getEigenbankrekening(), trans.getTegenrekening(), trans.getBedrag(), trans.getCommentaar()); System.out.println(requestResult); //requestResult bestaat altijd uit een aantal cijfers en een dubbele punt: //zie CentraleInstelling.java voor de exacte implementatie. String[] resultTokens = requestResult.split(":"); //Wanneer de geretourneerde string start met 200 betekent dat de transactie geaccepteerd is en dat de transactiestatus veranderd. // een andere geretourneerde code betekend dat de transactie niet geaccepteerd is en de status veranderd naar geweigerd. if (resultTokens[0].equals("200")) { trans.setStatus(TransactieStatus.GEACCEPTEERD); } else { trans.setStatus(TransactieStatus.GEWEIGERD); creditRekeningNr.stort(trans.getBedrag()); } } catch (RemoteException | NotBoundException ex) { creditRekeningNr.stort(trans.getBedrag()); Logger.getLogger(TransactieManager.class.getName()).log(Level.SEVERE, null, ex); } } } } } /** * Methode om één transactie uit te voeren. Waarbji van-rekening en tegen-rekening binnen deze bank bekend zijn. * @param trans Transactie */ private void executeTransaction(Transactie trans) { if (trans != null) { if (trans.getStatus() == TransactieStatus.OPENSTAAND) { Rekening creditRekeningNr = RekeningManager.getInstance().getRekening(trans.getEigenbankrekening()); Rekening debitRekeningNr = RekeningManager.getInstance().getRekening(trans.getTegenrekening()); if (debitRekeningNr != null & creditRekeningNr != null) { if (creditRekeningNr.neemOp(trans.getBedrag())) { debitRekeningNr.stort(trans.getBedrag()); trans.setStatus(TransactieStatus.VOLTOOID); } else { trans.setStatus(TransactieStatus.GEWEIGERD); } } else { trans.setStatus(TransactieStatus.GEWEIGERD); } } } } /** * Deze methode wordt gebruikt om transacties op te vragen. * @param creditRknNr van-rekeningnummer * @param debetRknNr tegen-rekeningnummer * @param vanafDatum de startdatum van de transacties die opgehaald worden. * @param totDatum de einddatum van de transacties die opgehaald worden. * @param status de status van de transacties. * @param type de type transactie (credit/debet). * @return Een lijst van transacties. */ public ArrayList<Transactie> getTransacties(String creditRknNr, String debetRknNr, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status, TransactieType type) { ArrayList<Transactie> gezochteTransactie = new ArrayList<>(); GregorianCalendar searchVanafDatum; GregorianCalendar searchTotDatum; if (vanafDatum == null | vanafDatum instanceof GregorianCalendar == false) { searchVanafDatum = new GregorianCalendar(); //geen datum opgegeven is standaard 30 dagen terug. searchVanafDatum.add(Calendar.DAY_OF_MONTH, -30); } else { searchVanafDatum = vanafDatum; } if (totDatum == null | totDatum instanceof GregorianCalendar == false) { searchTotDatum = new GregorianCalendar(); } else { searchTotDatum = totDatum; } synchronized (transacties) { for (Map.Entry pair : this.transacties.entrySet()) { Transactie t = (Transactie) pair.getValue(); if (status == null | status == t.getStatus()) { //nog aanpassen. Dit is een exclusive search i.p.v. inclusive if (t.getTransactieInvoerDatum().before(searchTotDatum) && t.getTransactieInvoerDatum().after(searchVanafDatum)) { //wanneer debetRknr is opgegeven maakt type niet uit. if (debetRknNr != null & creditRknNr.equals(t.getEigenbankrekening())) { gezochteTransactie.add(t); } else { switch (type) { case ALLE: //aanvragen die niet voltooid zijn mogen niet zichtbaar zijn voor de ontvanger. if (t.getStatus() == TransactieStatus.VOLTOOID) { if (creditRknNr.equals(t.getEigenbankrekening()) | creditRknNr.equals(t.getTegenrekening())) { gezochteTransactie.add(t); } } else { if (creditRknNr.equals(t.getEigenbankrekening())) { gezochteTransactie.add(t); } } break; case DEBET: if (creditRknNr.equals(t.getTegenrekening()) & debetRknNr.equals(t.getEigenbankrekening())) { gezochteTransactie.add(t); } break; case CREDIT: if (creditRknNr.equals(t.getEigenbankrekening()) & debetRknNr.equals(t.getTegenrekening())) { gezochteTransactie.add(t); } break; } } } } } } return gezochteTransactie; } }
1234banksysteem
trunk/Bank/src/managers/TransactieManager.java
Java
oos
10,615
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package server; import java.awt.Point; /** * * @author Melis */ public class StartServerFrame extends javax.swing.JFrame { /** * Creates new form StartServerFrame */ public StartServerFrame() { initComponents(); setLocation(new Point(500, 100)); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { cmbBanken = new javax.swing.JComboBox(); btnStart = new javax.swing.JButton(); btnStop = new javax.swing.JButton(); lblServerBackground = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Rainbow Sheep Software"); setName("StartFrame"); // NOI18N setResizable(false); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); cmbBanken.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Rabobank", "Fortis Bank", "ABNAmro Bank", "Rainbow Sheep Bank" })); cmbBanken.setBorder(null); getContentPane().add(cmbBanken, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 200, 170, -1)); btnStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/server/Images/ServerPlayButton.gif"))); // NOI18N btnStart.setBorder(null); btnStart.setBorderPainted(false); btnStart.setContentAreaFilled(false); btnStart.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION); btnStart.setDoubleBuffered(true); btnStart.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/server/Images/ServerPlayButton_Selected.gif"))); // NOI18N btnStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnStartActionPerformed(evt); } }); getContentPane().add(btnStart, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 270, -1, -1)); btnStop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/server/Images/ServerStopButton.gif"))); // NOI18N btnStop.setBorder(null); btnStop.setBorderPainted(false); btnStop.setContentAreaFilled(false); btnStop.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION); btnStop.setDoubleBuffered(true); btnStop.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/server/Images/ServerStopButton_Selected.gif"))); // NOI18N btnStop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnStopActionPerformed(evt); } }); getContentPane().add(btnStop, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 270, -1, -1)); lblServerBackground.setIcon(new javax.swing.ImageIcon(getClass().getResource("/server/Images/StartServerBackground.gif"))); // NOI18N lblServerBackground.setText("jLabel1"); lblServerBackground.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION); lblServerBackground.setDoubleBuffered(true); lblServerBackground.setMaximumSize(null); lblServerBackground.setMinimumSize(null); lblServerBackground.setPreferredSize(null); getContentPane().add(lblServerBackground, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 650, 520)); pack(); }// </editor-fold>//GEN-END:initComponents private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed if (bankserver == null) { bankserver = new BankServer(this.cmbBanken.getSelectedItem().toString()); this.cmbBanken.setEnabled(false); } else { bankserver.startConnectie(); } this.btnStart.setEnabled(false); this.btnStop.setEnabled(true); }//GEN-LAST:event_btnStartActionPerformed private void btnStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopActionPerformed bankserver.stopConnectie(); this.btnStart.setEnabled(true); this.btnStop.setEnabled(false); }//GEN-LAST:event_btnStopActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(StartServerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(StartServerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(StartServerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(StartServerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new StartServerFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnStart; private javax.swing.JButton btnStop; private javax.swing.JComboBox cmbBanken; private javax.swing.JLabel lblServerBackground; // End of variables declaration//GEN-END:variables private BankServer bankserver; }
1234banksysteem
trunk/Bank/src/server/StartServerFrame.java
Java
oos
6,827
package server; import API.Model.Klant; import API.Model.LoginAccount; import java.math.BigDecimal; import managers.KlantManager; import managers.LoginManager; import managers.RekeningManager; import API.Model.Rekening; /** * Deze klasse wordt vanuit BankServer geinstantieerd. * En vult gegevens in de bank. */ public class DummyBank { /** * Constructor voor DummyBank. Hierin zijn wat dummy gegevens opgenomen. * @param banknaam */ public DummyBank(String banknaam) { if (banknaam.equals("Rabobank")) { voegKlantToe("Ieme Welling", "Eindhoven", "ieme", "ieme"); voegKlantToe("test", "Ergens", "test", "test"); voegKlantToe("Melissa Coulthard", "Eindhoven", "Mel", "a"); voegKlantToe("Roland Ansems", "Somewhere", "Rollie", "Lolly"); voegKlantToe("Harry Harig", "Baurle-Naussau", "Harry", "Harry"); voegKlantToe("Barry van Bavel", "Loon op Zand", "Bar", "Weinig"); voegKlantToe("Superman", "Superwereld", "Superman", "Hero"); voegKlantToe("Theo Maassen", "Eindhoven", "Theootje", "123"); } else if (banknaam.equals("Fortis Bank")) { voegKlantToe("Mr. Test", "Ergens", "teest", "teest"); voegKlantToe("Mr. Fret", "Ergens", "fret", "fret"); } } /** * Methode om klanten eenvoudig toe te voegen aan de server middels deze dummyklasse. * @param naam van de klant * @param woonplaats van de klant * @param klantlogin van de klant * @param wachtwoord van de klant */ private void voegKlantToe(String naam, String woonplaats, String klantlogin, String wachtwoord) { KlantManager km = KlantManager.getInstance(); LoginManager lm = LoginManager.getInstance(); RekeningManager rm = RekeningManager.getInstance(); Klant klant = new Klant(naam, woonplaats); Rekening rekeningKlant = new Rekening(rm.getBankInitialen()); rekeningKlant.stort(new BigDecimal(50)); LoginAccount loginKlant = new LoginAccount(klantlogin, wachtwoord, klant.getKlantNr(), rekeningKlant.getRekeningnummer()); km.addKlant(klant); lm.addLogin(loginKlant); rm.addRekening(rekeningKlant); } }
1234banksysteem
trunk/Bank/src/server/DummyBank.java
Java
oos
2,344
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package server; import API.IAuth; import API.ITransactieHandler; import CiClient.CiConnector; import java.rmi.NoSuchObjectException; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import java.util.logging.Level; import java.util.logging.Logger; import controller.Auth; import controller.TransactieHandler; import managers.RekeningManager; /** * Dit is de klasse waar de server geinstantieerd wordt. */ public class BankServer { private static Auth login; private static TransactieHandler transactie; private static Registry registry; private String bankNaam; private DummyBank db; // Om te zorgen dat objecten niet GC'ed worden moet de return waarde van de stubs bijgehouden worden. // zie: http://stackoverflow.com/questions/5165320/rmi-server-stops private static IAuth loginStub; private static ITransactieHandler transactieStub; /** * Constructor voor de Server van een bank. Hierin wordt geprobeerd een RMI * connectie open te zetten zodat clients deze kunnen benaderen. Er worden 2 * stubs gemaakt. Een voor login waarmee simpele data opgehaald wordt bij de * server. Een voor transactie waarmee transacties opgehaald kunnen worden * bij de server. * @param bank Naam van de bank */ public BankServer(String bank) { this.bankNaam = bank; if (System.getSecurityManager() == null) { SecurityManager securM = new SecurityManager(); System.setSecurityManager(securM); } try { LocateRegistry.createRegistry(1099); registry = LocateRegistry.getRegistry(); } catch (RemoteException ex) { Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } startConnectie(); try { CiConnector ciConnector = new CiConnector("RABO", "testkey"); } catch (RemoteException | NotBoundException ex) { Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } } private void loadData() { db = new DummyBank(this.bankNaam); } /** * Methode om de server uit het RMI Registry te halen. */ public void stopConnectie() { try { UnicastRemoteObject.unexportObject(login, false); UnicastRemoteObject.unexportObject(transactie, false); registry.unbind("transactie"); registry.unbind("auth"); } catch (NoSuchObjectException ex) { Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException ex) { Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(this.bankNaam + " Server gestopt"); } /** * Methode om de server in het RMI Registry te zetten (maken van stubs). * Verder wordt in rekeningmanager de bankintialen gezet. */ public void startConnectie() { this.login = new Auth(); this.transactie = new TransactieHandler(); //zet bankinitialen. RekeningManager rekman = RekeningManager.getInstance(); rekman.setBankInitialen(bankNaam); loadData(); try { transactieStub = (ITransactieHandler) UnicastRemoteObject.exportObject(transactie, 0); loginStub = (IAuth) UnicastRemoteObject.exportObject(login, 0); registry.rebind("transactie", transactieStub); registry.rebind("auth", loginStub); System.out.println(this.bankNaam + " Server gestart"); } catch (RemoteException ex) { System.out.println(ex); Logger.getLogger(BankServer.class.getName()).log(Level.SEVERE, null, ex); } } }
1234banksysteem
trunk/Bank/src/server/BankServer.java
Java
oos
4,284
package controller; import API.IClient; import API.Model.LoginAccount; import java.sql.Timestamp; import java.util.UUID; /** * Sessie object om authenticatie te versimpelen. Eenmalig login nodig waarna de * sessie blijft leven tot 10 minuten na de laatste activiteit. */ public class Sessie { private Timestamp lastActivity; private final String SessieId; private final LoginAccount login; private IClient client; /** * Initialiseerd het sessie object. Na initialisatie is er een sessieID * gegenereerd en wordt er een sessietask ingepland om de sessie te * beindigen. * @param login Het login account waarvoor de sessie gestart wordt. */ public Sessie(LoginAccount login) { //UUID genereert een random unique nummer van 128 bits. //Absolute zekerheid op uniqueness krijg je hiermee niet, maar ruim voldoende voor opdracht. //Absolute zekerheid alleen te verkrijgen door lijst met verbruikte id's bij te houden of synced counter. this.SessieId = UUID.randomUUID().toString(); this.login = login; updateActivity(); } /** * Een get-methode voor de sessieID * @return de sessieID */ public String getSessieId() { return this.SessieId; } /** * Een get-methode voor het loginaccount * @return het loginaccount */ public LoginAccount getLogin() { updateActivity(); return login; } /** * Een get-methode om de IClient op te vragen * @return de IClient waarvoor deze sessie geregistreerd is. */ public IClient getClient() { return client; } /** * Methode om de client te zetten bij deze sessie. * @param client die client die bij deze specifieke sessie hoort. */ public void setClient(IClient client) { updateActivity(); this.client = client; } /** * Een get methode om de laatste activiteit op te halen. * @return timestamp van laatste activiteit. */ public Timestamp getLastActivity() { return lastActivity; } /** * Methode om laatste activiteit up te daten naar huidige datumtijd. */ public void updateActivity() { java.util.Date date = new java.util.Date(); this.lastActivity = new Timestamp(date.getTime()); } /** * Methode om loginaccount op te vragen bij de sessie * hierbij wordt de lastactivity niet geupdate. Deze methode wordt namelijk via * de callback functie vanuit de client (sessieframe) aangeroepen wanneer * de transacties worden opgevraagd. * @return */ public LoginAccount getLoginNoActivityChange() { return login; } }
1234banksysteem
trunk/Bank/src/controller/Sessie.java
Java
oos
2,827
package controller; import API.IAuth; import API.IClient; import API.IObservable; import API.Model.Klant; import API.Model.LoginAccount; import API.Model.Rekening; import API.Model.SessieExpiredException; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; import managers.*; /** * De server verstuurt berichten naar de ClientImpl middels deze klasse. Deze * klasse implementeert IAuth en bij ClientImpl is IAuth ook bekend. Zodanig kan * de klant onderstaande methoden opvragen bij de server. */ public class Auth implements IAuth { private static HashMap<IObservable, ArrayList<String>> obs = new HashMap<>(); //private String bankinitialen; /** * Methode die overgenomen is uit IAuth. En waarmee een sessie gestart wordt. * @param username inlognaam van de klant. * @param password wachtwoord van de klant. * @return sessieID * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. */ @Override public synchronized String startSessie(String username, String password) throws RemoteException { LoginManager loginManager = LoginManager.getInstance(); try { LoginAccount login = loginManager.getLoginAccount(username, password); Sessie newSessie = new Sessie(login); SessieManager sm = SessieManager.getInstance(); sm.addSessie(newSessie); return newSessie.getSessieId(); } catch (IllegalArgumentException e) { throw e; } } /** * Methode die een nieuwe klant registreert en daarbij kijkt of een klant al bestaat of niet. * Bestaat de klant al, dan wordt dat klantnummer gebruikt. Bestaat klant niet, dan wordt er * een nieuwe klant nummer aan gegeven. * @param klantnaam naam van de klant. * @param woonplaats woonplaats van de klant. * @param gebruikersnaam gebruikersnaam van de klant. * @param wachtwoord wachtwoord van de klant. * @return true als het gelukt is om de klant te registreren. False als het niet gelukt is. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. */ @Override public synchronized boolean registreerNieuweKlant(String klantnaam, String woonplaats, String gebruikersnaam, String wachtwoord) throws NullPointerException, IllegalArgumentException, RemoteException { KlantManager klantmanager = KlantManager.getInstance(); LoginManager loginmanager = LoginManager.getInstance(); RekeningManager rekeningmanager = RekeningManager.getInstance(); //Wanneer klantnaam of woonplaats leeg zijn, moet een exceptie gegooid worden. if(klantnaam == null | klantnaam.isEmpty() | woonplaats == null | woonplaats.isEmpty()) //verandert naar inclusive ipv xor, beide moeten ingevuld zijn. { throw new NullPointerException("Graag alle verplichte velden invullen"); } klantnaam = klantnaam.trim(); gebruikersnaam = gebruikersnaam.trim(); woonplaats = woonplaats.trim(); if(!Klant.isAlphabetical(klantnaam) | !Klant.isPlaatsnaam(woonplaats)) { throw new IllegalArgumentException("Naam en of woonplaats bevatten illegale karakters"); } if(!LoginAccount.isAlphanumeric(gebruikersnaam)) { throw new IllegalArgumentException("gebruikersnaam bevat illegale karakters, gebruikersnaam mag uit letters en cijfers bestaan"); } //loginnaam mag niet bekend zijn in het banksysteem. Loginnamen zijn uniek. if(!loginmanager.bestaatLoginNaam(gebruikersnaam)) { //Er hoeft geen nieuwe klant toegevoegd te worden als klantobject al bestaat. if (klantmanager.getBestaandeKlantNummer(klantnaam, woonplaats) != 0){ int klantnummer = klantmanager.getBestaandeKlantNummer(klantnaam, woonplaats); Rekening rekening = new Rekening(rekeningmanager.getBankInitialen()); LoginAccount loginaccount = new LoginAccount(gebruikersnaam, wachtwoord, klantnummer, rekening.getRekeningnummer()); loginmanager.addLogin(loginaccount); rekeningmanager.addRekening(rekening); return true; } //Wanneer er nog geen klantobject bestaat dan moet er wel een nieuw klantobject aangemaakt worden en bij klantmanager geregistreerd worden. else { Klant klant = new Klant(klantnaam, woonplaats); Rekening rekening = new Rekening(rekeningmanager.getBankInitialen()); LoginAccount loginaccount = new LoginAccount(gebruikersnaam, wachtwoord, klant.getKlantNr(), rekening.getRekeningnummer()); klantmanager.addKlant(klant); loginmanager.addLogin(loginaccount); rekeningmanager.addRekening(rekening); return true; } } return false; } /** * Methode om de sessie te stoppen. * @param sessionId sessieID die gestopt moet worden. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized void stopSessie(String sessionId) throws RemoteException, SessieExpiredException { SessieManager.getInstance().stopSessie(sessionId); } /** * Methode om klant op te vragen. * @param sessionId SessieId * @return Klant object * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized Klant getKlant(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { LoginAccount login = sm.getAccountFromSessie(sessionId); KlantManager km = KlantManager.getInstance(); Klant k = km.getKlant(login.getKlantNr()); registerObservable(k, sessionId); return k; } catch (SessieExpiredException e) { throw e; } } /** * Methode om rekening op te vragen. * @param sessionId sessieID is nodig om Rekening op te vragen. * @return Rekening object * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized Rekening getRekening(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { LoginAccount login = (LoginAccount) sm.getAccountFromSessie(sessionId); RekeningManager rm = RekeningManager.getInstance(); Rekening r = rm.getRekening(login.getRekeningNr()); registerObservable(r, sessionId); return r; } catch (SessieExpiredException e) { throw e; } } /** Methode om wachtwoord te resetten. Wordt momenteel nog niet gebruikt. * @param sessionId SessieID * @param username gebruikersnaam van de klant * @param password wachtwoord van de klant. * @return true als wachtwoord succesvol gereset is, false als het niet gelukt is. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized boolean resetWachtwoord(String sessionId, String username, String password) throws RemoteException, SessieExpiredException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } /** * Methode om client object te registreren bij de bankserver. * @param sessieId sessieID behorende bij client object. * @param clientObj IClient object. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized void registreerClientObject(String sessieId, IClient clientObj) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { sm.bindClientObjecToSessie(sessieId, clientObj); } catch (SessieExpiredException e) { throw e; } } /** * Deze methode wordt ALLEEN voor demo doeleinden gebruikt. In de deployment moet * deze methode er natuurlijk uitgehaald worden. * @param sessieId id van de sessie. * @param bedrag bedrag dat gestort wordt op het eigen reknr. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized void stort(String sessieId, BigDecimal bedrag) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); LoginAccount login = (LoginAccount) sm.getAccountFromSessie(sessieId); RekeningManager rm = RekeningManager.getInstance(); Rekening r = rm.getRekening(login.getRekeningNr()); r.stort(bedrag); } /** * Methode om objecten te updaten. Wordt via overerving van IObserver in IAuth hierin opgenomen. * @param observable Observable object. * @param arg nieuwe object. * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. */ @Override public synchronized void update(Object observable, Object arg) throws RemoteException { IObservable o = (IObservable) observable; if (obs.containsKey(o)) { ArrayList<String> sessieIds = obs.get(o); if (sessieIds == null || sessieIds.isEmpty()) { //geen observers bekend bij sessieId obs.remove(o); return; } ArrayList<String> shadowIds = new ArrayList<>(); for (String sid : sessieIds) { shadowIds.add(sid); } for (String sessieId : shadowIds) { IClient client = null; try { client = SessieManager.getInstance().getClient(sessieId); } catch (SessieExpiredException ex) { Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex); } if (client != null) { client.setObservable(o); } else { //geen client object bekend bij observer, uit de lijst gooien want kan nooit geupdate worden. sessieIds.remove(sessieId); } } } } /** * Methode om observables te registreren bij een instantie van deze klasse. * @param o IObservable object. * @param sessieId SessieId */ private synchronized void registerObservable(IObservable o, String sessieId) { ArrayList<String> sessieIds; o.addObserver(this); if (obs.containsKey(o)) { sessieIds = obs.get(o); boolean exists = false; while (!exists) { for (String sId : sessieIds) { if (sessieId.equals(sId)) { exists = true; } } break; } if (!exists) { sessieIds.add(sessieId); } } else { sessieIds = new ArrayList<>(); sessieIds.add(sessieId); obs.put(o, sessieIds); } } /** * Methode om loginaccount op te vragen. * @param sessionId SessieID van client die dit opvraagt. * @return LoginAccount object * @throws RemoteException moet afgevangen worden wanneer het via RMI gaat. * @throws SessieExpiredException moet afgevangen worden om te kijken of de klant 10 mins inactief is geweest. */ @Override public synchronized LoginAccount getLoginAccount(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { LoginAccount login = sm.getAccountFromSessie(sessionId); return login; } catch (SessieExpiredException e) { throw e; } } }
1234banksysteem
trunk/Bank/src/controller/Auth.java
Java
oos
13,339
package controller; import API.Model.SessieExpiredException; import API.IClient; import API.IObservable; import API.Model.Transactie; import API.ITransactieHandler; import API.Model.LoginAccount; import API.Model.TransactieStatus; import API.Model.TransactieType; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; import managers.SessieManager; import managers.TransactieManager; /** * De server verstuurt berichten naar de ClientImpl middels deze klasse. Deze * klasse implementeert ITransactie en bij ClientImpl is ITransactie ook bekend. * Zodanig kan de klant onderstaande methoden opvragen bij de server. */ public class TransactieHandler implements ITransactieHandler { private static HashMap<IObservable, ArrayList<String>> obs = new HashMap<>(); /** * Hiermee wordt een nieuwe transactie aangevraagd. * * @param sessieId sessieID van een actieve sessie * @param recipientRekeningnummer rekeningnummer van de ontvanger * @param bedrag het over te maken bedrag * @param comment beschrijving die bij de transactie ingevuld is * @return Transactie object * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de * klant verlopen is. */ @Override public synchronized Transactie requestTransaction(String sessieId, String recipientRekeningnummer, BigDecimal bedrag, String comment) throws SessieExpiredException, RemoteException, IllegalArgumentException { //check of tegenrekeningnummer en bedrag gevuld zijn if (recipientRekeningnummer.isEmpty() || recipientRekeningnummer.equals("") || bedrag == null) { throw new IllegalArgumentException("Vul alle verplichte velden in"); } if (bedrag.compareTo(BigDecimal.ZERO) < 1) { throw new IllegalArgumentException("Over te schrijven bedrag moet groter zijn dan 0"); } //haal rekeningnummer op van klant behorende bij sessieID LoginAccount login = SessieManager.getInstance().getAccountFromSessie(sessieId); if (login != null) { //check of tegenrekeningnummer anders is dan van-rekeningnummer if (login.getRekeningNr().equals(recipientRekeningnummer)) { throw new IllegalArgumentException("Het tegen rekeningnummer kan niet hetzelfde zijn als het eigen rekeningnummer"); } Transactie trans = new Transactie(login.getRekeningNr(), recipientRekeningnummer, bedrag, comment); TransactieManager.getInstance().addTransactie(trans); //voeg observale toe registerObservable(trans, sessieId); return trans; } return null; } /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. De * rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze * transactie! * * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. Null = heden. * @return ArrayList met transactie objects. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de * klant verlopen is. */ @Override public synchronized ArrayList<Transactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, null, TransactieType.ALLE); } /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. De * rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze * transactie! * * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param status status van de transacties. type TransactieStatus * @return ArrayList met transactie objects. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de * klant verlopen is. */ @Override public synchronized ArrayList<Transactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, status, TransactieType.ALLE); } /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. De * rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze * transactie! * * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param type type van de transactie als TransactieType. (debet of credit * t.o.v. de aanvrager) * @return ArrayList met transactie objects. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de * klant verlopen is. */ @Override public synchronized ArrayList<Transactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieType type) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, null, type); } /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. De * rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze * transactie! * * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param status status van de transacties. type TransactieStatus * @param type type van de transactie als TransactieType. (debet of credit * t.o.v. de aanvrager) * @return ArrayList met transactie objects. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. * @throws SessieExpiredException wordt gegooid wanneer de sessie van de * klant verlopen is. */ @Override public synchronized ArrayList<Transactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status, TransactieType type) throws RemoteException, SessieExpiredException { LoginAccount login = SessieManager.getInstance().getAccountFromSessieNoActivityChange(sessieId); if (login != null) { String rekeningnr = login.getRekeningNr(); ArrayList<Transactie> iTransacties = new ArrayList<>(); ArrayList<Transactie> transacties = TransactieManager.getInstance().getTransacties(rekeningnr, null, vanafDatum, totDatum, status, type); for (Transactie trans : transacties) { iTransacties.add(trans); } return iTransacties; } return null; } /** * Methode om aan het object die een ander object observeert, een update te * geven van een nieuw object. * * @param observable Een object dat observable object * @param arg Het geupdate object dat door de observable gebruikt wordt. * @throws RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet * deze exceptie afgevangen worden. */ @Override public synchronized void update(Object observable, Object arg) throws RemoteException { IObservable o = (IObservable) observable; if (obs.containsKey(o)) { ArrayList<String> sessieIds = obs.get(o); if (sessieIds == null || sessieIds.isEmpty()) { //geen observers bekend bij sessieId obs.remove(o); return; } ArrayList<String> shadowIds = new ArrayList<>(); for (String sid : sessieIds) { shadowIds.add(sid); } for (String sessieId : shadowIds) { IClient client = null; try { client = SessieManager.getInstance().getClient(sessieId); } catch (SessieExpiredException ex) { Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex); } finally { //geen client object bekend bij observer, uit de lijst gooien want kan nooit geupdate worden. sessieIds.remove(sessieId); } if (client != null) { client.setObservable(o); } } } } /** * Methode om Observables te registreren bij een instantie van deze klasse. * * @param o IObservable object. * @param sessieId SessieID van client. */ private synchronized void registerObservable(IObservable o, String sessieId) { ArrayList<String> sessieIds; o.addObserver(this); if (obs.containsKey(o)) { sessieIds = obs.get(o); boolean exists = false; while (!exists) { for (String sId : sessieIds) { if (sessieId.equals(sId)) { exists = true; } } break; } if (!exists) { sessieIds.add(sessieId); } } else { sessieIds = new ArrayList<>(); sessieIds.add(sessieId); obs.put(o, sessieIds); } } }
1234banksysteem
trunk/Bank/src/controller/TransactieHandler.java
Java
oos
10,493
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package API; /** * * @author Melis */ public enum TransactieStatus { /** Wanneer een transactie verwerkt is door de bank krijgt het de status voltooid. */ VOLTOOID, /** Wanneer een transactie nog niet verwerkt is door de bank krijgt het de status openstaand, * alleen tijdens deze status kan de transactie geannuleerd worden. */ OPENSTAAND, /** Wanneer een transactie tijdig geannuleerd wordt, zal het niet door de bank worden * verwerkt. */ GEANNULEERD, /** Wanneer een transactie niet verwerkt kon worden door de bank omdat er iets mis is gegaan * (bijvoorbeeld de connectie met de centrale instantie) wordt de transactie tijdelijk uitgesteld. */ UITGESTELD, /** Wanneer de bank de transactie probeerde te verwerken, maar er geen bestaande tegenrekeningnummer * was, zal de transactie geweigerd worden. */ GEWEIGERD; }
1234banksysteem
trunk/src_oplevering1/API/TransactieStatus.java
Java
oos
1,144
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; /** * * @author Ieme */ public interface IKlant { /** * Stuurt de klantnaam terug * @return klantnaam */ String getKlantnaam(); /** * Stuurt de woonplaats van de klant terug * @return klantwoonplaats */ String getKlantwoonplaats(); int getKlantNr(); }
1234banksysteem
trunk/src_oplevering1/API/IKlant.java
Java
oos
450
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package API; /** * */ public interface IObservable { /** * voegt een observer object toe * @param observer */ void addObserver(IObserver observer); public int getObservableId(); }
1234banksysteem
trunk/src_oplevering1/API/IObservable.java
Java
oos
425
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; import Bank.Model.SessieExpiredException; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.GregorianCalendar; /** * * @author Ieme */ public interface ITransactieHandler extends IObserver { /** * Hiermee wordt een nieuwe transactie aangevraagd. * @param sessieId sessieID van een actieve sessie * @param recipientRekeningnummer rekeningnummer van de ontvanger * @param bedrag het over te maken bedrag * @return Transactie object * @throws RemoteException * @throws SessieExpiredException */ public ITransactie requestTransaction(String sessieId, int recipientRekeningnummer, BigDecimal bedrag, String comment) throws RemoteException, SessieExpiredException; /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. * De rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze transactie! * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. Null = heden. * @return ArrayList met transactie objects. * @throws RemoteException * @throws SessieExpiredException */ public ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum) throws RemoteException, SessieExpiredException; /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. * De rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze transactie! * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param status status van de transacties. type TransactieStatus * @return ArrayList met transactie objects. * @throws RemoteException * @throws SessieExpiredException */ public ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status) throws RemoteException, SessieExpiredException; /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. * De rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze transactie! * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param type type van de transactie als TransactieType. (debet of credit t.o.v. de aanvrager) * @return ArrayList met transactie objects. * @throws RemoteException * @throws SessieExpiredException */ public ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieType type) throws RemoteException, SessieExpiredException; /** * Methode om bestaande transactie op te zoeken tussen gegeven datums. * De rekening bijbehorende aan het actieve sessieId moet bekend zijn in deze transactie! * @param sessieId sessieId van een actieve sessie * @param vanafDatum Datum vanaf we transactie opzoeken * @param totDatum Datum tot we transacties opzoeken. mag null zijn. * @param status status van de transacties. type TransactieStatus * @param type type van de transactie als TransactieType. (debet of credit t.o.v. de aanvrager) * @return ArrayList met transactie objects. * @throws RemoteException * @throws SessieExpiredException */ public ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status, TransactieType type) throws RemoteException, SessieExpiredException; }
1234banksysteem
trunk/src_oplevering1/API/ITransactieHandler.java
Java
oos
4,064
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; import java.math.BigDecimal; import java.util.GregorianCalendar; /** * * @author Ieme */ public interface ITransactie { public int getTransactieId(); public int getEigenbankrekening(); public int getTegenrekening(); public BigDecimal getBedrag(); public TransactieStatus getStatus(); public GregorianCalendar getTransactieInvoerDatum(); }
1234banksysteem
trunk/src_oplevering1/API/ITransactie.java
Java
oos
514
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; /** * * @author Ieme */ public interface ILoginAccount { /** * stuurt de loginnaam van het loginaccount terug * @return LoginNaam */ public String getLoginNaam(); /** * stuurt het klantnr van het loginaccount terug * @return KlantNr */ public int getKlantNr(); /** * stuurt het rekeningnr van het loginaccount terug * @return rekeningnr */ public int getRekeningNr(); }
1234banksysteem
trunk/src_oplevering1/API/ILoginAccount.java
Java
oos
592
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; import java.math.BigDecimal; /** * * @author Ieme */ public interface IRekening { /** * stuurt het rekeningnummer van de rekening terug * @return Rekeningnummer */ public int getRekeningnummer(); /** * stuurt het saldo van de rekening terug * @return Saldo */ public BigDecimal getSaldo(); /** * stuurt het kredietlimiet van de rekening terug * @return Kredietlimiet */ public BigDecimal getKredietlimiet(); }
1234banksysteem
trunk/src_oplevering1/API/IRekening.java
Java
oos
652
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; import java.rmi.Remote; import java.rmi.RemoteException; /** * Deze interface wordt geinstantieerd aan de client zijde. * * Zodoende kan de server methodes van de client aanroepen. De server kan de * client remote "uitloggen" en kan de client laten weten dat het saldo van de * rekening is gewijzigd. * */ public interface IClient extends Remote { /** * Methode om de client te melden dat de sessie is verlopen en dat hij uitgelogd wordt. * @throws java.rmi.RemoteException - Zodra er gebruik gemaakt wordt van Remote, moet deze exceptie afgevangen worden. */ public void logOut() throws RemoteException; public void setObservable(IObservable ob) throws RemoteException; }
1234banksysteem
trunk/src_oplevering1/API/IClient.java
Java
oos
851
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package API; import java.rmi.Remote; import java.rmi.RemoteException; /** */ public interface IObserver extends Remote { /** * Methode om aan het object die een ander object observeert, een update te geven van een nieuw object. * @param observable * @param updateBericht */ void update(Object observable, Object arg) throws RemoteException; }
1234banksysteem
trunk/src_oplevering1/API/IObserver.java
Java
oos
596
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; import Bank.Model.SessieExpiredException; import java.math.BigDecimal; import java.rmi.RemoteException; /** * Interface waarmee client een sessie kan starten en een client haar basis * gegevens kan opvragen Tevens verantwoordelijk voor bijhouden * clientRMIobjecten * */ public interface IAuth extends IObserver { /** * Deze methode is er alleen als snel voorbeeld. Dit moet als een transactie * behandeld worden. */ public void stort(String sessieId, BigDecimal bedrag) throws RemoteException, SessieExpiredException; /** * Starten van een sessie. Mits succesvol wordt er een sessieId terug * gegeven, anders null * * @param username client username om in te loggen * @param password client password om in te loggen * @return String sessieId of null * @throws RemoteException */ public String startSessie(String username, String password) throws RemoteException, IllegalArgumentException; /** * Hiermee kan een ClientObj geregistreert worden bij de server. Zodoende * kan de server remote calls maken bij de client. * * @param sessieId sessieId van actieve sessie * @param clientObj IClient object om remote calls uit te voeren bij de * client. * @throws RemoteException * @throws SessieExpiredException */ public void registerClientObj(String sessieId, IClient clientObj) throws RemoteException, SessieExpiredException; /** * Hiermee kan een bestaande sessie worden beeindigd. Returned true als het * gelukt is, anders false. * * @param sessionId sessieId van bestaande sessie * @return true wanneer succesvol, false wanneer niet succesvol. * @throws RemoteException * @throws SessieExpiredException */ public void stopSessie(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om wachtwoord aan te passen. * * @param sessionId sessieId van bestaande sessie * @param username username van de client. * @param password nieuwe password van de client. * @return true wanneer succesvol. * @throws RemoteException * @throws SessieExpiredException */ public boolean resetWachtwoord(String sessionId, String username, String password) throws RemoteException, SessieExpiredException; /** * Methode om klant object (gegevens) van een actieve sessie te verkrijgen * * @param sessionId sessieID van actieve sessie * @return Klant object. * @throws RemoteException * @throws SessieExpiredException */ public IKlant getKlant(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om rekening object bij een actieve sessie te verkrijgen. * * @param sessionId sessieId van actieve sessie * @return Rekening object bij actieve sessie. * @throws RemoteException * @throws SessieExpiredException */ public IRekening getRekening(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om loginaccount object bij een actieve sessie op te vragen. * @param sessionId sessieId van actieve sessie * @return LoginAccount object bij actieve sessie. * @throws RemoteException * @throws SessieExpiredException */ public ILoginAccount getLoginAccount(String sessionId) throws RemoteException, SessieExpiredException; /** * Methode om een nieuwe klant + loginaccount + rekening aan te maken. * @param klantnaam * @param woonplaats * @param gebruikersnaam * @param wachtwoord * @return * @throws RemoteException */ public boolean registreerNieuweKlant(String klantnaam, String woonplaats, String gebruikersnaam, String wachtwoord) throws RemoteException; }
1234banksysteem
trunk/src_oplevering1/API/IAuth.java
Java
oos
4,049
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package API; /** * Gebruiken om transacties op te zoeken. * */ public enum TransactieType { /** Wanneer er geld op een rekening gestort wordt, zal dit debet zijn. */ DEBET, /** Wanneer er geld van een bankrekening afgehaald wordt, zal dit credit zijn. */ CREDIT, /** Wanneer er geld van een bankrekening wordt gehaald of wordt gestort. */ ALLE; }
1234banksysteem
trunk/src_oplevering1/API/TransactieType.java
Java
oos
523
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Balie.Controller; import API.IClient; import API.IObservable; import API.IObserver; import java.rmi.*; import java.rmi.server.UnicastRemoteObject; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.*; /** * Biedt mogelijkheid voor de server om de client remote uit te loggen. */ public class ClientImpl implements IClient { private static volatile ClientImpl instance; private static HashMap<Integer, ArrayList<IObserver>> obs = new HashMap(); public ClientImpl() throws RemoteException { try { UnicastRemoteObject.exportObject(this, 0); instance = this; } catch (RemoteException ex) { Logger.getLogger(ClientImpl.class.getName()).log(Level.SEVERE, null, ex); } } @Override public synchronized void logOut() throws RemoteException { System.out.println("Client Stopped"); UnicastRemoteObject.unexportObject(this, true); } @Override public synchronized void setObservable(IObservable o) throws RemoteException { if (obs.containsKey(o.getObservableId())) { ArrayList<IObserver> observers = obs.get(o.getObservableId()); if (observers != null) { for (IObserver ob : observers) { ob.update(o, ""); } } } } public synchronized void addObserver(IObserver ob, IObservable o) { //Nog check inbouwen of IObserver al eerder geregistreerd is. ArrayList<IObserver> obsList = new ArrayList<>(); obsList.add(ob); obs.put(o.getObservableId(), obsList); } }
1234banksysteem
trunk/src_oplevering1/Balie/Controller/ClientImpl.java
Java
oos
1,810
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.ITransactie; import java.math.RoundingMode; import java.text.DateFormat; import java.util.ArrayList; import java.util.GregorianCalendar; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; /** * * @author Melis */ public class TransactiePanel extends javax.swing.JPanel { private ArrayList<ITransactie> transacties; private int eigenRekeningNr = 0; /** * Creates new form TransactiePanel */ public TransactiePanel() { initComponents(); this.transacties = new ArrayList<>(); } public void setEigenRekeningNr(int eigenRekeningNr) { this.eigenRekeningNr = eigenRekeningNr; } public void setTransacties(ArrayList<ITransactie> transacties) { this.transacties = transacties; refrestListView(); } private void refrestListView() { String col[] = {"Datum", "Tegenrekening", "Bij/af", "Bedrag", "Status"}; DefaultTableModel tableModel = new DefaultTableModel(col, 0); // The 0 argument is number rows. int rekening; String transRichting; for (int i = 0; i < transacties.size(); i++) { ITransactie trans = transacties.get(i); GregorianCalendar datum = trans.getTransactieInvoerDatum(); if (eigenRekeningNr == trans.getEigenbankrekening()) { transRichting = "Af"; rekening = trans.getTegenrekening(); } else { transRichting = "Bij"; rekening = trans.getEigenbankrekening(); } String bedrag = trans.getBedrag().setScale(2, RoundingMode.HALF_EVEN).toString(); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String datumStr = df.format(datum.getTime()); Object[] data = {datumStr, rekening, transRichting, bedrag, trans.getStatus()}; tableModel.addRow(data); } jTable1.setModel(tableModel); tableModel.fireTableDataChanged(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); setOpaque(false); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jTable1.setFont(new java.awt.Font("Calibri", 0, 13)); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Datum", "Begunstigde", "Bij/af", "Bedrag" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.Short.class, java.lang.Double.class }; boolean[] canEdit = new boolean [] { false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jTable1.setOpaque(false); jTable1.getTableHeader().setReorderingAllowed(false); jScrollPane1.setViewportView(jTable1); if (jTable1.getColumnModel().getColumnCount() > 0) { jTable1.getColumnModel().getColumn(0).setResizable(false); jTable1.getColumnModel().getColumn(0).setHeaderValue("Datum"); jTable1.getColumnModel().getColumn(1).setResizable(false); jTable1.getColumnModel().getColumn(1).setHeaderValue("Begunstigde"); jTable1.getColumnModel().getColumn(2).setResizable(false); jTable1.getColumnModel().getColumn(2).setPreferredWidth(50); jTable1.getColumnModel().getColumn(2).setHeaderValue("Bij/af"); jTable1.getColumnModel().getColumn(3).setResizable(false); jTable1.getColumnModel().getColumn(3).setHeaderValue("Bedrag"); } add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, 370, 260)); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/TransactiePanel.java
Java
oos
5,123
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IKlant; import API.ILoginAccount; /** * * @author Melis */ public class KlantPanel extends javax.swing.JPanel { /** * Creates new form KlantPanel */ public KlantPanel() { initComponents(); } public void setGegevens(IKlant klant, ILoginAccount login) { jtfKlantNummer.setText(String.valueOf(klant.getKlantNr())); jtfKlantnaam.setText(klant.getKlantnaam()); jtfWoonplaats.setText(klant.getKlantwoonplaats()); jtfGebruikersnaam.setText(login.getLoginNaam()); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jtfKlantNummer = new javax.swing.JTextField(); jtfGebruikersnaam = new javax.swing.JTextField(); jtfKlantnaam = new javax.swing.JTextField(); jtfWoonplaats = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jtfKlantNummer.setEditable(false); jtfKlantNummer.setBackground(new java.awt.Color(238, 238, 238)); jtfKlantNummer.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfKlantNummer.setForeground(new java.awt.Color(102, 102, 102)); jtfKlantNummer.setBorder(null); jtfKlantNummer.setOpaque(false); add(jtfKlantNummer, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 28, 350, 15)); jtfGebruikersnaam.setEditable(false); jtfGebruikersnaam.setBackground(new java.awt.Color(238, 238, 238)); jtfGebruikersnaam.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfGebruikersnaam.setForeground(new java.awt.Color(102, 102, 102)); jtfGebruikersnaam.setBorder(null); jtfGebruikersnaam.setOpaque(false); add(jtfGebruikersnaam, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 208, 350, 15)); jtfKlantnaam.setEditable(false); jtfKlantnaam.setBackground(new java.awt.Color(238, 238, 238)); jtfKlantnaam.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfKlantnaam.setForeground(new java.awt.Color(102, 102, 102)); jtfKlantnaam.setBorder(null); jtfKlantnaam.setOpaque(false); add(jtfKlantnaam, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 88, 350, 15)); jtfWoonplaats.setEditable(false); jtfWoonplaats.setBackground(new java.awt.Color(238, 238, 238)); jtfWoonplaats.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfWoonplaats.setForeground(new java.awt.Color(102, 102, 102)); jtfWoonplaats.setBorder(null); jtfWoonplaats.setOpaque(false); add(jtfWoonplaats, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 148, 350, 15)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/KlantPanel.gif"))); // NOI18N add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 230)); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JTextField jtfGebruikersnaam; private javax.swing.JTextField jtfKlantNummer; private javax.swing.JTextField jtfKlantnaam; private javax.swing.JTextField jtfWoonplaats; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/KlantPanel.java
Java
oos
3,890
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IAuth; import API.IObserver; import API.IRekening; import Bank.Model.SessieExpiredException; import java.math.BigDecimal; import java.math.RoundingMode; import java.rmi.RemoteException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Melis */ public class BankrekeningPanel extends javax.swing.JPanel implements IObserver { /** * Creates new form BankrekeningPanel */ public BankrekeningPanel() { initComponents(); } public void setGegevens(String sessieID, IRekening rekening, IAuth loginInterface) { this.sessieID = sessieID; this.loginInterface = loginInterface; this.rekening = rekening; } /** * Deze methode zit er in PUUR voor demo doeleinden! */ public void storten() { try { this.loginInterface.stort(sessieID, new BigDecimal(5.00).setScale(2, RoundingMode.HALF_EVEN)); } catch (RemoteException ex) { Logger.getLogger(BankrekeningPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (SessieExpiredException ex) { Logger.getLogger(BankrekeningPanel.class.getName()).log(Level.SEVERE, null, ex); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jtfKredietlimiet = new javax.swing.JTextField(); jtfEigenRekening = new javax.swing.JTextField(); jtfSaldo = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jtfKredietlimiet.setEditable(false); jtfKredietlimiet.setBackground(new java.awt.Color(238, 238, 238)); jtfKredietlimiet.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfKredietlimiet.setForeground(new java.awt.Color(102, 102, 102)); jtfKredietlimiet.setBorder(null); add(jtfKredietlimiet, new org.netbeans.lib.awtextra.AbsoluteConstraints(42, 148, 330, 15)); jtfEigenRekening.setEditable(false); jtfEigenRekening.setBackground(new java.awt.Color(238, 238, 238)); jtfEigenRekening.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfEigenRekening.setForeground(new java.awt.Color(102, 102, 102)); jtfEigenRekening.setBorder(null); add(jtfEigenRekening, new org.netbeans.lib.awtextra.AbsoluteConstraints(21, 26, 350, 15)); jtfSaldo.setEditable(false); jtfSaldo.setBackground(new java.awt.Color(238, 238, 238)); jtfSaldo.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfSaldo.setForeground(new java.awt.Color(102, 102, 102)); jtfSaldo.setBorder(null); add(jtfSaldo, new org.netbeans.lib.awtextra.AbsoluteConstraints(42, 87, 330, 15)); jLabel3.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jLabel3.setForeground(new java.awt.Color(102, 102, 102)); jLabel3.setText("€"); add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 148, 20, 15)); jLabel2.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jLabel2.setForeground(new java.awt.Color(102, 102, 102)); jLabel2.setText("€"); add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 87, 20, 15)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/RekeningPanel.gif"))); // NOI18N add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 170)); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JTextField jtfEigenRekening; private javax.swing.JTextField jtfKredietlimiet; private javax.swing.JTextField jtfSaldo; // End of variables declaration//GEN-END:variables private IAuth loginInterface; private IRekening rekening; private String sessieID; @Override public void update(Object observable, Object arg) throws RemoteException { rekening = (IRekening) observable; jtfEigenRekening.setText(rekening.toString()); jtfSaldo.setText(rekening.getSaldo().toString()); jtfKredietlimiet.setText(rekening.getKredietlimiet().toString()); } }
1234banksysteem
trunk/src_oplevering1/Balie/gui/BankrekeningPanel.java
Java
oos
4,983
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IAuth; import Balie.Controller.ClientImpl; import Bank.Model.SessieExpiredException; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RemoteException; import javax.swing.JFrame; import javax.swing.JOptionPane; /** * * @author Melis */ public class NieuweKlantPanel extends javax.swing.JPanel { private JFrame parentFrame; /** * Creates new form NieuweKlantPanel */ public NieuweKlantPanel() { initComponents(); } public NieuweKlantPanel(JFrame jframereferentie) { initComponents(); this.parentFrame = jframereferentie; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel2 = new javax.swing.JLabel(); jtfWachtwoord = new javax.swing.JPasswordField(); jtfGebruikersnaam = new javax.swing.JTextField(); jtfWoonplaats = new javax.swing.JTextField(); jtfKlantnaam = new javax.swing.JTextField(); btnRegistreren = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); setOpaque(false); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel2.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 0, 0)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Let op! U maakt een nieuwe rekening aan."); add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 254, 350, -1)); jtfWachtwoord.setBorder(null); jtfWachtwoord.setOpaque(false); add(jtfWachtwoord, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 214, 330, 30)); jtfGebruikersnaam.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfGebruikersnaam.setBorder(null); add(jtfGebruikersnaam, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, 330, 30)); jtfWoonplaats.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfWoonplaats.setBorder(null); add(jtfWoonplaats, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 88, 330, 30)); jtfKlantnaam.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfKlantnaam.setBorder(null); add(jtfKlantnaam, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 24, 330, 30)); btnRegistreren.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/RegistreerButton.gif"))); // NOI18N btnRegistreren.setBorder(null); btnRegistreren.setBorderPainted(false); btnRegistreren.setFocusPainted(false); btnRegistreren.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnRegistreren.setOpaque(false); btnRegistreren.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/RegistreerButtonClicked.gif"))); // NOI18N btnRegistreren.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRegistrerenActionPerformed(evt); } }); add(btnRegistreren, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 290, 150, 40)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/NieuweKlantPanel.gif"))); // NOI18N add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, -1)); }// </editor-fold>//GEN-END:initComponents private void btnRegistrerenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrerenActionPerformed try { String bankServerURL = "rmi://localhost/auth"; String sessieId = null; IAuth loginInterface; ClientImpl clientcontroller = new ClientImpl(); try { loginInterface = (IAuth) Naming.lookup(bankServerURL); if (loginInterface.registreerNieuweKlant(jtfKlantnaam.getText(), jtfWoonplaats.getText(), jtfGebruikersnaam.getText(), jtfWachtwoord.getText())) { sessieId = loginInterface.startSessie(jtfGebruikersnaam.getText(), jtfWachtwoord.getText()); loginInterface.registerClientObj(sessieId, clientcontroller); } } catch (IllegalArgumentException ex) { JOptionPane.showMessageDialog(this.parentFrame.getRootPane(), ex.getMessage()); return; } catch ( NotBoundException | MalformedURLException | SessieExpiredException ex) { } SessieFrame sessieFrame = new SessieFrame(sessieId, clientcontroller); sessieFrame.setVisible(true); this.parentFrame.dispose(); } catch (RemoteException ex) { } }//GEN-LAST:event_btnRegistrerenActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnRegistreren; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JTextField jtfGebruikersnaam; private javax.swing.JTextField jtfKlantnaam; private javax.swing.JPasswordField jtfWachtwoord; private javax.swing.JTextField jtfWoonplaats; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/NieuweKlantPanel.java
Java
oos
5,898
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IAuth; import Balie.Controller.ClientImpl; import Bank.Model.SessieExpiredException; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; import javax.swing.JOptionPane; /** * * @author Melis */ public class InlogPanel extends javax.swing.JPanel { /** * Creates new form NewJPanel * Er moet in dit geval een parameterloze constructor voor inlogpanel aanwezig zijn, daar * anders de GUI designer van netbeans foutmeldingen gaat geven. */ public InlogPanel() { initComponents(); } /** * Creates new form NewJPanel * @param jframereferentie * @param jframeReferentie er wordt een JFrame meegegeven omdat, wanneer login * voltooid is, dan moet het jframe afgesloten worden. */ public InlogPanel(JFrame jframereferentie) { initComponents(); this.parentFrame = jframereferentie; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jtfGebruiker = new javax.swing.JTextField(); jtfWachtwoord = new javax.swing.JPasswordField(); jLabel1 = new javax.swing.JLabel(); btnInloggen = new javax.swing.JButton(); setBackground(new java.awt.Color(255, 255, 255)); setOpaque(false); setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jtfGebruiker.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfGebruiker.setBorder(null); add(jtfGebruiker, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 84, 340, 30)); jtfWachtwoord.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfWachtwoord.setBorder(null); add(jtfWachtwoord, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 162, 340, 30)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/InlogPanel.gif"))); // NOI18N add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 270)); btnInloggen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogButton.gif"))); // NOI18N btnInloggen.setBorder(null); btnInloggen.setBorderPainted(false); btnInloggen.setFocusPainted(false); btnInloggen.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnInloggen.setOpaque(false); btnInloggen.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogButtonClicked.gif"))); // NOI18N btnInloggen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnInloggenActionPerformed(evt); } }); add(btnInloggen, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 290, 150, 40)); }// </editor-fold>//GEN-END:initComponents private void btnInloggenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInloggenActionPerformed try { String bankServerURL = "rmi://localhost/auth"; String sessieId = null; IAuth loginInterface; ClientImpl clientcontroller = new ClientImpl(); try { loginInterface = (IAuth) Naming.lookup(bankServerURL); sessieId = loginInterface.startSessie(jtfGebruiker.getText(), jtfWachtwoord.getText()); loginInterface.registerClientObj(sessieId, clientcontroller); } catch (IllegalArgumentException ex) { JOptionPane.showMessageDialog(this.parentFrame.getRootPane(), ex.getMessage()); return; } catch ( NotBoundException | MalformedURLException | SessieExpiredException ex) { } SessieFrame sessieFrame = new SessieFrame(sessieId, clientcontroller); sessieFrame.setVisible(true); this.parentFrame.dispose(); } catch (RemoteException ex) { } }//GEN-LAST:event_btnInloggenActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnInloggen; private javax.swing.JLabel jLabel1; private javax.swing.JTextField jtfGebruiker; private javax.swing.JPasswordField jtfWachtwoord; // End of variables declaration//GEN-END:variables private JFrame parentFrame; }
1234banksysteem
trunk/src_oplevering1/Balie/gui/InlogPanel.java
Java
oos
5,028
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IRekening; import API.ITransactieHandler; import Bank.Model.SessieExpiredException; import java.awt.Point; import java.math.BigDecimal; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; /** * * @author Melis */ public class NieuwTransactieDialog extends javax.swing.JDialog { private IRekening rekening; private String sessieID; /** * Creates new form NieuwTransactieDialog * * @param parent * @param modal */ public NieuwTransactieDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); setLocation(new Point(500, 200)); } /** * * @param parent * @param modal * @param rekening * @param sessieID */ public NieuwTransactieDialog(java.awt.Frame parent, boolean modal, IRekening rekening, String sessieID) { super(parent, modal); initComponents(); setLocation(new Point(500, 200)); this.sessieID = sessieID; jtfVanRekening.setText(rekening.toString()); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jtfVanRekening = new javax.swing.JTextField(); jtfSaldo = new javax.swing.JTextField(); jtfSaldoCenten = new javax.swing.JTextField(); jtfNaarRekening = new javax.swing.JTextField(); btnAnnuleren = new javax.swing.JButton(); btnVerzenden = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jtaOmschrijving = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Rainbow Sheep Bank"); setResizable(false); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jtfVanRekening.setEditable(false); jtfVanRekening.setBackground(new java.awt.Color(238, 238, 238)); jtfVanRekening.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfVanRekening.setHorizontalAlignment(javax.swing.JTextField.LEFT); jtfVanRekening.setBorder(null); getContentPane().add(jtfVanRekening, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 170, 330, 20)); jtfSaldo.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfSaldo.setHorizontalAlignment(javax.swing.JTextField.RIGHT); jtfSaldo.setBorder(null); getContentPane().add(jtfSaldo, new org.netbeans.lib.awtextra.AbsoluteConstraints(299, 235, 200, 30)); jtfSaldoCenten.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfSaldoCenten.setHorizontalAlignment(javax.swing.JTextField.RIGHT); jtfSaldoCenten.setBorder(null); getContentPane().add(jtfSaldoCenten, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 235, 30, 30)); jtfNaarRekening.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtfNaarRekening.setHorizontalAlignment(javax.swing.JTextField.RIGHT); jtfNaarRekening.setBorder(null); getContentPane().add(jtfNaarRekening, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 297, 340, 30)); btnAnnuleren.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/AnnulerenButton.gif"))); // NOI18N btnAnnuleren.setBorder(null); btnAnnuleren.setBorderPainted(false); btnAnnuleren.setContentAreaFilled(false); btnAnnuleren.setFocusPainted(false); btnAnnuleren.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnAnnuleren.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/AnnulerenButtonClicked.gif"))); // NOI18N btnAnnuleren.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/AnnulerenButtonClicked.gif"))); // NOI18N btnAnnuleren.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAnnulerenActionPerformed(evt); } }); getContentPane().add(btnAnnuleren, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 480, 150, 40)); btnVerzenden.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/VerzendenButton.gif"))); // NOI18N btnVerzenden.setBorder(null); btnVerzenden.setBorderPainted(false); btnVerzenden.setContentAreaFilled(false); btnVerzenden.setFocusPainted(false); btnVerzenden.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnVerzenden.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/VerzendenButtonClicked.gif"))); // NOI18N btnVerzenden.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/VerzendenButtonClicked.gif"))); // NOI18N btnVerzenden.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnVerzendenActionPerformed(evt); } }); getContentPane().add(btnVerzenden, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 480, 150, 40)); jScrollPane1.setBorder(null); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane1.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jScrollPane1.setMaximumSize(new java.awt.Dimension(340, 60)); jtaOmschrijving.setColumns(20); jtaOmschrijving.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N jtaOmschrijving.setLineWrap(true); jtaOmschrijving.setRows(5); jtaOmschrijving.setBorder(null); jtaOmschrijving.setMaximumSize(new java.awt.Dimension(280, 115)); jScrollPane1.setViewportView(jtaOmschrijving); getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 370, 340, 60)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/NieuweTransactieFrame.gif"))); // NOI18N getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 800, 600)); pack(); }// </editor-fold>//GEN-END:initComponents private void btnVerzendenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerzendenActionPerformed //moet nog netjes gemaakt worden. Dialog sluit zichzelf niet af bijv. int saldo = -1; int saldoCenten = -1; int rekeningnR = 0; BigDecimal transactieBedrag = new BigDecimal(0); try { saldo = Integer.parseInt(this.jtfSaldo.getText()); saldoCenten = Integer.parseInt(this.jtfSaldoCenten.getText()); rekeningnR = Integer.parseInt(this.jtfNaarRekening.getText()); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(rootPane, "Niet goed ingevuld"); } if (saldo > -1 && saldoCenten > -1) { float saldoCentenf = saldoCenten; saldoCentenf = saldoCentenf / 100; float saldof = saldo + saldoCentenf; transactieBedrag = new BigDecimal(saldof); } if(transactieBedrag.compareTo(new BigDecimal(0)) != 1) { JOptionPane.showMessageDialog(rootPane, "transactie bedrag moet groter zijn dan 0"); return; } ITransactieHandler transHandeler; try { String bankServerURL = "rmi://localhost/transactie"; transHandeler = (ITransactieHandler) Naming.lookup(bankServerURL); transHandeler.requestTransaction(sessieID, rekeningnR, transactieBedrag, this.jtaOmschrijving.getText()); JOptionPane.showMessageDialog(rootPane, "Transactie succesvol aangevraagd"); this.dispose(); } catch (NotBoundException | MalformedURLException | RemoteException ex) { Logger.getLogger(NieuwTransactieDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (SessieExpiredException ex) { Logger.getLogger(NieuwTransactieDialog.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_btnVerzendenActionPerformed private void btnAnnulerenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnnulerenActionPerformed this.dispose(); }//GEN-LAST:event_btnAnnulerenActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NieuwTransactieDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NieuwTransactieDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NieuwTransactieDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NieuwTransactieDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { NieuwTransactieDialog dialog = new NieuwTransactieDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnAnnuleren; private javax.swing.JButton btnVerzenden; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jtaOmschrijving; private javax.swing.JTextField jtfNaarRekening; private javax.swing.JTextField jtfSaldo; private javax.swing.JTextField jtfSaldoCenten; private javax.swing.JTextField jtfVanRekening; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/NieuwTransactieDialog.java
Java
oos
11,902
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import API.IAuth; import API.IKlant; import API.ILoginAccount; import API.IObservable; import API.IRekening; import API.ITransactie; import API.ITransactieHandler; import Balie.Controller.ClientImpl; import Bank.Model.SessieExpiredException; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Timer; /** * * @author Melis */ public class SessieFrame extends javax.swing.JFrame { private IAuth auth; private String sessieID; private ClientImpl clientController; private ITransactieHandler transHandler; private Timer timer; /** * Creates new form SessieFrame * * @param sessieID * @param clientcontroller */ public SessieFrame(String sessieID, ClientImpl clientcontroller) { initComponents(); setLocation(new Point(400, 100)); this.clientController = clientcontroller; this.sessieID = sessieID; try { String bankServerURL = "rmi://localhost/auth"; auth = (IAuth) Naming.lookup(bankServerURL); IRekening rekening = auth.getRekening(sessieID); lblWelkom.setText("Welkom " + auth.getKlant(sessieID).getKlantnaam()); bankrekeningPanel.setGegevens(sessieID, rekening, auth); IKlant klant = auth.getKlant(sessieID); ILoginAccount login = auth.getLoginAccount(sessieID); klantPanel.setGegevens(klant, login); IObservable o = (IObservable) rekening; clientcontroller.addObserver(bankrekeningPanel, o); bankrekeningPanel.update(rekening, null); bankServerURL = "rmi://localhost/transactie"; transHandler = (ITransactieHandler) Naming.lookup(bankServerURL); transactiePanel2.setEigenRekeningNr(login.getRekeningNr()); ArrayList<ITransactie> transacties; transacties = transHandler.getTransacties(sessieID, null, null); transactiePanel2.setTransacties(transacties); } catch (NotBoundException | MalformedURLException | RemoteException | SessieExpiredException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } timer = new Timer(5000, taskPerformer); timer.start(); } ActionListener taskPerformer = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { ArrayList<ITransactie> transacties; try { transacties = transHandler.getTransacties(sessieID, null, null); transactiePanel2.setTransacties(transacties); } catch (RemoteException | SessieExpiredException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } } }; /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { btnUitloggen = new javax.swing.JButton(); btnNieuweTransactie = new javax.swing.JButton(); bankrekeningPanel = new Balie.gui.BankrekeningPanel(); transactiePanel2 = new Balie.gui.TransactiePanel(); klantPanel = new Balie.gui.KlantPanel(); lblWelkom = new javax.swing.JLabel(); btnMakeMeRich = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Rainbow Sheep Bank"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); btnUitloggen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/UitlogButton.gif"))); // NOI18N btnUitloggen.setBorder(null); btnUitloggen.setBorderPainted(false); btnUitloggen.setContentAreaFilled(false); btnUitloggen.setFocusPainted(false); btnUitloggen.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnUitloggen.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/UitlogButtonClicked.gif"))); // NOI18N btnUitloggen.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/UitlogButtonClicked.gif"))); // NOI18N btnUitloggen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnUitloggenActionPerformed(evt); } }); getContentPane().add(btnUitloggen, new org.netbeans.lib.awtextra.AbsoluteConstraints(840, 60, 150, 40)); btnNieuweTransactie.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/TransactieButton.gif"))); // NOI18N btnNieuweTransactie.setBorder(null); btnNieuweTransactie.setBorderPainted(false); btnNieuweTransactie.setContentAreaFilled(false); btnNieuweTransactie.setFocusPainted(false); btnNieuweTransactie.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnNieuweTransactie.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/TransactieButtonClicked.gif"))); // NOI18N btnNieuweTransactie.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/TransactieButtonClicked.gif"))); // NOI18N btnNieuweTransactie.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNieuweTransactieActionPerformed(evt); } }); getContentPane().add(btnNieuweTransactie, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 524, 150, 40)); bankrekeningPanel.setOpaque(false); getContentPane().add(bankrekeningPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 214, -1, -1)); getContentPane().add(transactiePanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 220, -1, 270)); getContentPane().add(klantPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 506, -1, -1)); lblWelkom.setFont(new java.awt.Font("Calibri", 1, 48)); // NOI18N lblWelkom.setText("Welkom"); getContentPane().add(lblWelkom, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 58, 690, 40)); btnMakeMeRich.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/MakeMeRichButton.gif"))); // NOI18N btnMakeMeRich.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btnMakeMeRichMouseClicked(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { btnMakeMeRichMouseEntered(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { btnMakeMeRichMouseExited(evt); } public void mousePressed(java.awt.event.MouseEvent evt) { btnMakeMeRichMousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { btnMakeMeRichMouseReleased(evt); } }); getContentPane().add(btnMakeMeRich, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 702, -1, -1)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/SessieFrame_Background.gif"))); // NOI18N jLabel1.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION); jLabel1.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { jLabel1FocusGained(evt); } }); getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 770)); jTextField1.setText("jTextField1"); getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 60, -1, -1)); pack(); }// </editor-fold>//GEN-END:initComponents private void btnMakeMeRichMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnMakeMeRichMouseClicked this.bankrekeningPanel.storten(); }//GEN-LAST:event_btnMakeMeRichMouseClicked private void btnMakeMeRichMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnMakeMeRichMouseEntered btnMakeMeRich.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/MakeMeRichButtonClicked.gif"))); }//GEN-LAST:event_btnMakeMeRichMouseEntered private void btnMakeMeRichMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnMakeMeRichMouseExited btnMakeMeRich.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/MakeMeRichButton.gif"))); }//GEN-LAST:event_btnMakeMeRichMouseExited private void btnMakeMeRichMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnMakeMeRichMouseReleased btnMakeMeRich.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/MakeMeRichButton.gif"))); }//GEN-LAST:event_btnMakeMeRichMouseReleased private void btnMakeMeRichMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnMakeMeRichMousePressed btnMakeMeRich.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/MakeMeRichButtonClicked.gif"))); }//GEN-LAST:event_btnMakeMeRichMousePressed private void btnUitloggenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUitloggenActionPerformed try { auth.stopSessie(sessieID); timer.stop(); clientController.logOut(); } catch (RemoteException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SessieExpiredException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } StartFrame startframe = new StartFrame(); startframe.setVisible(true); this.dispose(); }//GEN-LAST:event_btnUitloggenActionPerformed /** * Eventhandler wanneer de gebruiker een nieuwe transactie wilt maken. Er * wordt een nieuw jdialog scherm opgestart. * * @param evt */ private void btnNieuweTransactieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNieuweTransactieActionPerformed try { IRekening rekening = auth.getRekening(sessieID); NieuwTransactieDialog transactieDialog = new NieuwTransactieDialog(this, true, rekening, sessieID); transactieDialog.setVisible(true); } catch (RemoteException | SessieExpiredException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_btnNieuweTransactieActionPerformed /** * Eventhandler die noodzakelijk wanneer het frame afgesloten wordt. De * verbinding tussen client en server moet verbroken worden. * * @param evt */ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing try { clientController.logOut(); } catch (RemoteException ex) { Logger.getLogger(SessieFrame.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_formWindowClosing private void jLabel1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jLabel1FocusGained }//GEN-LAST:event_jLabel1FocusGained // Variables declaration - do not modify//GEN-BEGIN:variables private Balie.gui.BankrekeningPanel bankrekeningPanel; private javax.swing.JLabel btnMakeMeRich; private javax.swing.JButton btnNieuweTransactie; private javax.swing.JButton btnUitloggen; private javax.swing.JLabel jLabel1; private javax.swing.JTextField jTextField1; private Balie.gui.KlantPanel klantPanel; private javax.swing.JLabel lblWelkom; private Balie.gui.TransactiePanel transactiePanel2; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/SessieFrame.java
Java
oos
13,103
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Balie.gui; import java.awt.Point; /** * * @author Melis */ public class StartFrame extends javax.swing.JFrame { /** * Creates new form NewJFrame */ public StartFrame() { initComponents(); setLocation(new Point(400,100)); nieuweKlantPanel1.setVisible(false); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { inlogPanel1 = new Balie.gui.InlogPanel(this); nieuweKlantPanel1 = new Balie.gui.NieuweKlantPanel(this); tabNieuweKlant = new javax.swing.JButton(); tabInloggen = new javax.swing.JButton(); jlbl_Background = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Rainbow Sheep Bank"); setMinimumSize(new java.awt.Dimension(1024, 768)); setResizable(false); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); getContentPane().add(inlogPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 260, -1, -1)); getContentPane().add(nieuweKlantPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 260, -1, -1)); tabNieuweKlant.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabInactive.gif"))); // NOI18N tabNieuweKlant.setBorder(null); tabNieuweKlant.setBorderPainted(false); tabNieuweKlant.setContentAreaFilled(false); tabNieuweKlant.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabActive.gif"))); // NOI18N tabNieuweKlant.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabActive.gif"))); // NOI18N tabNieuweKlant.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabNieuweKlant.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabHover.gif"))); // NOI18N tabNieuweKlant.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabActive.gif"))); // NOI18N tabNieuweKlant.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/NieuweKlantTabActive.gif"))); // NOI18N tabNieuweKlant.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tabNieuweKlantActionPerformed(evt); } }); getContentPane().add(tabNieuweKlant, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 187, -1, -1)); tabInloggen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogTabInactive.gif"))); // NOI18N tabInloggen.setBorder(null); tabInloggen.setBorderPainted(false); tabInloggen.setContentAreaFilled(false); tabInloggen.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogTabActive.gif"))); // NOI18N tabInloggen.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogTabActive.gif"))); // NOI18N tabInloggen.setEnabled(false); tabInloggen.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabInloggen.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogTabHover.gif"))); // NOI18N tabInloggen.setRolloverSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/Buttons/InlogTabActive.gif"))); // NOI18N tabInloggen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tabInloggenActionPerformed(evt); } }); getContentPane().add(tabInloggen, new org.netbeans.lib.awtextra.AbsoluteConstraints(304, 187, -1, -1)); jlbl_Background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Balie/gui/Images/BackgroundStartFrame.gif"))); // NOI18N jlbl_Background.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION); jlbl_Background.setOpaque(false); getContentPane().add(jlbl_Background, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); pack(); }// </editor-fold>//GEN-END:initComponents private void tabNieuweKlantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tabNieuweKlantActionPerformed tabInloggen.setEnabled(true); tabNieuweKlant.setEnabled(false); inlogPanel1.setVisible(false); nieuweKlantPanel1.setVisible(true); }//GEN-LAST:event_tabNieuweKlantActionPerformed private void tabInloggenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tabInloggenActionPerformed tabInloggen.setEnabled(false); tabNieuweKlant.setEnabled(true); inlogPanel1.setVisible(true); nieuweKlantPanel1.setVisible(false); }//GEN-LAST:event_tabInloggenActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(StartFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new StartFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private Balie.gui.InlogPanel inlogPanel1; private javax.swing.JLabel jlbl_Background; private Balie.gui.NieuweKlantPanel nieuweKlantPanel1; private javax.swing.JButton tabInloggen; private javax.swing.JButton tabNieuweKlant; // End of variables declaration//GEN-END:variables }
1234banksysteem
trunk/src_oplevering1/Balie/gui/StartFrame.java
Java
oos
7,746
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; /** * */ public class SessieExpiredException extends Exception { public SessieExpiredException() { } public SessieExpiredException(String message) { super(message); } public SessieExpiredException(Throwable cause) { super(cause); } public SessieExpiredException(String message, Throwable cause) { super(message, cause); } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/SessieExpiredException.java
Java
oos
533
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.ITransactie; import API.TransactieStatus; import java.math.BigDecimal; import java.util.GregorianCalendar; import java.util.Locale; /** * De klasse transatie is verantwoordelijk voor het registreren van een * overboeking. Hierbij is het bedrag van belang, en het rekeningnummer waar het * vanaf geschreven moet worden en de tegenrekening waarbij het bedrag * bijgeboekt moet worden. */ public class Transactie extends BaseObservable implements ITransactie { //transient zodat het tijdens het serializeren niet wordt opgeslagen (niet meegestuurd over RMI). //volatile zodat het automatisch gesynchronizeerd wordt en nextTransactieId blijft altijd beschikbaar. //volatile variablen kunnen niet locked raken. private transient static volatile int nextTransactieId; private final int transactieId; private final int eigenbankrekening; private final int tegenrekening; private final String commentaar; private final BigDecimal bedrag; private final GregorianCalendar transactieInvoerDatum; private TransactieStatus status; /** * De constructor van Transactie. Hierin wordt als transactieInvoerDatum de * datum van vandaag gepakt. De status van de transactie staat op OPENSTAAND * bij het aanmaken van een nieuwe transactie. * * @param eigenbankrekening de rekening waarvan het bedrag afgeschreven moet * worden. * @param tegenrekening de rekening waar het bedrag bij geschreven moet * worden. * @param bedrag het bedrag wat overgemaakt wordt. * @param comment bij elke overboeking kan er commentaar of een * betalingskenmerk ingevuld worden. */ public Transactie(int eigenbankrekening, int tegenrekening, BigDecimal bedrag, String comment) { this.eigenbankrekening = eigenbankrekening; this.tegenrekening = tegenrekening; this.bedrag = bedrag; this.commentaar = comment; this.status = TransactieStatus.OPENSTAAND; this.transactieInvoerDatum = new GregorianCalendar(Locale.GERMANY); this.transactieId = nextTransactieId; Transactie.nextTransactieId++; } /** * De status van een transactie kan veranderen in loop van tijd. * * @param status de status die de transactie moet krijgen. */ public void setStatus(TransactieStatus status) { this.status = status; this.setChanged(); this.notifyObservers(); } /** * Een get-methode voor het transactieID. * * @return Het transactieID. */ public int getTransactieId() { return transactieId; } /** * Een get-methode voor de rekening waarvan het bedrag afgeschren moet * worden. * * @return de rekening waar het bedrag van afgeschreven wordt. */ public int getEigenbankrekening() { return eigenbankrekening; } /** * Een get-methode voor de rekening waar het bedrag bij geschreven moet * worden. * * @return de tegenrekening */ public int getTegenrekening() { return tegenrekening; } /** * Een get-methode voor het bedrag * * @return het bedrag */ public BigDecimal getBedrag() { return bedrag; } /** * Een get-methode voor de transactiestatus * * @return de transactiestatus */ public TransactieStatus getStatus() { return status; } /** * Een get-methode voor de datum dat de transactie ingevoerd is. * * @return de datum dat de transactie ingevoerd is. */ public GregorianCalendar getTransactieInvoerDatum() { return transactieInvoerDatum; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/Transactie.java
Java
oos
3,933
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IRekening; import java.math.BigDecimal; import java.math.RoundingMode; /** * De klasse Rekening heeft als verantwoordelijkheid om rekeninggegevens. zoals * het saldo en kredietlimiet bij te houden. */ public class Rekening extends BaseObservable implements IRekening { private final int rekeningnummer; private BigDecimal saldo = new BigDecimal(0.00); private final BigDecimal kredietlimiet = new BigDecimal(0.00); //transient zodat het tijdens het serializeren niet wordt opgeslagen (niet meegestuurd over RMI) private transient static volatile int nextrekeningnummer = 1000; /** * Deze constructor maakt een nieuw rekeningnummer. Bij een nieuwe Rekening * is het saldo altijd 0 en het kredietlimiet is ook 0. */ public Rekening() { super(); this.rekeningnummer = nextrekeningnummer; nextrekeningnummer++; } /** * Een get-methode voor het rekeningnummer. * * @return het rekeningnummer. */ @Override public synchronized int getRekeningnummer() { return rekeningnummer; } /** * Een get-methode voor het saldo. * * @return het saldo. */ @Override public synchronized BigDecimal getSaldo() { return saldo.setScale(2, RoundingMode.HALF_EVEN); } /** * Een get-methode voor het kredietlimiet. * * @return het kredietlimiet. */ @Override public synchronized BigDecimal getKredietlimiet() { return kredietlimiet.setScale(2, RoundingMode.HALF_EVEN); } public synchronized boolean neemOp(BigDecimal bedrag) { if (bedrag.compareTo(new BigDecimal(0)) == 1) { BigDecimal saldoTotaal = new BigDecimal(0.00); saldoTotaal = saldoTotaal.add(this.saldo); saldoTotaal = saldoTotaal.add(this.kredietlimiet); if (saldoTotaal.compareTo(bedrag) == 1 | saldoTotaal.compareTo(bedrag)== 0) { this.saldo = this.saldo.subtract(bedrag); setChanged(); notifyObservers(); return true; } } return false; } public synchronized void stort(BigDecimal bedrag) { if (bedrag.compareTo(new BigDecimal(0)) == 1) { this.saldo = this.saldo.add(bedrag); } setChanged(); notifyObservers(); } /** * Een toString methode voor Rekening die de toString methode van Object * overschrijft. * * @return het rekeningnummer. */ @Override public String toString() { return Integer.toString(this.rekeningnummer); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof Rekening)) { return false; } Rekening r = (Rekening) obj; return Integer.compare(rekeningnummer, r.getRekeningnummer()) == 0; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/Rekening.java
Java
oos
3,257
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IClient; import java.sql.Timestamp; import java.util.UUID; /** * Sessie object om authenticatie te versimpelen. Eenmalig login nodig waarna de * sessie blijft leven tot 10 minuten na de laatste activiteit. * */ public class Sessie { private Timestamp lastActivity; private final String SessieId; private LoginAccount login; private IClient client; /** * Initialiseerd het sessie object. Na initialisatie is er een sessieID * gegenereerd en wordt er een sessietask ingepland om de sessie te * beindigen. * * @param login Het login account waarvoor de sessie gestart wordt. */ public Sessie(LoginAccount login) { //UUID genereert een random unique nummer van 128 bits. //Absolute zekerheid op uniqueness krijg je hiermee niet, maar ruim voldoende voor opdracht. //Absolute zekerheid alleen te verkrijgen door lijst met verbruikte id's bij te houden of synced counter. this.SessieId = UUID.randomUUID().toString(); this.login = login; updateActivity(); } /** * Een get-methode voor de sessieID * * @return de sessieID */ public String getSessieId() { return this.SessieId; } /** * Een get-methode voor het loginaccount * * @return het loginaccount */ public LoginAccount getLogin() { updateActivity(); return login; } /** * Een get-methode om de IClient op te vragen * * @return de IClient waarvoor deze sessie geregistreerd is. */ public IClient getClient() { return client; } /** * zet de client bij deze sessie. * * @param client */ public void setClient(IClient client) { updateActivity(); this.client = client; } public Timestamp getLastActivity() { return lastActivity; } public void updateActivity() { java.util.Date date = new java.util.Date(); this.lastActivity = new Timestamp(date.getTime()); } /** * Methode om loginaccount op te vragen bij de sessie * hierbij wordt de lastactivity niet geupdate. Deze methode wordt namelijk via * de callback functie vanuit de client (sessieframe) aangeroepen wanneer * de transacties worden opgevraagd. * @return */ public LoginAccount getLoginNoActivityChange() { return login; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/Sessie.java
Java
oos
2,645
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IClient; import API.IAuth; import API.IKlant; import API.ILoginAccount; import API.IObservable; import API.IRekening; import Bank.Managers.KlantManager; import Bank.Managers.LoginManager; import Bank.Managers.RekeningManager; import Bank.Managers.SessieManager; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; /** * De server verstuurt berichten naar de ClientImpl middels deze klasse. Deze * klasse implementeert IAuth en bij ClientImpl is IAuth ook bekend. Zodanig kan * de klant onderstaande methoden opvragen bij de server. */ public class Auth implements IAuth { private static HashMap<IObservable, ArrayList<String>> obs = new HashMap<>(); @Override public synchronized String startSessie(String username, String password) throws RemoteException { LoginManager loginManager = LoginManager.getInstance(); try { Bank.Model.LoginAccount login = loginManager.getLoginAccount(username, password); Sessie newSessie = new Sessie(login); SessieManager sm = SessieManager.getInstance(); sm.addSessie(newSessie); return newSessie.getSessieId(); } catch (IllegalArgumentException e) { throw e; } } /** * Methode die een nieuwe klant registreert en daarbij kijkt of een klant al bestaat of niet. * Bestaat de klant al, dan wordt dat klantnummer gebruikt. Bestaat klant niet, dan wordt er * een nieuwe klant nummer aan gegeven. * @param klantnaam * @param woonplaats * @param gebruikersnaam * @param wachtwoord * @return * @throws RemoteException */ @Override public synchronized boolean registreerNieuweKlant(String klantnaam, String woonplaats, String gebruikersnaam, String wachtwoord) throws RemoteException { KlantManager klantmanager = KlantManager.getInstance(); LoginManager loginmanager = LoginManager.getInstance(); RekeningManager rekeningmanager = RekeningManager.getInstance(); if(!loginmanager.bestaatLoginNaam(gebruikersnaam)) { //Er hoeft geen nieuwe klant toegevoegd te worden als klantobject al bestaat. if (klantmanager.getBestaandeKlantNummer(klantnaam, woonplaats) != 0){ int klantnummer = klantmanager.getBestaandeKlantNummer(klantnaam, woonplaats); Rekening rekening = new Rekening(); LoginAccount loginaccount = new LoginAccount(gebruikersnaam, wachtwoord, klantnummer, rekening.getRekeningnummer()); loginmanager.addLogin(loginaccount); rekeningmanager.addRekening(rekening); return true; } //Wanneer er nog geen klantobject bestaat dan moet er wel een nieuw klantobject aangemaakt worden en bij klantmanager geregistreerd worden. else { Klant klant = new Klant(klantnaam, woonplaats); Rekening rekening = new Rekening(); LoginAccount loginaccount = new LoginAccount(gebruikersnaam, wachtwoord, klant.getKlantNr(), rekening.getRekeningnummer()); klantmanager.addKlant(klant); loginmanager.addLogin(loginaccount); rekeningmanager.addRekening(rekening); return true; } } return false; } @Override public synchronized void stopSessie(String sessionId) throws RemoteException, SessieExpiredException { SessieManager.getInstance().stopSessie(sessionId); } @Override public synchronized IKlant getKlant(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { Bank.Model.LoginAccount login = sm.getAccountFromSessie(sessionId); KlantManager km = KlantManager.getInstance(); Klant k = km.getKlant(login.getKlantNr()); registerObservable(k, sessionId); return k; } catch (SessieExpiredException e) { throw e; } } @Override public synchronized IRekening getRekening(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { ILoginAccount login = (ILoginAccount) sm.getAccountFromSessie(sessionId); RekeningManager rm = RekeningManager.getInstance(); Rekening r = rm.getRekening(login.getRekeningNr()); registerObservable(r, sessionId); return r; } catch (SessieExpiredException e) { throw e; } } @Override public synchronized boolean resetWachtwoord(String sessionId, String username, String password) throws RemoteException, SessieExpiredException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public synchronized void registerClientObj(String sessieId, IClient clientObj) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { sm.bindClientObjecToSessie(sessieId, clientObj); } catch (SessieExpiredException e) { throw e; } } /** * Deze methode is er alleen als snel voorbeeld. Dit moet als een transactie * behandeld worden. * @param sessieId * @param bedrag * @throws java.rmi.RemoteException * @throws Bank.Model.SessieExpiredException */ @Override public synchronized void stort(String sessieId, BigDecimal bedrag) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); ILoginAccount login = (ILoginAccount) sm.getAccountFromSessie(sessieId); RekeningManager rm = RekeningManager.getInstance(); Rekening r = rm.getRekening(login.getRekeningNr()); r.stort(bedrag); } @Override public synchronized void update(Object observable, Object arg) throws RemoteException { IObservable o = (IObservable) observable; if (obs.containsKey(o)) { ArrayList<String> sessieIds = obs.get(o); if (sessieIds == null || sessieIds.isEmpty()) { //geen observers bekend bij sessieId obs.remove(o); return; } ArrayList<String> shadowIds = new ArrayList<>(); for (String sid : sessieIds) { shadowIds.add(sid); } for (String sessieId : shadowIds) { IClient client = null; try { client = SessieManager.getInstance().getClient(sessieId); } catch (SessieExpiredException ex) { Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex); } if (client != null) { client.setObservable(o); } else { //geen client object bekend bij observer, uit de lijst gooien want kan nooit geupdate worden. sessieIds.remove(sessieId); } } } } private synchronized void registerObservable(IObservable o, String sessieId) { ArrayList<String> sessieIds; o.addObserver(this); if (obs.containsKey(o)) { sessieIds = obs.get(o); boolean exists = false; while (!exists) { for (String sId : sessieIds) { if (sessieId.equals(sId)) { exists = true; } } break; } if (!exists) { sessieIds.add(sessieId); } } else { sessieIds = new ArrayList<>(); sessieIds.add(sessieId); obs.put(o, sessieIds); } } @Override public synchronized ILoginAccount getLoginAccount(String sessionId) throws RemoteException, SessieExpiredException { SessieManager sm = SessieManager.getInstance(); try { Bank.Model.LoginAccount login = sm.getAccountFromSessie(sessionId); return login; } catch (SessieExpiredException e) { throw e; } } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/Auth.java
Java
oos
8,835
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IObservable; import API.IObserver; import java.io.Serializable; import java.rmi.RemoteException; import java.util.Observable; import java.util.Observer; /** * * @author ieme */ public class BaseObservable extends Observable implements IObservable, Serializable { private transient static volatile int nextObservableId = 0; private final int observableId; private class WrappedObserver implements Observer, Serializable { private IObserver ro = null; public WrappedObserver(IObserver ro) { this.ro = ro; } @Override public void update(Observable o, Object arg) { try { ro.update(o, arg); } catch (RemoteException e) { System.out .println("Remote exception removing observer:" + this); o.deleteObserver(this); } } } @Override public synchronized void addObserver(IObserver o) { WrappedObserver mo = new WrappedObserver(o); addObserver(mo); } public BaseObservable() { this.observableId = nextObservableId; nextObservableId++; } @Override public int getObservableId() { return this.observableId; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/BaseObservable.java
Java
oos
1,455
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IKlant; /** De verantwoordelijkheid van de Klasse klant, is het bijhouden van de naam * en woonplaats van de klant. De combinatie van naam en woonplaats moeten uniek * zijn wil de klant zich registreren bij een bank. */ public class Klant extends BaseObservable implements IKlant { private final int klantNr; private String klantnaam; private String klantwoonplaats; //nog uit te breiden met postcode etc. private transient static volatile int nextklantnummer = 1; /** * De constructor voor Klant. * @param klantnaam de naam van de klant. * @param klantwoonplaats de woonplaats van de klant. */ public Klant(String klantnaam, String klantwoonplaats) { //wanneer klant zijn gegevens heeft ingevoerd zonder hoofdletter(s) // zal de eerste letter een hoofdletter moeten zijn. this.klantnaam = capitaliseerWoord(klantnaam); this.klantwoonplaats = capitaliseerWoord(klantwoonplaats); this.klantNr = nextklantnummer; nextklantnummer++; } /** Wanneer een klant een naamswijziging doorgeeft kan dat met onderstaande * methode verwerkt worden. * @param klantnaam de nieuwe naam van de klant. */ public void setKlantnaam(String klantnaam) { this.klantnaam = klantnaam; } /** Wanneer een klant een nieuwe woonplaats doorgeeft, kan dat met * onderstaande methode worden verwerkt. * @param klantwoonplaats de nieuwe woonplaats van de klant. */ public void setKlantwoonplaats(String klantwoonplaats) { this.klantwoonplaats = klantwoonplaats; } /** Een get-methode voor de klantnaam. * @return de naam van de klant. */ public String getKlantnaam() { return klantnaam; } /** Een get-methode voor de woonplaats van de klant. * @return de woonplaats van de klant. */ public String getKlantwoonplaats() { return klantwoonplaats; } public int getKlantNr() { return klantNr; } private String capitaliseerWoord(String string) { String[] token = string.split(" "); StringBuilder stringbuilder = new StringBuilder(); for(int i = 0; i < token.length; ++i) { String naam = token[i].toLowerCase(); naam = naam.substring(0, 1).toUpperCase() + naam.substring(1); stringbuilder.append(naam).append(" "); } //laatste spatie er uit halen die automatisch toegevoegd wordt aan de stringbuilder. return stringbuilder.toString().substring(0, stringbuilder.length()-1); } /** Een toString methode voor Klant die de toString methode van Object overschrijft. * @return de naam van de klant. */ @Override public String toString() { return this.klantnaam; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/Klant.java
Java
oos
3,021
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.ILoginAccount; /** * De verantwoordelijkheid van de klasse LoginAccount is het bijhouden van een * inlognaam en een wachtwoord. Een inlognaam mag niet vaker voorkomen bij een * bank (een wachtwoord wel). */ public class LoginAccount extends BaseObservable implements ILoginAccount { private String loginnaam; private transient String loginwachtwoord; private final int klantNr; private final int rekeningNr; /** * De constructor van LoginAccount * * @param loginnaam de loginnaam van de klant * @param loginwachtwoord het loginwachtwoord van de klant */ public LoginAccount(String loginnaam, String loginwachtwoord, int klantNr, int rekeningNr) { this.loginnaam = loginnaam; this.loginwachtwoord = loginwachtwoord; this.klantNr = klantNr; this.rekeningNr = rekeningNr; } /** * Een get-methode voor de loginnaam * * @return de loginnaam */ @Override public String getLoginNaam() { return this.loginnaam; } @Override public int getKlantNr() { return klantNr; } public String getLoginwachtwoord() { return loginwachtwoord; } @Override public int getRekeningNr() { return rekeningNr; } /** * Wanneer een klant bij het inloggen zijn wachtwoord is vergeten, moet het mogelijk zijn * (of worden) om het wachtwoord te wijzigen. * * @param nieuwwachtwoord het nieuwe wachtwoord */ public void setWachtwoord(String nieuwwachtwoord) { this.loginwachtwoord = nieuwwachtwoord; } /** * Een toString methode voor LoginAccount die de toString methode van Object * overschrijft. * * @return de loginnaam. */ @Override public String toString() { return this.loginnaam; } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/LoginAccount.java
Java
oos
2,148
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Model; import API.IClient; import API.IObservable; import API.ITransactie; import API.ITransactieHandler; import API.TransactieStatus; import API.TransactieType; import Bank.Managers.SessieManager; import Bank.Managers.TransactieManager; import java.math.BigDecimal; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; /** * De server verstuurt berichten naar de ClientImpl middels deze klasse. Deze * klasse implementeert ITransactie en bij ClientImpl is ITransactie ook bekend. * Zodanig kan de klant onderstaande methoden opvragen bij de server. */ public class TransactieHandler implements ITransactieHandler { private static HashMap<IObservable, ArrayList<String>> obs = new HashMap<>(); @Override public synchronized Transactie requestTransaction(String sessieId, int recipientRekeningnummer, BigDecimal bedrag, String comment) throws SessieExpiredException { LoginAccount login = SessieManager.getInstance().getAccountFromSessie(sessieId); if (login != null) { Transactie trans = new Transactie(login.getRekeningNr(), recipientRekeningnummer, bedrag, comment); TransactieManager.getInstance().addTransactie(trans); registerObservable(trans, sessieId); return trans; } return null; } @Override public synchronized ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, null, TransactieType.ALLE); } @Override public synchronized ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, status, TransactieType.ALLE); } @Override public synchronized ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieType type) throws RemoteException, SessieExpiredException { return getTransacties(sessieId, vanafDatum, totDatum, null, type); } @Override public synchronized ArrayList<ITransactie> getTransacties(String sessieId, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status, TransactieType type) throws RemoteException, SessieExpiredException { LoginAccount login = SessieManager.getInstance().getAccountFromSessieNoActivityChange(sessieId); if (login != null) { int rekeningnr = login.getRekeningNr(); ArrayList<ITransactie> iTransacties = new ArrayList<>(); ArrayList<Transactie> transacties = TransactieManager.getInstance().getTransacties(rekeningnr, 0, vanafDatum, totDatum, status, type); for(Transactie trans : transacties) { iTransacties.add(trans); } return iTransacties; } return null; } @Override public synchronized void update(Object observable, Object arg) throws RemoteException { IObservable o = (IObservable) observable; if (obs.containsKey(o)) { ArrayList<String> sessieIds = obs.get(o); if (sessieIds == null || sessieIds.isEmpty()) { //geen observers bekend bij sessieId obs.remove(o); return; } ArrayList<String> shadowIds = new ArrayList<>(); for (String sid : sessieIds) { shadowIds.add(sid); } for (String sessieId : shadowIds) { IClient client = null; try { client = SessieManager.getInstance().getClient(sessieId); } catch (SessieExpiredException ex) { Logger.getLogger(Auth.class.getName()).log(Level.SEVERE, null, ex); } if (client != null) { client.setObservable(o); } else { //geen client object bekend bij observer, uit de lijst gooien want kan nooit geupdate worden. sessieIds.remove(sessieId); } } } } private synchronized void registerObservable(IObservable o, String sessieId) { ArrayList<String> sessieIds; o.addObserver(this); if (obs.containsKey(o)) { sessieIds = obs.get(o); boolean exists = false; while (!exists) { for (String sId : sessieIds) { if (sessieId.equals(sId)) { exists = true; } } break; } if (!exists) { sessieIds.add(sessieId); } } else { sessieIds = new ArrayList<>(); sessieIds.add(sessieId); obs.put(o, sessieIds); } } }
1234banksysteem
trunk/src_oplevering1/Bank/Model/TransactieHandler.java
Java
oos
5,394
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import Bank.Model.Klant; import java.util.HashMap; /** * De klantmanager klasse houdt een hashmap waar klanten te zoeken zijn op klantnr */ public class KlantManager { private static volatile KlantManager instance = null; private HashMap<Integer, Klant> klanten; //klantNr, KlantObject private static class Loader { static KlantManager instance = new KlantManager(); } //constructor private KlantManager() { this.klanten = new HashMap<>(); } public static KlantManager getInstance() { if (instance == null) { synchronized (KlantManager.class) { instance = new KlantManager(); } } return instance; } /** * deze methode voegt een klant toe aan de klantmanager * @param klant * @return true indien het toevoegen gelukt is, anders false */ public boolean addKlant(Klant klant) { synchronized (this.klanten) { if (this.klanten.get(klant.getKlantNr()) == null) { this.klanten.put(klant.getKlantNr(), klant); return true; } } return false; } /** * deze methode stuurt de klant terug met het gekozen klantnr * @param klantNr het klantnr van de klant * @return gekozen klant */ public Klant getKlant(int klantNr) { synchronized (this.klanten) { return this.klanten.get(klantNr); } } /** * Methode die kijkt of een klant al bekend is in het systeem wanneer hij/zij * zich registreert. Dan kan het bestaande klantnummer meegegeven worden. * @param naam * @param woonplaats * @return */ public int getBestaandeKlantNummer(String naam, String woonplaats) { String klantnaam = capitaliseerWoord(naam); String klantwoonplaats = capitaliseerWoord(woonplaats); for (Klant klant : this.klanten.values()) { if (klant.getKlantnaam().equals(klantnaam) && klant.getKlantwoonplaats().equals(klantwoonplaats)) { return klant.getKlantNr(); } } return 0; } /** * deze functie zet de eerste letter van een string in hoofdletter en de rest van de string in kleine letters. * @param string de string die aangepast moet worden * @return string */ private String capitaliseerWoord(String string) { String[] token = string.split(" "); StringBuilder stringbuilder = new StringBuilder(); for(int i = 0; i < token.length; ++i) { String naam = token[i].toLowerCase(); naam = naam.substring(0, 1).toUpperCase() + naam.substring(1); stringbuilder.append(naam).append(" "); } //laatste spatie er uit halen die automatisch toegevoegd wordt aan de stringbuilder. return stringbuilder.toString().substring(0, stringbuilder.length()-1); } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/KlantManager.java
Java
oos
3,206
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import java.util.TimerTask; /** * SessieTask om een sessie te kunnen beindigen na inactiviteit. Kan gebruikt * worden i.c.m. java.util.Timer. * */ public class SessieTask extends TimerTask { public SessieTask() { } @Override public void run() { SessieManager sm = SessieManager.getInstance(); sm.expireCheck(); } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/SessieTask.java
Java
oos
508
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import API.IClient; import Bank.Model.LoginAccount; import Bank.Model.Sessie; import Bank.Model.SessieExpiredException; import java.rmi.RemoteException; import java.util.HashMap; import java.util.Map; import java.util.Timer; import java.util.logging.Level; import java.util.logging.Logger; /** * de SessieManager klasse houdt een hashmap bij waarin alle sessies worden bijgehouden. * Deze zijn te zoeken op SessieID. */ public class SessieManager { private static volatile SessieManager instance = null; //Hashmap zodat we met O(1) op sessieId kunnen zoeken. //zoeken op Sessie referentie is gelijk aan ArrayList O(n); private HashMap<String, Sessie> sessies; private Timer timer; private long timerInterval = 1000; private SessieTask sessieTask; /** * Methode om een loginaccount bij een sessie op te vragen zonder dat de laatste activiteit geupdate wordt. * Vanuit de gui wordt er elke keer een callback gedaan om de transactielijst te verversen. Hierbij mag de * lastActivity niet veranderd worden bij de betreffende sessie. * @param sessieId * @return * @throws SessieExpiredException */ public LoginAccount getAccountFromSessieNoActivityChange(String sessieId) throws SessieExpiredException { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); if (sessie != null) { return sessie.getLoginNoActivityChange(); } else { throw new SessieExpiredException("Sessie verlopen"); } } } return null; } private static class Loader { static SessieManager instance = new SessieManager(); } private SessieManager() { this.sessies = new HashMap<>(); scheduleExpireCheck(); } public static SessieManager getInstance() { if (instance == null) { synchronized (SessieManager.class) { instance = new SessieManager(); } } return instance; } /** * voegt een sessie toe aan de SessieManager * @param sessie de toe te voegen sessie * @return true indien de sessie is toegevoegd, anders false */ public boolean addSessie(Sessie sessie) { if (sessie != null) { synchronized (this.sessies) { if (this.sessies.get(sessie.getSessieId()) == null) { this.sessies.put(sessie.getSessieId(), sessie); return true; } } } return false; } /** * stuurt sessie terug met het opgegeven sessieId * @param sessieId sessieId van de terug te sturen sessie * @return sessie indien deze in de SessieManager voorkomt, anders null */ private Sessie getSessie(String sessieId) { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); return sessie; } } return null; } /** * stuurt een loginaccount terug waarbij de sessie het opgegeven sessieId heeft * @param sessieId het sessieId van de sessie * @return loginaccount van het gekozen sessieId indien deze is gevonden, anders null * @throws SessieExpiredException */ public LoginAccount getAccountFromSessie(String sessieId) throws SessieExpiredException { synchronized (sessies) { if (sessieId != null) { Sessie sessie = sessies.get(sessieId); if (sessie != null) { return sessie.getLogin(); } else { throw new SessieExpiredException("Sessie verlopen"); } } } return null; } private void scheduleExpireCheck() { try { if (timer != null) { timer.cancel(); } } catch (IllegalStateException e) { } finally { timer = new Timer(); sessieTask = new SessieTask(); timer.schedule(sessieTask, timerInterval); } } /** * Kijk of sessies 10 minuten ongebruikt zijn, logt ze dan uit. */ public void expireCheck() { java.util.Date date = new java.util.Date(); synchronized (this.sessies) { for (Map.Entry pair : this.sessies.entrySet()) { Sessie sessie = (Sessie) pair.getValue(); long verschil = date.getTime() - sessie.getLastActivity().getTime(); System.out.println("Sessie ID: " + sessie.getSessieId() + " Verschil: " + verschil ); if (verschil > 10000) { IClient clientOb = sessie.getClient(); try { clientOb.logOut(); } catch (RemoteException ex) { Logger.getLogger(SessieManager.class.getName()).log(Level.SEVERE, null, ex); } finally { this.sessies.remove(sessie.getSessieId()); } } } } scheduleExpireCheck(); } public void bindClientObjecToSessie(String sessieId, IClient clientObject) throws SessieExpiredException { synchronized (this.sessies) { Sessie sessie = this.sessies.get(sessieId); if (sessie != null) { sessie.setClient(clientObject); } else { throw new SessieExpiredException("Sessie verlopen"); } } } public synchronized IClient getClient(String sessieId) throws SessieExpiredException { if (sessieId != null && sessies.get(sessieId) != null) { Sessie sessie = sessies.get(sessieId); return sessie.getClient(); } return null; } /** * verwijdert de sessie * @param sessieId sessieId van de te verwijderen Sessie */ public void stopSessie(String sessieId) { if (sessieId != null) { synchronized (sessies) { if (sessies.containsKey(sessieId)) { sessies.remove(sessieId); } } } } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/SessieManager.java
Java
oos
6,625
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import Bank.Model.Rekening; import java.util.HashMap; /** * de rekeningmanager klasse houdt een hashmap met rekeningen waarbij * op rekeningnummer gezocht kan worden. */ public class RekeningManager { private static volatile RekeningManager instance = null; private HashMap<Integer, Rekening> rekeningen; private static class Loader { static RekeningManager instance = new RekeningManager(); } private RekeningManager() { this.rekeningen = new HashMap<>(); } public static RekeningManager getInstance() { if (instance == null) { synchronized (RekeningManager.class) { instance = new RekeningManager(); } } return instance; } /** * voegt een rekening toe aan de rekeningmanager * @param rekening de toe te voegen rekening * @return true indien de rekening is toegevoegd, anders false */ public boolean addRekening(Rekening rekening) { if (rekening != null) { synchronized (this.rekeningen) { if (this.rekeningen.get(rekening.getRekeningnummer()) == null) { this.rekeningen.put(rekening.getRekeningnummer(), rekening); return true; } } } return false; } /** * stuurt rekeningobject terug met gekozen rekeningnr * @param rekeningNr het rekeningnummer van het terug te sturen rekeningobject. * @return gekozen Rekening */ public Rekening getRekening(int rekeningNr) { synchronized (this.rekeningen) { return this.rekeningen.get(rekeningNr); } } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/RekeningManager.java
Java
oos
1,846
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import Bank.Model.LoginAccount; import java.util.HashMap; /** * De loginmanager klasse houdt een hashmap bij waarin loginaccounts te vinden zijn op loginnr */ public class LoginManager { private static volatile LoginManager instance = null; private HashMap<String, LoginAccount> logins; //loginNr, loginObject; private static class Loader { static LoginManager instance = new LoginManager(); } private LoginManager() { this.logins = new HashMap<>(); } public static LoginManager getInstance() { if (instance == null) { synchronized (LoginManager.class) { instance = new LoginManager(); } } return instance; } /** * voegt een loginaccount toe aan de loginmanager * @param login het toe te voegen loginaccount * @return true indien het toevoegen is gelukt, false indien dit niet is gelukt. */ public boolean addLogin(LoginAccount login) { if (login != null) { synchronized (this.logins) { if (this.logins.get(login.getLoginNaam()) == null) { this.logins.put(login.getLoginNaam(), login); return true; } } } return false; } /** * deze methode stuurt het loginaccount terug indien het opgegeven naam * en wachtwoord correct zijn. * Indien de loginnaam niet bestaat of het wachtwoord niet klopt zal dit * door middel van een exception door worden gegeven. * @param loginNaam de loginnaam van het op te vragen loginaccount * @param password het wachtwoord van het op te vragen loginaccount * @return LoginAccount indien naam en wachtwoord correct * @throws IllegalArgumentException */ public LoginAccount getLoginAccount(String loginNaam, String password) throws IllegalArgumentException { synchronized (this.logins) { LoginAccount login = this.logins.get(loginNaam); if (login == null) { throw new IllegalArgumentException("Onbekende gebruikersnaam"); } if (login.getLoginwachtwoord().equals(password)) { return login; } else { throw new IllegalArgumentException("Foutief wachtwoord"); } } } /** * checkt indien de opgegeven loginNaam al bestaat. * @param loginNaam de te checken naam van het inlogaccount * @return false indien de loginnaam niet bestaat */ public boolean bestaatLoginNaam(String loginNaam) { synchronized(this.logins) { LoginAccount login = this.logins.get(loginNaam); if (login == null) { return false; } else { throw new IllegalArgumentException("Loginnaam is al in gebruik"); } } } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/LoginManager.java
Java
oos
3,111
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Managers; import API.TransactieStatus; import API.TransactieType; import Bank.Model.Rekening; import Bank.Model.Transactie; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Map; /** * houdt een lijst bij van alle transacties */ public class TransactieManager { private static volatile TransactieManager instance = null; private HashMap<Integer, Transactie> transacties; private static class Loader { static TransactieManager instance = new TransactieManager(); } private TransactieManager() { this.transacties = new HashMap<>(); } public static TransactieManager getInstance() { if (instance == null) { synchronized (TransactieManager.class) { instance = new TransactieManager(); } } return instance; } public void addTransactie(Transactie trans) { if (trans != null) { synchronized (transacties) { if (transacties.get(trans.getTransactieId()) == null) { if (trans.getStatus() == TransactieStatus.OPENSTAAND) { Rekening creditRekeningNr = RekeningManager.getInstance().getRekening(trans.getEigenbankrekening()); if (creditRekeningNr == null) { trans.setStatus(TransactieStatus.GEWEIGERD); } } //hier moet een check komen wanneer tegenrekening geen onderdeel is van deze bank. transacties.put(trans.getTransactieId(), trans); executeTransactions(); } }; } } //uitvoeren van transacties kan beter in aparte threads worden gedaan. Voor nu zo gelaten. //Rekening moet ook nog verschillende banken gaan ondersteunen. private void executeTransactions() { synchronized (transacties) { for (Map.Entry pair : this.transacties.entrySet()) { Transactie trans = (Transactie) pair.getValue(); executeTransaction(trans); } }; } private void executeTransaction(Transactie trans) { if (trans != null) { if (trans.getStatus() == TransactieStatus.OPENSTAAND) { Rekening creditRekeningNr = RekeningManager.getInstance().getRekening(trans.getEigenbankrekening()); Rekening debitRekeningNr = RekeningManager.getInstance().getRekening(trans.getTegenrekening()); if (debitRekeningNr != null) { if (creditRekeningNr.neemOp(trans.getBedrag())) { debitRekeningNr.stort(trans.getBedrag()); trans.setStatus(TransactieStatus.VOLTOOID); } else { trans.setStatus(TransactieStatus.GEWEIGERD); } } else { trans.setStatus(TransactieStatus.GEWEIGERD); } } } } //niet getest public ArrayList<Transactie> getTransacties(int creditRknNr, int debetRknNr, GregorianCalendar vanafDatum, GregorianCalendar totDatum, TransactieStatus status, TransactieType type) { ArrayList<Transactie> gezochteTransactie = new ArrayList<>(); GregorianCalendar searchVanafDatum; GregorianCalendar searchTotDatum; if (vanafDatum == null | vanafDatum instanceof GregorianCalendar == false) { searchVanafDatum = new GregorianCalendar(); //geen datum opgegeven is standaard 30 dagen terug. searchVanafDatum.add(Calendar.DAY_OF_MONTH, -30); } else { searchVanafDatum = vanafDatum; } if (totDatum == null | totDatum instanceof GregorianCalendar == false) { searchTotDatum = new GregorianCalendar(); } else { searchTotDatum = totDatum; } synchronized (transacties) { for (Map.Entry pair : this.transacties.entrySet()) { Transactie t = (Transactie) pair.getValue(); if (status == null | status == t.getStatus()) { //nog aanpassen. Dit is een exclusive search i.p.v. inclusive if (t.getTransactieInvoerDatum().before(searchTotDatum) && t.getTransactieInvoerDatum().after(searchVanafDatum)) { //wanneer debetRknr is opgegeven maakt type niet uit. if (debetRknNr != 0 & creditRknNr == t.getEigenbankrekening()) { gezochteTransactie.add(t); } else { switch (type) { case ALLE: //aanvragen die niet voltooid zijn mogen niet zichtbaar zijn voor de ontvanger. if (t.getStatus() == TransactieStatus.VOLTOOID) { if (creditRknNr == t.getEigenbankrekening() | creditRknNr == t.getTegenrekening()) { gezochteTransactie.add(t); } } else { if (creditRknNr == t.getEigenbankrekening()) { gezochteTransactie.add(t); } } break; case DEBET: if (creditRknNr == t.getTegenrekening() & debetRknNr == t.getEigenbankrekening()) { gezochteTransactie.add(t); } break; case CREDIT: if (creditRknNr == t.getEigenbankrekening() & debetRknNr == t.getTegenrekening()) { gezochteTransactie.add(t); } break; } } } } } } return gezochteTransactie; } }
1234banksysteem
trunk/src_oplevering1/Bank/Managers/TransactieManager.java
Java
oos
6,586
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Bank.Server; import API.IAuth; import API.ITransactieHandler; import Bank.Model.TransactieHandler; import Bank.Model.Auth; import java.rmi.AlreadyBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import java.util.logging.Level; import java.util.logging.Logger; /** * Dit is de klasse waar de server geinstantieerd wordt. */ public class ServerStarter { // private ClientImpl client; private static Auth login; private static TransactieHandler transactie; private static Registry registry; /** * Constructor voor de Server van een bank. Hierin wordt geprobeerd een RMI * connectie open te zetten zodat clients deze kunnen benaderen. Er worden 2 * stubs gemaakt. Een voor login waarmee simpele data opgehaald wordt bij de * server. Een voor transactie waarmee transacties opgehaald kunnen worden * bij de server. */ public ServerStarter() { try { registry = LocateRegistry.createRegistry(1099); } catch (RemoteException ex) { Logger.getLogger(ServerStarter.class.getName()).log(Level.SEVERE, null, ex); } login = new Auth(); transactie = new TransactieHandler(); loadData(); try { ITransactieHandler transactieStub = (ITransactieHandler) UnicastRemoteObject.exportObject(transactie, 0); IAuth loginStub = (IAuth) UnicastRemoteObject.exportObject(login, 0); LocateRegistry.getRegistry().bind("transactie", transactieStub); LocateRegistry.getRegistry().bind("auth", loginStub); System.out.println("Server ready"); } catch (RemoteException | AlreadyBoundException ex) { Logger.getLogger(ServerStarter.class.getName()).log(Level.SEVERE, null, ex); } } private void loadData() { DummyBank db = new DummyBank(); } /** * De start-methode voor de Server. Hier zou nog een GUI voor gemaakt kunnen * worden mits er voldoende tijd is. * * @param args */ public static void main(String[] args) { ServerStarter starter = new ServerStarter(); while (true) { //do nothing, keeps thread alive. } } }
1234banksysteem
trunk/src_oplevering1/Bank/Server/ServerStarter.java
Java
oos
2,503
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Bank.Server; import Bank.Managers.KlantManager; import Bank.Managers.LoginManager; import Bank.Managers.RekeningManager; import Bank.Model.Klant; import Bank.Model.LoginAccount; import Bank.Model.Rekening; import java.math.BigDecimal; /** * * @author Melis */ public class DummyBank { //private int klantnummer = 1; public DummyBank() { voegKlantToe("Ieme Welling", "Eindhoven", "ieme", "ieme"); voegKlantToe("test", "Ergens", "test", "test"); voegKlantToe("Melissa Coulthard", "Eindhoven", "Mel", "a"); voegKlantToe("Roland Ansems", "Somewhere", "Rollie", "Lolly"); voegKlantToe("Harry Harig", "Baurle-Naussau", "Harry", "Harry"); voegKlantToe("Barry van Bavel", "Loon op Zand", "Bar", "Weinig"); voegKlantToe("Superman", "Superwereld", "Superman", "Hero"); voegKlantToe("Theo Maassen", "Eindhoven", "Theootje", "123"); } private void voegKlantToe(String naam, String woonplaats, String klantlogin, String wachtwoord) { // Klant klant = new Klant(naam, woonplaats, this.klantnummer); Klant klant = new Klant(naam, woonplaats); Rekening rekeningKlant = new Rekening(); rekeningKlant.stort(new BigDecimal(50)); //LoginAccount loginKlant = new LoginAccount(klantlogin, wachtwoord, this.klantnummer, rekeningKlant.getRekeningnummer()); LoginAccount loginKlant = new LoginAccount(klantlogin, wachtwoord, klant.getKlantNr(), rekeningKlant.getRekeningnummer()); KlantManager km = KlantManager.getInstance(); LoginManager lm = LoginManager.getInstance(); RekeningManager rm = RekeningManager.getInstance(); km.addKlant(klant); lm.addLogin(loginKlant); rm.addRekening(rekeningKlant); //this.klantnummer++; } }
1234banksysteem
trunk/src_oplevering1/Bank/Server/DummyBank.java
Java
oos
2,073
#!/bin/sh export CLASSPATH=cliq.jar:../*:lib/miglayout-3.7.1.jar:. java -Xmx256m com.salesforce.cliq.DataLoaderCliq $@ exit
00mohit-mohit
src/cliq.sh
Shell
mit
125
@echo off echo Salesforce Data Loader Command Line Interface Quickstart (CLIq) echo =============================================================== echo .oOOOo. o ooOoOOo echo .O o O O echo o o o echo o o O echo o O o .oOoO' echo O O O O o echo `o .o o . O o O echo `OoooO' OOoOooO ooOOoOo `OoOo echo O echo `o echo =============================================================== REM DL >=24 moved java to the Java dir set JAVADIR="" if exist "..\Java" (set JAVADIR=Java) else (set JAVADIR=_jvm) echo Using %JAVADIR% to run CLIq... ..\%JAVADIR%\bin\java.exe -Xmx256m -Djava.dir=%JAVADIR% -cp cliq.jar;..\*;lib\miglayout-3.7.1.jar;. com.salesforce.cliq.DataLoaderCliq %1 pause
00mohit-mohit
src/cliq.bat
Batchfile
mit
906
package com.nexes.wizard; import java.io.*; public class WizardPanelNotFoundException extends RuntimeException { public WizardPanelNotFoundException() { super(); } }
00mohit-mohit
src/com/nexes/wizard/WizardPanelNotFoundException.java
Java
mit
203
package com.nexes.wizard; import java.awt.*; import javax.swing.*; /** * A base descriptor class used to reference a Component panel for the Wizard, as * well as provide general rules as to how the panel should behave. */ public class WizardPanelDescriptor { private static final String DEFAULT_PANEL_IDENTIFIER = "defaultPanelIdentifier"; /** * Identifier returned by getNextPanelDescriptor() to indicate that this is the * last panel and the text of the 'Next' button should change to 'Finish'. */ public static final FinishIdentifier FINISH = new FinishIdentifier(); private Wizard wizard; private Component targetPanel; private Object panelIdentifier; /** * Default constructor. The id and the Component panel must be set separately. */ public WizardPanelDescriptor() { panelIdentifier = DEFAULT_PANEL_IDENTIFIER; targetPanel = new JPanel(); } /** * Constructor which accepts both the Object-based identifier and a reference to * the Component class which makes up the panel. * @param id Object-based identifier * @param panel A class which extends java.awt.Component that will be inserted as a * panel into the wizard dialog. */ public WizardPanelDescriptor(Object id, Component panel) { panelIdentifier = id; targetPanel = panel; } /** * Returns to java.awt.Component that serves as the actual panel. * @return A reference to the java.awt.Component that serves as the panel */ public final Component getPanelComponent() { return targetPanel; } /** * Sets the panel's component as a class that extends java.awt.Component * @param panel java.awt.Component which serves as the wizard panel */ public final void setPanelComponent(Component panel) { targetPanel = panel; } /** * Returns the unique Object-based identifier for this panel descriptor. * @return The Object-based identifier */ public final Object getPanelDescriptorIdentifier() { return panelIdentifier; } /** * Sets the Object-based identifier for this panel. The identifier must be unique * from all the other identifiers in the panel. * @param id Object-based identifier for this panel. */ public final void setPanelDescriptorIdentifier(Object id) { panelIdentifier = id; } final void setWizard(Wizard w) { wizard = w; } /** * Returns a reference to the Wizard component. * @return The Wizard class hosting this descriptor. */ public final Wizard getWizard() { return wizard; } /** * Returns a reference to the current WizardModel for this Wizard component. * @return The current WizardModel for this Wizard component. */ public WizardModel getWizardModel() { return wizard.getModel(); } // Override this method to provide an Object-based identifier // for the next panel. /** * Override this class to provide the Object-based identifier of the panel that the * user should traverse to when the Next button is pressed. Note that this method * is only called when the button is actually pressed, so that the panel can change * the next panel's identifier dynamically at runtime if necessary. Return null if * the button should be disabled. Return FinishIdentfier if the button text * should change to 'Finish' and the dialog should end. * @return Object-based identifier. */ public Object getNextPanelDescriptor() { return null; } // Override this method to provide an Object-based identifier // for the previous panel. /** * Override this class to provide the Object-based identifier of the panel that the * user should traverse to when the Back button is pressed. Note that this method * is only called when the button is actually pressed, so that the panel can change * the previous panel's identifier dynamically at runtime if necessary. Return null if * the button should be disabled. * @return Object-based identifier */ public Object getBackPanelDescriptor() { return null; } // Override this method in the subclass if you wish it to be called // just before the panel is displayed. /** * Override this method to provide functionality that will be performed just before * the panel is to be displayed. */ public void aboutToDisplayPanel() { } // Override this method in the subclass if you wish to do something // while the panel is displaying. /** * Override this method to perform functionality when the panel itself is displayed. */ public void displayingPanel() { } // Override this method in the subclass if you wish it to be called // just before the panel is switched to another or finished. /** * Override this method to perform functionality just before the panel is to be * hidden. */ public void aboutToHidePanel() { } static class FinishIdentifier { public static final String ID = "FINISH"; } }
00mohit-mohit
src/com/nexes/wizard/WizardPanelDescriptor.java
Java
mit
5,387
package com.nexes.wizard; import java.awt.*; import java.awt.event.*; import java.beans.*; import java.util.*; import java.net.*; import javax.swing.*; import javax.swing.border.*; /** * This class implements a basic wizard dialog, where the programmer can * insert one or more Components to act as panels. These panels can be navigated * through arbitrarily using the 'Next' or 'Back' buttons, or the dialog itself * can be closed using the 'Cancel' button. Note that even though the dialog * uses a CardLayout manager, the order of the panels is not linear. Each panel * determines at runtime what its next and previous panel will be. */ public class Wizard extends WindowAdapter implements PropertyChangeListener { /** * Indicates that the 'Finish' button was pressed to close the dialog. */ public static final int FINISH_RETURN_CODE = 0; /** * Indicates that the 'Cancel' button was pressed to close the dialog, or * the user pressed the close box in the corner of the window. */ public static final int CANCEL_RETURN_CODE = 1; /** * Indicates that the dialog closed due to an internal error. */ public static final int ERROR_RETURN_CODE = 2; /** * The String-based action command for the 'Next' button. */ public static final String NEXT_BUTTON_ACTION_COMMAND = "NextButtonActionCommand"; /** * The String-based action command for the 'Back' button. */ public static final String BACK_BUTTON_ACTION_COMMAND = "BackButtonActionCommand"; /** * The String-based action command for the 'Cancel' button. */ public static final String CANCEL_BUTTON_ACTION_COMMAND = "CancelButtonActionCommand"; // The i18n text used for the buttons. Loaded from a property resource file. static String BACK_TEXT; static String NEXT_TEXT; static String FINISH_TEXT; static String CANCEL_TEXT; // The image icons used for the buttons. Filenames are loaded from a property resource file. static Icon BACK_ICON; static Icon NEXT_ICON; static Icon FINISH_ICON; static Icon CANCEL_ICON; private WizardModel wizardModel; private WizardController wizardController; private JDialog wizardDialog; private JPanel cardPanel; private CardLayout cardLayout; private JButton backButton; private JButton nextButton; private JButton cancelButton; private int returnCode; /** * Default constructor. This method creates a new WizardModel object and passes it * into the overloaded constructor. */ public Wizard() { this((Frame)null); } /** * This method accepts a java.awt.Dialog object as the javax.swing.JDialog's * parent. * @param owner The java.awt.Dialog object that is the owner of this dialog. */ public Wizard(Dialog owner) { wizardModel = new WizardModel(); wizardDialog = new JDialog(owner); initComponents(); } /** * This method accepts a java.awt.Frame object as the javax.swing.JDialog's * parent. * @param owner The java.awt.Frame object that is the owner of the javax.swing.JDialog. */ public Wizard(Frame owner) { wizardModel = new WizardModel(); wizardDialog = new JDialog(owner); initComponents(); } /** * Returns an instance of the JDialog that this class created. This is useful in * the event that you want to change any of the JDialog parameters manually. * @return The JDialog instance that this class created. */ public JDialog getDialog() { return wizardDialog; } /** * Returns the owner of the generated javax.swing.JDialog. * @return The owner (java.awt.Frame or java.awt.Dialog) of the javax.swing.JDialog generated * by this class. */ public Component getOwner() { return wizardDialog.getOwner(); } /** * Sets the title of the generated javax.swing.JDialog. * @param s The title of the dialog. */ public void setTitle(String s) { wizardDialog.setTitle(s); } /** * Returns the current title of the generated dialog. * @return The String-based title of the generated dialog. */ public String getTitle() { return wizardDialog.getTitle(); } /** * Sets the modality of the generated javax.swing.JDialog. * @param b the modality of the dialog */ public void setModal(boolean b) { wizardDialog.setModal(b); } /** * Returns the modality of the dialog. * @return A boolean indicating whether or not the generated javax.swing.JDialog is modal. */ public boolean isModal() { return wizardDialog.isModal(); } /** * Convienence method that displays a modal wizard dialog and blocks until the dialog * has completed. * @return Indicates how the dialog was closed. Compare this value against the RETURN_CODE * constants at the beginning of the class. */ public int showModalDialog() { wizardDialog.setModal(true); wizardDialog.pack(); wizardDialog.toFront(); wizardDialog.setVisible(true); return returnCode; } /** * Returns the current model of the wizard dialog. * @return A WizardModel instance, which serves as the model for the wizard dialog. */ public WizardModel getModel() { return wizardModel; } /** * Add a Component as a panel for the wizard dialog by registering its * WizardPanelDescriptor object. Each panel is identified by a unique Object-based * identifier (often a String), which can be used by the setCurrentPanel() * method to display the panel at runtime. * @param id An Object-based identifier used to identify the WizardPanelDescriptor object. * @param panel The WizardPanelDescriptor object which contains helpful information about the panel. */ public void registerWizardPanel(Object id, WizardPanelDescriptor panel) { // Add the incoming panel to our JPanel display that is managed by // the CardLayout layout manager. cardPanel.add(panel.getPanelComponent(), id); // Set a callback to the current wizard. panel.setWizard(this); // Place a reference to it in the model. wizardModel.registerPanel(id, panel); } /** * Displays the panel identified by the object passed in. This is the same Object-based * identified used when registering the panel. * @param id The Object-based identifier of the panel to be displayed. */ public void setCurrentPanel(Object id) { // Get the hashtable reference to the panel that should // be displayed. If the identifier passed in is null, then close // the dialog. if (id == null) close(ERROR_RETURN_CODE); WizardPanelDescriptor oldPanelDescriptor = wizardModel.getCurrentPanelDescriptor(); if (oldPanelDescriptor != null) oldPanelDescriptor.aboutToHidePanel(); wizardModel.setCurrentPanel(id); wizardModel.getCurrentPanelDescriptor().aboutToDisplayPanel(); // Show the panel in the dialog. cardLayout.show(cardPanel, id.toString()); wizardModel.getCurrentPanelDescriptor().displayingPanel(); } /** * Method used to listen for property change events from the model and update the * dialog's graphical components as necessary. * @param evt PropertyChangeEvent passed from the model to signal that one of its properties has changed value. */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(WizardModel.CURRENT_PANEL_DESCRIPTOR_PROPERTY)) { wizardController.resetButtonsToPanelRules(); } else if (evt.getPropertyName().equals(WizardModel.NEXT_FINISH_BUTTON_TEXT_PROPERTY)) { nextButton.setText(evt.getNewValue().toString()); } else if (evt.getPropertyName().equals(WizardModel.BACK_BUTTON_TEXT_PROPERTY)) { backButton.setText(evt.getNewValue().toString()); } else if (evt.getPropertyName().equals(WizardModel.CANCEL_BUTTON_TEXT_PROPERTY)) { cancelButton.setText(evt.getNewValue().toString()); } else if (evt.getPropertyName().equals(WizardModel.NEXT_FINISH_BUTTON_ENABLED_PROPERTY)) { nextButton.setEnabled(((Boolean)evt.getNewValue()).booleanValue()); } else if (evt.getPropertyName().equals(WizardModel.BACK_BUTTON_ENABLED_PROPERTY)) { backButton.setEnabled(((Boolean)evt.getNewValue()).booleanValue()); } else if (evt.getPropertyName().equals(WizardModel.CANCEL_BUTTON_ENABLED_PROPERTY)) { cancelButton.setEnabled(((Boolean)evt.getNewValue()).booleanValue()); } else if (evt.getPropertyName().equals(WizardModel.NEXT_FINISH_BUTTON_ICON_PROPERTY)) { nextButton.setIcon((Icon)evt.getNewValue()); } else if (evt.getPropertyName().equals(WizardModel.BACK_BUTTON_ICON_PROPERTY)) { backButton.setIcon((Icon)evt.getNewValue()); } else if (evt.getPropertyName().equals(WizardModel.CANCEL_BUTTON_ICON_PROPERTY)) { cancelButton.setIcon((Icon)evt.getNewValue()); } } /** * Retrieves the last return code set by the dialog. * @return An integer that identifies how the dialog was closed. See the *_RETURN_CODE * constants of this class for possible values. */ public int getReturnCode() { return returnCode; } /** * Mirrors the WizardModel method of the same name. * @return A boolean indicating if the button is enabled. */ public boolean getBackButtonEnabled() { return wizardModel.getBackButtonEnabled().booleanValue(); } /** * Mirrors the WizardModel method of the same name. * @param boolean newValue The new enabled status of the button. */ public void setBackButtonEnabled(boolean newValue) { wizardModel.setBackButtonEnabled(new Boolean(newValue)); } /** * Mirrors the WizardModel method of the same name. * @return A boolean indicating if the button is enabled. */ public boolean getNextFinishButtonEnabled() { return wizardModel.getNextFinishButtonEnabled().booleanValue(); } /** * Mirrors the WizardModel method of the same name. * @param boolean newValue The new enabled status of the button. */ public void setNextFinishButtonEnabled(boolean newValue) { wizardModel.setNextFinishButtonEnabled(new Boolean(newValue)); } /** * Mirrors the WizardModel method of the same name. * @return A boolean indicating if the button is enabled. */ public boolean getCancelButtonEnabled() { return wizardModel.getCancelButtonEnabled().booleanValue(); } /** * Mirrors the WizardModel method of the same name. * @param boolean newValue The new enabled status of the button. */ public void setCancelButtonEnabled(boolean newValue) { wizardModel.setCancelButtonEnabled(new Boolean(newValue)); } /** * Closes the dialog and sets the return code to the integer parameter. * @param code The return code. */ void close(int code) { returnCode = code; wizardDialog.dispose(); } /** * This method initializes the components for the wizard dialog: it creates a JDialog * as a CardLayout panel surrounded by a small amount of space on each side, as well * as three buttons at the bottom. */ private void initComponents() { wizardModel.addPropertyChangeListener(this); wizardController = new WizardController(this); wizardDialog.getContentPane().setLayout(new BorderLayout()); wizardDialog.addWindowListener(this); // Create the outer wizard panel, which is responsible for three buttons: // Next, Back, and Cancel. It is also responsible a JPanel above them that // uses a CardLayout layout manager to display multiple panels in the // same spot. JPanel buttonPanel = new JPanel(); JSeparator separator = new JSeparator(); Box buttonBox = new Box(BoxLayout.X_AXIS); cardPanel = new JPanel(); cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); cardLayout = new CardLayout(); cardPanel.setLayout(cardLayout); backButton = new JButton(new ImageIcon("com/nexes/wizard/backIcon.gif")); nextButton = new JButton(); cancelButton = new JButton(); backButton.setActionCommand(BACK_BUTTON_ACTION_COMMAND); nextButton.setActionCommand(NEXT_BUTTON_ACTION_COMMAND); cancelButton.setActionCommand(CANCEL_BUTTON_ACTION_COMMAND); backButton.addActionListener(wizardController); nextButton.addActionListener(wizardController); cancelButton.addActionListener(wizardController); // Create the buttons with a separator above them, then place them // on the east side of the panel with a small amount of space between // the back and the next button, and a larger amount of space between // the next button and the cancel button. buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(separator, BorderLayout.NORTH); buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); buttonBox.add(backButton); buttonBox.add(Box.createHorizontalStrut(10)); buttonBox.add(nextButton); buttonBox.add(Box.createHorizontalStrut(30)); buttonBox.add(cancelButton); buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); wizardDialog.getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); wizardDialog.getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER); } private static Object getImage(String name) { URL url = null; try { Class c = Class.forName("com.nexes.wizard.Wizard"); url = c.getResource(name); } catch (ClassNotFoundException cnfe) { System.err.println("Unable to find Wizard class"); } return url; } /** * If the user presses the close box on the dialog's window, treat it * as a cancel. * @param WindowEvent The event passed in from AWT. */ public void windowClosing(WindowEvent e) { returnCode = CANCEL_RETURN_CODE; } static { try { PropertyResourceBundle resources = (PropertyResourceBundle) ResourceBundle.getBundle("com.nexes.wizard.wizard"); BACK_TEXT = (String)(resources.getObject("backButtonText")); NEXT_TEXT = (String)(resources.getObject("nextButtonText")); CANCEL_TEXT = (String)(resources.getObject("cancelButtonText")); FINISH_TEXT = (String)(resources.getObject("finishButtonText")); BACK_ICON = new ImageIcon((URL)getImage((String)(resources.getObject("backButtonIcon")))); NEXT_ICON = new ImageIcon((URL)getImage((String)(resources.getObject("nextButtonIcon")))); CANCEL_ICON = new ImageIcon((URL)getImage((String)(resources.getObject("cancelButtonIcon")))); FINISH_ICON = new ImageIcon((URL)getImage((String)(resources.getObject("finishButtonIcon")))); } catch (MissingResourceException mre) { System.out.println(mre); System.exit(1); } } }
00mohit-mohit
src/com/nexes/wizard/Wizard.java
Java
mit
16,320
package com.nexes.wizard; import java.beans.*; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.border.*; /** * The model for the Wizard component, which tracks the text, icons, and enabled state * of each of the buttons, as well as the current panel that is displayed. Note that * the model, in its current form, is not intended to be subclassed. */ public class WizardModel { /** * Identification string for the current panel. */ public static final String CURRENT_PANEL_DESCRIPTOR_PROPERTY = "currentPanelDescriptorProperty"; /** * Property identification String for the Back button's text */ public static final String BACK_BUTTON_TEXT_PROPERTY = "backButtonTextProperty"; /** * Property identification String for the Back button's icon */ public static final String BACK_BUTTON_ICON_PROPERTY = "backButtonIconProperty"; /** * Property identification String for the Back button's enabled state */ public static final String BACK_BUTTON_ENABLED_PROPERTY = "backButtonEnabledProperty"; /** * Property identification String for the Next button's text */ public static final String NEXT_FINISH_BUTTON_TEXT_PROPERTY = "nextButtonTextProperty"; /** * Property identification String for the Next button's icon */ public static final String NEXT_FINISH_BUTTON_ICON_PROPERTY = "nextButtonIconProperty"; /** * Property identification String for the Next button's enabled state */ public static final String NEXT_FINISH_BUTTON_ENABLED_PROPERTY = "nextButtonEnabledProperty"; /** * Property identification String for the Cancel button's text */ public static final String CANCEL_BUTTON_TEXT_PROPERTY = "cancelButtonTextProperty"; /** * Property identification String for the Cancel button's icon */ public static final String CANCEL_BUTTON_ICON_PROPERTY = "cancelButtonIconProperty"; /** * Property identification String for the Cancel button's enabled state */ public static final String CANCEL_BUTTON_ENABLED_PROPERTY = "cancelButtonEnabledProperty"; private WizardPanelDescriptor currentPanel; private HashMap panelHashmap; private HashMap buttonTextHashmap; private HashMap buttonIconHashmap; private HashMap buttonEnabledHashmap; private PropertyChangeSupport propertyChangeSupport; /** * Default constructor. */ public WizardModel() { panelHashmap = new HashMap(); buttonTextHashmap = new HashMap(); buttonIconHashmap = new HashMap(); buttonEnabledHashmap = new HashMap(); propertyChangeSupport = new PropertyChangeSupport(this); } /** * Returns the currently displayed WizardPanelDescriptor. * @return The currently displayed WizardPanelDescriptor */ WizardPanelDescriptor getCurrentPanelDescriptor() { return currentPanel; } /** * Registers the WizardPanelDescriptor in the model using the Object-identifier specified. * @param id Object-based identifier * @param descriptor WizardPanelDescriptor that describes the panel */ void registerPanel(Object id, WizardPanelDescriptor descriptor) { // Place a reference to it in a hashtable so we can access it later // when it is about to be displayed. panelHashmap.put(id, descriptor); } /** * Sets the current panel to that identified by the Object passed in. * @param id Object-based panel identifier * @return boolean indicating success or failure */ boolean setCurrentPanel(Object id) { // First, get the hashtable reference to the panel that should // be displayed. WizardPanelDescriptor nextPanel = (WizardPanelDescriptor)panelHashmap.get(id); // If we couldn't find the panel that should be displayed, return // false. if (nextPanel == null) throw new WizardPanelNotFoundException(); WizardPanelDescriptor oldPanel = currentPanel; currentPanel = nextPanel; if (oldPanel != currentPanel) firePropertyChange(CURRENT_PANEL_DESCRIPTOR_PROPERTY, oldPanel, currentPanel); return true; } Object getBackButtonText() { return buttonTextHashmap.get(BACK_BUTTON_TEXT_PROPERTY); } void setBackButtonText(Object newText) { Object oldText = getBackButtonText(); if (!newText.equals(oldText)) { buttonTextHashmap.put(BACK_BUTTON_TEXT_PROPERTY, newText); firePropertyChange(BACK_BUTTON_TEXT_PROPERTY, oldText, newText); } } Object getNextFinishButtonText() { return buttonTextHashmap.get(NEXT_FINISH_BUTTON_TEXT_PROPERTY); } void setNextFinishButtonText(Object newText) { Object oldText = getNextFinishButtonText(); if (!newText.equals(oldText)) { buttonTextHashmap.put(NEXT_FINISH_BUTTON_TEXT_PROPERTY, newText); firePropertyChange(NEXT_FINISH_BUTTON_TEXT_PROPERTY, oldText, newText); } } Object getCancelButtonText() { return buttonTextHashmap.get(CANCEL_BUTTON_TEXT_PROPERTY); } void setCancelButtonText(Object newText) { Object oldText = getCancelButtonText(); if (!newText.equals(oldText)) { buttonTextHashmap.put(CANCEL_BUTTON_TEXT_PROPERTY, newText); firePropertyChange(CANCEL_BUTTON_TEXT_PROPERTY, oldText, newText); } } Icon getBackButtonIcon() { return (Icon)buttonIconHashmap.get(BACK_BUTTON_ICON_PROPERTY); } void setBackButtonIcon(Icon newIcon) { Object oldIcon = getBackButtonIcon(); if (!newIcon.equals(oldIcon)) { buttonIconHashmap.put(BACK_BUTTON_ICON_PROPERTY, newIcon); firePropertyChange(BACK_BUTTON_ICON_PROPERTY, oldIcon, newIcon); } } Icon getNextFinishButtonIcon() { return (Icon)buttonIconHashmap.get(NEXT_FINISH_BUTTON_ICON_PROPERTY); } public void setNextFinishButtonIcon(Icon newIcon) { Object oldIcon = getNextFinishButtonIcon(); if (!newIcon.equals(oldIcon)) { buttonIconHashmap.put(NEXT_FINISH_BUTTON_ICON_PROPERTY, newIcon); firePropertyChange(NEXT_FINISH_BUTTON_ICON_PROPERTY, oldIcon, newIcon); } } Icon getCancelButtonIcon() { return (Icon)buttonIconHashmap.get(CANCEL_BUTTON_ICON_PROPERTY); } void setCancelButtonIcon(Icon newIcon) { Icon oldIcon = getCancelButtonIcon(); if (!newIcon.equals(oldIcon)) { buttonIconHashmap.put(CANCEL_BUTTON_ICON_PROPERTY, newIcon); firePropertyChange(CANCEL_BUTTON_ICON_PROPERTY, oldIcon, newIcon); } } Boolean getBackButtonEnabled() { return (Boolean)buttonEnabledHashmap.get(BACK_BUTTON_ENABLED_PROPERTY); } void setBackButtonEnabled(Boolean newValue) { Boolean oldValue = getBackButtonEnabled(); if (newValue != oldValue) { buttonEnabledHashmap.put(BACK_BUTTON_ENABLED_PROPERTY, newValue); firePropertyChange(BACK_BUTTON_ENABLED_PROPERTY, oldValue, newValue); } } Boolean getNextFinishButtonEnabled() { return (Boolean)buttonEnabledHashmap.get(NEXT_FINISH_BUTTON_ENABLED_PROPERTY); } void setNextFinishButtonEnabled(Boolean newValue) { Boolean oldValue = getNextFinishButtonEnabled(); if (newValue != oldValue) { buttonEnabledHashmap.put(NEXT_FINISH_BUTTON_ENABLED_PROPERTY, newValue); firePropertyChange(NEXT_FINISH_BUTTON_ENABLED_PROPERTY, oldValue, newValue); } } Boolean getCancelButtonEnabled() { return (Boolean)buttonEnabledHashmap.get(CANCEL_BUTTON_ENABLED_PROPERTY); } void setCancelButtonEnabled(Boolean newValue) { Boolean oldValue = getCancelButtonEnabled(); if (newValue != oldValue) { buttonEnabledHashmap.put(CANCEL_BUTTON_ENABLED_PROPERTY, newValue); firePropertyChange(CANCEL_BUTTON_ENABLED_PROPERTY, oldValue, newValue); } } public void addPropertyChangeListener(PropertyChangeListener p) { propertyChangeSupport.addPropertyChangeListener(p); } public void removePropertyChangeListener(PropertyChangeListener p) { propertyChangeSupport.removePropertyChangeListener(p); } protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } }
00mohit-mohit
src/com/nexes/wizard/WizardModel.java
Java
mit
9,132
package com.salesforce.cliq; import com.nexes.wizard.Wizard; import com.nexes.wizard.WizardPanelDescriptor; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfig; import com.salesforce.cliq.cliconfig.CliConfigDml; import com.salesforce.cliq.cliconfig.CliConfigExport; import com.salesforce.cliq.cliconfig.CliConfigFactory; import com.salesforce.cliq.ui.EntityPanelDescriptor; import com.salesforce.cliq.ui.LoginPanelDescriptor; import com.salesforce.cliq.ui.OperationPanelDescriptor; import com.salesforce.cliq.ui.QueryPanelDescriptor; import com.salesforce.cliq.ui.ResultPanelDescriptor; import com.salesforce.dataloader.config.*; import java.io.*; import java.net.*; import java.util.MissingResourceException; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import java.util.Properties; /** * DataLoaderCliq is the main class for Data Loader CLIq. * It provides both a Text and Graphical UI for the CliConfig * Classes. On execution of main, it will check for newer * versions in the public SVN repository. * * @author Vijay Swamidass * */ public class DataLoaderCliq { public static final String VERSION_URL = "http://dataloadercliq.googlecode.com/svn/trunk/src/version.properties"; public static final String DOWNLOAD_URL = "http://code.google.com/p/dataloadercliq/"; public static boolean debugMode = false; /* Used to read user input */ static BufferedReader rdr = new BufferedReader( new java.io.InputStreamReader(System.in)); /** * A shared instance of CliConfig used by the various * Wizard panels */ static CliConfig theConfig; /** * Used by the Wizard to set the shared instance of CliConfig * * @param c An instance of CliConfig */ public static void setCliConfig(CliConfig c) { theConfig = c; } /** * Used by the Wizard to get the shared instance of CliConfig * * @param c An instance of CliConfig */ public static CliConfig getCliConfig() { return theConfig; } public static boolean isDebugMode() { return debugMode; } public static void log(String m) { log(m,null); } public static void log(String m,Exception e) { if (DataLoaderCliq.isDebugMode()) { if (e != null) { e.printStackTrace(); } System.out.println("log: " + m); } } /** * Shows a text prompt, reads the user input, and returns the input. * * @param prompt String to show the user * @return The user input */ static String getUserInput(String prompt) { System.out.print(prompt); try { return rdr.readLine(); } catch (IOException e) { e.printStackTrace(); return null; } } /** * Shows a simple text menu */ private static void displayMenu() { // set up a simple menu system Integer operationNumber = 1; for (CliConfig.DataLoaderOperation operation : CliConfig.DataLoaderOperation.values()) { System.out.println(operationNumber++ + ". " + operation.toString()); } } /** * Runs the GUI using the Sun Wizard Class */ private static void runGui() { Wizard wizard = new Wizard(); wizard.getDialog().setTitle("Data Loader CLIq"); WizardPanelDescriptor operationDescriptor = new OperationPanelDescriptor(); wizard.registerWizardPanel(OperationPanelDescriptor.IDENTIFIER, operationDescriptor); WizardPanelDescriptor loginDescriptor = new LoginPanelDescriptor(); wizard.registerWizardPanel(LoginPanelDescriptor.IDENTIFIER, loginDescriptor); WizardPanelDescriptor queryDescriptor = new QueryPanelDescriptor(); wizard.registerWizardPanel(QueryPanelDescriptor.IDENTIFIER, queryDescriptor); WizardPanelDescriptor entityDescriptor = new EntityPanelDescriptor(); wizard.registerWizardPanel(EntityPanelDescriptor.IDENTIFIER, entityDescriptor); WizardPanelDescriptor resultDescriptor = new ResultPanelDescriptor(); wizard.registerWizardPanel(ResultPanelDescriptor.IDENTIFIER, resultDescriptor); wizard.setCurrentPanel(OperationPanelDescriptor.IDENTIFIER); int ret = wizard.showModalDialog(); } private static void showError(String message) { System.out.println("========================================================="); System.out.println("## " + message); System.out.println("========================================================="); } private static void showStepSeparator(Integer stepNumber, String title) { System.out.println(); System.out.println("#########################################################"); System.out.println("Step " + stepNumber); System.out.println(title); System.out.println("#########################################################"); } /** * Run the Text-based UI */ private static void runTextUi() { String username; String processName; String password; String dlHome; showStepSeparator(1, "Choose Operation"); displayMenu(); Integer menuOption = Integer.valueOf(getUserInput("Operation number? ")); while (menuOption < 1 && menuOption > CliConfig.DataLoaderOperation.values().length) { //Get the count of options System.out.println("Please enter a valid choice: "); displayMenu(); } System.out.println("Each process needs a unique indentifier. Use word characters only."); processName = getUserInput("Enter the name of your process: "); File dlHomeDir = new File(System.getProperty("user.dir")); dlHome = dlHomeDir.getParent(); CliConfig.DataLoaderOperation operation = CliConfig.DataLoaderOperation.values()[menuOption-1]; System.out.println("Configuring for operation: " + operation.toString()); theConfig = CliConfigFactory.getCliConfig(operation, dlHome, processName); showStepSeparator(2, "Verify Salesforce Login"); System.out.println("Using endpoint: " + theConfig.getConfigValue(Config.ENDPOINT)); try { if (theConfig.getConfigValue(Config.USERNAME).length() > 0) { System.out.println("Logging in to Salesforce..."); theConfig.doSalesforceLogin(); } } catch (Exception e) { showError("Error logging in to Salesforce with cliq.properties: " + e.getMessage()); } while (!theConfig.isLoggedIn()) { username = getUserInput("Enter your username: "); password = getUserInput("Enter your password: "); theConfig.setConfigValue(Config.USERNAME,username); theConfig.setPassword(password); try { System.out.println("Logging in to Salesforce..."); theConfig.doSalesforceLogin(); } catch (Exception e) { showError("Error logging in to Salesforce: " + e.getMessage()); } } if (theConfig instanceof CliConfigExport) { String query; showStepSeparator(3, "Configure Export"); while (!((CliConfigExport)theConfig).isQueryValid()) { query = getUserInput("Enter your SOQL query: "); try { ((CliConfigExport)theConfig).setQueryAndEntity(query); } catch (Exception e) { showError(e.getMessage()); } } } else { String entity; showStepSeparator(3, "Validate Salesforce Entity"); while (!theConfig.isEntityNameValid()) { entity = getUserInput("Enter the Object name: "); try { theConfig.setEntityName(entity); } catch (Exception e) { showError("Invalid Object - Please try again."); } } } showStepSeparator(4, "Create Scripts"); System.out.println("Creating files..."); try { theConfig.createCliConfig(); System.out.println("CLIq completed successfully!"); System.out.println("Your files are in: " + theConfig.SCRIPT_DIR); } catch (Exception e) { showError("Error creating configuration files: " + e.getMessage()); } } /** * Checks if newer version is available and pauses for user response if so. * If an argument is provided (any argument), run the Text UI, otherwise * run the GUI. * * @param args Any single arg will launch the Text UI */ public static void main(String[] args) { DataLoaderCliq dlc = new DataLoaderCliq(); System.out.println("You can download the latest version of CLIq at:"); System.out.println(DOWNLOAD_URL); boolean textMode = false; for (String param : args) { if (param.contains("-d")) { System.out.println("Enabling debug mode."); debugMode = true; } else if (param.contains("-t")) { textMode = true; } } if (textMode) { runTextUi(); } else { System.out.println("Loading GUI..."); runGui(); } } }
00mohit-mohit
src/com/salesforce/cliq/DataLoaderCliq.java
Java
mit
9,575
package com.salesforce.cliq.ui; import net.miginfocom.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.net.*; import javax.swing.*; import javax.swing.border.*; public class LoginPanel extends CliqWizardPanel { private javax.swing.JPanel jPanel1; private javax.swing.JPanel userPanel; private JTextArea resultMessage; private javax.swing.JLabel welcomeTitle; private javax.swing.JLabel usernameLabel; private javax.swing.JTextField usernameField; private javax.swing.JLabel passwordLabel; private javax.swing.JPasswordField passwordField; private JButton loginButton = new JButton(); private javax.swing.JLabel messageLabel = new javax.swing.JLabel(); public LoginPanel() { super("Salesforce Login"); addContentPanel(getContentPanel()); } public String getUsername() { return usernameField.getText(); } public String getPassword() { return String.valueOf(passwordField.getPassword()); } public void addLoginActionListener(ActionListener l) { loginButton.addActionListener(l); } public void setMessage(String e) { resultMessage.setText(e); } public void setUsername(String username) { usernameField.setText(username); } public void setPassword(String password) { passwordField.setText(password); } protected JPanel getContentPanel() { userPanel = new JPanel(); welcomeTitle = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); passwordLabel = new javax.swing.JLabel(); passwordField = new JPasswordField(20); usernameLabel = new javax.swing.JLabel(); usernameField = new JTextField(20); messageLabel = new javax.swing.JLabel(); JPanel contentPanel1 = new JPanel(); contentPanel1.setLayout(new java.awt.BorderLayout()); welcomeTitle = new javax.swing.JLabel(); contentPanel1.add(welcomeTitle, java.awt.BorderLayout.NORTH); jPanel1.setLayout(new MigLayout("wrap 1")); /* User Panel */ userPanel.setLayout(new MigLayout("wrap 2,w 400")); userPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Login to Salesforce", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); usernameLabel.setText("Username:"); userPanel.add(usernameLabel); userPanel.add(usernameField); passwordLabel.setText("Password:"); userPanel.add(passwordLabel); userPanel.add(passwordField); loginButton = new JButton(); loginButton.setText("Verify Username and Password"); userPanel.add(loginButton,"wrap,span 2"); jPanel1.add(userPanel); /* Result Panel */ resultMessage = createResultMessage(); jPanel1.add(createResultPanel(resultMessage)); /* End */ contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; } }
00mohit-mohit
src/com/salesforce/cliq/ui/LoginPanel.java
Java
mit
3,442
package com.salesforce.cliq.ui; import net.miginfocom.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.net.*; import javax.swing.*; import javax.swing.border.*; public class ResultPanel extends CliqWizardPanel { public static final String SHOW_FILES_ACTION_COMMAND = "ShowFilesActionCommand"; public static final String CREATE_FILES_ACTION_COMMAND = "CreateFilesActionCommand"; private javax.swing.JPanel jPanel1; private javax.swing.JPanel summaryPanel; private javax.swing.JPanel resultPanel; private javax.swing.JTextArea summaryField; private JButton createFilesButton; private JButton showFilesButton; private javax.swing.JTextArea statusField; public ResultPanel() { super("Generate Files"); addContentPanel(getContentPanel()); } public void addCreateFilesActionListener(ActionListener l) { createFilesButton.addActionListener(l); } public void addShowFilesActionListener(ActionListener l) { showFilesButton.addActionListener(l); } public void setEnabledShowFiles(boolean b) { showFilesButton.setEnabled(b); } public void clearStatus() { statusField.setText(""); } public void addStatus(String s) { statusField.append(s); } public void clearSummary() { statusField.setText(""); } public void addSummaryItem(String s) { summaryField.append(s); } private JPanel getContentPanel() { JPanel contentPanel1 = new JPanel(); summaryPanel = new JPanel(); resultPanel = new JPanel(); jPanel1 = new javax.swing.JPanel(); createFilesButton = new JButton(); showFilesButton = new JButton(); contentPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setLayout(new MigLayout("wrap 1")); /* Summary */ summaryPanel.setLayout(new MigLayout("wrap 1,w 400")); summaryPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Summary", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); summaryField = new JTextArea("",10,30); summaryField.setLineWrap(true); summaryField.setWrapStyleWord(true); summaryField.setEditable(false); JScrollPane summaryScrollPane = new JScrollPane(summaryField); summaryScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); summaryPanel.add(summaryScrollPane); createFilesButton.setText("Create Data Loader CLI Files"); createFilesButton.setActionCommand(CREATE_FILES_ACTION_COMMAND); summaryPanel.add(createFilesButton,""); jPanel1.add(summaryPanel); /* Results */ resultPanel.setLayout(new MigLayout("wrap 1,w 400")); resultPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Results", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); statusField = new JTextArea("",6,30); statusField.setLineWrap(true); statusField.setWrapStyleWord(true); statusField.setEditable(false); JScrollPane messageScrollPane = new JScrollPane(statusField); messageScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); resultPanel.add(messageScrollPane); /* Not supported by Java 1.5 showFilesButton.setText("Show Files"); showFilesButton.setActionCommand(SHOW_FILES_ACTION_COMMAND); showFilesButton.setEnabled(false); resultPanel.add(showFilesButton,""); */ jPanel1.add(resultPanel); /* End */ contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; } }
00mohit-mohit
src/com/salesforce/cliq/ui/ResultPanel.java
Java
mit
4,441
package com.salesforce.cliq.ui; import java.awt.*; import java.awt.event.*; import java.net.*; import javax.swing.*; import javax.swing.border.*; import com.salesforce.cliq.cliconfig.CliConfig; import net.miginfocom.swing.MigLayout; public abstract class CliqWizardPanel extends JPanel implements ComponentListener { private static final String LOGO_URL = "http://code.google.com/p/dataloadercliq/logo?logo_id=1258144218"; private static final String DEFAULT_TITLE = "Data Loader CLIq"; private static final String WELCOME_MESSAGE = "Welcome to CLIq"; private static String currentEndpoint; private JLabel iconLabel; private JSeparator separator; private JLabel textLabel; private JLabel versionLabel; private JPanel titlePanel; private JPanel contentContainer; private JPanel contentPanel; public void componentHidden(ComponentEvent e) {} public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) {} public void componentShown(ComponentEvent e) { doDisplayEndpoint(); } private void doDisplayEndpoint() { if (currentEndpoint == null) { versionLabel.setText(WELCOME_MESSAGE); } else { versionLabel.setText(currentEndpoint); } } public CliqWizardPanel() { this(DEFAULT_TITLE); } public void setEndpoint(String e) { currentEndpoint = e; } public CliqWizardPanel(String title) { super(); addComponentListener(this); titlePanel = new javax.swing.JPanel(); textLabel = new javax.swing.JLabel(); versionLabel = new javax.swing.JLabel(); iconLabel = new javax.swing.JLabel(); separator = new javax.swing.JSeparator(); setLayout(new java.awt.BorderLayout()); titlePanel.setLayout(new java.awt.BorderLayout()); titlePanel.setBackground(Color.white); try { URL logoUrl = new URL(LOGO_URL); Icon icon = new ImageIcon(logoUrl); textLabel.setIcon(icon); } catch (Exception e) { //do something later } textLabel.setBackground(Color.white); textLabel.setIconTextGap(100); textLabel.setFont(new Font("MS Sans Serif", Font.BOLD, 18)); textLabel.setText(title); textLabel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); textLabel.setOpaque(true); versionLabel.setBackground(Color.gray); versionLabel.setIconTextGap(100); versionLabel.setFont(new Font("MS Sans Serif", Font.PLAIN, 10)); doDisplayEndpoint(); versionLabel.setForeground(Color.white); versionLabel.setBorder(new EmptyBorder(new Insets(3, 3, 3, 3))); versionLabel.setOpaque(true); titlePanel.add(textLabel,BorderLayout.CENTER); titlePanel.add(versionLabel,BorderLayout.SOUTH); titlePanel.add(iconLabel, BorderLayout.EAST); //versionLabel.add(separator, BorderLayout.SOUTH); contentContainer = new JPanel(); contentContainer.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); add(contentContainer, BorderLayout.WEST); add(titlePanel, BorderLayout.NORTH); } public void addContentPanel(JPanel newContentPanel) { removeContentPanel(); contentPanel = newContentPanel; contentContainer.add(contentPanel, BorderLayout.NORTH); } public void removeContentPanel() { if (contentPanel != null) contentContainer.remove(contentPanel); } public JPanel createResultPanel(JTextArea message) { JPanel resultPanel = new JPanel(); resultPanel.setLayout(new MigLayout("wrap 2,w 400")); resultPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Result", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); JScrollPane messageScrollPane = new JScrollPane(message); messageScrollPane.setPreferredSize(new Dimension(500, 120)); messageScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); resultPanel.add(messageScrollPane); return resultPanel; } public JTextArea createResultMessage() { JTextArea resultMessage = new JTextArea(); resultMessage.setFont(new Font("Arial", Font.ITALIC,12)); resultMessage.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); resultMessage.setLineWrap(true); return resultMessage; } }
00mohit-mohit
src/com/salesforce/cliq/ui/CliqWizardPanel.java
Java
mit
4,727
package com.salesforce.cliq.ui; import java.awt.*; import java.awt.event.ActionListener; import java.net.*; import javax.swing.*; import javax.swing.border.*; import net.miginfocom.swing.MigLayout; public class EntityPanel extends CliqWizardPanel { private javax.swing.JTextField entityField = new JTextField(40); private boolean showExternalIdTextInput; private javax.swing.JTextField externalIdField = new JTextField(40); //private javax.swing.JLabel resultMessage = new javax.swing.JLabel(); private JTextArea resultMessage = new JTextArea(); private javax.swing.JLabel entityLabel = new javax.swing.JLabel(); private javax.swing.JLabel externalIdLabel = new javax.swing.JLabel(); private JButton verifyButton = new JButton(); private String operationName; public EntityPanel() { super("Salesforce Entity (Object)"); verifyButton = new JButton(); addContentPanel(getContentPanel()); } public String getEntityName() { return entityField.getText(); } public String getExternalIdField() { return externalIdField.getText(); } public void setOperationName(String name) { operationName = name; addContentPanel(getContentPanel()); } public String getOperationName() { return operationName; } public void addVerifyActionListener(ActionListener l) { verifyButton.addActionListener(l); } public void setStatus (String s) { resultMessage.setText(s); } public void setShowExternalIdTextInput(boolean shouldShowExternalIdTextInput) { showExternalIdTextInput = shouldShowExternalIdTextInput; //Refresh the content to update the display of external id field addContentPanel(getContentPanel()); } protected JPanel getContentPanel() { JPanel contentPanel1 = new JPanel(); JPanel jPanel1 = new javax.swing.JPanel(); JPanel entityPanel = new JPanel(); contentPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setLayout(new MigLayout("wrap 1")); /* User Panel */ entityPanel.setLayout(new MigLayout("wrap 2,w 400")); entityPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Salesforce Entity (Object) to " + getOperationName(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); entityLabel.setText("Entity Name:"); entityPanel.add(entityLabel); entityPanel.add(entityField); if (showExternalIdTextInput) { externalIdLabel.setText("External Id (optional):"); entityPanel.add(externalIdLabel); entityPanel.add(externalIdField); } verifyButton.setText("Verify"); entityPanel.add(verifyButton); jPanel1.add(entityPanel); /* Result Panel */ resultMessage = createResultMessage(); jPanel1.add(createResultPanel(resultMessage)); /* End */ contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; } }
00mohit-mohit
src/com/salesforce/cliq/ui/EntityPanel.java
Java
mit
3,471
package com.salesforce.cliq.ui; import java.awt.*; import java.util.*; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.DocumentListener; import com.salesforce.cliq.cliconfig.*; import net.miginfocom.swing.MigLayout; public class OperationPanel extends CliqWizardPanel { private javax.swing.ButtonGroup operationGroup; private javax.swing.JPanel jPanel1; private javax.swing.JPanel operationPanel; private javax.swing.JPanel processPanel; private javax.swing.JTextField processField; public OperationPanel() { super("Select Operation"); addContentPanel(getContentPanel()); } public CliConfig.DataLoaderOperation getRadioButtonSelected() { if (operationGroup.getSelection() != null) { return Enum.valueOf(CliConfig.DataLoaderOperation.class,operationGroup.getSelection().getActionCommand()); } else { return null; } } public String getProcess() { return processField.getText(); } public boolean isProcessValid() { //Word Chars, > 0 length, etc. return (processField.getText().length() > 0) ? true : false; } public Boolean isRadioButtonSelected() { return getRadioButtonSelected() != null ? true : false; } public void addDocumentListener(DocumentListener l) { processField.getDocument().addDocumentListener(l); } public void addRadioActionListener(ActionListener l) { Enumeration e = operationGroup.getElements(); while (e.hasMoreElements()) { JRadioButton button = (JRadioButton)e.nextElement(); button.addActionListener(l); } } private JPanel getContentPanel() { JPanel contentPanel1 = new JPanel(); operationGroup = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); operationPanel = new javax.swing.JPanel(); processPanel = new javax.swing.JPanel(); processField = new JTextField(20); contentPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setLayout(new MigLayout("wrap 1")); /* Operation Choice */ operationPanel.setLayout(new MigLayout("wrap 1,w 300")); operationPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Select Operation", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); jPanel1.add(operationPanel); //Add all of the operations to the panel for (CliConfig.DataLoaderOperation op : CliConfig.DataLoaderOperation.values()) { JRadioButton radioButton = new javax.swing.JRadioButton(); radioButton.setActionCommand(op.toString()); radioButton.setText(op.getDisplayName()); operationGroup.add(radioButton); operationPanel.add(radioButton); } /* Process Name */ processPanel.setLayout(new MigLayout("wrap 1,w 300")); processPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Enter Process Name (Letters Only)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); processPanel.add(processField); jPanel1.add(processPanel); contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; } }
00mohit-mohit
src/com/salesforce/cliq/ui/OperationPanel.java
Java
mit
3,847
package com.salesforce.cliq.ui; import net.miginfocom.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.net.URL; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; public class QueryPanel extends CliqWizardPanel { private javax.swing.JPanel jPanel1; private javax.swing.JLabel welcomeTitle; private javax.swing.JPanel queryPanel; private javax.swing.JTextArea queryField; private javax.swing.JCheckBox includeDeletedRecords; private JTextArea resultMessage; private javax.swing.JTextArea messageField; private JButton loginButton; public QueryPanel() { super("Validate SOQL Query"); addContentPanel(getContentPanel()); } public String getQuery() { return queryField.getText(); } public boolean isIncludeDeletedRecordsChecked() { return includeDeletedRecords.isSelected(); } public void setMessage(String e) { resultMessage.setText(e); } public void addVerifyActionListener(ActionListener l) { loginButton.addActionListener(l); } public void addDocumentListener(DocumentListener l) { queryField.getDocument().addDocumentListener(l); } private JPanel getContentPanel() { JPanel contentPanel1 = new JPanel(); loginButton = new JButton(); welcomeTitle = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); queryPanel = new javax.swing.JPanel(); queryField = new JTextArea(5,50); //change to text area includeDeletedRecords = new javax.swing.JCheckBox(); contentPanel1.setLayout(new java.awt.BorderLayout()); contentPanel1.add(welcomeTitle, java.awt.BorderLayout.NORTH); jPanel1.setLayout(new MigLayout("wrap 1")); /* Query Panel */ queryPanel.setLayout(new MigLayout("wrap 1,w 400")); queryPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Query", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD,14) )); queryPanel.add(queryField); queryField.setFont(new Font("Courier", Font.PLAIN, 12)); queryField.setLineWrap(true); queryField.setWrapStyleWord(true); JScrollPane queryScrollPane = new JScrollPane(queryField); queryScrollPane.setPreferredSize(new Dimension(500, 120)); queryScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); queryPanel.add(queryScrollPane); loginButton.setText("Verify"); queryPanel.add(loginButton,"span 2,align 50% 50%"); jPanel1.add(queryPanel); /* Result Panel */ resultMessage = createResultMessage(); jPanel1.add(createResultPanel(resultMessage)); /* End */ contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; } }
00mohit-mohit
src/com/salesforce/cliq/ui/QueryPanel.java
Java
mit
3,385
package com.salesforce.cliq.ui; import com.nexes.wizard.*; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfigExport; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.event.*; public class QueryPanelDescriptor extends WizardPanelDescriptor implements ActionListener,DocumentListener { public static final String IDENTIFIER = "QUERY_PANEL"; private CliConfigExport myConfig; QueryPanel queryPanel; public QueryPanelDescriptor() { queryPanel = new QueryPanel(); queryPanel.addVerifyActionListener(this); queryPanel.addDocumentListener(this); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(queryPanel); } public void insertUpdate(DocumentEvent e) { displayEditInfo(e); } public void removeUpdate(DocumentEvent e) { displayEditInfo(e); } public void changedUpdate(DocumentEvent e) { displayEditInfo(e); } private void displayEditInfo(DocumentEvent e) { } public void actionPerformed(ActionEvent e) { try { myConfig.setQueryAndEntity(queryPanel.getQuery()); queryPanel.setMessage("Query is valid."); } catch (Exception ex) { queryPanel.setMessage(ex.getMessage()); } setNextButtonAccordingToQuery(); } public void aboutToDisplayPanel() { myConfig = (CliConfigExport)DataLoaderCliq.getCliConfig(); setNextButtonAccordingToQuery(); } public Object getNextPanelDescriptor() { return ResultPanelDescriptor.IDENTIFIER; } public Object getBackPanelDescriptor() { return LoginPanelDescriptor.IDENTIFIER; } private void setNextButtonAccordingToQuery() { if (myConfig.isQueryValid()) getWizard().setNextFinishButtonEnabled(true); else getWizard().setNextFinishButtonEnabled(false); } }
00mohit-mohit
src/com/salesforce/cliq/ui/QueryPanelDescriptor.java
Java
mit
2,124
package com.salesforce.cliq.ui; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfig; import com.salesforce.cliq.cliconfig.CliConfigExport; import com.salesforce.dataloader.config.Config; import com.nexes.wizard.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class LoginPanelDescriptor extends WizardPanelDescriptor implements ActionListener { public static final String IDENTIFIER = "LOGIN_PANEL"; LoginPanel loginPanel; private CliConfig myConfig; public LoginPanelDescriptor() { loginPanel = new LoginPanel(); loginPanel.addLoginActionListener(this); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(loginPanel); } public void actionPerformed(ActionEvent e) { myConfig.setConfigValue(Config.USERNAME,loginPanel.getUsername()); myConfig.setPassword(loginPanel.getPassword()); try { loginPanel.setMessage("Logging in..."); myConfig.doSalesforceLogin(); loginPanel.setMessage("Login Successful."); } catch (Exception ex) { DataLoaderCliq.log("Exception during login: " + ex.getMessage(), ex); loginPanel.setMessage(ex.getMessage()); } loginPanel.setEndpoint(myConfig.getConfigValue(Config.ENDPOINT)); setNextButtonAccordingToLogin(); } public void aboutToDisplayPanel() { myConfig = DataLoaderCliq.getCliConfig(); loginPanel.setUsername(myConfig.getConfigValue(Config.USERNAME)); loginPanel.setPassword(myConfig.getPlainPassword()); setNextButtonAccordingToLogin(); } public void aboutToHidePanel() { } public Object getNextPanelDescriptor() { if (myConfig instanceof CliConfigExport) { return QueryPanelDescriptor.IDENTIFIER; } else { return EntityPanelDescriptor.IDENTIFIER; } } public Object getBackPanelDescriptor() { return OperationPanelDescriptor.IDENTIFIER; } private void setNextButtonAccordingToLogin() { if (myConfig.isLoggedIn()) getWizard().setNextFinishButtonEnabled(true); else getWizard().setNextFinishButtonEnabled(false); } }
00mohit-mohit
src/com/salesforce/cliq/ui/LoginPanelDescriptor.java
Java
mit
2,407
package com.salesforce.cliq.ui; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfig; import com.salesforce.cliq.cliconfig.CliConfigExport; import com.salesforce.dataloader.config.Config; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import com.nexes.wizard.*; public class ResultPanelDescriptor extends WizardPanelDescriptor implements ActionListener { public static final String IDENTIFIER = "RESULT_PANEL"; private CliConfig myConfig; ResultPanel resultPanel; private boolean isSuccess = false; public ResultPanelDescriptor() { resultPanel = new ResultPanel(); resultPanel.addCreateFilesActionListener(this); //resultPanel.addShowFilesActionListener(this); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(resultPanel); } public void actionPerformed(ActionEvent e) { //Ignoring Show files for now since it is not widely supported if (e.getActionCommand().equals(ResultPanel.SHOW_FILES_ACTION_COMMAND)) { Desktop dt = Desktop.getDesktop(); try { dt.open(CliConfig.SCRIPT_DIR); } catch (Exception ex) { System.out.println("Unable to display directory."); } } else if (e.getActionCommand().equals(ResultPanel.CREATE_FILES_ACTION_COMMAND)) { doCreateCliConfig(); } } private void doCreateCliConfig() { resultPanel.clearStatus(); try { myConfig.createCliConfig(); resultPanel.addStatus("Files created successfully!" + "\n\n"); resultPanel.addStatus("Your files are in: \n" + CliConfig.SCRIPT_DIR); isSuccess = true; //resultPanel.setEnabledShowFiles(true); } catch (Exception e) { resultPanel.addStatus(e.getMessage()); isSuccess = false; //resultPanel.setEnabledShowFiles(false); } setNextButtonAccordingToResult(); } public void aboutToDisplayPanel() { myConfig = DataLoaderCliq.getCliConfig(); resultPanel.clearSummary(); resultPanel.addSummaryItem("Directory: " + CliConfig.SCRIPT_DIR + "\n\n"); resultPanel.addSummaryItem("Entity (Object): " + myConfig.getConfigValue(Config.ENTITY) + "\n\n"); resultPanel.addSummaryItem("Username: " + myConfig.getConfigValue(Config.USERNAME) + "\n\n"); resultPanel.addSummaryItem("Operation: " + myConfig.getConfigValue(Config.OPERATION) + "\n\n"); setNextButtonAccordingToResult(); } public void aboutToHidePanel() { } public Object getNextPanelDescriptor() { return FINISH; } public Object getBackPanelDescriptor() { if (myConfig instanceof CliConfigExport) { return QueryPanelDescriptor.IDENTIFIER; } else { return EntityPanelDescriptor.IDENTIFIER; } } private void setNextButtonAccordingToResult() { if (isSuccess) { getWizard().setNextFinishButtonEnabled(true); } else { getWizard().setNextFinishButtonEnabled(false); } } }
00mohit-mohit
src/com/salesforce/cliq/ui/ResultPanelDescriptor.java
Java
mit
3,315
package com.salesforce.cliq.ui; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfig; import com.salesforce.cliq.cliconfig.CliConfigDml; import com.salesforce.cliq.cliconfig.CliConfigExport; import com.salesforce.cliq.cliconfig.CliConfigFactory; import com.salesforce.dataloader.config.Config; import com.nexes.wizard.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.event.*; public class OperationPanelDescriptor extends WizardPanelDescriptor implements ActionListener,DocumentListener { public static final String IDENTIFIER = "OPERATION_PANEL"; OperationPanel operationPanel; private CliConfig myConfig; public OperationPanelDescriptor() { operationPanel = new OperationPanel(); operationPanel.addRadioActionListener(this); operationPanel.addDocumentListener(this); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(operationPanel); } public void insertUpdate(DocumentEvent e) { setNextButtonAccordingToRadio(); } public void removeUpdate(DocumentEvent e) { setNextButtonAccordingToRadio(); } public void changedUpdate(DocumentEvent e) { setNextButtonAccordingToRadio(); } public void actionPerformed(ActionEvent e) { setNextButtonAccordingToRadio(); } public void aboutToDisplayPanel() { setNextButtonAccordingToRadio(); if (myConfig == null) { myConfig = DataLoaderCliq.getCliConfig(); } } public void aboutToHidePanel() { String dlHome; File dlHomeDir = new File(System.getProperty("user.dir")); dlHome = dlHomeDir.getParent(); myConfig = CliConfigFactory.getCliConfig( operationPanel.getRadioButtonSelected(), dlHome, operationPanel.getProcess()); DataLoaderCliq.setCliConfig(myConfig); operationPanel.setEndpoint(myConfig.getConfigValue(Config.ENDPOINT)); } public Object getNextPanelDescriptor() { return LoginPanelDescriptor.IDENTIFIER; } public Object getBackPanelDescriptor() { return null; } private void setNextButtonAccordingToRadio() { if (operationPanel.isRadioButtonSelected() && operationPanel.isProcessValid()) getWizard().setNextFinishButtonEnabled(true); else getWizard().setNextFinishButtonEnabled(false); } }
00mohit-mohit
src/com/salesforce/cliq/ui/OperationPanelDescriptor.java
Java
mit
2,649
package com.salesforce.cliq.ui; import com.salesforce.cliq.*; import com.salesforce.cliq.cliconfig.CliConfigDml; import com.salesforce.dataloader.config.Config; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import com.nexes.wizard.*; public class EntityPanelDescriptor extends WizardPanelDescriptor implements ActionListener { public static final String IDENTIFIER = "ENTITY_PANEL"; private CliConfigDml myConfig; EntityPanel entityPanel; public EntityPanelDescriptor() { entityPanel = new EntityPanel(); entityPanel.addVerifyActionListener(this); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(entityPanel); } public void actionPerformed(ActionEvent e) { try { myConfig.setEntityName(entityPanel.getEntityName()); String externalId = entityPanel.getExternalIdField(); if (externalId != null && externalId.length() > 0) { myConfig.setExternalIdField(entityPanel.getEntityName(),entityPanel.getExternalIdField()); } entityPanel.setStatus("Configuration is valid"); } catch (Exception ex) { entityPanel.setStatus(ex.getMessage()); } setNextButtonAccordingToQuery(); } public void aboutToDisplayPanel() { myConfig = (CliConfigDml)DataLoaderCliq.getCliConfig(); entityPanel.setShowExternalIdTextInput(myConfig.isExternalIdOperation()); entityPanel.setOperationName(myConfig.getConfigValue(Config.OPERATION)); setNextButtonAccordingToQuery(); } public Object getNextPanelDescriptor() { return ResultPanelDescriptor.IDENTIFIER; } public Object getBackPanelDescriptor() { return LoginPanelDescriptor.IDENTIFIER; } //TODO Recheck the external id field and refresh if the user hit the back button private void setNextButtonAccordingToQuery() { if (myConfig.isEntityNameValid()) { if (myConfig.getDmlOperation() == CliConfigDml.DmlOperation.UPSERT) { if (entityPanel.getExternalIdField().length() > 0) { //a value was entered if (myConfig.isExternalIdValid()) { //is it valid? getWizard().setNextFinishButtonEnabled(true); } else { getWizard().setNextFinishButtonEnabled(false); } } else { getWizard().setNextFinishButtonEnabled(true); //external id not provided } } else { getWizard().setNextFinishButtonEnabled(true); } } else { getWizard().setNextFinishButtonEnabled(false); } } }
00mohit-mohit
src/com/salesforce/cliq/ui/EntityPanelDescriptor.java
Java
mit
2,663
package com.salesforce.cliq.cliconfig; import java.io.*; import java.util.*; import java.security.*; import com.sforce.soap.partner.*; import com.sforce.soap.partner.fault.*; import com.sforce.ws.ConnectorConfig; import com.sforce.ws.ConnectionException; import com.salesforce.cliq.DataLoaderCliq; import com.salesforce.dataloader.client.ClientBase; import com.salesforce.dataloader.config.*; import com.salesforce.dataloader.controller.*; import com.salesforce.dataloader.security.*; /** * Abstract class for all CLI configurations. * * @author vswamidass * */ public abstract class CliConfig { public static File HOME_DIR; // The Data Loader Directory public static File SCRIPT_DIR; // processname directory public static File WRITE_DIR; // processname/write directory public static File READ_DIR; // processname/read directory public static File LOG_DIR; // processname/log directory public static File CONFIG_DIR; // processname/config directory public static File OUTPUT_DIR; // location of CLIq output files/scripts public static String INSTALL_DIR = "/cliq/"; //The cliq home directory public static String WINDOWS_JAVA_DIR = "Java"; //for windows, the location of the JRE in the DL Directory /** * This is the data loader process-conf.xml setting */ public static String endpoint; public static final List<String> allowedCliqProperties = Arrays.asList( Config.USERNAME, Config.PASSWORD, Config.ENDPOINT, Config.PROXY_HOST, Config.PROXY_PORT, Config.PROXY_NTLM_DOMAIN, Config.PROXY_USERNAME, Config.PROXY_PASSWORD ); /* * Defines the type of operation */ public enum DataLoaderOperation { EXTRACT("Export"), EXTRACT_ALL("Export All (Include Deleted)"), INSERT, UPDATE, UPSERT, DELETE, HARD_DELETE("Hard Delete"); private String displayName; private DataLoaderOperation() { String enumName = this.toString().toLowerCase(); displayName = enumName.substring(0,1).toUpperCase() + enumName.substring(1); } private DataLoaderOperation(String name) { displayName = name; } public String getDisplayName() { return displayName; } } /* * This should be implemented by subclass enums */ interface Operation { public DataLoaderOperation toDataLoaderOperation(); } public DataLoaderOperation operation; public static String PROCESS_NAME; // The user specified Process Name public static String PROCESS_DIR = "cliq_process"; // The user specified Process Name /* The system newline character used to create the CLI files */ public static final String NEWLINE = System.getProperty("line.separator"); /** * The unencrypted password, stored temporarily only, * so we can login to Salesforce */ private String password; /** * The unencrypted password, stored temporarily only, * so we can login to Salesforce */ private String proxyPassword; /** * Map of process-conf.xml property to value */ protected Map<String,String> configMap = new TreeMap<String,String>(); /** * Salesfore API */ //protected SoapBindingStub binding = null; protected ConnectorConfig config = new ConnectorConfig(); protected PartnerConnection connection; /** Main **/ /** * Constructor * * @param dir The home directory for Data Loader * @param name The process name used to name the files * and identify the process in process-conf.xml. */ public CliConfig (DataLoaderOperation op, String dir, String name) { this(op,dir,dir + "/" + PROCESS_DIR,name); } /** * Constructor * * @param homeDir The home directory for Data Loader * @param outputDir The output directory for CLIq files * @param name The process name used to name the files * and identify the process in process-conf.xml. */ public CliConfig (DataLoaderOperation op, String homeDir, String outputDir, String name) { operation = op; HOME_DIR = new File(homeDir); /* Set a default Output Directory */ OUTPUT_DIR = new File(outputDir); /* The Directory Names need to be Windows Compatible */ PROCESS_NAME = name.replaceAll("[\\W|\\d]+","_"); SCRIPT_DIR = new File(OUTPUT_DIR.getAbsolutePath() + "/" + PROCESS_NAME); WRITE_DIR = new File(SCRIPT_DIR.getAbsolutePath() + "/write"); READ_DIR = new File(SCRIPT_DIR.getAbsolutePath() + "/read"); LOG_DIR = new File(SCRIPT_DIR.getAbsolutePath() + "/log"); CONFIG_DIR = new File(SCRIPT_DIR.getAbsolutePath() + "/config"); try { connection = Connector.newConnection(config); } catch (Exception e) { //this is expected, but we are trying a hack to get the endpoint and version from Dataloader.jar } String defaultEndpoint = config.getAuthEndpoint(); String fixedUpEndpoint = "https://www.salesforce.com/" + defaultEndpoint.substring(defaultEndpoint.indexOf("services")); setConfigValue(Config.ENDPOINT,fixedUpEndpoint); //On Windows, we pass in the value of the java directory location String javaDirProperty = System.getProperty("java.dir"); if (javaDirProperty != null) { WINDOWS_JAVA_DIR = javaDirProperty; } setConfigDefaults(); } /** * Sets default values for process-conf.xml */ protected void setConfigDefaults() { setConfigValue(Config.ENDPOINT,endpoint); setConfigValue(Config.READ_UTF8,"true"); setConfigValue(Config.WRITE_UTF8,"true"); setConfigValue(Config.ENABLE_EXTRACT_STATUS_OUTPUT,"true"); setConfigValue(Config.ENABLE_LAST_RUN_OUTPUT,"true"); setConfigValue(Config.LAST_RUN_OUTPUT_DIR,LOG_DIR.getAbsolutePath()); setConfigValue(Config.OUTPUT_STATUS_DIR,LOG_DIR.getAbsolutePath()); setConfigValue(Config.BULK_API_CHECK_STATUS_INTERVAL,"5000"); setConfigValue(Config.BULK_API_SERIAL_MODE,"5000"); setConfigValue(Config.DEBUG_MESSAGES,"false"); setConfigValue(Config.ENABLE_RETRIES,"true"); setConfigValue(Config.EXTRACT_REQUEST_SIZE,"500"); setConfigValue(Config.INSERT_NULLS,"false"); setConfigValue(Config.LOAD_BATCH_SIZE,"100"); setConfigValue(Config.MAX_RETRIES,"3"); setConfigValue(Config.MIN_RETRY_SLEEP_SECS,"2"); setConfigValue(Config.NO_COMPRESSION,"false"); setConfigValue(Config.TIMEOUT_SECS,"60"); setConfigValue(Config.BULK_API_ENABLED,"false"); setConfigValue(Config.OPERATION,operation.toString().toLowerCase()); /* Load the settings from the properties file */ try { Properties cliqProperties = new Properties(); cliqProperties.load(new FileInputStream("cliq.properties")); for (String property : allowedCliqProperties) { String propertyValue = cliqProperties.getProperty(property); if (propertyValue != null) { if (property == Config.PASSWORD) { //Password must be encrypted setPassword(propertyValue); } else { setConfigValue(property, propertyValue); } } } } catch (IOException e) { System.out.println("WARNING: unable to read cliq.properties."); } } /** * Sets a key/value pair for process-conf.xml * The list of constants are in com.salesforce.dataloader.config.Config * * @param key The process-conf.xml key * @param value The process-conf.xml value */ public void setConfigValue(String key, String value) { if (key == Config.ENDPOINT) { if (value != null) { configMap.put(key,value); endpoint = value; } } else if (key == Config.PROXY_PASSWORD) { proxyPassword = value; //save the unecrypted value configMap.put(key,encryptPassword(value)); //save encrypted pass to config } else { configMap.put(key,value); } } public String getConfigValue(String key) { return configMap.get(key); } /** * Checks if the user has logged in to Salesforce.com * * @return true if the loginResult is not null * false if the loginResult is null (not logged in) */ public boolean isLoggedIn() { DataLoaderCliq.log("Session Id: " + config.getSessionId()); return (config.getSessionId() != null); } /** * Gets the Unique Process Name for this instance of CLIq * * @return String ProcessName */ public String getProcess() { return PROCESS_NAME; } /** * Sets the entity (Salesforce object) * Queries Salesforce to verify that it is valid and to get * the right case * * @param name The Entity (Object) name * @throws Exception Indicates a failure to verify the entity */ public void setEntityName(String name) throws Exception { DescribeSObjectResult describeSObjectResult; setConfigValue(Config.ENTITY,null); try { describeSObjectResult = connection.describeSObject(name); } catch (ApiFault ex) { throw new Exception(ex.getExceptionMessage()); } if (describeSObjectResult != null) { setConfigValue(Config.ENTITY,describeSObjectResult.getName()); } } public boolean isEntityNameValid() { return getConfigValue(Config.ENTITY) != null; } public boolean isFieldExternalId(String entity,String field) throws Exception { DescribeSObjectResult describeSObjectResult; try { describeSObjectResult = connection.describeSObject(entity); for (Field f : describeSObjectResult.getFields()) { if (f.getName().equals(field) && f.isExternalId()) { return true; } } return false; //we didn't find the external id } catch (Exception ex) { return false; } } protected void setDataLoaderOperation(DataLoaderOperation op) { operation = op; } protected DataLoaderOperation getDataLoaderOperation() { return operation; } /** * encryptPassword calls the EncryptionUtil Class * from the DataLoader.jar library. * * @param p plain-text password * @return CLI compatible encrypted password string */ private String encryptPassword(String p) { EncryptionUtil eu = new EncryptionUtil(); try { return eu.encryptString(p); } catch (GeneralSecurityException e) { return null; } } /** * Set the process-conf.xml password to the encrypted value. * Saves the plain-text string for logging into salesforce. * * @param p The plain-text password. */ public void setPassword(String p) { password = p; //save unencrypted pw for login setConfigValue(Config.PASSWORD,encryptPassword(p)); } public String getPlainPassword() { return password; } public String getPlainProxyPassword() { return proxyPassword; } /** * Main method to create directories and files for CLI configuation */ public void createCliConfig() throws Exception { /* * These methods may be overridden by subclasses to * add new directories or files. */ createDirectories(); createFiles(); } /** * Creates the Process directory and all subdirectories. * * @throws Exception If the Script Directory (Process Name) exists */ public void createDirectories() throws Exception { if (SCRIPT_DIR.isDirectory()) { throw new Exception("Directory already exists. Please delete first."); } OUTPUT_DIR.mkdirs(); SCRIPT_DIR.mkdir(); WRITE_DIR.mkdir(); READ_DIR.mkdir(); LOG_DIR.mkdir(); CONFIG_DIR.mkdir(); } /** * Creates all configuration and script files for running the CLI Data Loader. * * @throws Exception */ public void createFiles() throws Exception { createProcessXml(); createLogXml(); createConfigProperties(); createBatScript(); createShScript(); } public void createProcessXml() throws Exception { File processXml = new File(CONFIG_DIR,"process-conf.xml"); processXml.createNewFile(); FileWriter fw = new FileWriter(processXml); fw.write("<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" + NEWLINE); fw.write("<beans>" + NEWLINE); fw.write("\t<bean id=\"" + PROCESS_NAME + "\" class=\"com.salesforce.dataloader.process.ProcessRunner\" singleton=\"false\">" + NEWLINE); fw.write("\t\t<description>Created by Dataloader Cliq.</description>" + NEWLINE); fw.write("\t\t<property name=\"name\" value=\"" + PROCESS_NAME + "\"/>" + NEWLINE); fw.write("\t\t<property name=\"configOverrideMap\">" + NEWLINE); fw.write("\t\t\t<map>" + NEWLINE); //Loop through properties for (String k : configMap.keySet()) { fw.write("\t\t\t\t<entry key=\"" + k + "\" value=\"" + configMap.get(k) + "\"/>" + NEWLINE); } fw.write("\t\t\t</map>" + NEWLINE); fw.write("\t\t</property>" + NEWLINE); fw.write("\t</bean>" + NEWLINE); fw.write("</beans>" + NEWLINE); fw.flush(); fw.close(); } public void createLogXml() throws Exception { File logXml = new File(CONFIG_DIR,"log-conf.xml"); logXml.createNewFile(); FileWriter fw = new FileWriter(logXml); fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NEWLINE); fw.write("<!DOCTYPE log4j:configuration SYSTEM \"log4j.dtd\">" + NEWLINE); fw.write("<log4j:configuration>" + NEWLINE); fw.write("\t<appender name=\"fileAppender\" class=\"org.apache.log4j.RollingFileAppender\">" + NEWLINE); fw.write("\t\t<param name=\"File\" value=\"log/sdl.log\" />" + NEWLINE); fw.write("\t\t<param name=\"Append\" value=\"true\" />" + NEWLINE); fw.write("\t\t<param name=\"MaxFileSize\" value=\"100KB\" />" + NEWLINE); fw.write("\t\t<param name=\"MaxBackupIndex\" value=\"1\" />" + NEWLINE); fw.write("\t\t<layout class=\"org.apache.log4j.PatternLayout\">" + NEWLINE); fw.write("\t\t\t<param name=\"ConversionPattern\" value=\"%d %-5p [%t] %C{2} %M (%F:%L) - %m%n\"/>" + NEWLINE); fw.write("\t\t</layout>" + NEWLINE); fw.write("\t</appender>" + NEWLINE); fw.write("\t<appender name=\"STDOUT\" class=\"org.apache.log4j.ConsoleAppender\">" + NEWLINE); fw.write("\t\t<layout class=\"org.apache.log4j.PatternLayout\">" + NEWLINE); fw.write("\t\t\t<param name=\"ConversionPattern\" value=\"%d %-5p [%t] %C{2} %M (%F:%L) - %m%n\"/>" + NEWLINE); fw.write("\t\t</layout>" + NEWLINE); fw.write("\t</appender>" + NEWLINE); fw.write("\t<category name=\"org.apache.log4j.xml\">" + NEWLINE); fw.write("\t\t<priority value=\"warn\" />" + NEWLINE); fw.write("\t\t<appender-ref ref=\"fileAppender\" />" + NEWLINE); fw.write("\t\t<appender-ref ref=\"STDOUT\" />" + NEWLINE); fw.write("\t</category>" + NEWLINE); fw.write("\t<logger name=\"org.apache\" >" + NEWLINE); fw.write("\t\t<level value =\"warn\" />" + NEWLINE); fw.write("\t</logger>" + NEWLINE); fw.write("\t<root>" + NEWLINE); fw.write("\t\t<priority value =\"info\" />" + NEWLINE); fw.write("\t\t<appender-ref ref=\"fileAppender\" />" + NEWLINE); fw.write("\t\t<appender-ref ref=\"STDOUT\" />" + NEWLINE); fw.write("\t</root>" + NEWLINE); fw.write("</log4j:configuration>" + NEWLINE); fw.flush(); fw.close(); } public void createConfigProperties() { File configProperties = new File(CONFIG_DIR,"config.properties"); try { configProperties.createNewFile(); } catch (IOException ie) { //Do Nothing } } /** * Creates .bat script for Windows * * @throws Exception */ public void createBatScript() throws Exception { File batScript = new File(SCRIPT_DIR,PROCESS_NAME + ".bat"); batScript.createNewFile(); FileWriter fw = new FileWriter(batScript); fw.write("SET DLPATH=\"" + HOME_DIR + "\"" + NEWLINE); fw.write("SET DLCONF=\"" + CONFIG_DIR + "\"" + NEWLINE); fw.write("SET DLDATA=\"" + WRITE_DIR + "\"" + NEWLINE); fw.write("call %DLPATH%\\" + WINDOWS_JAVA_DIR + "\\bin\\java.exe " + "-cp %DLPATH%\\* " + "-Dsalesforce.config.dir=%DLCONF% com.salesforce.dataloader.process.ProcessRunner " + "process.name=" + PROCESS_NAME + NEWLINE); fw.write("REM To rotate your export files, uncomment the line below" + NEWLINE); fw.write("REM copy %DLDATA%\\" + PROCESS_NAME + ".csv " + "%DLDATA%\\%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%-" + PROCESS_NAME + ".csv" + NEWLINE); fw.flush(); fw.close(); } /** * Creates .sh script for UNIX * * @throws Exception */ public void createShScript() throws Exception { File batScript = new File(SCRIPT_DIR,PROCESS_NAME + ".sh"); batScript.createNewFile(); FileWriter fw = new FileWriter(batScript); fw.write("#!/bin/sh" + NEWLINE); fw.write("export DLPATH=\"" + HOME_DIR + "\"" + NEWLINE); fw.write("export DLCONF=\"" + CONFIG_DIR + "\"" + NEWLINE); fw.write("java -cp \"$DLPATH/*\" " + "-Dsalesforce.config.dir=$DLCONF " + "com.salesforce.dataloader.process.ProcessRunner " + "process.name=" + PROCESS_NAME + NEWLINE); fw.flush(); fw.close(); } /** * Verifies that the username and password are valid with Salesforce * * setUsername and setPassword must be called before this method. */ public void doSalesforceLogin() throws Exception { if (getConfigValue(Config.USERNAME).length() == 0 || getPlainPassword().length() == 0) throw new Exception("Username and password cannot be blank."); else { DataLoaderCliq.log("Logging in to salesforce as " + getConfigValue(Config.USERNAME)); config.setUsername(getConfigValue(Config.USERNAME)); config.setPassword(getPlainPassword()); config.setAuthEndpoint(getConfigValue(Config.ENDPOINT)); if (getConfigValue(Config.PROXY_HOST) != null && getConfigValue(Config.PROXY_HOST).length() > 0) { System.out.println("Enabling proxy host: " + getConfigValue(Config.PROXY_HOST)); config.setProxy(getConfigValue(Config.PROXY_HOST), Integer.valueOf(getConfigValue(Config.PROXY_PORT))); } if (getConfigValue(Config.PROXY_USERNAME) != null && getConfigValue(Config.PROXY_USERNAME).length() > 0) { config.setProxyUsername(getConfigValue(Config.PROXY_USERNAME)); config.setProxyPassword(getConfigValue(Config.PROXY_PASSWORD)); } try { connection = new PartnerConnection(config); connection.login(getConfigValue(Config.USERNAME), getPlainPassword()); } catch (LoginFault ex) { DataLoaderCliq.log("Login exception: " + ex.getFaultCode(), ex); throw new Exception(ex.getFaultCode().getLocalPart() + " - " + ex.getExceptionMessage()); } catch (ApiFault ex) { DataLoaderCliq.log("API exception: " + ex.getCause(), ex); throw new Exception(ex.getFaultCode().getLocalPart() + " - " + ex.getExceptionMessage()); } catch (ConnectionException ex) { DataLoaderCliq.log("Connection exception: " + ex.getCause(), ex); throw ex; } } } }
00mohit-mohit
src/com/salesforce/cliq/cliconfig/CliConfig.java
Java
mit
19,538
package com.salesforce.cliq.cliconfig; import com.salesforce.cliq.cliconfig.CliConfig.Operation; import com.salesforce.dataloader.config.Config; import com.sforce.soap.partner.fault.*; import java.io.File; import java.util.regex.*; /** * Extends CliConfig with specific implementation for Export(Extract) operations * * @author vswamidass * */ public class CliConfigExport extends CliConfig { public enum ExportOperation implements Operation { EXTRACT, EXTRACT_ALL; public DataLoaderOperation toDataLoaderOperation() { switch (this) { case EXTRACT_ALL: return CliConfig.DataLoaderOperation.EXTRACT_ALL; default: return CliConfig.DataLoaderOperation.EXTRACT; } } } ExportOperation exportOperation; /* Indicates if the current query has been validated with Salesforce */ private boolean queryValid = false; private String queryOriginal = null; /** * Constructor * * @param dir * Data Loader home dir * @param name * The Process name */ public CliConfigExport(ExportOperation operation, String dir, String processName) { super(operation.toDataLoaderOperation(), dir, processName); exportOperation = operation; } /** * Sets specific process-conf.xml parameters for Export operations. */ @Override protected void setConfigDefaults() { setConfigValue(Config.OPERATION, "extract"); setConfigValue(Config.DAO_TYPE, "csvWrite"); File outputFile = new File(WRITE_DIR, PROCESS_NAME + ".csv"); setConfigValue(Config.DAO_NAME, outputFile.getAbsolutePath()); super.setConfigDefaults(); } /** * Sets the process-conf.xml extractionSOQL and entity key/values - Verifies * that the query is valid with Salesforce - Parses out the entity from the * query * * @param q * SOQL Query to Export * @throws Exception * Salesforce reported an error with the query */ public void setQueryAndEntity(String q) throws Exception { String xmlCompatibleQuery = new String(); /* Set the variables */ queryOriginal = q; setQueryValid(false); /* Fix > */ Pattern greaterThan = Pattern.compile(">"); xmlCompatibleQuery = greaterThan.matcher(getQueryOriginal()) .replaceAll("&gt;"); /* Fix < */ Pattern lessThan = Pattern.compile("<"); xmlCompatibleQuery = lessThan.matcher(xmlCompatibleQuery).replaceAll( "&lt;"); setConfigValue(Config.EXTRACT_SOQL, xmlCompatibleQuery); /* Run the query and verify */ try { connection.query(getQueryOriginal()); setQueryValid(true); } catch (UnexpectedErrorFault uef) { throw new Exception(uef.getExceptionMessage()); } catch (MalformedQueryFault mqf) { throw new Exception(mqf.getExceptionMessage()); } catch (InvalidFieldFault iff) { throw new Exception(iff.getExceptionMessage()); } catch (InvalidSObjectFault isf) { throw new Exception(isf.getExceptionMessage()); } catch (Exception e) { throw new Exception("Unknown error in query."); } /* TODO need to validate */ Pattern p = Pattern.compile("FROM (\\w+)", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(this.getQueryOriginal()); m.find(); setEntityName(m.group(1)); } public String getQueryOriginal() { return queryOriginal; } public void setQueryValid(boolean v) { queryValid = v; } public boolean isQueryValid() { return queryValid; } public void setExportOperation(ExportOperation op) { exportOperation = op; setDataLoaderOperation(op.toDataLoaderOperation()); } public ExportOperation getExportOperation() { return exportOperation; } }
00mohit-mohit
src/com/salesforce/cliq/cliconfig/CliConfigExport.java
Java
mit
3,704
package com.salesforce.cliq.cliconfig; import com.salesforce.cliq.DataLoaderCliq; import com.salesforce.dataloader.config.Config; /* * Based on the CliConfig.DataLoaderOperation, constructs a CliConfig object and returns it */ public class CliConfigFactory { public static CliConfig getCliConfig(CliConfig.DataLoaderOperation op, String dir, String processName, String endPoint) { CliConfig myConfig; switch (op) { case EXTRACT: myConfig = new CliConfigExport(CliConfigExport.ExportOperation.EXTRACT, dir, processName); break; case EXTRACT_ALL: myConfig = new CliConfigExport(CliConfigExport.ExportOperation.EXTRACT_ALL, dir, processName); break; case INSERT: myConfig = new CliConfigDml(CliConfigDml.DmlOperation.INSERT, dir, processName); break; case UPDATE: myConfig = new CliConfigDml(CliConfigDml.DmlOperation.UPDATE, dir, processName); break; case UPSERT: myConfig = new CliConfigDml(CliConfigDml.DmlOperation.UPSERT, dir, processName); break; case DELETE: myConfig = new CliConfigDml(CliConfigDml.DmlOperation.DELETE, dir, processName); break; case HARD_DELETE: myConfig = new CliConfigDml(CliConfigDml.DmlOperation.HARD_DELETE, dir, processName); break; default: myConfig = null; //this should never be hit } myConfig.setConfigValue(Config.ENDPOINT,endPoint); return myConfig; } public static CliConfig getCliConfig(CliConfig.DataLoaderOperation op, String dir, String processName) { return CliConfigFactory.getCliConfig(op,dir,processName,null); } }
00mohit-mohit
src/com/salesforce/cliq/cliconfig/CliConfigFactory.java
Java
mit
1,906
package com.salesforce.cliq.cliconfig; import java.io.File; import java.io.FileWriter; import com.salesforce.cliq.cliconfig.CliConfig.DataLoaderOperation; import com.salesforce.cliq.cliconfig.CliConfig.Operation; import com.salesforce.cliq.cliconfig.CliConfigExport.ExportOperation; import com.salesforce.dataloader.config.Config; import com.sforce.soap.partner.fault.LoginFault; import com.sforce.soap.partner.fault.UnexpectedErrorFault; /** * Extends CliConfig with specific implementation for DML operations * INSERT, UPDATE, UPSERT, DELETE * * @author vswamidass * */ public class CliConfigDml extends CliConfig { public static final String EXTERNAL_ID_PROPERTY = "sfdc.externalIdField"; public enum DmlOperation implements Operation { INSERT(false), UPDATE(false), UPSERT(true), DELETE(false), HARD_DELETE(false); public DataLoaderOperation toDataLoaderOperation() { switch (this) { case INSERT: return CliConfig.DataLoaderOperation.INSERT; case UPDATE: return CliConfig.DataLoaderOperation.UPDATE; case UPSERT: return CliConfig.DataLoaderOperation.UPSERT; case DELETE: return CliConfig.DataLoaderOperation.DELETE; case HARD_DELETE: return CliConfig.DataLoaderOperation.HARD_DELETE; default: return null; //this should never be hit } } private boolean canUseExternalId; private DmlOperation(boolean usesExternalId) { canUseExternalId = usesExternalId; } public boolean isExternalIdOperation() { return canUseExternalId; } } DmlOperation dmlOperation; /** * Constructor * Sets the process-conf.xml process.operation to the operation parameter. * * @param dir Data Loader Directory * @param name Process Name * @param operation DML Operation (enum Operations) */ public CliConfigDml(DmlOperation operation, String dir, String name) { super(operation.toDataLoaderOperation(), dir, name); //setEndpoint(endPoint); dmlOperation = operation; } /** * Overrides CliConfig.setConfigDefaults * * Sets specific process-conf.xml parameters for DML operations. */ protected void setConfigDefaults() { setConfigValue(Config.MAPPING_FILE,getSdlFile().getAbsolutePath()); setConfigValue(Config.DAO_NAME,getInputFile().getAbsolutePath()); setConfigValue(Config.DAO_TYPE,"csvRead"); super.setConfigDefaults(); } /** * Overrides CliConfig.createFiles to add files for DML operations. */ public void createFiles() throws Exception { super.createFiles(); createSdl(); createInputFile(); } protected File getSdlFile() { return new File(CONFIG_DIR,PROCESS_NAME + ".sdl"); } protected File getInputFile() { return new File(READ_DIR,PROCESS_NAME + ".csv"); } /** * Creates a placeholder sdl mapping file * * @throws Exception */ protected void createSdl() throws Exception { File sdl = getSdlFile(); sdl.createNewFile(); FileWriter fw = new FileWriter(sdl); fw.write("# Created by Dataloader Cliq" + NEWLINE); fw.write("#" + NEWLINE); fw.write("# Create your field mapping list in the following format" + NEWLINE); fw.write("# <Your CSV Field1>=<Salesforce Field in " + getConfigValue(Config.ENTITY) + ">" + NEWLINE); fw.write("# NOTE: Salesforce Fields are case-sensitive. " + NEWLINE); fw.write(NEWLINE); fw.write("# Example: " + NEWLINE); fw.write("ID=Id" + NEWLINE); fw.flush(); fw.close(); }; /** * Creates a placeHolder CSV file in the read directory * * @throws Exception */ protected void createInputFile() throws Exception { File inputFile = getInputFile(); inputFile.createNewFile(); FileWriter fw = new FileWriter(inputFile); fw.write("Replace this file with your csv. The first row should have the field names."); fw.write("Make sure to update the sdl file also " + getSdlFile().getAbsolutePath()); fw.flush(); fw.close(); }; public void setExternalIdField(String entity, String externalIdField) throws Exception { if (this.isFieldExternalId(entity, externalIdField)) { this.setConfigValue(EXTERNAL_ID_PROPERTY, externalIdField); } else { this.setConfigValue(EXTERNAL_ID_PROPERTY, null); throw new Exception("External Id not valid for " + entity); } } public String getExternalIdField() { return getConfigValue(EXTERNAL_ID_PROPERTY); } public boolean isExternalIdOperation() { return dmlOperation.isExternalIdOperation(); } public boolean isExternalIdValid() { try { return this.isFieldExternalId(this.getConfigValue(Config.ENTITY), this.getExternalIdField()); } catch (Exception e) { return false; } } public void setDmlOperation(DmlOperation op) { dmlOperation = op; setDataLoaderOperation(op.toDataLoaderOperation()); } public DmlOperation getDmlOperation() { return dmlOperation; } }
00mohit-mohit
src/com/salesforce/cliq/cliconfig/CliConfigDml.java
Java
mit
4,999
$(function(){ var aBackgrounds = $( 'section > .bg' ) , $content = $( '#content' ) ; function measureBackgrounds(){ var i, l, oData, $item, $section, fRW, fRH; for( i=0, l=aBackgrounds.length; i<l; i++ ){ $item = aBackgrounds.eq(i); oData = $item.data(); $section = $item.parent(); $section.appendTo( $content ); if( !oData.width ){ oData.width = $item.width(); oData.height = $item.height(); } fRW = $section.width() / oData.width; fRH = $section.height() / oData.height; $item.css( { width: 'auto', height: 'auto' } ).css( fRW > fRH ? 'width' : 'height', '100%' ); $section.detach(); } } $( window ).bind( 'post-resize-anim', measureBackgrounds ); });
123-asdf
trunk/js/backgrounds.js
JavaScript
mit
726
$(function() { //LANGUAGE BUTTONS EFFECTS $('#lang > ul > li > a').mouseover(function() { $(this).css({'color': '#E8E595'}); }).mouseout(function() { $(this).css({'color': ''}); }); //SLIDES - WORK SHOW/HIDE BUTTONS $('.how_we_work_nav').find('li').click(function(){ var i = $('.how_we_work_nav > ul > li').index(this); //if visibility check, else no action if( $(".slides_work:eq(" + i + "):visible").length !== 1 ) { //animate buttons $(".how_we_work_buttons").removeClass('b_active'); $(".how_we_work_buttons:eq(" + i + ")").addClass(' b_active'); //calculate left margin var $div = $(".slides_work:eq(" + i + ")"); var $lm = ($div.parent().width() / 2 - $div.width() / 2) / $div.parent().width() * 100 + "%"; $(".slides_work").hide(); $div.css({'marginLeft' : '-100%' , 'opacity' : '0'}) .show() .animate({'marginLeft' : $lm , 'opacity' : '1'}, 1200, "easeInOutQuint"); } }); //CONTACT FORM SHOW/HIDE BUTTONS $('.contact_us_nav').find('li').click(function(){ var i = $('.contact_us_nav > ul > li').index(this); //if visibility check, else no action if( $(".contact_forms:eq(" + i + "):visible").length !== 1 ) { //animate buttons $(".project_form_buttons").css('background', 'transparent'); $(".project_form_buttons:eq(" + i + ")").css('background', '#D0A825'); $(".contact_forms").stop().hide(); $(".contact_forms:eq(" + i + ")") .effect('bounce', {"direction" : "down", "mode" : "show", "distance" : "6", "times" : 2}, 800); $('input, textarea').placeholder(); } }); //ROTATING BILLBOARD var Banner = setInterval( "slideSwitch(direction, easing)", 9000 ); //Banner; //STOP BILLBOARD ROTATION clearInterval(Banner); var playback = true; $('#playback').click(function() { if(playback === true) { $(this).find('img').attr("src", "http://forafreeworld.com/img/playback_play.png").effect('highlight', 1000); clearInterval(Banner); playback = false; } else { $(this).find('img').attr("src", "http://forafreeworld.com/img/playback_pause.png").effect('highlight', 1000); Banner = setInterval( "slideSwitch(direction, easing)", 9000 ); playback = true; } }); //BE FREE BUTTON HOVER $('#be_free_button').mouseover(function() { $(this).stop().animate({ "borderColor" : "#3F617B", "backgroundColor" : "#FFF", "color" : "#3F617B"}, 500); }) .mouseout(function() { $(this).stop().animate({ "borderColor" : "#FFF", "backgroundColor" : "transparent", "color" : "#fff"}, 500); }) .click(function() { $(this).stop().animate({ "borderColor" : "#FFF", "backgroundColor" : "transparent", "color" : "#fff"}, 500); }); //TEXTAREA AUTO-RESIZE $('body').on('keyup','textarea', function (){ $(this).css({'minHeight' : '40px', 'maxHeight' : '100px', 'height' : 'auto' }); $(this).height( this.scrollHeight ); }); $('body').find( 'textarea' ).keyup(); //form support for browsers not supporting placeholder $('input, textarea').placeholder(); }); //define animation options - our work var direction = new Array(); direction[0] = { "left" : "-150%", "top" : "-150%" }; direction[1] = { "top" : "150%" }; direction[2] = { "left" : "150%" }; direction[3] = { "top" : "-150%" }; var easing = new Array('easeInQuint', 'easeInOutElastic', 'easeOutBack', 'easeOutCirc'); function slideSwitch(dir, ease) { var $active = $('#slider_work > div.active'); if ( $active.length == 0 ) $active = $('#slider_work > div:last'); var $next = $active.next('div').length ? $active.next('div') : $('#slider_work > div:first'); $active.addClass('last-active'); //random direction generator var i = Math.floor(Math.random()*4); var j = Math.floor(Math.random()*4); var option = dir[i]; var easing = ease[j]; $next.css(option) .addClass('active') .animate({ "left" : "" , "top" : ""}, {duration: 2000, easing: easing, start: function() { $active.removeClass('active last-active'); } }); }
123-asdf
trunk/js/main.js
JavaScript
mit
4,479
/*! http://mths.be/placeholder v2.0.7 by @mathias */ ;(function(window, document, $) { var isInputSupported = 'placeholder' in document.createElement('input'); var isTextareaSupported = 'placeholder' in document.createElement('textarea'); var prototype = $.fn; var valHooks = $.valHooks; var propHooks = $.propHooks; var hooks; var placeholder; if (isInputSupported && isTextareaSupported) { placeholder = prototype.placeholder = function() { return this; }; placeholder.input = placeholder.textarea = true; } else { placeholder = prototype.placeholder = function() { var $this = this; $this .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') .not('.placeholder') .bind({ 'focus.placeholder': clearPlaceholder, 'blur.placeholder': setPlaceholder }) .data('placeholder-enabled', true) .trigger('blur.placeholder'); return $this; }; placeholder.input = isInputSupported; placeholder.textarea = isTextareaSupported; hooks = { 'get': function(element) { var $element = $(element); var $passwordInput = $element.data('placeholder-password'); if ($passwordInput) { return $passwordInput[0].value; } return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value; }, 'set': function(element, value) { var $element = $(element); var $passwordInput = $element.data('placeholder-password'); if ($passwordInput) { return $passwordInput[0].value = value; } if (!$element.data('placeholder-enabled')) { return element.value = value; } if (value == '') { element.value = value; // Issue #56: Setting the placeholder causes problems if the element continues to have focus. if (element != safeActiveElement()) { // We can't use `triggerHandler` here because of dummy text/password inputs :( setPlaceholder.call(element); } } else if ($element.hasClass('placeholder')) { clearPlaceholder.call(element, true, value) || (element.value = value); } else { element.value = value; } // `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363 return $element; } }; if (!isInputSupported) { valHooks.input = hooks; propHooks.value = hooks; } if (!isTextareaSupported) { valHooks.textarea = hooks; propHooks.value = hooks; } $(function() { // Look for forms $(document).delegate('form', 'submit.placeholder', function() { // Clear the placeholder values so they don't get submitted var $inputs = $('.placeholder', this).each(clearPlaceholder); setTimeout(function() { $inputs.each(setPlaceholder); }, 10); }); }); // Clear placeholder values upon page reload $(window).bind('beforeunload.placeholder', function() { $('.placeholder').each(function() { this.value = ''; }); }); } function args(elem) { // Return an object of element attributes var newAttrs = {}; var rinlinejQuery = /^jQuery\d+$/; $.each(elem.attributes, function(i, attr) { if (attr.specified && !rinlinejQuery.test(attr.name)) { newAttrs[attr.name] = attr.value; } }); return newAttrs; } function clearPlaceholder(event, value) { var input = this; var $input = $(input); if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) { if ($input.data('placeholder-password')) { $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id')); // If `clearPlaceholder` was called from `$.valHooks.input.set` if (event === true) { return $input[0].value = value; } $input.focus(); } else { input.value = ''; $input.removeClass('placeholder'); input == safeActiveElement() && input.select(); } } } function setPlaceholder() { var $replacement; var input = this; var $input = $(input); var id = this.id; if (input.value == '') { if (input.type == 'password') { if (!$input.data('placeholder-textinput')) { try { $replacement = $input.clone().attr({ 'type': 'text' }); } catch(e) { $replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' })); } $replacement .removeAttr('name') .data({ 'placeholder-password': $input, 'placeholder-id': id }) .bind('focus.placeholder', clearPlaceholder); $input .data({ 'placeholder-textinput': $replacement, 'placeholder-id': id }) .before($replacement); } $input = $input.removeAttr('id').hide().prev().attr('id', id).show(); // Note: `$input[0] != input` now! } $input.addClass('placeholder'); $input[0].value = $input.attr('placeholder'); } else { $input.removeClass('placeholder'); } } function safeActiveElement() { // Avoid IE9 `document.activeElement` of death // https://github.com/mathiasbynens/jquery-placeholder/pull/99 try { return document.activeElement; } catch (err) {} } }(this, document, jQuery));
123-asdf
trunk/js/jquery.placeholder.js
JavaScript
mit
6,663
$(function(){ var $nav = $('#nav'), aRules = []; //create the ul $('section').each(function(){ var $this = $(this) , sTitle = $this.attr('data-nav') || $this.find('h2:first').text() , sId = $this.attr('id').split('-').pop(); //story-header -> header aRules.push('body.section-' + sId + ' #nav li.' + sId + ' a'); $nav.append('<li class="' + sId + '"><h1><span>' + sTitle + '</span></h1><a href="#' + sId + '">' + sId + '</a></li>'); }); //add blog link to menu manually var $url = $(location).attr('href'); var $lang = 'en'; var $blog = 'Blog'; if ($url.toLowerCase().indexOf('/bg/') >= 0) { $lang = 'bg'; $blog = 'Блог'; } $nav.append('<li class="Blog"><h1><span>' + $blog + '</span></h1>' + '<a href="http://blog.forafreeworld.com" target="_blank">' + $blog + '</a></li>'); $nav.on('click', 'a', function(){ scrollToSection($(this).attr('href').substr(1)); //to remove # }); //scrollToSection for all a's in document $('body').on('click', 'a', function(ev){ var href = this.getAttribute('href') || ''; if( href.indexOf('#') === 0){ ev.preventDefault(); scrollToSection(href.substr(1)); } } ); });
123-asdf
trunk/js/side-nav.js
JavaScript
mit
1,193
$(function(){ var $window = $( window ) , $body = $( 'body' ) , $bodyAndHTML = $body.add( 'html' ) , $content = $( '#content' ) , $sections = $content.find( 'section' ) , $scroller = $( '#mock-scroller' ) , fScrPercent = 0 , aAnimProps = [ 'opacity', 'left', 'top', 'width', 'height', 'background-position' ] , sHash = location.hash , bAllowAnims = !~location.href.indexOf( 'noanims' ) , aAnimations = [] , webkitCSS = document.body.style[ 'webkitTransform' ] !== undefined , mozCSS = document.body.style[ 'MozTransform' ] !== undefined , msCSS = document.body.style[ 'msTransform' ] !== undefined , iAnimTimeout, iWindowHeight, sLastHash, iMaxHeight, iWinScrTop, iLastScrTime, iScrTimeout, sWinSize, kinetics ; // find all animatable nodes and store properties $sections.each( function( ix ){ var $sec = $sections.eq( ix ); $sec.data( '$pNodes' , $sec.find( '.animate' ) ); $sec.data( 'bSection', true ); $sec.add( $sec.data( '$pNodes' ) ).each( function(){ var $this = $( this ) , oData = $this.data() ; oData.iPause = 0 | $this.attr( 'anim-pause' ); oData.bDetached = !!~'1 true'.indexOf( $this.attr( 'anim-detached' ) ); oData.fSpeed = parseFloat( $this.attr( 'anim-speed' ) ) || 1; oData.onFocus = $this.attr( 'anim-focus-handler' ); oData.onBlur = $this.attr( 'anim-blur-handler' ); } ); // remove the section from the DOM $sec.detach(); } ); // converts a unit string to px function parseUnit( vVal, $node, sValFn ){ var aVal = /(-?\d+)(.*)/.exec( vVal ) , fUnit = parseFloat( aVal[ 1 ] ) , sUnit = aVal[ 2 ] ; switch( sUnit ){ case '': case 'px': return fUnit; case '%': return $node[ sValFn ]() * fUnit / 100; default: throw new Error( 'Unexpected unit type: ' + sUnit ); return; } } // reads all listed css properties from $node with sClass applied function readCSSProps( $node, sClass ){ var oObj = {} , i, l, vPropVal, sProp ; $node.addClass( sClass ).removeAttr( 'style' ); for( i=0, l=aAnimProps.length; i<l; i++ ){ sProp = aAnimProps[i]; switch( sProp ){ // numeric css case 'opacity': vPropVal = 0 | $node.css( sProp ); break; // numeric position case 'left': case 'top': vPropVal = $node.position()[ sProp ]; break; // numeric size case 'width': case 'height': vPropVal = $node[ 'outer' + sProp.substr( 0, 1 ).toUpperCase() + sProp.substr( 1 ) ](); break; // split numeric properties case 'background-position': vPropVal = ( $node.css( sProp ) || '0 0' ).split( ' ' ); vPropVal[0] = parseUnit( vPropVal[0], $node, 'outerWidth' ); vPropVal[1] = parseUnit( vPropVal[1], $node, 'outerHeight' ); break; } oObj[ sProp ] = vPropVal; } $node.removeClass( 'start focus to end' ); return oObj; } // determines if two values are equal if they are basic types or arrays function eq( vVal1, vVal2 ){ var i, l; if( vVal1 === vVal2 ){ return true; } if( typeof vVal1 !== typeof vVal2 ){ return false; } if( vVal1.length && vVal1.splice && vVal2.length && vVal2.splice ){ if( vVal1.length != vVal2.length ){ return false; } for( i=0, l=vVal1.length; i<l; i++ ){ if( !eq( vVal1[i], vVal2[i] ) ){ return false; } } return true; } return false; } // returns properties that differ between two objects function propDiff( oProps1, oProps2 ){ var oDiff = {} , n, bProp; for( n in oProps2 ){ if( !eq( oProps1[n], oProps2[n] ) ){ oDiff[n] = bProp = [ oProps1[n], oProps2[n] ]; } } return bProp && oDiff; } // given a node, top & stage, stores an animation for the node function addDiffAnimation( $node, iTop, iStage, iAnimLength ){ var stages = [ 'start', 'focus', 'to', 'end' ] , iStartStage = iStage - 1 , sEndStage = stages[ iStage ] , oPropsEnd = readCSSProps( $node, sEndStage ) , oData = $node.data() , bPreDefLen = !!iAnimLength , oPropDiff, n, iDiff ; if( !iAnimLength ){ iAnimLength = 0; } // get the diff between this stage and the prior one oPropDiff = propDiff( readCSSProps( $node, stages[ iStartStage ] ), oPropsEnd ); if( !oPropDiff ){ return 0; } for( n in oPropDiff ){ iDiff = Math.abs( oPropDiff[n][1] - oPropDiff[n][0] ); if( !bPreDefLen && ( iDiff > iAnimLength ) ){ iAnimLength = iDiff; } } aAnimations.push( { $node : $node , oProps : oPropDiff , iTop : iTop , iBottom : iTop + iAnimLength , bSection : oData.bSection } ); return oData.bDetached ? 0 : iAnimLength; } // window loaded or re-sized, re-calculate all dimensions function measureAnimations(){ var iTop = 0 , iStartTimer = +new Date() , iLastSection = $sections.length - 1 , iPageHeight = 0 , oAnim, oData ; aAnimations = window.aAnimations = []; $scroller.css( 'height', 10000 ); // add animations for each section & .animate tag in each section $sections.each( function( ix ){ var $sec = $( this ) , oData = $sec.data() , $pNodes = oData.$pNodes , iSecHeight = 0 , iMaxPause = oData.iPause , i, l, iAnimSize, $pNode ; oData.startsAt = iTop; // append section to content and reset position $sec .css({ top : '', visibility: 'hidden' }) .appendTo( $content ); if( ix ){ iSecHeight = addDiffAnimation( $sec, iTop, 1 ); } for( i=0, l=$pNodes.length; i<l; i++ ){ $pNode = $pNodes.eq( i ); if( bAllowAnims ){ iMaxPause = Math.max( iMaxPause , addDiffAnimation( $pNode, iTop , 1, iSecHeight ) , iAnimSize = addDiffAnimation( $pNode, iTop + iSecHeight + iMaxPause , 2, iSecHeight ) , addDiffAnimation( $pNode, iTop + iSecHeight + iMaxPause + iAnimSize, 3, iSecHeight ) ); } } if( ix ){ iTop += iMaxPause; // Math.max( iSecHeight, iMaxPause, $sec.outerHeight() ); } addDiffAnimation( $sec, iTop + iSecHeight, 2 ); if( ix < iLastSection ){ addDiffAnimation( $sec, iTop + iSecHeight, 3 ); } $sec.detach().css({ visibility: 'visible' }); oData.endsAt = iTop += iSecHeight; oData.bVisible = false; } ); // wipe start/end positions on sections for( i=0, l=$sections.length; i<l; i++ ){ $sections.eq(i).data().iTop = Infinity; $sections.eq(i).data().iBottom = -Infinity; } // post-process animations for( i=0, l=aAnimations.length; i<l; i++ ){ oAnim = aAnimations[i]; if( oAnim.iBottom > iPageHeight ){ iPageHeight = oAnim.iBottom; } if( oAnim.bSection ){ oData = oAnim.$node.data(); if( oAnim.iTop < oData.iTop ){ oData.iTop = oAnim.iTop; } if( oAnim.iBottom > oData.iBottom ){ oData.iBottom = oAnim.iBottom; } } } iPageHeight = Math.max( iPageHeight, ++$sections.last().data().iBottom ); $scroller.css( 'height', ( iMaxHeight = iPageHeight ) + iWindowHeight ); $window.trigger( 'animations-added', { animations: aAnimations } ); } function onResize(){ var pTop = ( iWinScrTop / iMaxHeight ) || 0; measureAnimations(); $window.trigger( 'post-resize-anim' ); $window.scrollTop( pTop * iMaxHeight ); onScroll(); kinetics .adjustRange( iMaxHeight ) .setPosition( pTop * iMaxHeight ); } function singlePartialCSSProp( iScrTop, oAnim, oProp ){ return ( iScrTop - oAnim.iTop ) / ( oAnim.iBottom - oAnim.iTop ) * ( oProp[1] - oProp[0] ) + oProp[0]; } function partialCSSProp( iScrTop, oAnim, oProp ){ if( oProp[0].splice ){ return $.map( oProp[0], function( nul, ix ){ return ( 0|singlePartialCSSProp( iScrTop, oAnim, [ oProp[0][ix], oProp[1][ix] ] ) ) + 'px'; } ).join( ' ' ); }else{ return singlePartialCSSProp( iScrTop, oAnim, oProp ); } } function onScrollHandler(){ var cDate = +new Date() , iScrTop = $window.scrollTop() , iDiff = cDate - iLastScrTime ; iLastScrTime = cDate; if( iScrTimeout ){ clearTimeout( iScrTimeout ); iScrTimeout = 0; } // last tick was either recent enough or a while ago. pass through if( ( iDiff > 200 ) || ( iDiff < 50 ) ){ onScroll( iScrTop ); }else{ // stupid browser scrolling is too slow, fix it var iLastTop = iWinScrTop , iScrDiff = iScrTop - iLastTop ; function nextScrollTick(){ var now = +new Date() , iStep = ( now + 30 - cDate ) / iDiff; if( iStep > 1 ){ iStep = 1; } onScroll( iLastTop + iScrDiff * iStep ) if( iStep < 1 ){ iScrTimeout = setTimeout( nextScrollTick, 30 ); } } nextScrollTick(); } } function onScroll( iScrTop ){ var bChangedLoc = false , i, l, oAnim, $sec, oData , $node, sSecId, n, oCssProps, oProps, iCurScr, sState ; iScrTop || ( iScrTop = $window.scrollTop() ); iWinScrTop = iScrTop; if( iScrTop < 0 ){ iScrTop = 0; } if( iScrTop > iMaxHeight ){ iScrTop = iMaxHeight; } // hide/show sections for( i=0, l=$sections.length; i<l; i++ ){ $sec = $sections.eq(i); oData = $sec.data(); if( ( oData.iTop <= iScrTop ) && ( oData.iBottom >= ( iScrTop ) ) ){ if( !oData.bVisible ){ $sec.appendTo( $content ); oData.bVisible = true; } if( !bChangedLoc ){ if( sLastHash != ( sSecId = $sec.attr( 'id' ).split( '-' ).pop() ) ){ location.replace( '#' + ( sLastHash = sSecId ) ); $body.prop( 'class', $body.prop( 'class' ).replace( /(?: |^)section-[^ ]+/g, '' ) ).addClass( 'section-' + sSecId ); } bChangedLoc = true; } }else{ if( oData.bVisible ){ $sec.detach(); oData.bVisible = false; } } } for( i=0, l=aAnimations.length; i<l; i++ ){ oAnim = aAnimations[i]; $node = oAnim.$node; iCurScr = iScrTop; if( ( oAnim.iTop > iCurScr ) || ( oAnim.iBottom < iCurScr ) ){ sState = oAnim.lastState; oAnim.lastState = 'disabled'; // animation is newly disabled if( sState === 'enabled' ){ iCurScr = ( oAnim.iTop > iCurScr ) ? oAnim.iTop : oAnim.iBottom; }else{ continue; } }else{ oAnim.lastState = 'enabled'; } // in the middle of an animation oCssProps = {}; oProps = oAnim.oProps; for( n in oProps ){ oCssProps[ n ] = partialCSSProp( iCurScr, oAnim, oProps[n] ); //oCssProps[n] = 0|-( ( iScrTop - oProps[n][0] ) / ( oProps[n][1] - oProps[n][0] ) * ( oProps[n][1] - oProps[n][0] ) + oProps[n][0] ); } $node.css( hardwareCSSTransform( oCssProps ) ); } } function hardwareCSSTransform( props ){ if( props.top!=null || props.left!=null ){ if( webkitCSS ){ props.webkitTransform = 'translate3d(' + ( props.left || 0 ) + 'px, ' + ( props.top || 0 ) + 'px, 0)'; if( null != props.top ){ props.top = 0; } if( null != props.left ){ props.left = 0; } } if( mozCSS || msCSS ){ props[ mozCSS ? 'MozTransform' : 'msTransform' ] = ( props.top ? 'translateY(' + props.top + 'px)' : '' ) + ( props.left ? 'translateX(' + props.left + 'px)' : '' ); if( null != props.top ){ props.top = 0; } if( null != props.left ){ props.left = 0; } } } return props; } window.getAnimationController = function( sSelector ){ var oAnim, i, l; for( i=0, l=aAnimations.length; i<l; i++ ){ if( aAnimations[i].$node.is( sSelector ) ){ oAnim = aAnimations[i]; break; } } if( !oAnim ){ throw new Error( 'no animation matches selector ' + sSelector ); } return { scrollTo: function( iTop ){ iTop += oAnim.iTop; iTop = Math.max( oAnim.iTop, Math.min( oAnim.iBottom, iTop ) ); $bodyAndHTML.scrollTop( iTop ); } , scrollBy : function( iTop ){ iTop = iWinScrTop + iTop; iTop = Math.max( oAnim.iTop, Math.min( oAnim.iBottom, iTop ) ); $bodyAndHTML.scrollTop( iTop ); } } } window.scrollToSection = function( sSec, immediate ){ var $sect = $sections.filter( '#section-' + sSec ) , oData = $sect.data() , top = oData.iTop + ( $sections[0] === $sect[0] ? 0 : iWindowHeight + 1 ); if( immediate ){ $bodyAndHTML.scrollTop( top ); }else{ $bodyAndHTML.animate({ scrollTop: top }, 1000); } } if( sHash ){ setTimeout( function(){ scrollToSection( sHash.substr( 1 ), true ); }, 100 ); } /* touch move kinetics */ kinetics = new Kinetics( window ); window.kinetics = kinetics; kinetics.bind( 'move', function( ev, y ){ onScroll( y ); } ); $window /** * On resize: * * - save window height for onscroll calculations * - re-calculate the height of all the <section> elements * - adjust top position so that it's at the same %, not same px **/ .bind( 'resize', function(){ // patch IE which keeps triggering resize events when elements are resized var sCurWinSize = $window.width() + 'x' + $window.height(); if( sCurWinSize === sWinSize ){ return; } sWinSize = sCurWinSize; if( iAnimTimeout ){ clearTimeout( iAnimTimeout ); } iAnimTimeout = setTimeout( onResize, 50 ); iWindowHeight = $window.height(); }) .trigger( 'resize' ) .bind( 'scroll', onScrollHandler ); });
123-asdf
trunk/js/parallax.js
JavaScript
mit
13,236
~function(){ function KineticModel() { var min = 0 , max = 1000 , lastPosition = 0 , velocity = 0 , timestamp = Date.now() , timeConstant, ticker ; function clamped(pos) { return (pos > max) ? max : (pos < min) ? min : pos; } function nop() {} this.duration = 1950; this.position = 0; this.updateInterval = 1000 / 60; this.onPositionChanged = nop; this.onScrollStarted = nop; this.onScrollStopped = nop; this.setRange = function (start, end) { min = start; max = end; }; this.getRange = function () { return { minimum : min , maximum : max }; }; this.setPosition = function (pos) { var self = this; this.position = clamped(pos); this.onPositionChanged(this.position); if (!ticker) { // Track down the movement to compute the initial // scrolling velocity. ticker = window.setInterval(function () { var now = Date.now(), elapsed = now - timestamp, v = (self.position - lastPosition) * 1000 / elapsed; // Moving average to filter the speed. if (ticker && elapsed >= self.updateInterval) { timestamp = now; if (v > 1 || v < -1) { velocity = 0.2 * (velocity) + 0.8 * v; lastPosition = self.position; } } }, this.updateInterval); } }; this.resetSpeed = function () { velocity = 0; lastPosition = this.position; window.clearInterval(ticker); ticker = null; }; this.release = function () { var self = this , amplitude = velocity , targetPosition = this.position + amplitude , timeConstant = 1 + this.duration / 6 , timestamp = Date.now() ; window.clearInterval(ticker); ticker = null; if (velocity > 1 || velocity < -1) { this.onScrollStarted(self.position); window.clearInterval(ticker); ticker = window.setInterval(function () { var elapsed = Date.now() - timestamp; if (ticker) { self.position = targetPosition - amplitude * Math.exp(-elapsed / timeConstant); self.position = clamped(self.position); self.onPositionChanged(self.position); if (elapsed > self.duration) { self.resetSpeed(); self.onScrollStopped(self.position); } } }, this.updateInterval); } }; } function Kinetics( el ){ var scroller = new KineticModel() , pressed = false , refPos = 0 , $watcher = $( '<div></div>' ); scroller.onPositionChanged = function( y ){ $watcher.trigger( 'move', y ); }; $watcher.adjustRange = function( max ){ scroller.setRange( 0, max ); return $watcher } $watcher.setPosition = function( y ){ scroller.position = y; return $watcher; } function tap( e ){ pressed = true; if (e.targetTouches && (e.targetTouches.length >= 1)) { refPos = e.targetTouches[0].clientY; } else { refPos = e.clientY; } scroller.resetSpeed(); e.preventDefault(); e.stopPropagation(); return false; } function untap( e ){ pressed = false; scroller.release(); e.preventDefault(); e.stopPropagation(); return false; } function drag( e ){ var pos, delta; if (!pressed) { return; } if (e.targetTouches && (e.targetTouches.length >= 1)) { pos = e.targetTouches[0].clientY; } else { pos = e.clientY; } delta = refPos - pos; if (delta > 2 || delta < -2) { scroller.setPosition( scroller.position += delta ); refPos = pos; } e.preventDefault(); e.stopPropagation(); return false; } if( el.addEventListener ){ el.addEventListener( 'touchstart', tap ); el.addEventListener( 'touchmove' , drag ); el.addEventListener( 'touchend' , untap ); } return $watcher; } window.Kinetics = Kinetics; }();
123-asdf
trunk/js/kinetics.js
JavaScript
mit
3,848
/*! * jQuery Mobile 1.4.0 * Git HEAD hash: f09aae0e035d6805e461a7be246d04a0dbc98f69 <> Date: Thu Dec 19 2013 17:34:22 UTC * http://jquerymobile.com * * Copyright 2010, 2013 jQuery Foundation, Inc. and other contributors * Released under the MIT license. * http://jquery.org/license * */ /* Globals */ /* Font -----------------------------------------------------------------------------------------------------------*/ html { font-size: 100%; } body, input, select, textarea, button, .ui-btn { font-size: 1em; line-height: 1.3; font-family: sans-serif /*{global-font-family}*/; } legend, .ui-input-text input, .ui-input-search input { color: inherit; text-shadow: inherit; } /* Form labels (overrides font-weight bold in bars, and mini font-size) */ .ui-mobile label, div.ui-controlgroup-label { font-weight: normal; font-size: 16px; } /* Separators -----------------------------------------------------------------------------------------------------------*/ /* Field contain separator (< 28em) */ .ui-field-contain { border-bottom-color: #828282; border-bottom-color: rgba(0,0,0,.15); border-bottom-width: 1px; border-bottom-style: solid; } /* Table opt-in classes: strokes between each row, and alternating row stripes */ /* Classes table-stroke and table-stripe are deprecated in 1.4. */ .table-stroke thead th, .table-stripe thead th, .table-stripe tbody tr:last-child { border-bottom: 1px solid #d6d6d6; /* non-RGBA fallback */ border-bottom: 1px solid rgba(0,0,0,.1); } .table-stroke tbody th, .table-stroke tbody td { border-bottom: 1px solid #e6e6e6; /* non-RGBA fallback */ border-bottom: 1px solid rgba(0,0,0,.05); } .table-stripe.table-stroke tbody tr:last-child th, .table-stripe.table-stroke tbody tr:last-child td { border-bottom: 0; } .table-stripe tbody tr:nth-child(odd) td, .table-stripe tbody tr:nth-child(odd) th { background-color: #eeeeee; /* non-RGBA fallback */ background-color: rgba(0,0,0,.04); } /* Buttons -----------------------------------------------------------------------------------------------------------*/ .ui-btn, label.ui-btn { font-weight: bold; border-width: 1px; border-style: solid; } .ui-btn:link { text-decoration: none !important; } .ui-btn-active { cursor: pointer; } /* Corner rounding -----------------------------------------------------------------------------------------------------------*/ /* Class ui-btn-corner-all deprecated in 1.4 */ .ui-corner-all { -webkit-border-radius: .6em /*{global-radii-blocks}*/; border-radius: .6em /*{global-radii-blocks}*/; } /* Buttons */ .ui-btn-corner-all, .ui-btn.ui-corner-all, /* Slider track */ .ui-slider-track.ui-corner-all, /* Flipswitch */ .ui-flipswitch.ui-corner-all, /* Count bubble */ .ui-li-count { -webkit-border-radius: .3125em /*{global-radii-buttons}*/; border-radius: .3125em /*{global-radii-buttons}*/; } /* Icon-only buttons */ .ui-btn-icon-notext.ui-btn-corner-all, .ui-btn-icon-notext.ui-corner-all { -webkit-border-radius: 1em; border-radius: 1em; } /* Radius clip workaround for cleaning up corner trapping */ .ui-btn-corner-all, .ui-corner-all { -webkit-background-clip: padding; background-clip: padding-box; } /* Popup arrow */ .ui-popup.ui-corner-all > .ui-popup-arrow-guide { left: .6em /*{global-radii-blocks}*/; right: .6em /*{global-radii-blocks}*/; top: .6em /*{global-radii-blocks}*/; bottom: .6em /*{global-radii-blocks}*/; } /* Shadow -----------------------------------------------------------------------------------------------------------*/ .ui-shadow { -webkit-box-shadow: 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; -moz-box-shadow: 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; box-shadow: 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; } .ui-shadow-inset { -webkit-box-shadow: inset 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; -moz-box-shadow: inset 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; box-shadow: inset 0 1px 3px /*{global-box-shadow-size}*/ rgba(0,0,0,.2) /*{global-box-shadow-color}*/; } .ui-overlay-shadow { -webkit-box-shadow: 0 0 12px rgba(0,0,0,.6); -moz-box-shadow: 0 0 12px rgba(0,0,0,.6); box-shadow: 0 0 12px rgba(0,0,0,.6); } /* Icons -----------------------------------------------------------------------------------------------------------*/ .ui-btn-icon-left:after, .ui-btn-icon-right:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after, .ui-btn-icon-notext:after { background-color: #666666 /*{global-icon-color}*/; background-color: rgba(0,0,0,.3) /*{global-icon-disc}*/; background-position: center center; background-repeat: no-repeat; -webkit-border-radius: 1em; border-radius: 1em; } /* Alt icons */ .ui-alt-icon.ui-btn:after, .ui-alt-icon .ui-btn:after, html .ui-alt-icon.ui-checkbox-off:after, html .ui-alt-icon.ui-radio-off:after, html .ui-alt-icon .ui-checkbox-off:after, html .ui-alt-icon .ui-radio-off:after { background-color: #666666 /*{global-icon-color}*/; background-color: rgba(0,0,0,.15); } /* No disc */ .ui-nodisc-icon.ui-btn:after, .ui-nodisc-icon .ui-btn:after { background-color: transparent; } /* Icon shadow */ .ui-shadow-icon.ui-btn:after, .ui-shadow-icon .ui-btn:after { -webkit-box-shadow: 0 1px 0 rgba(255,255,255,.3) /*{global-icon-shadow}*/; -moz-box-shadow: 0 1px 0 rgba(255,255,255,.3) /*{global-icon-shadow}*/; box-shadow: 0 1px 0 rgba(255,255,255,.3) /*{global-icon-shadow}*/; } /* Checkbox and radio */ .ui-btn.ui-checkbox-off:after, .ui-btn.ui-checkbox-on:after, .ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after { display: block; width: 18px; height: 18px; margin: -9px 2px 0 2px; } .ui-checkbox-off:after, .ui-btn.ui-radio-off:after { filter: Alpha(Opacity=30); opacity: .3; } .ui-btn.ui-checkbox-off:after, .ui-btn.ui-checkbox-on:after { -webkit-border-radius: .1875em; border-radius: .1875em; } .ui-radio .ui-btn.ui-radio-on:after { background-image: none; background-color: #fff; width: 8px; height: 8px; border-width: 5px; border-style: solid; } .ui-alt-icon.ui-btn.ui-radio-on:after, .ui-alt-icon .ui-btn.ui-radio-on:after { background-color: #000; } /* Loader */ .ui-icon-loading { background: url(images/ajax-loader.gif); background-size: 2.875em 2.875em; } /* Swatches */ /* A -----------------------------------------------------------------------------------------------------------*/ /* Bar: Toolbars, dividers, slider track */ .ui-bar-a, .ui-page-theme-a .ui-bar-inherit, html .ui-bar-a .ui-bar-inherit, html .ui-body-a .ui-bar-inherit, html body .ui-group-theme-a .ui-bar-inherit { background: #26393d /*{a-bar-background-color}*/; border-color: #fffae4 /*{a-bar-border}*/; color: #fffae4 /*{a-bar-color}*/; text-shadow: 1px /*{a-bar-shadow-x}*/ 1px /*{a-bar-shadow-y}*/ 2px /*{a-bar-shadow-radius}*/ #e8e595 /*{a-bar-shadow-color}*/; font-weight: bold; } .ui-bar-a { border-width: 1px; border-style: solid; } /* Page and overlay */ .ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper { background: #e8e595 /*{a-page-background-color}*/; border-color: #fffae4 /*{a-page-border}*/; color: #40627c /*{a-page-color}*/; text-shadow: 0 /*{a-page-shadow-x}*/ 1px /*{a-page-shadow-y}*/ 0 /*{a-page-shadow-radius}*/ #f3f3f3 /*{a-page-shadow-color}*/; } /* Body: Read-only lists, text inputs, collapsible content */ .ui-body-a, .ui-page-theme-a .ui-body-inherit, html .ui-bar-a .ui-body-inherit, html .ui-body-a .ui-body-inherit, html body .ui-group-theme-a .ui-body-inherit, html .ui-panel-page-container-a { background: #ffffff /*{a-body-background-color}*/; border-color: #d0a825 /*{a-body-border}*/; color: #26393d /*{a-body-color}*/; text-shadow: 0 /*{a-body-shadow-x}*/ 1px /*{a-body-shadow-y}*/ 0 /*{a-body-shadow-radius}*/ #f3f3f3 /*{a-body-shadow-color}*/; } .ui-body-a { border-width: 1px; border-style: solid; } /* Links */ .ui-page-theme-a a, html .ui-bar-a a, html .ui-body-a a, html body .ui-group-theme-a a { color: #26393d /*{a-link-color}*/; font-weight: bold; } .ui-page-theme-a a:visited, html .ui-bar-a a:visited, html .ui-body-a a:visited, html body .ui-group-theme-a a:visited { color: #293f50 /*{a-link-visited}*/; } .ui-page-theme-a a:hover, html .ui-bar-a a:hover, html .ui-body-a a:hover, html body .ui-group-theme-a a:hover { color: #d0a825 /*{a-link-hover}*/; } .ui-page-theme-a a:active, html .ui-bar-a a:active, html .ui-body-a a:active, html body .ui-group-theme-a a:active { color: #40627c /*{a-link-active}*/; } /* Button up */ .ui-page-theme-a .ui-btn, html .ui-bar-a .ui-btn, html .ui-body-a .ui-btn, html body .ui-group-theme-a .ui-btn, html head + body .ui-btn.ui-btn-a, /* Button visited */ .ui-page-theme-a .ui-btn:visited, html .ui-bar-a .ui-btn:visited, html .ui-body-a .ui-btn:visited, html body .ui-group-theme-a .ui-btn:visited, html head + body .ui-btn.ui-btn-a:visited { background: #fffae4 /*{a-bup-background-color}*/; border-color: #dddddd /*{a-bup-border}*/; color: #40627c /*{a-bup-color}*/; text-shadow: 0 /*{a-bup-shadow-x}*/ 1px /*{a-bup-shadow-y}*/ 0 /*{a-bup-shadow-radius}*/ #f3f3f3 /*{a-bup-shadow-color}*/; } /* Button hover */ .ui-page-theme-a .ui-btn:hover, html .ui-bar-a .ui-btn:hover, html .ui-body-a .ui-btn:hover, html body .ui-group-theme-a .ui-btn:hover, html head + body .ui-btn.ui-btn-a:hover { background: #ededed /*{a-bhover-background-color}*/; border-color: #dddddd /*{a-bhover-border}*/; color: #333333 /*{a-bhover-color}*/; text-shadow: 0 /*{a-bhover-shadow-x}*/ 1px /*{a-bhover-shadow-y}*/ 0 /*{a-bhover-shadow-radius}*/ #f3f3f3 /*{a-bhover-shadow-color}*/; } /* Button down */ .ui-page-theme-a .ui-btn:active, html .ui-bar-a .ui-btn:active, html .ui-body-a .ui-btn:active, html body .ui-group-theme-a .ui-btn:active, html head + body .ui-btn.ui-btn-a:active { background: #e8e8e8 /*{a-bdown-background-color}*/; border-color: #dddddd /*{a-bdown-border}*/; color: #d0a825 /*{a-bdown-color}*/; text-shadow: 0 /*{a-bdown-shadow-x}*/ 1px /*{a-bdown-shadow-y}*/ 0 /*{a-bdown-shadow-radius}*/ #f3f3f3 /*{a-bdown-shadow-color}*/; } /* Active button */ .ui-page-theme-a .ui-btn.ui-btn-active, html .ui-bar-a .ui-btn.ui-btn-active, html .ui-body-a .ui-btn.ui-btn-active, html body .ui-group-theme-a .ui-btn.ui-btn-active, html head + body .ui-btn.ui-btn-a.ui-btn-active, /* Active checkbox icon */ .ui-page-theme-a .ui-checkbox-on:after, html .ui-bar-a .ui-checkbox-on:after, html .ui-body-a .ui-checkbox-on:after, html body .ui-group-theme-a .ui-checkbox-on:after, .ui-btn.ui-checkbox-on.ui-btn-a:after, /* Active flipswitch background */ .ui-page-theme-a .ui-flipswitch-active, html .ui-bar-a .ui-flipswitch-active, html .ui-body-a .ui-flipswitch-active, html body .ui-group-theme-a .ui-flipswitch-active, html body .ui-flipswitch.ui-bar-a.ui-flipswitch-active, /* Active slider track */ .ui-page-theme-a .ui-slider-track .ui-btn-active, html .ui-bar-a .ui-slider-track .ui-btn-active, html .ui-body-a .ui-slider-track .ui-btn-active, html body .ui-group-theme-a .ui-slider-track .ui-btn-active, html body div.ui-slider-track.ui-body-a .ui-btn-active { background-color: #3388cc /*{a-active-background-color}*/; border-color: #3388cc /*{a-active-border}*/; color: #ffffff /*{a-active-color}*/; text-shadow: 0 /*{a-active-shadow-x}*/ 1px /*{a-active-shadow-y}*/ 0 /*{a-active-shadow-radius}*/ #005599 /*{a-active-shadow-color}*/; } /* Active radio button icon */ .ui-page-theme-a .ui-radio-on:after, html .ui-bar-a .ui-radio-on:after, html .ui-body-a .ui-radio-on:after, html body .ui-group-theme-a .ui-radio-on:after, .ui-btn.ui-radio-on.ui-btn-a:after { border-color: #3388cc /*{a-active-background-color}*/; } /* Focus */ .ui-page-theme-a .ui-btn:focus, html .ui-bar-a .ui-btn:focus, html .ui-body-a .ui-btn:focus, html body .ui-group-theme-a .ui-btn:focus, html head + body .ui-btn.ui-btn-a:focus, /* Focus buttons and text inputs with div wrap */ .ui-page-theme-a .ui-focus, html .ui-bar-a .ui-focus, html .ui-body-a .ui-focus, html body .ui-group-theme-a .ui-focus, html head + body .ui-btn-a.ui-focus, html head + body .ui-body-a.ui-focus { -webkit-box-shadow: 0 0 12px #3388cc /*{a-active-background-color}*/; -moz-box-shadow: 0 0 12px #3388cc /*{a-active-background-color}*/; box-shadow: 0 0 12px #3388cc /*{a-active-background-color}*/; } /* B -----------------------------------------------------------------------------------------------------------*/ /* Bar: Toolbars, dividers, slider track */ .ui-bar-b, .ui-page-theme-b .ui-bar-inherit, html .ui-bar-b .ui-bar-inherit, html .ui-body-b .ui-bar-inherit, html body .ui-group-theme-b .ui-bar-inherit { background: #e9e9e9 /*{b-bar-background-color}*/; border-color: #dddddd /*{b-bar-border}*/; color: #333333 /*{b-bar-color}*/; text-shadow: 0 /*{b-bar-shadow-x}*/ 1px /*{b-bar-shadow-y}*/ 0 /*{b-bar-shadow-radius}*/ #eeeeee /*{b-bar-shadow-color}*/; font-weight: bold; } .ui-bar-b { border-width: 1px; border-style: solid; } /* Page and overlay */ .ui-overlay-b, .ui-page-theme-b, .ui-page-theme-b .ui-panel-wrapper { background: #f9f9f9 /*{b-page-background-color}*/; border-color: #bbbbbb /*{b-page-border}*/; color: #333333 /*{b-page-color}*/; text-shadow: 0 /*{b-page-shadow-x}*/ 1px /*{b-page-shadow-y}*/ 0 /*{b-page-shadow-radius}*/ #f3f3f3 /*{b-page-shadow-color}*/; } /* Body: Read-only lists, text inputs, collapsible content */ .ui-body-b, .ui-page-theme-b .ui-body-inherit, html .ui-bar-b .ui-body-inherit, html .ui-body-b .ui-body-inherit, html body .ui-group-theme-b .ui-body-inherit, html .ui-panel-page-container-b { background: #ffffff /*{b-body-background-color}*/; border-color: #dddddd /*{b-body-border}*/; color: #333333 /*{b-body-color}*/; text-shadow: 0 /*{b-body-shadow-x}*/ 1px /*{b-body-shadow-y}*/ 0 /*{b-body-shadow-radius}*/ #f3f3f3 /*{b-body-shadow-color}*/; } .ui-body-b { border-width: 1px; border-style: solid; } /* Links */ .ui-page-theme-b a, html .ui-bar-b a, html .ui-body-b a, html body .ui-group-theme-b a { color: #3388cc /*{b-link-color}*/; font-weight: bold; } .ui-page-theme-b a:visited, html .ui-bar-b a:visited, html .ui-body-b a:visited, html body .ui-group-theme-b a:visited { color: #3388cc /*{b-link-visited}*/; } .ui-page-theme-b a:hover, html .ui-bar-b a:hover, html .ui-body-b a:hover, html body .ui-group-theme-b a:hover { color: #005599 /*{b-link-hover}*/; } .ui-page-theme-b a:active, html .ui-bar-b a:active, html .ui-body-b a:active, html body .ui-group-theme-b a:active { color: #005599 /*{b-link-active}*/; } /* Button up */ .ui-page-theme-b .ui-btn, html .ui-bar-b .ui-btn, html .ui-body-b .ui-btn, html body .ui-group-theme-b .ui-btn, html head + body .ui-btn.ui-btn-b, /* Button visited */ .ui-page-theme-b .ui-btn:visited, html .ui-bar-b .ui-btn:visited, html .ui-body-b .ui-btn:visited, html body .ui-group-theme-b .ui-btn:visited, html head + body .ui-btn.ui-btn-b:visited { background: #f6f6f6 /*{b-bup-background-color}*/; border-color: #dddddd /*{b-bup-border}*/; color: #333333 /*{b-bup-color}*/; text-shadow: 0 /*{b-bup-shadow-x}*/ 1px /*{b-bup-shadow-y}*/ 0 /*{b-bup-shadow-radius}*/ #f3f3f3 /*{b-bup-shadow-color}*/; } /* Button hover */ .ui-page-theme-b .ui-btn:hover, html .ui-bar-b .ui-btn:hover, html .ui-body-b .ui-btn:hover, html body .ui-group-theme-b .ui-btn:hover, html head + body .ui-btn.ui-btn-b:hover { background: #ededed /*{b-bhover-background-color}*/; border-color: #dddddd /*{b-bhover-border}*/; color: #333333 /*{b-bhover-color}*/; text-shadow: 0 /*{b-bhover-shadow-x}*/ 1px /*{b-bhover-shadow-y}*/ 0 /*{b-bhover-shadow-radius}*/ #f3f3f3 /*{b-bhover-shadow-color}*/; } /* Button down */ .ui-page-theme-b .ui-btn:active, html .ui-bar-b .ui-btn:active, html .ui-body-b .ui-btn:active, html body .ui-group-theme-b .ui-btn:active, html head + body .ui-btn.ui-btn-b:active { background: #e8e8e8 /*{b-bdown-background-color}*/; border-color: #dddddd /*{b-bdown-border}*/; color: #333333 /*{b-bdown-color}*/; text-shadow: 0 /*{b-bdown-shadow-x}*/ 1px /*{b-bdown-shadow-y}*/ 0 /*{b-bdown-shadow-radius}*/ #f3f3f3 /*{b-bdown-shadow-color}*/; } /* Active button */ .ui-page-theme-b .ui-btn.ui-btn-active, html .ui-bar-b .ui-btn.ui-btn-active, html .ui-body-b .ui-btn.ui-btn-active, html body .ui-group-theme-b .ui-btn.ui-btn-active, html head + body .ui-btn.ui-btn-b.ui-btn-active, /* Active checkbox icon */ .ui-page-theme-b .ui-checkbox-on:after, html .ui-bar-b .ui-checkbox-on:after, html .ui-body-b .ui-checkbox-on:after, html body .ui-group-theme-b .ui-checkbox-on:after, .ui-btn.ui-checkbox-on.ui-btn-b:after, /* Active flipswitch background */ .ui-page-theme-b .ui-flipswitch-active, html .ui-bar-b .ui-flipswitch-active, html .ui-body-b .ui-flipswitch-active, html body .ui-group-theme-b .ui-flipswitch-active, html body .ui-flipswitch.ui-bar-b.ui-flipswitch-active, /* Active slider track */ .ui-page-theme-b .ui-slider-track .ui-btn-active, html .ui-bar-b .ui-slider-track .ui-btn-active, html .ui-body-b .ui-slider-track .ui-btn-active, html body .ui-group-theme-b .ui-slider-track .ui-btn-active, html body div.ui-slider-track.ui-body-b .ui-btn-active { background-color: #3388cc /*{b-active-background-color}*/; border-color: #3388cc /*{b-active-border}*/; color: #ffffff /*{b-active-color}*/; text-shadow: 0 /*{b-active-shadow-x}*/ 1px /*{b-active-shadow-y}*/ 0 /*{b-active-shadow-radius}*/ #005599 /*{b-active-shadow-color}*/; } /* Active radio button icon */ .ui-page-theme-b .ui-radio-on:after, html .ui-bar-b .ui-radio-on:after, html .ui-body-b .ui-radio-on:after, html body .ui-group-theme-b .ui-radio-on:after, .ui-btn.ui-radio-on.ui-btn-b:after { border-color: #3388cc /*{b-active-background-color}*/; } /* Focus */ .ui-page-theme-b .ui-btn:focus, html .ui-bar-b .ui-btn:focus, html .ui-body-b .ui-btn:focus, html body .ui-group-theme-b .ui-btn:focus, html head + body .ui-btn.ui-btn-b:focus, /* Focus buttons and text inputs with div wrap */ .ui-page-theme-b .ui-focus, html .ui-bar-b .ui-focus, html .ui-body-b .ui-focus, html body .ui-group-theme-b .ui-focus, html head + body .ui-btn-b.ui-focus, html head + body .ui-body-b.ui-focus { -webkit-box-shadow: 0 0 12px #3388cc /*{b-active-background-color}*/; -moz-box-shadow: 0 0 12px #3388cc /*{b-active-background-color}*/; box-shadow: 0 0 12px #3388cc /*{b-active-background-color}*/; } /* C -----------------------------------------------------------------------------------------------------------*/ /* Bar: Toolbars, dividers, slider track */ .ui-bar-c, .ui-page-theme-c .ui-bar-inherit, html .ui-bar-c .ui-bar-inherit, html .ui-body-c .ui-bar-inherit, html body .ui-group-theme-c .ui-bar-inherit { background: #e9e9e9 /*{c-bar-background-color}*/; border-color: #dddddd /*{c-bar-border}*/; color: #333333 /*{c-bar-color}*/; text-shadow: 0 /*{c-bar-shadow-x}*/ 1px /*{c-bar-shadow-y}*/ 0 /*{c-bar-shadow-radius}*/ #eeeeee /*{c-bar-shadow-color}*/; font-weight: bold; } .ui-bar-c { border-width: 1px; border-style: solid; } /* Page and overlay */ .ui-overlay-c, .ui-page-theme-c, .ui-page-theme-c .ui-panel-wrapper { background: #f9f9f9 /*{c-page-background-color}*/; border-color: #bbbbbb /*{c-page-border}*/; color: #333333 /*{c-page-color}*/; text-shadow: 0 /*{c-page-shadow-x}*/ 1px /*{c-page-shadow-y}*/ 0 /*{c-page-shadow-radius}*/ #f3f3f3 /*{c-page-shadow-color}*/; } /* Body: Read-only lists, text inputs, collapsible content */ .ui-body-c, .ui-page-theme-c .ui-body-inherit, html .ui-bar-c .ui-body-inherit, html .ui-body-c .ui-body-inherit, html body .ui-group-theme-c .ui-body-inherit, html .ui-panel-page-container-c { background: #ffffff /*{c-body-background-color}*/; border-color: #dddddd /*{c-body-border}*/; color: #333333 /*{c-body-color}*/; text-shadow: 0 /*{c-body-shadow-x}*/ 1px /*{c-body-shadow-y}*/ 0 /*{c-body-shadow-radius}*/ #f3f3f3 /*{c-body-shadow-color}*/; } .ui-body-c { border-width: 1px; border-style: solid; } /* Links */ .ui-page-theme-c a, html .ui-bar-c a, html .ui-body-c a, html body .ui-group-theme-c a { color: #3388cc /*{c-link-color}*/; font-weight: bold; } .ui-page-theme-c a:visited, html .ui-bar-c a:visited, html .ui-body-c a:visited, html body .ui-group-theme-c a:visited { color: #3388cc /*{c-link-visited}*/; } .ui-page-theme-c a:hover, html .ui-bar-c a:hover, html .ui-body-c a:hover, html body .ui-group-theme-c a:hover { color: #005599 /*{c-link-hover}*/; } .ui-page-theme-c a:active, html .ui-bar-c a:active, html .ui-body-c a:active, html body .ui-group-theme-c a:active { color: #005599 /*{c-link-active}*/; } /* Button up */ .ui-page-theme-c .ui-btn, html .ui-bar-c .ui-btn, html .ui-body-c .ui-btn, html body .ui-group-theme-c .ui-btn, html head + body .ui-btn.ui-btn-c, /* Button visited */ .ui-page-theme-c .ui-btn:visited, html .ui-bar-c .ui-btn:visited, html .ui-body-c .ui-btn:visited, html body .ui-group-theme-c .ui-btn:visited, html head + body .ui-btn.ui-btn-c:visited { background: #f6f6f6 /*{c-bup-background-color}*/; border-color: #dddddd /*{c-bup-border}*/; color: #333333 /*{c-bup-color}*/; text-shadow: 0 /*{c-bup-shadow-x}*/ 1px /*{c-bup-shadow-y}*/ 0 /*{c-bup-shadow-radius}*/ #f3f3f3 /*{c-bup-shadow-color}*/; } /* Button hover */ .ui-page-theme-c .ui-btn:hover, html .ui-bar-c .ui-btn:hover, html .ui-body-c .ui-btn:hover, html body .ui-group-theme-c .ui-btn:hover, html head + body .ui-btn.ui-btn-c:hover { background: #ededed /*{c-bhover-background-color}*/; border-color: #dddddd /*{c-bhover-border}*/; color: #333333 /*{c-bhover-color}*/; text-shadow: 0 /*{c-bhover-shadow-x}*/ 1px /*{c-bhover-shadow-y}*/ 0 /*{c-bhover-shadow-radius}*/ #f3f3f3 /*{c-bhover-shadow-color}*/; } /* Button down */ .ui-page-theme-c .ui-btn:active, html .ui-bar-c .ui-btn:active, html .ui-body-c .ui-btn:active, html body .ui-group-theme-c .ui-btn:active, html head + body .ui-btn.ui-btn-c:active { background: #e8e8e8 /*{c-bdown-background-color}*/; border-color: #dddddd /*{c-bdown-border}*/; color: #333333 /*{c-bdown-color}*/; text-shadow: 0 /*{c-bdown-shadow-x}*/ 1px /*{c-bdown-shadow-y}*/ 0 /*{c-bdown-shadow-radius}*/ #f3f3f3 /*{c-bdown-shadow-color}*/; } /* Active button */ .ui-page-theme-c .ui-btn.ui-btn-active, html .ui-bar-c .ui-btn.ui-btn-active, html .ui-body-c .ui-btn.ui-btn-active, html body .ui-group-theme-c .ui-btn.ui-btn-active, html head + body .ui-btn.ui-btn-c.ui-btn-active, /* Active checkbox icon */ .ui-page-theme-c .ui-checkbox-on:after, html .ui-bar-c .ui-checkbox-on:after, html .ui-body-c .ui-checkbox-on:after, html body .ui-group-theme-c .ui-checkbox-on:after, .ui-btn.ui-checkbox-on.ui-btn-c:after, /* Active flipswitch background */ .ui-page-theme-c .ui-flipswitch-active, html .ui-bar-c .ui-flipswitch-active, html .ui-body-c .ui-flipswitch-active, html body .ui-group-theme-c .ui-flipswitch-active, html body .ui-flipswitch.ui-bar-c.ui-flipswitch-active, /* Active slider track */ .ui-page-theme-c .ui-slider-track .ui-btn-active, html .ui-bar-c .ui-slider-track .ui-btn-active, html .ui-body-c .ui-slider-track .ui-btn-active, html body .ui-group-theme-c .ui-slider-track .ui-btn-active, html body div.ui-slider-track.ui-body-c .ui-btn-active { background-color: #3388cc /*{c-active-background-color}*/; border-color: #3388cc /*{c-active-border}*/; color: #ffffff /*{c-active-color}*/; text-shadow: 0 /*{c-active-shadow-x}*/ 1px /*{c-active-shadow-y}*/ 0 /*{c-active-shadow-radius}*/ #005599 /*{c-active-shadow-color}*/; } /* Active radio button icon */ .ui-page-theme-c .ui-radio-on:after, html .ui-bar-c .ui-radio-on:after, html .ui-body-c .ui-radio-on:after, html body .ui-group-theme-c .ui-radio-on:after, .ui-btn.ui-radio-on.ui-btn-c:after { border-color: #3388cc /*{c-active-background-color}*/; } /* Focus */ .ui-page-theme-c .ui-btn:focus, html .ui-bar-c .ui-btn:focus, html .ui-body-c .ui-btn:focus, html body .ui-group-theme-c .ui-btn:focus, html head + body .ui-btn.ui-btn-c:focus, /* Focus buttons and text inputs with div wrap */ .ui-page-theme-c .ui-focus, html .ui-bar-c .ui-focus, html .ui-body-c .ui-focus, html body .ui-group-theme-c .ui-focus, html head + body .ui-btn-c.ui-focus, html head + body .ui-body-c.ui-focus { -webkit-box-shadow: 0 0 12px #3388cc /*{c-active-background-color}*/; -moz-box-shadow: 0 0 12px #3388cc /*{c-active-background-color}*/; box-shadow: 0 0 12px #3388cc /*{c-active-background-color}*/; } /* Structure */ /* Disabled -----------------------------------------------------------------------------------------------------------*/ /* Class ui-disabled deprecated in 1.4. :disabled not supported by IE8 so we use [disabled] */ .ui-disabled, .ui-state-disabled, button[disabled], .ui-select .ui-btn.ui-state-disabled { filter: Alpha(Opacity=30); opacity: .3; cursor: default !important; pointer-events: none; } /* Focus state outline -----------------------------------------------------------------------------------------------------------*/ .ui-btn:focus, .ui-btn.ui-focus { outline: 0; } /* Unset box-shadow in browsers that don't do it right */ .ui-noboxshadow .ui-shadow, .ui-noboxshadow .ui-shadow-inset, .ui-noboxshadow .ui-overlay-shadow, .ui-noboxshadow .ui-shadow-icon.ui-btn:after, .ui-noboxshadow .ui-shadow-icon .ui-btn:after, .ui-noboxshadow .ui-focus, .ui-noboxshadow .ui-btn:focus, .ui-noboxshadow input:focus, .ui-noboxshadow .ui-panel { -webkit-box-shadow: none !important; -moz-box-shadow: none !important; box-shadow: none !important; } .ui-noboxshadow .ui-btn:focus, .ui-noboxshadow .ui-focus { outline-width: 1px; outline-style: auto; }
123-asdf
trunk/phone/themes/forafreeworld.css
CSS
mit
25,570
<!DOCTYPE html> <html> <head> <title>For A Free World - Mobile</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="themes/forafreeworld.min.css" /> <link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile.structure-1.4.0.min.css" /> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>For A Free World - Mobile</h1> </div> <div role="main" class="ui-content"> <div id="home" data-role="collapsible" data-collapsed="false"> <h4>Home</h4> <!-- minipicture of main background --> <p>Welcome to Be Free Web Design Studio's Mobile Page !</p> <p>Be Free Web Design Studio is a small team which specializes in providing full-scope web services to clients around the Free World of Earth. We are based in Sofia, Bulgaria (Southeastern Europe). Currently the Team consists of Nikolay Ivanov - Web Designer, and Denislav Dimitrov - Web Developer. Some of the services we provide are: Website creation, website updates, redesign, creative design, logo and banner design, security updates, Wordpress site management, database optimization and maintenance, server-side web services.</p> </div> <div id="about" data-role="collapsible"> <h4>About Us</h4> <p> <h4>Nikolay, The Designer</h4> <!-- href minipicture of Niki --> I build and design beautiful websites.<br/> <h7>Skills:</h7> <ul> <li>HTML5</li> <li>CSS3</li> <li>Photoshop</li> <li>Banner Design</li> <li>Responsive Design</li> </ul> </p> <p> <h4>Denislav, The Developer</h4> <!-- href minipicture of Deni --> I work with APIs, databases and servers.<br/> <h7>Skills:</h7> <ul> <li>Javascript</li> <li>jQuery and AJAX</li> <li>PHP</li> <li>MySQL</li> <li>CMS / WordPress</li> </ul> </p> </div> <div id="process" data-role="collapsible"> <h4>Process and Workflow</h4> <p>We value our customer's time and our own time, this is why we have an informal workflow process in place. It guarantees high-quality deliverables and great resource optimization.</p> <ul> <li>Meeting You</li><br/> <li>Project Planning</li><br/> <li>Mockup project build ready</li><br/> <li>Client suggestions</li><br/> <li>The Hardcore Coding</li><br/> <li>Performance Optimization</li><br/> <li>Draft Deliverable ready</li><br/> <li>Client Review and Final Product</li><br/> </ul> </div> <div id="work" data-role="collapsible"> <h4>Our Portfolio:</h4> Teniskashop | <a href="http://teniskashop.eu/">http://teniskashop.eu/</a><br/> <i>Photoshop, HTML5, CSS3, Javascript/jQuery, AJAX, PHP, Apache 2/cPanel</i><br/><br/> Academic Boxing Club | <a href="http://academicboxingclub.org/">http://academicboxingclub.org/</a><br/> <i>Graphic Design, HTML5, CSS3, Javascript/jQuery, PHP, MySQL</i><br/><br/> Kineziterapia.bg | <a href="http://kineziterapia.bg/">http://kineziterapia.bg/</a><br/> <i>HTML5, CSS3, Javascript/jQuery, PHP, MySQL</i><br/><br/> Extravagant | <a href="http://extravagant.io/">http://extravagant.io/</a><br/> <i>Photoshop, HTML5, CSS3, Javascript/jQuery, JS Bootstrap, Javascript History, AJAX, Flash, Responsive Design, Custom Animations, Custom Transitions, Custom UI, Custom Effects/Textures</i><br/><br/> </div> <div id="contact" data-role="collapsible"> <h4>Get in touch with us</h4> <p> <form method="POST" action="http:///forafreeworld.com/#Contact"> <input type="text" name="name_short" placeholder="Name"> <input type="text" name="email_short" placeholder="Email Address"> <textarea name="question_short" placeholder="What do you have in mind"></textarea> <input type="submit" name="submit" value="SEND OVER"> </form> </p> </div> <br/><hr> <span> Visit our blog to stay tuned: <a class="ui-shadow ui-btn ui-corner-all ui-btn-inline ui-btn-a ui-mini" href="http://blog.forafreeworld.com/" target="_blank">Go to Blog (new window)</a> </span> </div> <div data-role="footer"> <h6>&copy; 2014 FORAFREEWORLD.COM . All rights reserved.</h6> </div> </div> </body> </html>
123-asdf
trunk/phone/index.html
HTML
mit
4,715
<?php error_reporting(0); //redirect for mobile (excl. tablets) include '../includes/Mobile_Detect.php'; $detect = new Mobile_Detect; if( $detect->isMobile() && !$detect->isTablet() ){ Header("Location: http://phone.forafreeworld.com/"); exit; } Header("Cache-Control: public, max-age=2592000"); Header("Content-Type: text/html; charset=utf-8"); mb_internal_encoding("UTF-8"); $message = array(); $mailed = false; $budget_checked = false; $project_type_checked = false; if($_POST) { //USER INPUT NORMALIZATION if(isset($_POST['name_detail'])) { $name = htmlspecialchars(trim($_POST['name_detail'])); $email = htmlspecialchars(trim($_POST['email_detail'])); $phone = htmlspecialchars(trim($_POST['phone_detail'])); $company = htmlspecialchars(trim($_POST['company_detail'])); $budget = $_POST['budget']; $project_type = $_POST['project_type']; $question = htmlspecialchars($_POST['question_detail']); $detail = true; } if(isset($_POST['name_short'])) { $name = htmlspecialchars(trim($_POST['name_short'])); $email = htmlspecialchars(trim($_POST['email_short'])); $question = htmlspecialchars($_POST['question_short']); $phone = ""; $company = ""; $budget = ""; $project_type = ""; } //USER INPUT VALIDATION if(mb_strlen($name) < 3) { $message[] = "Der Name muss länger als 3 Zeichen sein."; } if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $message[] = "Bitte geben Sie eine gültige E-Mail ein."; } if(isset($detail) && (int)mb_strlen($phone) < 7) { $message[] = "Bitte geben Sie eine gültige Telefonnummer, Vorwahl inklusiv, ein."; } if(mb_strlen($question) < 20) { $message[] = "Die Anfrage sollte 20 Zeichen oder länger sein."; } //send email if no input validation successful if(count($message) == 0) { $mail_msg = "<html><head></head><body> Kundenname (customer name): ".$name."<br/>". "Kundenemail: ".$email."<br/>". "Telefonnummer: ".$phone."<br/>". "Firma: ".$company."<br/>". "Budget: ".$budget."<br/>". "Projekttyp: ".$project_type."<br/>". "Anfrage: ".$question."<br/></body></html>"; $mail_msg = wordwrap($mail_msg, 70, "\r\n"); $mailed = @mail('az3@abv.bg', 'forafreeworld.com Customer Enquiry - DE', $mail_msg, 'Content-type: text/html; charset=utf-8' . "\r\n"); if($mailed) { $message[] = "Die Anfrage wurde erfolreich weitergeleitet. Wir werden mit Ihnen baldmöglichst in Kontakt treten."; } else { $message[] = "Fehler beim Senden der Anfrage - bitte versuchen Sie ein bisschen später nochmals."; } } } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="author" content="Faszinierendes Webdesign"/> <meta name="description" content="Webgestaltungsstudio Be Free ist ein kleines Team, das in Internet- und Webseitedienstleistungen an Kunden irgendwo auf der Freien Welt spezialisiert. Wir befinden uns in Sofia, Bulgarien (Osteuropa). Momentan besteht das Team aus zwei Spezialisten: Nikolay Ivanov - Webdesigner, und Denislav Dimitrov - Webentwickler. Unter der von uns angebotenen Dienstleistungen zählen: komplette Erstellung von Webseiten, Webseite Änderungen und Updates, Neugestaltung, kreative Gestaltung, Logo- und Bannergestaltung, Sicherheitsaktualisierungen, Datenbankenoptimisation und -Versorgung, Webdienste seitens des Server."/> <meta name="Keywords" content="Webseite, Webdesign, Webentwicklung, Wordpress Seiten, reaktionsfähiges Webdesign, Datenbankenaufrechterhaltung, Datensicherheit"/> <meta name="googlebot" content="all"/> <link href="../img/favicon.ico" rel="shortcut icon"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Webdesign für eine Freie Welt!</title> <!--[if lte IE 9]> <script src="../shivs/html5shiv/html5shiv.js"></script> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![endif]--> <!--[if IE 9 ]> <html class="ie9"> <![endif]--> <!--[if IE ]> <html class="ie"> <![endif]--> <link rel="stylesheet" type="text/css" href="../css/style.css"/> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="../js/jquery.placeholder.js"></script> <script src="../js/main.js"></script> <script src="../js/side-nav.js"></script> <script src="../js/backgrounds.js"></script> <script src="../js/kinetics.js"></script> <script src="../js/parallax.js"></script> </head> <body> <div id="mock-scroller"> </div> <ul id="nav"> </ul> <!-- WEB CONTENT --> <div id="content"> <section id="section-Anfang"> <img class="bg animate" src="../img/bg.jpg" anim-detached="true"/> <header id="container_header"> <div id="header_holder"> <div id="copyright"> <p> &copy; Forafreeworld.com. Alle Rechte vorbehalten. </p> </div> <div id="social_lang_holder"> <div id="social"> <ul> <li><a href="https://www.facebook.com/pages/Be-Free-Web-Design-Studio/561352003933342" target="_blank"><img src="../img/facebook.png" alt=""></a></li> <li><a href="https://twitter.com/be_free_studio" target="_blank"><img src="../img/twitter.png" alt=""></a></li> <li><a href="https://plus.google.com/communities/115431413168700794942" target="_blank"><img src="../img/google.png" alt=""></a></li> </ul> </div> <div id="lang"> <ul> <li><a href="http://forafreeworld.com/">en</a></li> <li><a href="http://forafreeworld.com/de/">de</a></li> <li><a href="http://forafreeworld.com/bg/"><span id="separate_it">bg</span></a></li> </ul> </div> <div id="logo"> <img src="../img/logo.png" alt=""> </div> </div> </div> <div id="second_header"> <div id="left_info"> <ul> <li> <span class="where_we_at">E-Mail</span> <span class="where_we_at_left">welcome@forafreeworld.com</span> </li> <li><span class="where_we_at">Telefonnr.</span> <span class="where_we_at_left">+359 877 36 55 44</span> </li> <li><span class="where_we_at">Adresse</span> <span class="where_we_at_left">Sofia, Bulgarien, Reduta 80</span> </li> </ul> </div> <div id="right_info"> <div id="icons_holder"> <ul> <li><img src="../img/ps.png" alt=""></li> <li><img src="../img/css3.png" alt=""></li> <li><img src="../img/wordpress.png" alt=""></li> <li><img src="../img/ie.png" alt=""></li> <li><img src="../img/mysql.png" alt=""></li> <li><img src="../img/javascript.png" alt=""></li> <li><img src="../img/php.png" alt=""></li> </ul> </div> </div> </div> </header> <!--Billboard--> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <div id="slogan"> <h2>WIR GLAUBEN, DASS DIR EINE <br/> WEBSEITE FREIHEIT GEWÄHRT</h2> </div> <div id="be_free_button_holder"> <a href="#Kontakt"><span id="be_free_button">SEI FREI</span></a> </div> <div id="container_nav_holder"> <nav id="container_nav"> <ul> <li><a href="#"><img src="../img/home.png" alt=""></a></li> <li><a href="#">Leute</a></li> <li><a href="#">Prozess</a></li> <li><a href="#">Projekte</a></li> <li><a href="#">Kontakt</a></li> <li><a href="#">Blog</a></li> </ul> </nav> </div> </section> <section id="section-Leute"> <img class="bg animate" src="../img/about_us_bg.jpg" anim-detached="true"/> <div id="about_us"> <h2>Die freien Leute</h2> <div class="player_holder"> <div class="players"> <h3>Nikolay Ivanov</h3> <h4>Der Webdesigner</h4> <img src="../img/niko.png" alt=""> <p> HTML5 <br/> CSS3<br/> Photoshop<br/> Bannergestaltung<br/> Reaktionsfähiges<br/> &nbsp;Design<br/> </p> </div> <div class="about_the_players"> <p> ¡hola! Mein Name ist Nikolay, der Webdesigner unseres Studios. Ich spezialisiere mich auf das Planen und die Gestaltung von Webseiten von Grund auf, da ich so meine Schaffenskraft ausdrücken kann. Meine Kompetenzen reichen von ausgezeichneten HTML5 und CSS3 Kenntnissen über gute Photoshopkenntnisse bis zu ansprechenden Designs. Was mich am meisten fasziniert, sind Projekte, bei denen ich etwas von mir dazugeben kann, indem ich mit kleinen Details der Webseite einen besonders stimmigen Gesamteindruck geben kann, bzw. einzigartige Seiten für einzigartige Firmen schaffe. </p> </div> </div> <div class="player_holder"> <div class="players"> <h3>Denislav Dimitrov</h3> <h4>Der Webentwickler</h4> <img src="../img/denkata.png" alt=""> <p> Javascript<br/> jQuery und AJAX<br/> PHP<br/> MySQL<br/> CMS / WordPress<br/> </p> </div> <div class="about_the_players"> <p> Einige Worte über mich: Ich existiere in meiner eigenen Realität, wo alles seinen Platz und Zweck hat. Ich "spiele" gerne mit PHP und MySQL herum, das ist mein Job und mein Hobby. Meine berufliche Tätigkeit besteht darin, für Ihre Webseite eine geordnete und wartungsfreundliche Struktur zu erstellen, wobei ich ein benutzerfreundliches CMS-System, hohes Niveau von Informationssicherheit und eine optimierte Datenbank anwende. Als der Webentwickler bin ich auch für die Serververwaltung, Cachespeicherung der Daten und Dataminingprävention verantwortlich. </p> </div> </div> </div> </section> <section id="section-Prozess"> <img class="bg animate" src="../img/how_we_work_bg.png" anim-detached="true"/> <div id="how_we_work"> <h2>Prozess</h2> <div class="how_we_work_nav"> <ul> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons b_active">Projekt Anfang</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Design und Kodieren</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Endprodukt</span> </div> </a></li> </ul> </div> <div id="meeting" class="slides_work"> <h2>Projekt Kennerlernen</h2> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/meet_the_customer.png" alt=""> </div> <p> Am Anfang treffen wir uns mit dem Kunden und versuchen ihn, sein Geschäft und seine Ziele kennenzulernen. Das wird später äußerst wichtig sein, wenn wir zusätzlichen Wert zum Projekt des Arbeitgebers anbringen, indem wir Prozessverbesserungen und fachlichen Rat, auf der Webseite gerichtet, aufstellen. Wir glauben fest, dass man den Anderen zuerst als Menschen behandeln sollte, da wir alle letztendlich gemeinsame Lebenszwecke teilen. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/thinking_and_creating.png" alt=""> </div> <p id="thinking_parg"> Bevor wir selbst eine Zeile Code schreiben (und wir schreiben viele Zeilen!), nehmen wir ruhig Platz und besprechen, wie wir uns die Projektentfaltung vorstellen. Was zielt die Webseite? Sollte sie neue Kunden werben, oder vielleicht Leute neugierig machen und einzigartiger Inhalt gewähren? Muss sie etwas verkaufen oder sagen wir mal Mittel für etwas sammeln? Wir erstellen den Arbeitsplan und klären die Unklarheiten mit dem Kunden. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/mockup.png" alt=""> </div> <p id="mockup_text"> Wenn wir den Plan haben, beginnen wir das Modell der Webseite zu bilden. Zuerst erstellen wir eine grobe schwarz-und-weiße Variante, damit wir diese mit dem Arbeitsgeber früh im Arbeitsprozess besprechen können. Während dieser Etappe hören wir im Prinzip genau dem Kunden zu, aber falls es nötig ist, können wir auch unseres Traumbild für die Webseite darstellen. Der Konsensus mit dem Arbeitsgeber diesbezüglich bezeichnet auch das Ende der Anfangsphase des Projekts. </p> </div> </div> <div id="coding_part" class="slides_work"> <h2>Design und Kodieren - hier spielt sich der Zauber ab</h2> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info"> Wir betonen die kleinen, aber wichtigen Einzelheiten - Fonts, Farben.. </div> <div class="desing_and_coding_info lower"> Logo- und Bannergestaltung sind wichtiges Teil Ihrer Webpräsenz </div> <div class="desing_and_coding_info"> Wir erstellen SEO-optimisierten, puren HTML5 und CSS3 - Code </div> </div> <img src="../img/fireworks.jpg" alt=""> </div> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info lower"> Eine respektvolle Webseite muss heutzutage dynamischen Inhalt aufweisen </div> <div class="desing_and_coding_info"> Hier kommen die Systems für Inhaltsverwaltung und das Serverprogrammieren </div> <div class="desing_and_coding_info lower"> Wir fassen die letzten Webtechnologien und kreatives Denken zusammen, um die beste Webseite zu erstellen </div> </div> <img src="../img/brackets.jpg" alt=""> </div> </div> <div id="end_work" class="slides_work"> <h2>Was kriegen Sie am Ende</h2> <div id="center_that"> <div class="end_work_info"> Bildschöne Webseite mit intuitive Funktionalität </div> <div class="end_work_info"> Optimisierten Inhalt, der rasche Ladung sichert </div> <div class="end_work_info"> Webseite, die auf allen Systems und Anlagen funktioniert </div> </div> <div id="end_work_img"> <img src="../img/end_work.png" alt=""> </div> </div> </div> </section> <section id="section-Projekte"> <img class="bg animate" src="../img/office2.jpeg" anim-detached="true"/> <div id="our_work"> <h2>Projekte</h2> <div id="slider_work"> <div class="active"> <div class="websites"> <div class="web_info1"> <h3>Academic Boxing Klub</h3> <a href="http://www.academicboxingclub.org" target="_blank"><h4>academicboxingclub.org</h4></a> <div class="web_discription"> <ul> <li> <h5>Projektbeschreibung</h5> <p> Wir haben die Webseite unseres Boxing Klubs erschafft. Wir haben bei Null angefangen, wobei wir unser Farbenmodell, Fotos, Banners und Logo kreiert haben, als auch ein verbessertes Benutzerinterface. Die Webseite verwendet eine MySQL Datenbank für die Nachrichten und eine kleine eigene CMS. Wir erhalten die Seite aufrecht. </p> </li> <li> <h5>Technologien:</h5> <ul> <li>Graphische Gestaltung/Photoshop</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website"> <img src="../img/box.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>Teniskashop</h3> <a href="http://www.teniskashop.eu" target="_blank"><h4>teniskashop.eu</h4></a> <div class="web_discription"> <ul> <li> <h5>Projektbeschreibung</h5> <p> Online Laden für T-Shirts mit einzigartigem Entwurf. Die komplette Aussicht der Seite wurde von uns gemalt und entworfen. Teniskashop.eu schließt auch eine eigene CMS ein, die wir selbst erstellt haben. Wir betreuen das Datenhosting und das Serverteil der Webseiteverwaltung(cPanel). </p> </li> <li> <h5>Technologien:</h5> <ul> <li>Photoshop</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>AJAX</li> <li>PHP</li> <li>Apache 2.0/cPanel</li> </ul> </li> </ul> </div> </div> <div class="the_website1"> <img src="../img/teniskashop.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>Kinesitherapeutisches Studio "GabieAngie"</h3> <a href="http://www.kineziterapiabg.com" target="_blank"><h4>kineziterapiabg.com</h4></a> <div class="web_discription"> <ul> <li> <h5>Projektbeschreibung</h5> <p> Eine kleine Webseite, die für einen der besten Kinesitherapisten in Bulgarien erfasst wurde. Wir haben die ganze Gestaltung und Benutzerinterface kreiert. Unseres Ziel war, eine leichte und einfach zu navigierende Webseite als Endresultat zu erreichen. Für die Benutzerreviews wurde eine kleine MySQL Datenbank verwendet. </p> </li> <li> <h5>Technologien:</h5> <ul> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website2"> <img src="../img/kineziterapiabg.png" alt=""> </div> </div> </div> </div> <span id="playback"><img src="../img/playback_pause.png"/></span> </div> </section> <section id="section-Kontakt"> <img class="bg" src="../img/eb8.jpg" anim-detached="true" /> <div id="contact_us"> <h2>Interesse an Zusammenarbeit mit uns?</h2> <div class="contact_us_nav"> <ul> <li><a href="javascript:;"> <span id="form_button_one" class="project_form_buttons">Erweiterte Form</span> </a> </li><li><a href="javascript:;"> <span class="project_form_buttons">Kurze Form </span> </a> <li> </ul> </div> <?php //FORM USER ACTION FEEDBACK foreach ($message as $v) { echo "<div class='message_feedback'>".$v."</div>"; } ?> <div id="detailed_form" class="contact_forms"> <form method="POST" action=""> <div class="quick_form_holder"> <input type="text" name="name_detail" placeholder="Name" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div id="email_and_phone_holder"> <div id="email"> <input type="text" name="email_detail" placeholder="E-Mail" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div id="phone"> <input type="text" name="phone_detail" placeholder="Telefonnummer" <?php if(isset($phone) && !$mailed) { echo "value='$phone'";} ?> > </div> </div> <div class="quick_form_holder1"> <input type="text" name="company_detail" placeholder="Firma" <?php if(isset($company) && !$mailed) { echo "value='$company'";} ?> > </div> <div id="budget"> <h3>Budget</h3> <br /> <br /> <ul> <li> <div> <input type="radio" id="radio-1-1-de" name="budget" value="Bis €150" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "Bis €150") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-1-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-2-de" name="budget" value="€150 - €400" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "€150 - €400") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-2-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-3-de" name="budget" value="€400 - €1500" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "€400 - €1500") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-3-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-4-de" name="budget" value="> €1500" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "> €1500") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-4-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-5-de" name="budget" value="Unklar" class="regular-radio" <?php if($budget_checked !== true) {echo " checked";} ?> /><label for="radio-1-5-de"></label> </div> </li> </ul> </div> <div id="project_type"> <h3>Projekttyp</h3> <br /> <br/> <ul> <li> <div> <input type="radio" id="radio-2-1-de" name="project_type" value="Komplett" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Komplett") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-1-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-2-de" name="project_type" value="Nur Design" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Nur Design") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-2-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-3-de" name="project_type" value="Nur Pflege" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Nur Pflege") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-3-de"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-4-de" name="project_type" value="Anderes" class="regular-radio" <?php if($project_type_checked !== true) {echo " checked";} ?> /><label for="radio-2-4-de"></label> </div> </li> </ul> </div> <div class="quick_form_holder2"> <textarea name="question_detail" cols="30" rows="1" placeholder="Alles Anderes, was Sie interessiert.."><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="detailed_form_send"> <input type="image" name="submit" src="../img/send_de.png"> </div> </form> </div> <div id="quick_form_wrapper"> <div id="quick_form" class="contact_forms"> <form method="POST" action=""> <div class="quick_form_holder"> <input type="text" name="name_short" placeholder="Name" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div class="quick_form_holder"> <input type="text" name="email_short" placeholder="E-Mail" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div class="quick_form_holder1"> <textarea name="question_short" cols="30" rows="1" placeholder="Ihre Gedanken hier.."><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="quick_form_send"> <input type="hidden" name="short_form_check" value="show_short_form"> <input type="image" name="submit" src="../img/send_de.png"> </div> <!--[if lt IE 10]> <script src="../js/placeholder.js"></script> <![endif]--> </form> </div> </div> </div> <!-- WEB FOOTER --> <footer id="container_footer"> <a href="#Anfang"> <div id="footer_arrow"> <img src="../img/footer_arrow.png" alt=""> </div> </a> </footer> </section> </div> </body> </html>
123-asdf
trunk/de/index.php
PHP
mit
33,116
/** * @preserve HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */ ;(function(window, document) { /*jshint evil:true */ /** version */ var version = '3.6.2'; /** Preset options */ var options = window.html5 || {}; /** Used to skip problem elements */ var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; /** Not all elements can be cloned in IE **/ var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; /** Detect whether the browser supports default html5 styles */ var supportsHtml5Styles; /** Name of the expando, to work with multiple documents or to re-shiv one document */ var expando = '_html5shiv'; /** The id for the the documents expando */ var expanID = 0; /** Cached data for each document */ var expandoData = {}; /** Detect whether the browser supports unknown elements */ var supportsUnknownElements; (function() { try { var a = document.createElement('a'); a.innerHTML = '<xyz></xyz>'; //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles supportsHtml5Styles = ('hidden' in a); supportsUnknownElements = a.childNodes.length == 1 || (function() { // assign a false positive if unable to shiv (document.createElement)('a'); var frag = document.createDocumentFragment(); return ( typeof frag.cloneNode == 'undefined' || typeof frag.createDocumentFragment == 'undefined' || typeof frag.createElement == 'undefined' ); }()); } catch(e) { // assign a false positive if detection fails => unable to shiv supportsHtml5Styles = true; supportsUnknownElements = true; } }()); /*--------------------------------------------------------------------------*/ /** * Creates a style sheet with the given CSS text and adds it to the document. * @private * @param {Document} ownerDocument The document. * @param {String} cssText The CSS text. * @returns {StyleSheet} The style element. */ function addStyleSheet(ownerDocument, cssText) { var p = ownerDocument.createElement('p'), parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; p.innerHTML = 'x<style>' + cssText + '</style>'; return parent.insertBefore(p.lastChild, parent.firstChild); } /** * Returns the value of `html5.elements` as an array. * @private * @returns {Array} An array of shived element node names. */ function getElements() { var elements = html5.elements; return typeof elements == 'string' ? elements.split(' ') : elements; } /** * Returns the data associated to the given document * @private * @param {Document} ownerDocument The document. * @returns {Object} An object of data. */ function getExpandoData(ownerDocument) { var data = expandoData[ownerDocument[expando]]; if (!data) { data = {}; expanID++; ownerDocument[expando] = expanID; expandoData[expanID] = data; } return data; } /** * returns a shived element for the given nodeName and document * @memberOf html5 * @param {String} nodeName name of the element * @param {Document} ownerDocument The context document. * @returns {Object} The shived element. */ function createElement(nodeName, ownerDocument, data){ if (!ownerDocument) { ownerDocument = document; } if(supportsUnknownElements){ return ownerDocument.createElement(nodeName); } if (!data) { data = getExpandoData(ownerDocument); } var node; if (data.cache[nodeName]) { node = data.cache[nodeName].cloneNode(); } else if (saveClones.test(nodeName)) { node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); } else { node = data.createElem(nodeName); } // Avoid adding some elements to fragments in IE < 9 because // * Attributes like `name` or `type` cannot be set/changed once an element // is inserted into a document/fragment // * Link elements with `src` attributes that are inaccessible, as with // a 403 response, will cause the tab/window to crash // * Script elements appended to fragments will execute when their `src` // or `text` property is set return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node; } /** * returns a shived DocumentFragment for the given document * @memberOf html5 * @param {Document} ownerDocument The context document. * @returns {Object} The shived DocumentFragment. */ function createDocumentFragment(ownerDocument, data){ if (!ownerDocument) { ownerDocument = document; } if(supportsUnknownElements){ return ownerDocument.createDocumentFragment(); } data = data || getExpandoData(ownerDocument); var clone = data.frag.cloneNode(), i = 0, elems = getElements(), l = elems.length; for(;i<l;i++){ clone.createElement(elems[i]); } return clone; } /** * Shivs the `createElement` and `createDocumentFragment` methods of the document. * @private * @param {Document|DocumentFragment} ownerDocument The document. * @param {Object} data of the document. */ function shivMethods(ownerDocument, data) { if (!data.cache) { data.cache = {}; data.createElem = ownerDocument.createElement; data.createFrag = ownerDocument.createDocumentFragment; data.frag = data.createFrag(); } ownerDocument.createElement = function(nodeName) { //abort shiv if (!html5.shivMethods) { return data.createElem(nodeName); } return createElement(nodeName, ownerDocument, data); }; ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' + 'var n=f.cloneNode(),c=n.createElement;' + 'h.shivMethods&&(' + // unroll the `createElement` calls getElements().join().replace(/\w+/g, function(nodeName) { data.createElem(nodeName); data.frag.createElement(nodeName); return 'c("' + nodeName + '")'; }) + ');return n}' )(html5, data.frag); } /*--------------------------------------------------------------------------*/ /** * Shivs the given document. * @memberOf html5 * @param {Document} ownerDocument The document to shiv. * @returns {Document} The shived document. */ function shivDocument(ownerDocument) { if (!ownerDocument) { ownerDocument = document; } var data = getExpandoData(ownerDocument); if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) { data.hasCSS = !!addStyleSheet(ownerDocument, // corrects block display not defined in IE6/7/8/9 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' + // adds styling not present in IE6/7/8/9 'mark{background:#FF0;color:#000}' + // hides non-rendered elements 'template{display:none}' ); } if (!supportsUnknownElements) { shivMethods(ownerDocument, data); } return ownerDocument; } /*--------------------------------------------------------------------------*/ /** * The `html5` object is exposed so that more elements can be shived and * existing shiving can be detected on iframes. * @type Object * @example * * // options can be changed before the script is included * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false }; */ var html5 = { /** * An array or space separated string of node names of the elements to shiv. * @memberOf html5 * @type Array|String */ 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video', /** * current version of html5shiv */ 'version': version, /** * A flag to indicate that the HTML5 style sheet should be inserted. * @memberOf html5 * @type Boolean */ 'shivCSS': (options.shivCSS !== false), /** * Is equal to true if a browser supports creating unknown/HTML5 elements * @memberOf html5 * @type boolean */ 'supportsUnknownElements': supportsUnknownElements, /** * A flag to indicate that the document's `createElement` and `createDocumentFragment` * methods should be overwritten. * @memberOf html5 * @type Boolean */ 'shivMethods': (options.shivMethods !== false), /** * A string to describe the type of `html5` object ("default" or "default print"). * @memberOf html5 * @type String */ 'type': 'default', // shivs the document according to the specified `html5` object options 'shivDocument': shivDocument, //creates a shived element createElement: createElement, //creates a shived documentFragment createDocumentFragment: createDocumentFragment }; /*--------------------------------------------------------------------------*/ // expose html5 window.html5 = html5; // shiv the document shivDocument(document); /*------------------------------- Print Shiv -------------------------------*/ /** Used to filter media types */ var reMedia = /^$|\b(?:all|print)\b/; /** Used to namespace printable elements */ var shivNamespace = 'html5shiv'; /** Detect whether the browser supports shivable style sheets */ var supportsShivableSheets = !supportsUnknownElements && (function() { // assign a false negative if unable to shiv var docEl = document.documentElement; return !( typeof document.namespaces == 'undefined' || typeof document.parentWindow == 'undefined' || typeof docEl.applyElement == 'undefined' || typeof docEl.removeNode == 'undefined' || typeof window.attachEvent == 'undefined' ); }()); /*--------------------------------------------------------------------------*/ /** * Wraps all HTML5 elements in the given document with printable elements. * (eg. the "header" element is wrapped with the "html5shiv:header" element) * @private * @param {Document} ownerDocument The document. * @returns {Array} An array wrappers added. */ function addWrappers(ownerDocument) { var node, nodes = ownerDocument.getElementsByTagName('*'), index = nodes.length, reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'), result = []; while (index--) { node = nodes[index]; if (reElements.test(node.nodeName)) { result.push(node.applyElement(createWrapper(node))); } } return result; } /** * Creates a printable wrapper for the given element. * @private * @param {Element} element The element. * @returns {Element} The wrapper. */ function createWrapper(element) { var node, nodes = element.attributes, index = nodes.length, wrapper = element.ownerDocument.createElement(shivNamespace + ':' + element.nodeName); // copy element attributes to the wrapper while (index--) { node = nodes[index]; node.specified && wrapper.setAttribute(node.nodeName, node.nodeValue); } // copy element styles to the wrapper wrapper.style.cssText = element.style.cssText; return wrapper; } /** * Shivs the given CSS text. * (eg. header{} becomes html5shiv\:header{}) * @private * @param {String} cssText The CSS text to shiv. * @returns {String} The shived CSS text. */ function shivCssText(cssText) { var pair, parts = cssText.split('{'), index = parts.length, reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'), replacement = '$1' + shivNamespace + '\\:$2'; while (index--) { pair = parts[index] = parts[index].split('}'); pair[pair.length - 1] = pair[pair.length - 1].replace(reElements, replacement); parts[index] = pair.join('}'); } return parts.join('{'); } /** * Removes the given wrappers, leaving the original elements. * @private * @params {Array} wrappers An array of printable wrappers. */ function removeWrappers(wrappers) { var index = wrappers.length; while (index--) { wrappers[index].removeNode(); } } /*--------------------------------------------------------------------------*/ /** * Shivs the given document for print. * @memberOf html5 * @param {Document} ownerDocument The document to shiv. * @returns {Document} The shived document. */ function shivPrint(ownerDocument) { var shivedSheet, wrappers, data = getExpandoData(ownerDocument), namespaces = ownerDocument.namespaces, ownerWindow = ownerDocument.parentWindow; if (!supportsShivableSheets || ownerDocument.printShived) { return ownerDocument; } if (typeof namespaces[shivNamespace] == 'undefined') { namespaces.add(shivNamespace); } function removeSheet() { clearTimeout(data._removeSheetTimer); if (shivedSheet) { shivedSheet.removeNode(true); } shivedSheet= null; } ownerWindow.attachEvent('onbeforeprint', function() { removeSheet(); var imports, length, sheet, collection = ownerDocument.styleSheets, cssText = [], index = collection.length, sheets = Array(index); // convert styleSheets collection to an array while (index--) { sheets[index] = collection[index]; } // concat all style sheet CSS text while ((sheet = sheets.pop())) { // IE does not enforce a same origin policy for external style sheets... // but has trouble with some dynamically created stylesheets if (!sheet.disabled && reMedia.test(sheet.media)) { try { imports = sheet.imports; length = imports.length; } catch(er){ length = 0; } for (index = 0; index < length; index++) { sheets.push(imports[index]); } try { cssText.push(sheet.cssText); } catch(er){} } } // wrap all HTML5 elements with printable elements and add the shived style sheet cssText = shivCssText(cssText.reverse().join('')); wrappers = addWrappers(ownerDocument); shivedSheet = addStyleSheet(ownerDocument, cssText); }); ownerWindow.attachEvent('onafterprint', function() { // remove wrappers, leaving the original elements, and remove the shived style sheet removeWrappers(wrappers); clearTimeout(data._removeSheetTimer); data._removeSheetTimer = setTimeout(removeSheet, 500); }); ownerDocument.printShived = true; return ownerDocument; } /*--------------------------------------------------------------------------*/ // expose API html5.type += ' print'; html5.shivPrint = shivPrint; // shiv for print shivPrint(document); }(this, document));
123-asdf
trunk/shivs/html5shiv/html5shiv-printshiv.js
JavaScript
mit
15,465
/*=================================*/ /* CSS Reset /*=================================*/ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } html { position: relative; min-height: 100%; } body { line-height: 1.5; font-size:14px; font-family:"Myriad Pro", tahoma, sans-serif; background:#fff; /* START PARALLAX */ width : 100%; height : 100%; overflow-x : hidden; } #container_nav_holder { display: none; } #content:after{ content: ""; display: block; } #container_footer, #content:after{ height:30px; } #content { position : fixed; top : 0px; left : 0px; width : 100%; height : 100%; margin-bottom:30px; min-height:100%; } /* to show properly left menu */ p, ul { list-style : none; } section { min-height : 500px; min-height : 100%; width : 100%; position : absolute; overflow : hidden; visibility : hidden; } /* default section show / hide animations */ section.start { top : 100%; } section.focus, section.to { bottom : 0%; } section.end { bottom : 100%; } /* default background image animation */ section .bg { position : absolute; left : 0px; top : 0%; } section .bg.start { top : -50%; } section .bg, section .bg.focus, section .bg.to { top : 0%; } section .bg.end { top : 100%; } .bg { position: fixed; top: 0; left: 0; z-index: -1; height: 100%; } /* Side Nav */ #nav{ width:65px; height:320px; background: rgba(38, 57, 61, 0.6); border-radius:5px; border:1px solid rgba(250, 250, 250, 0.3); } ul#nav { position : fixed; left : 0.4%; top : 30%; z-index : 999; } ul#nav li { width:0px; height:40px; line-height:40px; text-align:center; padding-top:2px; padding-bottom:10px; } ul#nav a { width:55px; height:55px; width:60px; display : block; outline : none; } ul#nav > li:hover:first-child a { background: url('../img/home.png') no-repeat; margin-left:6px; } ul#nav > li:first-child + li:hover a { background: url('../img/about_icon.png') no-repeat; margin-left:6px;} ul#nav > li:first-child + li + li:hover a { background: url('../img/how_we_work.png') no-repeat; margin-left:6px;} ul#nav > li:first-child + li + li + li:hover a { background: url('../img/work_icon.png') no-repeat; margin-left:6px;} ul#nav > li:first-child + li + li + li + li:hover a { background: url('../img/contact_icon.png') no-repeat;margin-left:6px; } body.section-Home #nav li.Home a { text-indent: -9999px; background: url('../img/home.png') no-repeat; margin-left:6px; } body.section-About #nav li.About a { text-indent: -9999px; background: url('../img/about_icon.png') no-repeat; margin-left:6px; } body.section-Process #nav li.Process a { text-indent: -9999px; background: url('../img/how_we_work.png') no-repeat; margin-left:6px; } body.section-Work #nav li.Work a { text-indent: -9999px; background: url('../img/work_icon.png') no-repeat; margin-left:6px; } body.section-Contact #nav li.Contact a { text-indent: -9999px; background: url('../img/contact_icon.png') no-repeat; margin-left:6px; } #nav li.Blog a:hover { text-indent: -9999px; background: url('../img/blog_icon.png') no-repeat; margin-left:6px; } /*BG VERSION*/ body.section-Начало #nav li.Начало a { text-indent: -9999px; background: url('../img/home.png') no-repeat; margin-left:6px; } body.section-Ние #nav li.Ние a { text-indent: -9999px; background: url('../img/about_icon.png') no-repeat; margin-left:6px; } body.section-Работа #nav li.Работа a { text-indent: -9999px; background: url('../img/how_we_work.png') no-repeat; margin-left:6px; } body.section-Проекти #nav li.Проекти a { text-indent: -9999px; background: url('../img/work_icon.png') no-repeat; margin-left:6px; } body.section-Контакт #nav li.Контакт a { text-indent: -9999px; background: url('../img/contact_icon.png') no-repeat; margin-left:6px; } #nav li.Блог a:hover { text-indent: -9999px; background: url('../img/blog_icon.png') no-repeat; margin-left:6px; } /*DE VERSION*/ body.section-Anfang #nav li.Anfang a { text-indent: -9999px; background: url('../img/home.png') no-repeat; margin-left:6px; } body.section-Leute #nav li.Leute a { text-indent: -9999px; background: url('../img/about_icon.png') no-repeat; margin-left:6px; } body.section-Prozess #nav li.Prozess a { text-indent: -9999px; background: url('../img/how_we_work.png') no-repeat; margin-left:6px; } body.section-Projekte #nav li.Projekte a { text-indent: -9999px; background: url('../img/work_icon.png') no-repeat; margin-left:6px; } body.section-Kontakt #nav li.Kontakt a { text-indent: -9999px; background: url('../img/contact_icon.png') no-repeat; margin-left:6px; } ul#nav a:hover{ text-indent:-9999px; } ul#nav h1 { display : none; opacity : 0; position : absolute; left : 15px; top : 0px; white-space : nowrap; padding : 0 0 0 18px; overflow : hidden; margin : 0; font-size : 16px; } /* END PARALLAX */ a { outline: none; } ol, ul { list-style: none; } a{ text-decoration:none; color:#fff; } img{ max-width: 100%; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } @font-face{ font-family:'Comfortaa'; src: url('../fonts/Comfortaa-Bold.ttf'); } /*=================================*/ /* Main Page /*=================================*/ #section-Home{ width:100%; } #container_header{ z-index: 1; height:50px; width:100%; background:#002F2F; } #header_holder{ width:100%; margin:0 auto; height:50px; } #social_lang_holder{ position:relative; right:2%; } #copyright{ float:left; position:absolute; left:2%; } #copyright p{ line-height:50px; height:50px; color:#fff; font-size:1.14em; font-family:Comfortaa, arial, sans-serif; } #lang{ float:right; line-height:20px; height:20px; font-weight:400; margin-top:15px; } #lang ul li{ display:inline-block; color:#fff; font-family:"Myriad Pro", arial, sans-serif; margin-right:15px; } #lang ul li +li + li{ border-right:1px solid rgba(255, 255, 255, 0.3); padding-right:30px; } #lang ul ul a{ } #social{ float:right; margin-top:14px; } #social ul li { display:inline-block; margin-left:15px; } #google{ padding-top:14px; } #second_header{ width:100%; } #left_info ul{ position:absolute; left:6.5%; margin-top:3px; } #left_info{ width:420px; height:72px; background: url("../img/left.png") no-repeat; float:left; font-family:"Myriad Pro", sans-serif; font-weight:500; color:#fff; font-size:1em; overflow:hidden; position:relative; } #right_info{ width:420px; height:72px; background: url("../img/right.png") no-repeat; float:right; } #logo{ width:18%; position:absolute; top:50px; left:43%; } .left_info_holder{ width:350px; } .where_we_at{ width:60px; display:block; border-right:1px solid #fff; margin-bottom:2px; font-size:12px; float:left; padding-right:5px; } .where_we_at_left{ display:block; float:left; width:230px; margin-right:45px; font-size:14px; padding-left:20px; } #icons_holder{ width:100%; height:50px; overflow:hidden; position:relative; right:2%; } #icons_holder ul li{ display:inline-block; margin-top:15px; margin-right:1.1%; width:auto; } #right_info ul{ margin-left:27%; } /*=================================*/ /* Web Header /*=================================*/ /*=================================*/ /* Billboard /*=================================*/ #slogan{ width:580px; height:120px; background:rgba(38, 57, 61, 0.4); border-radius:20px 0 20px 0; margin:6% auto 0; } #slogan h2{ font-size:2.286em; font-family:comfortaa, sans-serif; text-align:center; padding-top:10px; color:#fff; } #be_free_button_holder{ margin:20% auto 0; width:240px; height:68px; margin:10% auto 0; } #be_free_button{ width:250px; height:68px; display:block; border:5px solid #fff; border-radius:9px; text-align:center; line-height:68px; font-size:1.571em; font-family:"comfortaa", Arial, sans-serif; color:#fff; font-weight:900; } /*=================================*/ /* About /*=================================*/ #about_us{ max-width:1200px; width:100%; height:900px; margin:0 auto; position:relative; left:20px; } #about_us h2{ font-size:35px; color:#fff; text-align:center; padding-top:20px; } .player_holder{ float:left; margin-right:2.5em; margin-left:2.1875%; width:43%; /*520 / 1200 */ } .players{ width:98%; height:450px; margin-top:100px; } .players h3{ font-size:2em; color:#FFFAE4; } .players h4{ font-size:1.143em; color:#FFFAE4; margin-left:40px; } .players img { position:relative; top:-50px; float:right; margin-right:10px; /* width:57%; */ } .players p{ float:left; margin-top:100px; font-size:1.429em; color:#fff; } .about_the_players{ width:100%; height:auto; background:#E8E595; border-radius: 15px 0 15px 0; } .about_the_players p{ width:98%; height:auto; margin:0 auto; overflow:hidden; padding: 4px 4px 10px 4px; text-align: justify; } /*=================================*/ /* How We Work /*=================================*/ #how_we_work{ width:1200px; height:790px; width:100%; margin:0 auto; } #how_we_work h2{ font-size:2.5em; text-align:center; color:#3F617B; padding-top:20px; } .how_we_work_nav{ width:700px; margin:0 auto; margin-top:30px; } #how_we_work ul li{ display:inline-block; margin-left:20px; } .how_we_work_buttons_holder{ width:200px; height:68px; } .how_we_work_buttons{ display:block; width:200px; height:68px; line-height:68px; text-align:center; font-size:1.143em; font-family:"comfortaa" , Tahoma, sans-serif; color:#40627C; border-radius:9px; border:2px solid #E8E595; background:#E8E595; text-decoration: underline; } .how_we_work_buttons.b_active{ display:block; width:200px; height:68px; line-height:68px; text-align:center; font-size:1.143em; font-family:"comfortaa" , Tahoma, sans-serif; color:#40627C; border-radius:9px; border:2px solid #D0A825; background: transparent; } #how_we_work h3{ text-align:center; font-size:1.786em; font-weight:bold; margin-top:30px; } #meeting{ position: relative; max-width:1200px; width:100%; margin:0 auto; } .meeting_and_creating_info{ float:left; width:28.333333333333332%; /* 340 / 1200 */ height:390px; margin-left:5%; /* 60 / 1200 */ margin-top:30px; } .img_holder{ width:100%; height:220px; } .meeting_and_creating_info img{ margin-left:10.823529411764707%; /* 30 / 340 */ } .meeting_and_creating_info p{ margin-top:65px; font-size:14px; height:auto; margin-bottom:30px; } #thinking_parg{ margin-top: 66px; } .design_and_coding{ width:45.83333333333333%; /* 550 / 1200 */ float:left; margin-left:4.083333333333333%; /* 85 / 1200 */ margin-top:50px; height:auto; } .design_and_coding img{ width:50%; } .design_and_coding_info_holder{ width:100%; height:150px; } .desing_and_coding_info{ width:25.454545454545453%; /* 140 / 550 */ float:left; height:150px; margin-right:2.727272727272727%; /* 15 / 550 */ margin-left:4%; /* 22 / 550 */ color:#000; } .desing_and_coding_info img{ width:30%; } #fireworks_fix{ margin-top:23.09090909090909%; /* 127 / 550 */ width:100%; } #coding_part{ display: none; max-width:1200px; width:100%; } #coding_part img{ margin-top:70px; width:100%; } #end_work{ max-width:1200px; margin:0 auto; display: none; } .end_work_info{ float:left; margin-left:20px; margin-right:20px; margin-top:30px; width:18.333333333333332%; /* 220 / 1200 */ } #center_that{ width:66%; /*720 / 1200 */ margin:0 auto; position:relative; left:50px; } #end_work_img{ width:500px; margin:150px auto; } #end_work img{ } /*=================================*/ /* Our Work /*=================================*/ #slider_work { background: #fff; border-radius: 17px; max-width:90%; height:660px; display: block; position: relative; overflow: hidden; margin-left: 5%; } #slider_work > div { position:absolute; top:0; left:0; z-index:8; opacity: 0; height: 660px; } #slider_work > div.active { z-index:10; opacity: 1; } #slider_work > div.last-active { z-index:9; } #our_work{ max-width:1200px; margin:0 auto; } #our_work h2{ font-size:2.5em; text-align:center; padding-bottom:40px; padding-top:1px; color:#fff; } .web_info{ background:#fff; width:36%; height:auto; border-radius:5px; float:left; border:1px solid #000; margin-left:1.8%; } .web_info h3{ font-size:1.143em; font-weight:bold; text-align:center; margin-top:15px; } .web_info h4{ font-size:1.143em; text-align:center; margin-top:25px; padding-bottom:30px; border-bottom:1px dashed black;; } .web_discription{ width:80%; margin:0 auto; } .web_discription p{ text-align: justify; } .web_discription h5{ font-size:1em; font-weight:bold; border-bottom:1px solid #000; padding-bottom:5px; margin-top:20px; margin-bottom:20px; } .the_website{ float:left; width:50%; } .the_website img{ max-width:100%; min-width:60%; margin-left:3%; margin-top:10%; } .websites{ margin-top:50px; padding-bottom:40px; padding-right: 10px; } .websites a{ color: #40627C; text-decoration: underline; } .web_info1{ background:#fff; width:36%; /* 436 / 1200 */ height:auto; border-radius:5px; float:right; margin-right:2%; border:1px solid #000; } .web_info1 h3{ font-size:1.143em; font-weight:bold; text-align:center; margin-top:15px; } .web_info1 h4{ font-size:1.143em; text-align:center; margin-top:25px; padding-bottom:30px; border-bottom:1px dashed #000; } .web_discription1{ margin-left:54px; } .web_discription1 h5{ font-size:1em; font-weight:bold; border-bottom:1px solid #000; padding-bottom:5px; margin-top:20px; margin-bottom:20px; } .the_website1{ float:right; margin-top:100px; width:60%; } .the_website2{ float:right; margin-top:100px; width:50%; margin-right:2.2%; } #playback { z-index: 999; display: block; width: 40px; margin: 0 auto; position:relative; bottom:5em; } #playback img{ padding: 15px; } /*=================================*/ /* Contact Us /*=================================*/ #contact_us_background{ background: url("../img/eb8.jpg") no-repeat; } #quick_form_wrapper{ width:100%; } #contact_us{ min-height:1200px; max-width:1200px; width:100%; position:relative; left:10px; margin:0 auto; } #contact_us h2{ font-size:2.5em; color:#fff; text-align:center; padding-top:20px; padding-bottom:20px; } .contact_us_nav{ width:610px; margin:20px auto; } .contact_us_nav ul li{ display:inline-block; } .project_form_buttons{ display:block; width:300px; height:56px; line-height:56px; border:1px solid #E6E394; background:transparent; color:#FFF; border-radius:0 5px 5px 0; text-align:center; font-size:1.429em; font-family:"Myriad Pro"; } #form_button_one { border-radius: 5px 0 0 5px; background: #D0A825; } input[type="text"] { width:100%; border-top:none; border-left:none; border-right:none; border-bottom:1px solid #7F8589; outline:none; height:32px; line-height:32px; background-color: transparent; font-size:1.714em; color:#fff; } input[type="text"]:focus{ border-bottom: 1px solid #E8E595; outline:none; } textarea:focus{ border-bottom: 1px solid #E8E595; outline:none; } textarea{ max-height:100px; font-size:1.714em; color:#fff; border-top:none; border-left:none; border-right:none; border-bottom:1px solid #7F8589; font-family:"Myriad Pro", sans-serif; font-weight:500; width:100%; background-color: transparent; overflow-y: hidden; /* prevents scroll bar flash */ padding-top:.1em /* prevents text jump on Enter keypress */ } #quick_form { display: none; } #quick_form_send{ margin-top:50px; margin-bottom:20px; float:right; margin-right:50px } #detailed_form_send{ margin-top:50px; margin-bottom:20px; float:right; margin-right:50px } .quick_form_holder2{ padding-top:30px; padding-bottom:15px; max-width:91.66666666666666%; /* 1100px / 1200px */ width:100%; margin:0 auto; } .quick_form_holder{ padding-top:30px; padding-bottom:15px; max-width:91.66666666666666%; /* 1100px / 1200px */ width:100%; margin:0 auto; } .quick_form_holder1{ max-width:91.66666666666666%; /* 1100px / 1200px */ width:100%; margin:0 auto; margin-top:20px; } #email_and_phone_holder{ max-width:91.66666666666666%; /* 1100px / 1200px */ width:100%; margin:20px auto; } #email{ width:46.66666666666667%; /*500px / 1200px */ float:left; padding-top:20px; } #phone{ width:41.66666666666667%; /*500px / 1200px */ float:right; padding-top:20px; margin-bottom:30px; } #detailed_form h3{ font-size:2em; text-align:center; color:#fff; margin-top:40px; } #budget{ max-width:1100px; width:100%; margin:40px auto 0; } #budget ul li{ float:left; margin-left:1%; } .regular-radio { display: none; } .regular-radio + label { -webkit-appearance: none; display:block; width:200px; height:52px; border:1px solid #7F8589; border-radius:5px; color:#7F8589; font-size:1.571em; font-family:"Myriad Pro", tahoma, sans-serif; display: inline-block; position: relative; } .regular-radio:checked + label:after { content: ' '; width:200px; height:52px; border:1px solid #E8E595; border-radius:5px; color:#E8E595; font-size:1.05em; font-family:"Myriad Pro", tahoma, sans-serif; } #radio-1-1 +label:after{ content: "Up to $200"; text-align:center; line-height:52px; display:block; } #radio-1-2 + label:after{ content: "$200 - $500"; text-align:center; line-height:52px; display:block; } #radio-1-3 +label:after{ content: "$500 - $2000"; text-align:center; line-height:52px; display:block; } #radio-1-4 +label:after{ content: "$2000 and up"; text-align:center; line-height:52px; display:block; } #radio-1-5 +label:after{ content: "Not Sure"; text-align:center; line-height:52px; display:block; } /* STRATEGY */ #radio-2-1 +label:after{ content: "Full Service"; text-align:center; line-height:52px; display:block; } #radio-2-2 +label:after{ content: "Design only"; text-align:center; line-height:52px; display:block; } #radio-2-3 +label:after{ content: "Maintenance"; text-align:center; line-height:52px; display:block; } #radio-2-4 +label:after{ content: "Other"; text-align:center; line-height:52px; display:block; } /* BG RADIO BUTTONS*/ #radio-1-1-bg +label:after{ content: "До 300лв."; text-align:center; line-height:52px; display:block; } #radio-1-2-bg + label:after{ content: "300 - 750лв."; text-align:center; line-height:52px; display:block; } #radio-1-3-bg +label:after{ content: "750 - 3000лв."; text-align:center; line-height:52px; display:block; } #radio-1-4-bg +label:after{ content: "> 3000лв."; text-align:center; line-height:52px; display:block; } #radio-1-5-bg +label:after{ content: "Не е ясно"; text-align:center; line-height:52px; display:block; } #radio-2-1-bg +label:after{ content: "Цялостен"; text-align:center; line-height:52px; display:block; } #radio-2-2-bg +label:after{ content: "Дизайн"; text-align:center; line-height:52px; display:block; } #radio-2-3-bg +label:after{ content: "Поддръжка"; text-align:center; line-height:52px; display:block; } #radio-2-4-bg +label:after{ content: "Друг"; text-align:center; line-height:52px; display:block; } /* END OF BG RADIO BUTTONS */ /* DE RADIO BUTTONS*/ #radio-1-1-de +label:after{ content: "Bis €150"; text-align:center; line-height:52px; display:block; } #radio-1-2-de + label:after{ content: "€150 - €400"; text-align:center; line-height:52px; display:block; } #radio-1-3-de +label:after{ content: "€400 - €1500"; text-align:center; line-height:52px; display:block; } #radio-1-4-de +label:after{ content: "> €1500"; text-align:center; line-height:52px; display:block; } #radio-1-5-de +label:after{ content: "Unklar"; text-align:center; line-height:52px; display:block; } #radio-2-1-de +label:after{ content: "Komplett"; text-align:center; line-height:52px; display:block; } #radio-2-2-de +label:after{ content: "Nur Design"; text-align:center; line-height:52px; display:block; } #radio-2-3-de +label:after{ content: "Nur Pflege"; text-align:center; line-height:52px; display:block; } #radio-2-4-de +label:after{ content: "Anderes"; text-align:center; line-height:52px; display:block; } /* END OF DE RADIO BUTTONS */ .regular-radio:checked:after { line-height:52px; text-align:center; top: 3px; width:200px; height:52px; font-size: 1.571em; } .regular-radio:checked { border: 1px solid #E8E595; color: #E8E595; } #project_type{ width:1000px; margin:40px auto; } #project_type ul li{ float:left; margin-left:3%; } .message_feedback { color: #ffa9af; margin: 0 auto; text-align: center; } /*=================================*/ /* Web Footer /*=================================*/ #container_footer{ background:#FFFAE4; width:100%; height:30px; position: absolute; left: 0; bottom: 0; } #footer_arrow{ width:80px; margin:0 auto; } /*=================================*/ /* Web.Helpers /*=================================*/ #container_header, #second_header, #icons_holder, #right_info, .players, #about_us, .player_holder, #how_we_work, .meeting_and_creating_info, .design_and_coding, #end_work, .websites, #contact_us, #project_type, #email_and_phone_holder, #detailed_form, #budget, #detailed_form, #project_type{ zoom:1; } #container_header:after, #second_header:after, #icons_holder:after, #right_info:after, .players:after, #about_us:after, .player_holder:after, #how_we_work:after, .meeting_and_creating_info:after, .design_and_coding:after, #end_work:after, .websites:after, #contact_us:after, #project_type:after, #email_and_phone_holder:after, #detailed_form:after, #budget:after, #detailed_form:after, #project_type:after{ display:block; content:""; clear:both; } /*=================================*/ /* Responsive Querys /*=================================*/ /* Large desktop */ @media (min-width: 1200px) { ... } @media (min-width: 980px) and (max-width: 1082px) { #project_type{ width:760px; } #budget{ width:800px; margin:0 auto; } .regular-radio + label { width:140px; margin-left:10px; font-size:16px; } .regular-radio:checked + label:after { width:140px; font-size:16px; } } /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { #left_info{ display:none; border:none; } #right_info{ display:none; } #copyright{ display:none; } /* Side Nav */ #nav{ width:320px; height:60px; border:none; background:#002F2F; border-radius:5px 0 5px 0; } ul#nav { position : fixed; left : 0.8%; top : 0; z-index : 999; } ul#nav li { width:40px; height:40px; line-height:40px; text-align:center; margin-right:11px; padding-top:5px; padding-bottom:10px; display:inline-block; } #container_header{ height:60px; position:fixed; } #logo{ width:18%; position:absolute; top:60px; left:41%; } #slogan{ width:480px; height:100px; } #slogan h2{ font-size:1.8em; } #be_free_button{ width:200px; height:50px; font-size:1.3em; line-height:50px; } #section-About{ height:800px; } .players p{ font-size:0.9em; } .about_the_players { position:relative; bottom:120px; } .about_the_players p{ font-size:0.75em; } .meeting_and_creating_info{ margin-left:1%; margin-right:3%; } #section-Process{ height:900px; } #budget{ width:770px; } #project_type{ width:680px; } .regular-radio + label { width:140px; font-size:16px } .regular-radio:checked + label:after { width:140px; font-size:16px } .web_info{ font-size:0.9em; } .web_info1{ font-size:0.9em; } } /* Landscape phone to portrait tablet */ @media (max-width: 767px) { #how_we_work{ height:740; } #left_info{ display:none; border:none; } #right_info{ display:none; } #copyright{ display:none; } #lang{ float:left; margin-left:30px; } #nav{ display:none; } #slogan{ width:400px; height:80px; } #slogan h2{ font-size:1.4em; } #be_free_button_holder{ width:180px; } #be_free_button{ width:150px; height:50px; font-size:1.1em; line-height:50px; } #about_us{ width:520px; } .player_holder{ float:left; margin-right:2.5em; margin-left:2.1875%; width:500px; margin:20px auto 0; } .about_the_players{ height:auto; margin-bottom:20px; margin-top:-20px; } .about_the_players p{ font-size:0.85em; } #lang ul li +li + li{ border-right:0; } #thinking_parg{ margin:0; } .meeting_and_creating_info p{ font-size:0.8em; margin-top:-10px; } .desing_and_coding_info{ float:none; width:100%; height:70px; padding:0; font-size:0.8em; } .end_work_info{ width:280px; margin:none; font-size:0.8em; } .web_info1{ width:70%; margin: 0 auto; float:none; } .web_info{ width:70%; margin: 0 auto; float:none; } .the_website1{ display:none; } .the_website{ display:none; } .the_website2{ display:none; } #budget{ float:left; width:210px; margin-left:4% } #project_type{ float:right; width:210px; margin-right:4%; } #budget ul li{ float:none; } #project_type ul li{ float:none; } .contact_us_nav{ width:410px; margin:20px auto; } .project_form_buttons{ width:200px; height:46px; line-height:46px; border-radius:0 5px 5px 0; font-size:1.229em; } .how_we_work_nav{ width:490px; margin:0 auto; margin-top:30px; } #how_we_work ul li{ display:inline-block; margin-left:10px; } .how_we_work_buttons_holder{ width:150px; height:48px; } .how_we_work_buttons{ width:150px; height:48px; line-height:48px; font-size:1em; } .how_we_work_buttons.b_active{ width:150px; height:48px; line-height:48px; font-size:1em; } .quick_form_holder2{ margin-top:480px; } } /* Landscape phones and down */ @media (max-width: 480px) { }
123-asdf
trunk/css/style.css
CSS
mit
29,491
<?php error_reporting(0); //redirect for mobile (excl. tablets) include '../includes/Mobile_Detect.php'; $detect = new Mobile_Detect; if( $detect->isMobile() && !$detect->isTablet() ){ Header("Location: http://phone.forafreeworld.com/"); exit; } Header("Cache-Control: public, max-age=2592000"); Header("Content-Type: text/html; charset=utf-8"); mb_internal_encoding("UTF-8"); $message = array(); $mailed = false; $budget_checked = false; $project_type_checked = false; if($_POST) { //USER INPUT NORMALIZATION if(isset($_POST['name_detail'])) { $name = htmlspecialchars(trim($_POST['name_detail'])); $email = htmlspecialchars(trim($_POST['email_detail'])); $phone = htmlspecialchars(trim($_POST['phone_detail'])); $company = htmlspecialchars(trim($_POST['company_detail'])); $budget = $_POST['budget']; $project_type = $_POST['project_type']; $question = htmlspecialchars($_POST['question_detail']); $detail = true; } if(isset($_POST['name_short'])) { $name = htmlspecialchars(trim($_POST['name_short'])); $email = htmlspecialchars(trim($_POST['email_short'])); $question = htmlspecialchars($_POST['question_short']); $phone = ""; $company = ""; $budget = ""; $project_type = ""; } //USER INPUT VALIDATION if(mb_strlen($name) < 3) { $message[] = "Името трябва да е по-дълго от 2 символа."; } if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $message[] = "Моля, въведете валиден имейл адрес."; } if(isset($detail) && (int)mb_strlen($phone) < 7) { $message[] = "Моля, въведете валиден телефонен номер, включително префикси за населени места."; } if(mb_strlen($question) < 20) { $message[] = "Запитването трябва да съдържа повече от 20 символа."; } //send email if no input validation successful if(count($message) == 0) { $mail_msg = "<html><head></head><body> Име на клиента: ".$name."<br/>". "Имейл на клиента: ".$email."<br/>". "Телефон на клиента: ".$phone."<br/>". "Име на компанията: ".$company."<br/>". "Избран бюджет: ".$budget."<br/>". "Избран тип проект: ".$project_type."<br/>". "Запитване: ".$question."<br/></body></html>"; $mail_msg = wordwrap($mail_msg, 70, "\r\n"); $mailed = @mail('az3@abv.bg', 'forafreeworld.com Customer Enquiry - BG', $mail_msg, 'Content-type: text/html; charset=utf-8' . "\r\n"); if($mailed) { $message[] = "Запитването беше изпратено успешно. Ще се свържем с Вас във възможно най-кратък срок."; } else { $message[] = "Грешка при изпращането на съобщението. Моля, опитайте отново по-късно."; } } } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="author" content="Необикновен уеб дизайн"/> <meta name="description" content="Уеб дизайн студио Be Free е малък екип, който специализира в предоставянето на пълна гама уеб услуги до клиенти по целия Свободен свят. Ние се намираме в София, България (Югоизточна Европа). В момента отборът се състои от Николай Иванов - Уеб дизайнер, и Денислав Димитров - Уеб разработчик. Някои от услугите, които предоставяме, са: Изработка на уебсайт, ъпдейти и текущи промени на уебсайт, редизайн, креативен дизайн, лого и банер дизайн, обновявания и ъпдейти по сигурността, оптимизиране и поддръжка на бази данни, уеб услуги от страна на сървъра."/> <meta name="Keywords" content="web design, web development, website, wordpress site, responsive design, custom website, web content management, уеб дизайн, уебсайт, интернет страница"/> <meta name="googlebot" content="all"/> <link href="../img/favicon.ico" rel="shortcut icon"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Уеб дизайн за един Свободен Свят!</title> <!--[if lte IE 9]> <script src="../shivs/html5shiv/html5shiv.js"></script> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![endif]--> <!--[if IE 9 ]> <html class="ie9"> <![endif]--> <!--[if IE ]> <html class="ie"> <![endif]--> <link rel="stylesheet" type="text/css" href="../css/style.css"/> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="../js/jquery.placeholder.js"></script> <script src="../js/main.js"></script> <script src="../js/side-nav.js"></script> <script src="../js/backgrounds.js"></script> <script src="../js/kinetics.js"></script> <script src="../js/parallax.js"></script> </head> <body> <div id="mock-scroller"> </div> <ul id="nav"> </ul> <!-- WEB CONTENT --> <div id="content"> <section id="section-Начало"> <img class="bg animate" src="../img/bg.jpg" anim-detached="true"/> <header id="container_header"> <div id="header_holder"> <div id="copyright"> <p> &copy; Forafreeworld.com. Всички права запазени. </p> </div> <div id="social_lang_holder"> <div id="social"> <ul> <li><a href="https://www.facebook.com/pages/Be-Free-Web-Design-Studio/561352003933342" target="_blank"><img src="../img/facebook.png" alt=""></a></li> <li><a href="https://twitter.com/be_free_studio" target="_blank"><img src="../img/twitter.png" alt=""></a></li> <li><a href="https://plus.google.com/communities/115431413168700794942" target="_blank"><img src="../img/google.png" alt=""></a></li> </ul> </div> <div id="lang"> <ul> <li><a href="http://forafreeworld.com/">en</a></li> <li><a href="http://forafreeworld.com/de/">de</a></li> <li><a href="http://forafreeworld.com/bg/"><span id="separate_it">bg</span></a></li> </ul> </div> <div id="logo"> <img src="../img/logo.png" alt=""> </div> </div> </div> <div id="second_header"> <div id="left_info"> <ul> <li> <span class="where_we_at">Имейл</span> <span class="where_we_at_left">welcome@forafreeworld.com</span> </li> <li><span class="where_we_at">Телефон</span> <span class="where_we_at_left">+359 877 36 55 44</span> </li> <li><span class="where_we_at">Адрес</span> <span class="where_we_at_left">София, България, Редута 80</span> </li> </ul> </div> <div id="right_info"> <div id="icons_holder"> <ul> <li><img src="../img/ps.png" alt=""></li> <li><img src="../img/css3.png" alt=""></li> <li><img src="../img/wordpress.png" alt=""></li> <li><img src="../img/ie.png" alt=""></li> <li><img src="../img/mysql.png" alt=""></li> <li><img src="../img/javascript.png" alt=""></li> <li><img src="../img/php.png" alt=""></li> </ul> </div> </div> </div> </header> <!--Billboard--> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <div id="slogan"> <h2>НИЕ ВЯРВАМЕ, ЧЕ ДА ИМАШ <br/> УЕБСАЙТ ДАВА СВОБОДА</h2> </div> <div id="be_free_button_holder"> <a href="#Контакт"><span id="be_free_button">БЪДИ СВОБОДЕН</span></a> </div> <div id="container_nav_holder"> <nav id="container_nav"> <ul> <li><a href="#"><img src="../img/home.png" alt=""></a></li> <li><a href="#">За нас</a></li> <li><a href="#">Работа</a></li> <li><a href="#">Проекти</a></li> <li><a href="#">Контакт</a></li> <li><a href="#">Блог</a></li> </ul> </nav> </div> </section> <section id="section-Ние"> <img class="bg animate" src="../img/about_us_bg.jpg" anim-detached="true"/> <div id="about_us"> <h2>Свободните хора</h2> <div class="player_holder"> <div class="players"> <h3>Николай Иванов</h3> <h4>Дизайнерът</h4> <img src="../img/niko.png" alt=""> <p> HTML5 <br/> CSS3<br/> Фотошоп<br/> Банер дизайн<br/> Медия дизайн<br/> </p> </div> <div class="about_the_players"> <p> ¡hola! Аз съм Николай, дизайнерът на нашия уеб екип Be Free Studio. Моята специалност е планирането и дизайна на уебсайтове от нулата, защото по този начин мога да покажа моята креативност. Уменията ми включват отлични HTML5 и CSS3 познания, добро ниво на владеене на продуктите на Adobe Photoshop и дизайни на уебсайтове и приложения за телефони/таблети и други мултимедийни устройства. Това, което най-много ме вълнува, са проектите, където мога да добавя нещо от себе си чрез малки детайли и промени във външния вид на крайния продукт, както и брандирането. </p> </div> </div> <div class="player_holder"> <div class="players"> <h3>Денислав Димитров</h3> <h4>Разработчикът</h4> <img src="../img/denkata.png" alt=""> <p> Javascript<br/> jQuery и AJAX<br/> PHP<br/> MySQL<br/> CMS / WordPress<br/> </p> </div> <div class="about_the_players"> <p> Няколко думи за мен: Аз живея в мой собствен организиран свят, където всичко си има своето място и цел. Обичам да си играя с PHP и MySQL, това е моята работа и моето хоби. Моята работа е да създам подредена и лесна за поддръжка структура за вашия уебсайт, като за целта имплементирам интуитивна CMS система, високо ниво на информационна сигурност и оптимизирана база от данни за вашата информация. Като разработчик, аз съм отговорен и за управлението на вашия уебсайт от сървърна страна, като това включва пренасочване на адреси, кеширане на файлове и защита от кражба на данни. </p> </div> </div> </div> </section> <section id="section-Работа"> <img class="bg animate" src="../img/how_we_work_bg.png" anim-detached="true"/> <div id="how_we_work"> <h2>Работа</h2> <div class="how_we_work_nav"> <ul> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons b_active">Начало на проекта</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Дизайн и кодиране</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Краен продукт</span> </div> </a></li> </ul> </div> <div id="meeting" class="slides_work"> <h2>Първи срещи</h2> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/meet_the_customer.png" alt=""> </div> <p> В началото се срещаме с нашия клиент и се опитваме да го опознаем, за да разберем бизнеса и целите му. Това ще бъде от значителна важност по-късно, когато ще добавим стойност към проекта на клиента като предложим подобрения на съществуващия процес и професионални съвети, насочени към конкретния уебсайт. Ние вярваме, че трябва да се отнасяме един към друг преди всичко като човек към човек, защото знаем, че в крайна сметка ние всички споделяме общи цели в живота. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/thinking_and_creating.png" alt=""> </div> <p id="thinking_parg"> Преди да напишем дори един ред код (а ние пишем много редове!), сядаме и обсъждаме плана на проекта и как виждаме неговото осъществяване. Каква е целта на този уебсайт? Цели ли той да привлича клиенти или може би да интригува и да предоставя уникално съдържание? Трябва ли да продава или може би да набира средства за нещо? Ние създаваме работния график и изясняваме неяснотите с работодателя. Тук пием МНОГО кафе. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="../img/mockup.png" alt=""> </div> <p id="mockup_text"> След като плана е налице, започваме да нахвърляме уебсайта за нашия клиент. Първо правим груба черно-бяла скица, за да я обсъдим и постигнем консенсус за основния вид на сайта с работодателя рано в процеса на работа. В тази фаза ние слушаме внимателно инструкциите на клиента, но ако се наложи можем и да предложим нашата визия за сайта. Постигането на окончателно съгласие с клиента е и краят на началната фаза на проекта. </p> </div> </div> <div id="coding_part" class="slides_work"> <h2>Дизайн и кодиране - това е вълшебната част</h2> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info"> Наблягаме на малките, но важни детайли - шрифтове, цветови комбинации.. </div> <div class="desing_and_coding_info lower"> Дизайна на логото и банерите е важна част от уеб присъствието ви </div> <div class="desing_and_coding_info"> Създаваме SEO-оптимизиран, чист код с HTML5 и CSS3 </div> </div> <img src="../img/fireworks.jpg" alt=""> </div> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info lower"> Един уважаващ себе си уебсайт трябва да е с динамично съдържание </div> <div class="desing_and_coding_info"> Тук идват системите за управление на съдържанието и сървърното програмиране </div> <div class="desing_and_coding_info lower"> Ние комбинираме последните уеб технологии и иновативно мислене, за да създадем най-добрия за вас уебсайт </div> </div> <img src="../img/brackets.jpg" alt=""> </div> </div> <div id="end_work" class="slides_work"> <h2>Какво получавате накрая</h2> <div id="center_that"> <div class="end_work_info"> Красив уебсайт с интуитивна функционалност </div> <div class="end_work_info"> Оптимизирано съдържание, гарантиращо бързо зареждане </div> <div class="end_work_info"> Уебсайт, който работи на всякакви системи и устройства </div> </div> <div id="end_work_img"> <img src="../img/end_work.png" alt=""> </div> </div> </div> </section> <section id="section-Проекти"> <img class="bg animate" src="../img/office2.jpeg" anim-detached="true"/> <div id="our_work"> <h2>Проекти</h2> <div id="slider_work"> <div class="active"> <div class="websites"> <div class="web_info1"> <h3>Боксов Клуб "Академик"</h3> <a href="http://www.academicboxingclub.org" target="_blank"><h4>academicboxingclub.org</h4></a> <div class="web_discription"> <ul> <li> <h5>Описание на работата</h5> <p> Ние създадохме уебсайта на нашия боксов клуб. Той беше направен от нулата, като добавихме цветова схема, снимки, банери и лого, както и подобрен потребителски интерфейс. Сайтът използва MySQL база данни за новините и малка собствена система за управлението им. За този проект предоставяме и текуща поддръжка на уебсайта. </p> </li> <li> <h5>Използвахме:</h5> <ul> <li>Графичен дизайн/Фотошоп</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website"> <img src="../img/box.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>Тениска Шоп</h3> <a href="http://www.teniskashop.eu" target="_blank"><h4>teniskashop.eu</h4></a> <div class="web_discription"> <ul> <li> <h5>Описание на работата</h5> <p> Онлайн магазин за тениски с уникален дизайн. Цялостният външен вид на сайта е нарисуван и пресъздаден на ръка от нас. Teniskashop.eu включва и собствена система за управление на съдържанието, създадена от нас. Ние се грижим за хостинга и сървърната страна на управлението на сайта (cPanel). </p> </li> <li> <h5>Използвахме:</h5> <ul> <li>Фотошоп</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>AJAX</li> <li>PHP</li> <li>Apache 2.0/cPanel</li> </ul> </li> </ul> </div> </div> <div class="the_website1"> <img src="../img/teniskashop.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>Кинезитерапевтично студио "ГабиАнджи"</h3> <a href="http://www.kineziterapiabg.com" target="_blank"><h4>kineziterapiabg.com</h4></a> <div class="web_discription"> <ul> <li> <h5>Описание на работата</h5> <p> Малък уебсайт, създаден за един от най-добрите кинезитерапевти в България, Димитър Стоянов. Ние създадохме целия уеб дизайн концепт и потребителски интерфейс. Целта ни беше да направим един лек и лесен за навигация уебсайт като краен резултат. Използвахме малка MySQL база данни за да поддържаме потребителските коментари. </p> </li> <li> <h5>Използвахме:</h5> <ul> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website2"> <img src="../img/kineziterapiabg.png" alt=""> </div> </div> </div> </div> <span id="playback"><img src="../img/playback_pause.png"/></span> </div> </section> <section id="section-Контакт"> <img class="bg" src="../img/eb8.jpg" anim-detached="true" /> <div id="contact_us"> <h2>Искате да работите с нас по проект?</h2> <div class="contact_us_nav"> <ul> <li><a href="javascript:;"> <span id="form_button_one" class="project_form_buttons">Подробна форма </span> </a> </li><li><a href="javascript:;"> <span class="project_form_buttons">Съкратена форма </span> </a> <li> </ul> </div> <?php //FORM USER ACTION FEEDBACK foreach ($message as $v) { echo "<div class='message_feedback'>".$v."</div>"; } ?> <div id="detailed_form" class="contact_forms"> <form method="POST" action=""> <div class="quick_form_holder"> <input type="text" name="name_detail" placeholder="Име" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div id="email_and_phone_holder"> <div id="email"> <input type="text" name="email_detail" placeholder="Имейл" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div id="phone"> <input type="text" name="phone_detail" placeholder="Телефон" <?php if(isset($phone) && !$mailed) { echo "value='$phone'";} ?> > </div> </div> <div class="quick_form_holder1"> <input type="text" name="company_detail" placeholder="Компания" <?php if(isset($company) && !$mailed) { echo "value='$company'";} ?> > </div> <div id="budget"> <h3>Бюджет</h3> <br /> <br /> <ul> <li> <div> <input type="radio" id="radio-1-1-bg" name="budget" value="До 300лв." class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "До 300лв.") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-1-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-2-bg" name="budget" value="300 - 750лв." class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "300 - 750лв.") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-2-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-3-bg" name="budget" value="750 - 3000лв." class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "750 - 3000лв.") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-3-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-4-bg" name="budget" value="> 3000лв." class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "> 3000лв.") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-4-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-5-bg" name="budget" value="Не е ясно" class="regular-radio" <?php if($budget_checked !== true) {echo " checked";} ?> /><label for="radio-1-5-bg"></label> </div> </li> </ul> </div> <div id="project_type"> <h3>Тип проект</h3> <br /> <br/> <ul> <li> <div> <input type="radio" id="radio-2-1-bg" name="project_type" value="Цялостен" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Цялостен") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-1-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-2-bg" name="project_type" value="Дизайн" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Дизайн") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-2-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-3-bg" name="project_type" value="Поддръжка" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Поддръжка") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-3-bg"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-4-bg" name="project_type" value="Друг" class="regular-radio" <?php if($project_type_checked !== true) {echo " checked";} ?> /><label for="radio-2-4-bg"></label> </div> </li> </ul> </div> <div class="quick_form_holder2"> <textarea name="question_detail" cols="30" rows="1" placeholder="Всичко друго, което ви интересува.."><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="detailed_form_send"> <input type="image" name="submit" src="../img/send_bg.png"> </div> </form> </div> <div id="quick_form_wrapper"> <div id="quick_form" class="contact_forms"> <form method="POST" action=""> <div class="quick_form_holder"> <input type="text" name="name_short" placeholder="Име" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div class="quick_form_holder"> <input type="text" name="email_short" placeholder="Имейл" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div class="quick_form_holder1"> <textarea name="question_short" cols="30" rows="1" placeholder="Какво си мислите.."><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="quick_form_send"> <input type="hidden" name="short_form_check" value="show_short_form"> <input type="image" name="submit" src="../img/send_bg.png"> </div> <!--[if lt IE 10]> <script src="../js/placeholder.js"></script> <![endif]--> </form> </div> </div> </div> <!-- WEB FOOTER --> <footer id="container_footer"> <a href="#Начало"> <div id="footer_arrow"> <img src="../img/footer_arrow.png" alt=""> </div> </a> </footer> </section> </div> </body> </html>
123-asdf
trunk/bg/index.php
PHP
mit
37,632
<?php /** * Mobile Detect Library * ===================== * * Motto: "Every business should have a mobile detection script to detect mobile readers" * * Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). * It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment. * * @author Current authors: Serban Ghita <serbanghita@gmail.com>, Nick Ilyin <nick.ilyin@gmail.com> * Original author: Victor Stanciu <vic.stanciu@gmail.com> * * @license Code and contributions have 'MIT License' * More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt * * @link Homepage: http://mobiledetect.net * GitHub Repo: https://github.com/serbanghita/Mobile-Detect * Google Code: http://code.google.com/p/php-mobile-detect/ * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples * * @version 2.7.6 */ class Mobile_Detect { /** * Mobile detection type. * * @deprecated since version 2.6.9 */ const DETECTION_TYPE_MOBILE = 'mobile'; /** * Extended detection type. * * @deprecated since version 2.6.9 */ const DETECTION_TYPE_EXTENDED = 'extended'; /** * A frequently used regular expression to extract version #s. * * @deprecated since version 2.6.9 */ const VER = '([\w._\+]+)'; /** * Top-level device. */ const MOBILE_GRADE_A = 'A'; /** * Mid-level device. */ const MOBILE_GRADE_B = 'B'; /** * Low-level device. */ const MOBILE_GRADE_C = 'C'; /** * Stores the version number of the current release. */ const VERSION = '2.7.6'; /** * A type for the version() method indicating a string return value. */ const VERSION_TYPE_STRING = 'text'; /** * A type for the version() method indicating a float return value. */ const VERSION_TYPE_FLOAT = 'float'; /** * The User-Agent HTTP header is stored in here. * @var string */ protected $userAgent = null; /** * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE. * @var array */ protected $httpHeaders = array(); /** * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED. * * @deprecated since version 2.6.9 * * @var string */ protected $detectionType = self::DETECTION_TYPE_MOBILE; /** * HTTP headers that trigger the 'isMobile' detection * to be true. * * @var array */ protected static $mobileHeaders = array( 'HTTP_ACCEPT' => array('matches' => array( // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/ 'application/x-obml2d', // BlackBerry devices. 'application/vnd.rim.html', 'text/vnd.wap.wml', 'application/vnd.wap.xhtml+xml' )), 'HTTP_X_WAP_PROFILE' => null, 'HTTP_X_WAP_CLIENTID' => null, 'HTTP_WAP_CONNECTION' => null, 'HTTP_PROFILE' => null, // Reported by Opera on Nokia devices (eg. C3). 'HTTP_X_OPERAMINI_PHONE_UA' => null, 'HTTP_X_NOKIA_IPADDRESS' => null, 'HTTP_X_NOKIA_GATEWAY_ID' => null, 'HTTP_X_ORANGE_ID' => null, 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null, 'HTTP_X_HUAWEI_USERID' => null, // Reported by Windows Smartphones. 'HTTP_UA_OS' => null, // Reported by Verizon, Vodafone proxy system. 'HTTP_X_MOBILE_GATEWAY' => null, // Seend this on HTC Sensation. @ref: SensationXE_Beats_Z715e. 'HTTP_X_ATT_DEVICEID' => null, // Seen this on a HTC. 'HTTP_UA_CPU' => array('matches' => array('ARM')), ); /** * List of mobile devices (phones). * * @var array */ protected static $phoneDevices = array( 'iPhone' => '\biPhone.*Mobile|\biPod', // |\biTunes 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+', 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m', 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile', // @todo: Is 'Dell Streak' a tablet or a phone? ;) 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b', 'Motorola' => 'Motorola|\bDroid\b.*Build|DROIDX|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925', 'Samsung' => 'Samsung|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B', 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999)', 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i', 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', // @ref: http://www.micromaxinfo.com/mobiles/smartphones // Added because the codes might conflict with Acer Tablets. 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b', 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;) // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH) // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android. 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790', // @ref: http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones. 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250', // Added simvalley mobile just for fun. They have some interesting devices. // @ref: http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b', // @Tapatalk is a mobile app; @ref: http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser' ); /** * List of tablet devices. * * @var array */ protected static $tabletDevices = array( 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic. 'NexusTablet' => '^.*Android.*Nexus(((?:(?!Mobile))|(?:(\s(7|10).+))).)*$', 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|SM-T311|SM-T310|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500', // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/ 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b', // Only the Surface tablets with Windows RT are considered mobile. // @ref: http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;', // @ref: http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT 'HPTablet' => 'HP Slate 7|HP ElitePad 900|hp-tablet|EliteBook.*Touch', // @note: watch out for PadFone, see #132 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101', 'BlackBerryTablet' => 'PlayBook|RIM Tablet', 'HTCtablet' => 'HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200', 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617', 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2', // @ref: http://www.acer.ro/ac/ro/RO/content/drivers // @ref: http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer) // @ref: http://us.acer.com/ac/en/US/content/group/tablets // @note: Can conflict with Micromax and Motorola phones codes. 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810)\b|W3-810', // @ref: http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/ // @ref: http://us.toshiba.com/tablets/tablet-finder // @ref: http://www.toshiba.co.jp/regza/tablet/ 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO', // @ref: http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html 'LGTablet' => '\bL-06C|LG-V900|LG-V909\b', 'FujitsuTablet' => 'Android.*\b(F-01D|F-05E|F-10D|M532|Q572)\b', // Prestigio Tablets http://www.prestigio.com/support 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD', // @ref: http://support.lenovo.com/en_GB/downloads/default.page?# 'LenovoTablet' => 'IdeaTab|S2110|S6000|K3011|A3000|A1000|A2107|A2109|A1107|ThinkPad([ ]+)?Tablet', 'YarvikTablet' => 'Android.*(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468)', 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB', 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT', // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/ 'IRUTablet' => 'M702pro', 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b', // @ref: http://www.e-boda.ro/tablete-pc.html 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)', // @ref: http://www.allview.ro/produse/droseries/lista-tablete-pc/ 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)', // @reference: http://wiki.archosfans.com/index.php?title=Main_Page 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R', // @ref: http://www.ainol.com/plugin.php?identifier=ainol&module=product 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark', // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER // @ref: Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser // @ref: http://www.sony.jp/support/tablet/ 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201', // @ref: db + http://www.cube-tablet.com/buy-products.html 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT', // @ref: http://www.cobyusa.com/?p=pcat&pcat_id=3001 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010', // @ref: http://www.match.net.cn/products.asp 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733', // @ref: http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets) // @ref: http://www.imp3.net/14/show.php?itemid=20454 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)', // @ref: http://www.rock-chips.com/index.php?do=prod&pid=2 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A', // @ref: http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/ 'FlyTablet' => 'IQ310|Fly Vision', // @ref: http://www.bqreaders.com/gb/tablets-prices-sale.html 'bqTablet' => 'bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)|Maxwell.*Lite|Maxwell.*Plus', // @ref: http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290 // @ref: http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets) 'HuaweiTablet' => 'MediaPad|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim', // Nec or Medias Tab 'NecTablet' => '\bN-06D|\bN-08D', // Pantech Tablets: http://www.pantechusa.com/phones/ 'PantechTablet' => 'Pantech.*P4100', // Broncho Tablets: http://www.broncho.cn/ (hard to find) 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)', // @ref: http://versusuk.com/support.html 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b', // @ref: http://www.zync.in/index.php/our-products/tablet-phablets 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900', // @ref: http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/ 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA', // @ref: https://www.nabitablet.com/ 'NabiTablet' => 'Android.*\bNabi', 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build', // French Danew Tablets http://www.danew.com/produits-tablette.php 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b', // Texet Tablets and Readers http://www.texet.ru/tablet/ 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE', // @note: Avoid detecting 'PLAYSTATION 3' as mobile. 'PlaystationTablet' => 'Playstation.*(Portable|Vita)', // @ref: http://www.galapad.net/product.html 'GalapadTablet' => 'Android.*\bG1\b', // @ref: http://www.micromaxinfo.com/tablet/funbook 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b', // http://www.karbonnmobiles.com/products_tablet.php 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b', // @ref: http://www.myallfine.com/Products.asp 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide', // @ref: http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr= 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b', // @ref: http://www.yonesnav.com/products/products.php 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026', // @ref: http://www.cjshowroom.com/eproducts.aspx?classcode=004001001 // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html) 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503', // @ref: http://www.gloryunion.cn/products.asp // @ref: http://www.allwinnertech.com/en/apply/mobile.html // @ref: http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB) // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions. 'GUTablet' => 'TX-A1301|TX-M9002|Q702', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G // @ref: http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10', // @ref: http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/ // @todo: add more tests. 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)', // @ref: http://hclmetablet.com/India/index.php 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync', // @ref: http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html 'DPSTablet' => 'DPS Dream 9|DPS Dual 7', // @ref: http://www.visture.com/index.asp 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10', // @ref: http://www.mijncresta.nl/tablet 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989', // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b', // Concorde tab 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan', // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/ 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042', // Modecom Tablets - http://www.modecom.eu/tablets/portal/ 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003', // @ref: http://www.tesco.com/direct/hudl/ 'Hudl' => 'Hudl HT7S3', // @ref: http://www.telstra.com.au/home-phone/thub-2/ 'TelstraTablet' => 'T-Hub2', 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|ViewPad7|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|SmartTabII10|SmartTab10|M758A|ET904', ); /** * List of mobile Operating Systems. * * @var array */ protected static $operatingSystems = array( 'AndroidOS' => 'Android', 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os', 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b', // @reference: http://en.wikipedia.org/wiki/Windows_Mobile 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;', // @reference: http://en.wikipedia.org/wiki/Windows_Phone // http://wifeng.cn/?r=blog&a=view&id=106 // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx 'WindowsPhoneOS' => 'Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7', 'iOS' => '\biPhone.*Mobile|\biPod|\biPad', // http://en.wikipedia.org/wiki/MeeGo // @todo: research MeeGo in UAs 'MeeGoOS' => 'MeeGo', // http://en.wikipedia.org/wiki/Maemo // @todo: research Maemo in UAs 'MaemoOS' => 'Maemo', 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135 'webOS' => 'webOS|hpwOS', 'badaOS' => '\bBada\b', 'BREWOS' => 'BREW', ); /** * List of mobile User Agents. * * @var array */ protected static $browsers = array( // @reference: https://developers.google.com/chrome/mobile/docs/user-agent 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', 'Dolfin' => '\bDolfin\b', 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+', 'Skyfire' => 'Skyfire', 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+ 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile', 'Bolt' => 'bolt', 'TeaShark' => 'teashark', 'Blazer' => 'Blazer', // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile', // @ref: http://en.wikipedia.org/wiki/Midori_(web_browser) //'Midori' => 'midori', 'Tizen' => 'Tizen', 'UCBrowser' => 'UC.*Browser|UCWEB', // @ref: https://github.com/serbanghita/Mobile-Detect/issues/7 'DiigoBrowser' => 'DiigoBrowser', // http://www.puffinbrowser.com/index.php 'Puffin' => 'Puffin', // @ref: http://mercury-browser.com/index.html 'Mercury' => '\bMercury\b', // @reference: http://en.wikipedia.org/wiki/Minimo // http://en.wikipedia.org/wiki/Vision_Mobile_Browser 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger' ); /** * Utilities. * * @var array */ protected static $utilities = array( // Experimental. When a mobile device wants to switch to 'Desktop Mode'. // @ref: http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/ // @ref: https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011 'DesktopMode' => 'WPDesktop', 'TV' => 'SonyDTV|HbbTV', // experimental 'WebKit' => '(webkit)[ /]([\w.]+)', 'Bot' => 'Googlebot|DoCoMo|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|facebookexternalhit', 'MobileBot' => 'Googlebot-Mobile|DoCoMo|YahooSeeker/M1A1-R2D2', 'Console' => '\b(Nintendo|Nintendo WiiU|PLAYSTATION|Xbox)\b', 'Watch' => 'SM-V700', ); /** * All possible HTTP headers that represent the * User-Agent string. * * @var array */ protected static $uaHttpHeaders = array( // The default User-Agent string. 'HTTP_USER_AGENT', // Header can occur on devices using Opera Mini. 'HTTP_X_OPERAMINI_PHONE_UA', // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/ 'HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_ORIGINAL_USER_AGENT', 'HTTP_X_SKYFIRE_PHONE', 'HTTP_X_BOLT_PHONE_UA', 'HTTP_DEVICE_STOCK_UA', 'HTTP_X_UCBROWSER_DEVICE_UA' ); /** * The individual segments that could exist in a User-Agent string. VER refers to the regular * expression defined in the constant self::VER. * * @var array */ protected static $properties = array( // Build 'Mobile' => 'Mobile/[VER]', 'Build' => 'Build/[VER]', 'Version' => 'Version/[VER]', 'VendorID' => 'VendorID/[VER]', // Devices 'iPad' => 'iPad.*CPU[a-z ]+[VER]', 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]', 'iPod' => 'iPod.*CPU[a-z ]+[VER]', //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'), 'Kindle' => 'Kindle/[VER]', // Browser 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'), 'Coast' => array('Coast/[VER]'), 'Dolfin' => 'Dolfin/[VER]', // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference 'Firefox' => 'Firefox/[VER]', 'Fennec' => 'Fennec/[VER]', // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];'), // http://en.wikipedia.org/wiki/NetFront 'NetFront' => 'NetFront/[VER]', 'NokiaBrowser' => 'NokiaBrowser/[VER]', 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ), 'Opera Mini' => 'Opera Mini/[VER]', 'Opera Mobi' => 'Version/[VER]', 'UC Browser' => 'UC Browser[VER]', 'MQQBrowser' => 'MQQBrowser/[VER]', 'MicroMessenger' => 'MicroMessenger/[VER]', // @note: Safari 7534.48.3 is actually Version 5.1. // @note: On BlackBerry the Version is overwriten by the OS. 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ), 'Skyfire' => 'Skyfire/[VER]', 'Tizen' => 'Tizen/[VER]', 'Webkit' => 'webkit[ /][VER]', // Engine 'Gecko' => 'Gecko/[VER]', 'Trident' => 'Trident/[VER]', 'Presto' => 'Presto/[VER]', // OS 'iOS' => ' \bOS\b [VER] ', 'Android' => 'Android [VER]', 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'), 'BREW' => 'BREW [VER]', 'Java' => 'Java/[VER]', // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'), 'Windows Phone' => 'Windows Phone [VER]', 'Windows CE' => 'Windows CE/[VER]', // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd 'Windows NT' => 'Windows NT [VER]', 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'), 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'), ); /** * Construct an instance of this class. * * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored. * If left empty, will use the global _SERVER['HTTP_*'] vars instead. * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT * from the $headers array instead. */ public function __construct( array $headers = null, $userAgent = null ){ $this->setHttpHeaders($headers); $this->setUserAgent($userAgent); } /** * Get the current script version. * This is useful for the demo.php file, * so people can check on what version they are testing * for mobile devices. * * @return string The version number in semantic version format. */ public static function getScriptVersion() { return self::VERSION; } /** * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers. * * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract * the headers. The default null is left for backwards compatibilty. */ public function setHttpHeaders($httpHeaders = null) { //use global _SERVER if $httpHeaders aren't defined if (!is_array($httpHeaders) || !count($httpHeaders)) { $httpHeaders = $_SERVER; } //clear existing headers $this->httpHeaders = array(); //Only save HTTP headers. In PHP land, that means only _SERVER vars that //start with HTTP_. foreach ($httpHeaders as $key => $value) { if (substr($key,0,5) == 'HTTP_') { $this->httpHeaders[$key] = $value; } } } /** * Retrieves the HTTP headers. * * @return array */ public function getHttpHeaders() { return $this->httpHeaders; } /** * Retrieves a particular header. If it doesn't exist, no exception/error is caused. * Simply null is returned. * * @param string $header The name of the header to retrieve. Can be HTTP compliant such as * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the * all-caps, HTTP_ prefixed, underscore seperated awesomeness. * * @return string|null The value of the header. */ public function getHttpHeader($header) { //are we using PHP-flavored headers? if (strpos($header, '_') === false) { $header = str_replace('-', '_', $header); $header = strtoupper($header); } //test the alternate, too $altHeader = 'HTTP_' . $header; //Test both the regular and the HTTP_ prefix if (isset($this->httpHeaders[$header])) { return $this->httpHeaders[$header]; } elseif (isset($this->httpHeaders[$altHeader])) { return $this->httpHeaders[$altHeader]; } } public function getMobileHeaders() { return self::$mobileHeaders; } /** * Get all possible HTTP headers that * can contain the User-Agent string. * * @return array List of HTTP headers. */ public function getUaHttpHeaders() { return self::$uaHttpHeaders; } /** * Set the User-Agent to be used. * * @param string $userAgent The user agent string to set. */ public function setUserAgent($userAgent = null) { if (!empty($userAgent)) { return $this->userAgent = $userAgent; } else { $this->userAgent = null; foreach($this->getUaHttpHeaders() as $altHeader){ if(!empty($this->httpHeaders[$altHeader])){ // @todo: should use getHttpHeader(), but it would be slow. (Serban) $this->userAgent .= $this->httpHeaders[$altHeader] . " "; } } return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null); } } /** * Retrieve the User-Agent. * * @return string|null The user agent if it's set. */ public function getUserAgent() { return $this->userAgent; } /** * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set. * * @deprecated since version 2.6.9 * * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default * parameter is null which will default to self::DETECTION_TYPE_MOBILE. */ public function setDetectionType($type = null) { if ($type === null) { $type = self::DETECTION_TYPE_MOBILE; } if ($type != self::DETECTION_TYPE_MOBILE && $type != self::DETECTION_TYPE_EXTENDED) { return; } $this->detectionType = $type; } /** * Retrieve the list of known phone devices. * * @return array List of phone devices. */ public static function getPhoneDevices() { return self::$phoneDevices; } /** * Retrieve the list of known tablet devices. * * @return array List of tablet devices. */ public static function getTabletDevices() { return self::$tabletDevices; } /** * Alias for getBrowsers() method. * * @return array List of user agents. */ public static function getUserAgents() { return self::getBrowsers(); } /** * Retrieve the list of known browsers. Specifically, the user agents. * * @return array List of browsers / user agents. */ public static function getBrowsers() { return self::$browsers; } /** * Retrieve the list of known utilities. * * @return array List of utilities. */ public static function getUtilities() { return self::$utilities; } /** * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*(). * * @deprecated since version 2.6.9 * * @return array All the rules (but not extended). */ public static function getMobileDetectionRules() { static $rules; if (!$rules) { $rules = array_merge( self::$phoneDevices, self::$tabletDevices, self::$operatingSystems, self::$browsers ); } return $rules; } /** * Method gets the mobile detection rules + utilities. * The reason this is separate is because utilities rules * don't necessary imply mobile. This method is used inside * the new $detect->is('stuff') method. * * @deprecated since version 2.6.9 * * @return array All the rules + extended. */ public function getMobileDetectionRulesExtended() { static $rules; if (!$rules) { // Merge all rules together. $rules = array_merge( self::$phoneDevices, self::$tabletDevices, self::$operatingSystems, self::$browsers, self::$utilities ); } return $rules; } /** * Retrieve the current set of rules. * * @deprecated since version 2.6.9 * * @return array */ public function getRules() { if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) { return self::getMobileDetectionRulesExtended(); } else { return self::getMobileDetectionRules(); } } /** * Retrieve the list of mobile operating systems. * * @return array The list of mobile operating systems. */ public static function getOperatingSystems() { return self::$operatingSystems; } /** * Check the HTTP headers for signs of mobile. * This is the fastest mobile check possible; it's used * inside isMobile() method. * * @return bool */ public function checkHttpHeadersForMobile() { foreach($this->getMobileHeaders() as $mobileHeader => $matchType){ if( isset($this->httpHeaders[$mobileHeader]) ){ if( is_array($matchType['matches']) ){ foreach($matchType['matches'] as $_match){ if( strpos($this->httpHeaders[$mobileHeader], $_match) !== false ){ return true; } } return false; } else { return true; } } } return false; } /** * Magic overloading method. * * @method boolean is[...]() * @param string $name * @param array $arguments * @return mixed * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' */ public function __call($name, $arguments) { //make sure the name starts with 'is', otherwise if (substr($name, 0, 2) != 'is') { throw new BadMethodCallException("No such method exists: $name"); } $this->setDetectionType(self::DETECTION_TYPE_MOBILE); $key = substr($name, 2); return $this->matchUAAgainstKey($key); } /** * Find a detection rule that matches the current User-agent. * * @param null $userAgent deprecated * @return boolean */ protected function matchDetectionRulesAgainstUA($userAgent = null) { // Begin general search. foreach ($this->getRules() as $_regex) { if (empty($_regex)) { continue; } if ($this->match($_regex, $userAgent)) { return true; } } return false; } /** * Search for a certain key in the rules array. * If the key is found the try to match the corresponding * regex agains the User-Agent. * * @param string $key * @param null $userAgent deprecated * @return mixed */ protected function matchUAAgainstKey($key, $userAgent = null) { // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc. $key = strtolower($key); //change the keys to lower case $_rules = array_change_key_case($this->getRules()); if (array_key_exists($key, $_rules)) { if (empty($_rules[$key])) { return null; } return $this->match($_rules[$key], $userAgent); } return false; } /** * Check if the device is mobile. * Returns true if any type of mobile device detected, including special ones * @param null $userAgent deprecated * @param null $httpHeaders deprecated * @return bool */ public function isMobile($userAgent = null, $httpHeaders = null) { if ($httpHeaders) { $this->setHttpHeaders($httpHeaders); } if ($userAgent) { $this->setUserAgent($userAgent); } $this->setDetectionType(self::DETECTION_TYPE_MOBILE); if ($this->checkHttpHeadersForMobile()) { return true; } else { return $this->matchDetectionRulesAgainstUA(); } } /** * Check if the device is a tablet. * Return true if any type of tablet device is detected. * * @param string $userAgent deprecated * @param array $httpHeaders deprecated * @return bool */ public function isTablet($userAgent = null, $httpHeaders = null) { $this->setDetectionType(self::DETECTION_TYPE_MOBILE); foreach (self::$tabletDevices as $_regex) { if ($this->match($_regex, $userAgent)) { return true; } } return false; } /** * This method checks for a certain property in the * userAgent. * @todo: The httpHeaders part is not yet used. * * @param $key * @param string $userAgent deprecated * @param string $httpHeaders deprecated * @return bool|int|null */ public function is($key, $userAgent = null, $httpHeaders = null) { // Set the UA and HTTP headers only if needed (eg. batch mode). if ($httpHeaders) { $this->setHttpHeaders($httpHeaders); } if ($userAgent) { $this->setUserAgent($userAgent); } $this->setDetectionType(self::DETECTION_TYPE_EXTENDED); return $this->matchUAAgainstKey($key); } /** * Some detection rules are relative (not standard), * because of the diversity of devices, vendors and * their conventions in representing the User-Agent or * the HTTP headers. * * This method will be used to check custom regexes against * the User-Agent string. * * @param $regex * @param string $userAgent * @return bool * * @todo: search in the HTTP headers too. */ public function match($regex, $userAgent = null) { // Escape the special character which is the delimiter. $regex = str_replace('/', '\/', $regex); return (bool) preg_match('/'.$regex.'/is', (!empty($userAgent) ? $userAgent : $this->userAgent)); } /** * Get the properties array. * * @return array */ public static function getProperties() { return self::$properties; } /** * Prepare the version number. * * @todo Remove the error supression from str_replace() call. * * @param string $ver The string version, like "2.6.21.2152"; * * @return float */ public function prepareVersionNo($ver) { $ver = str_replace(array('_', ' ', '/'), '.', $ver); $arrVer = explode('.', $ver, 2); if (isset($arrVer[1])) { $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions. } return (float) implode('.', $arrVer); } /** * Check the version of the given property in the User-Agent. * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) * * @param string $propertyName The name of the property. See self::getProperties() array * keys for all possible properties. * @param string $type Either self::VERSION_TYPE_STRING to get a string value or * self::VERSION_TYPE_FLOAT indicating a float value. This parameter * is optional and defaults to self::VERSION_TYPE_STRING. Passing an * invalid parameter will default to the this type as well. * * @return string|float The version of the property we are trying to extract. */ public function version($propertyName, $type = self::VERSION_TYPE_STRING) { if (empty($propertyName)) { return false; } //set the $type to the default if we don't recognize the type if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) { $type = self::VERSION_TYPE_STRING; } $properties = self::getProperties(); // Check if the property exists in the properties array. if (array_key_exists($propertyName, $properties)) { // Prepare the pattern to be matched. // Make sure we always deal with an array (string is converted). $properties[$propertyName] = (array) $properties[$propertyName]; foreach ($properties[$propertyName] as $propertyMatchString) { $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString); // Escape the special character which is the delimiter. $propertyPattern = str_replace('/', '\/', $propertyPattern); // Identify and extract the version. preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match); if (!empty($match[1])) { $version = ( $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1] ); return $version; } } } return false; } /** * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants. * * @return string One of the self::MOBILE_GRADE_* constants. */ public function mobileGrade() { $isMobile = $this->isMobile(); if ( // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1) $this->version('iPad', self::VERSION_TYPE_FLOAT)>=4.3 || $this->version('iPhone', self::VERSION_TYPE_FLOAT)>=3.1 || $this->version('iPod', self::VERSION_TYPE_FLOAT)>=3.1 || // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) || // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800 $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT)>=7.0 || // Blackberry 7 - Tested on BlackBerry® Torch 9810 // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670 $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=6.0 || // Blackberry Playbook (1.0-2.0) - Tested on PlayBook $this->match('Playbook.*Tablet') || // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0) ( $this->version('webOS', self::VERSION_TYPE_FLOAT)>=1.4 && $this->match('Palm|Pre|Pixi') ) || // Palm WebOS 3.0 - Tested on HP TouchPad $this->match('hp.*TouchPad') || // Firefox Mobile (12 Beta) - Tested on Android 2.3 device ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=12 ) || // Chrome for Android - Tested on Android 4.0, 4.1 device ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=4.0 ) || // Skyfire 4.1 - Tested on Android 2.3 device ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT)>=4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || // Opera Mobile 11.5-12: Tested on Android 2.3 ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>11 && $this->is('AndroidOS') ) || // Meego 1.2 - Tested on Nokia 950 and N9 $this->is('MeeGoOS') || // Tizen (pre-release) - Tested on early hardware $this->is('Tizen') || // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser // @todo: more tests here! $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT)>=2.0 || // UC Browser - Tested on Android 2.3 device ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || // Kindle 3 and Fire - Tested on the built-in WebKit browser for each ( $this->match('Kindle Fire') || $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT)>=3.0 ) || // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet $this->is('AndroidOS') && $this->is('NookTablet') || // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7 $this->version('Chrome', self::VERSION_TYPE_FLOAT)>=11 && !$isMobile || // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7 $this->version('Safari', self::VERSION_TYPE_FLOAT)>=5.0 && !$isMobile || // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7 $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=4.0 && !$isMobile || // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 $this->version('MSIE', self::VERSION_TYPE_FLOAT)>=7.0 && !$isMobile || // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 // @reference: http://my.opera.com/community/openweb/idopera/ $this->version('Opera', self::VERSION_TYPE_FLOAT)>=10 && !$isMobile ){ return self::MOBILE_GRADE_A; } if ( $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 || $this->version('iPhone', self::VERSION_TYPE_FLOAT)<3.1 || $this->version('iPod', self::VERSION_TYPE_FLOAT)<3.1 || // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 || //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 ( $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)>=5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)<=6.5 && ($this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 || $this->is('iOS')) ) || // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || // @todo: report this (tested on Nokia N71) $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11 && $this->is('SymbianOS') ){ return self::MOBILE_GRADE_B; } if ( // Blackberry 4.x - Tested on the Curve 8330 $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<5.0 || // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)<=5.2 ){ return self::MOBILE_GRADE_C; } //All older smartphone platforms and featurephones - Any device that doesn't support media queries //will receive the basic, C grade experience. return self::MOBILE_GRADE_C; } }
123-asdf
trunk/includes/Mobile_Detect.php
PHP
mit
60,620
<?php error_reporting(0); //redirect for mobile (excl. tablets) include 'includes/Mobile_Detect.php'; $detect = new Mobile_Detect; if( $detect->isMobile() && !$detect->isTablet() ){ Header("Location: http://phone.forafreeworld.com/"); exit; } Header("Cache-Control: public, max-age=2592000"); Header("Content-Type: text/html; charset=utf-8"); mb_internal_encoding("UTF-8"); $message = array(); $mailed = false; $budget_checked = false; $project_type_checked = false; if($_POST) { //USER INPUT NORMALIZATION if(isset($_POST['name_detail'])) { $name = htmlspecialchars(trim($_POST['name_detail'])); $email = htmlspecialchars(trim($_POST['email_detail'])); $phone = htmlspecialchars(trim($_POST['phone_detail'])); $company = htmlspecialchars(trim($_POST['company_detail'])); $budget = $_POST['budget']; $project_type = $_POST['project_type']; $question = htmlspecialchars($_POST['question_detail']); $detail = true; } if(isset($_POST['name_short'])) { $name = htmlspecialchars(trim($_POST['name_short'])); $email = htmlspecialchars(trim($_POST['email_short'])); $question = htmlspecialchars($_POST['question_short']); $phone = ""; $company = ""; $budget = ""; $project_type = ""; } //USER INPUT VALIDATION if(mb_strlen($name) < 3) { $message[] = "The name should be longer than 2 characters."; } if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $message[] = "Please enter a valid email address."; } if(isset($detail) && (int)mb_strlen($phone) < 7) { $message[] = "Please enter a valid phone number, including location dialing prefixes."; } if(mb_strlen($question) < 20) { $message[] = "Please enter 20 characters or more for your enquiry."; } //send email if no input validation successful if(count($message) == 0) { $mail_msg = "<html><head></head><body> Customer name: ".$name."<br/>". "Customer email: ".$email."<br/>". "Customer phone number: ".$phone."<br/>". "Company name: ".$company."<br/>". "Selected budget: ".$budget."<br/>". "Selected project_type: ".$project_type."<br/>". "Enquiry: ".$question."<br/></body></html>"; $mail_msg = wordwrap($mail_msg, 70, "\r\n"); $mailed = @mail('az3@abv.bg', 'forafreeworld.com Customer Enquiry', $mail_msg, 'Content-type: text/html; charset=utf-8' . "\r\n"); if($mailed) { $message[] = "The enquiry has been sent successfully, we will get in touch with you as soon as possible."; } else { $message[] = "An error occurred while sending the message. Please try again later."; } } } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="author" content="Extraordinary web design"/> <meta name="description" content="Be Free Web Design Studio is a small team which specializes in providing full-scope web services to clients around the Free World of Earth. We are based in Sofia, Bulgaria (Southeastern Europe). Currently the Team consists of Nikolay Ivanov - Web Designer, and Denislav Dimitrov - Web Developer. Some of the services we provide are: Website creation, website updates, redesign, creative design, logo and banner design, security updates, Wordpress site management, database optimization and maintenance, server-side web services."/> <meta name="Keywords" content="web design, web development, website, wordpress site, responsive design, custom website, web content management, уеб дизайн, уебсайт, интернет страница"/> <meta name="googlebot" content="all"/> <link href="img/favicon.ico" rel="shortcut icon"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Web Design For A Free World</title> <!--[if lte IE 9]> <script src="shivs/html5shiv/html5shiv.js"></script> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![endif]--> <!--[if IE 9 ]> <html class="ie9"> <![endif]--> <!--[if IE ]> <html class="ie"> <![endif]--> <link rel="stylesheet" type="text/css" href="css/style.css"/> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="js/jquery.placeholder.js"></script> <script src="js/main.js"></script> <script src="js/side-nav.js"></script> <script src="js/backgrounds.js"></script> <script src="js/kinetics.js"></script> <script src="js/parallax.js"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-45637344-4']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div id="mock-scroller"> </div> <ul id="nav"> </ul> <!-- WEB CONTENT --> <div id="content"> <section id="section-Home"> <img class="bg animate" src="img/bg.jpg" anim-detached="true"/> <header id="container_header"> <div id="header_holder"> <div id="copyright"> <p> Copyright &copy; Forafreeworld.com </p> </div> <div id="social_lang_holder"> <div id="social"> <ul> <li><a href="https://www.facebook.com/pages/Be-Free-Web-Design-Studio/561352003933342" target="_blank"><img src="img/facebook.png" alt=""></a></li> <li><a href="https://twitter.com/be_free_studio" target="_blank"><img src="img/twitter.png" alt=""></a></li> <li><a href="https://plus.google.com/communities/115431413168700794942" target="_blank"><img src="img/google.png" alt=""></a></li> </ul> </div> <div id="lang"> <ul> <li><a href="http://forafreeworld.com/">en</a></li> <li><a href="http://forafreeworld.com/de/">de</a></li> <li><a href="http://forafreeworld.com/bg/"><span id="separate_it">bg</span></a></li> </ul> </div> <div id="logo"> <img src="img/logo.png" alt=""> </div> </div> </div> <div id="second_header"> <div id="left_info"> <ul> <li> <span class="where_we_at">E-mail</span> <span class="where_we_at_left">welcome@forafreeworld.com</span> </li> <li><span class="where_we_at">Phone</span> <span class="where_we_at_left">+359 877 36 55 44</span> </li> <li><span class="where_we_at">Address</span> <span class="where_we_at_left">Sofia, Bulgaria, Reduta 80</span> </li> </ul> </div> <div id="right_info"> <div id="icons_holder"> <ul> <li><img src="img/ps.png" alt=""></li> <li><img src="img/css3.png" alt=""></li> <li><img src="img/wordpress.png" alt=""></li> <li><img src="img/ie.png" alt=""></li> <li><img src="img/mysql.png" alt=""></li> <li><img src="img/javascript.png" alt=""></li> <li><img src="img/php.png" alt=""></li> </ul> </div> </div> </div> </header> <!--Billboard--> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <div id="slogan"> <h2>WE BELIEVE HAVING A WEBSITE <br/> CAN GIVE YOU FREEDOM</h2> </div> <div id="be_free_button_holder"> <a href="#Contact"><span id="be_free_button">BE FREE</span></a> </div> <div id="container_nav_holder"> <nav id="container_nav"> <ul> <li><a href="#"><img src="img/home.png" alt=""></a></li> <li><a href="#">About</a></li> <li><a href="#">Process</a></li> <li><a href="#">Work</a></li> <li><a href="#">Contact</a></li> <li><a href="#">Blog</a></li> </ul> </nav> </div> </section> <section id="section-About"> <img class="bg animate" src="img/about_us_bg.jpg" anim-detached="true"/> <div id="about_us"> <h2>The Free People</h2> <div class="player_holder"> <div class="players"> <h3>Nikolay Ivanov</h3> <h4>The Designer</h4> <img src="img/niko.png" alt=""> <p> HTML5 <br/> CSS3<br/> Photoshop<br/> Banner Design<br/> Responsive Design<br/> </p> </div> <div class="about_the_players"> <p> ¡hola! I am Nikolay, the Designer-in-charge for the Be Free Studio Team. I specialize in planning and designing websites from scratch, because this way I can get creative. My skills include HTML5 and CSS3 proficiency, good level of Adobe Photoshop Suite and I create Responsive Designs with accent on excellent user experience. What really fascinates me are the projects where I can add value by inserting custom details and tweaks and be able to work on company branding. I love creating unique sites for unique businesses.. </p> </div> </div> <div class="player_holder"> <div class="players"> <h3>Denislav Dimitrov</h3> <h4>The Developer</h4> <img src="img/denkata.png" alt=""> <p> Javascript<br/> jQuery and AJAX<br/> PHP<br/> MySQL<br/> CMS / WordPress<br/> </p> </div> <div class="about_the_players"> <p> A few words about me: I live in my own organized world where everything has its place and purpose. I like to get 'crazy' with PHP and MySQL, this is what I do for a living and I really enjoy it. My focus is on creating an organized and sustainable backbone for your website by providing user-friendly Content Management, top level information security and an optimized database for your data. I am also responsible for the server-side website management incl. URL redirecting, content caching and data mining protection. </p> </div> </div> </div> </section> <section id="section-Process"> <img class="bg animate" src="img/how_we_work_bg.png" anim-detached="true"/> <div id="how_we_work"> <h2>How we work</h2> <div class="how_we_work_nav"> <ul> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons b_active">Starting the project</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Design and coding</span> </div> </a></li> <li><a href="javascript:;"> <div class="how_we_work_buttons_holder"> <span class="how_we_work_buttons">Final product</span> </div> </a></li> </ul> </div> <div id="meeting" class="slides_work"> <h2>Meeting and Creating</h2> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="img/meet_the_customer.png" alt=""> </div> <p> We meet our customer and try to get to know them, their idea or their business and their goals to the best possible extent. This will prove important for all of us later when we will use this to offer additional value to the project by suggesting process improvements and professional advice related to the website. We believe in human to human connections with our customers, because we realize that eventually we all share the same global purpose in life. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="img/thinking_and_creating.png" alt=""> </div> <p id="thinking_parg"> Before we write even one line of code (and we write lots of lines!), we sit down and discuss the project plan. What is the main purpose of the website? Is it to attract customers or its goal is to intrigue and offer amazing content? Is it there to sell or maybe to raise funds about something? We create the work schedule and clarify unclear points with our patron. This is when we drink a LOT of coffee. </p> </div> <div class="meeting_and_creating_info"> <div class="img_holder"> <img src="img/mockup.png" alt=""> </div> <p id="mockup_text"> After there is a plan in place, we start drafting the website for our customer. We do a raw black-and white sketch only first, in order to discuss and agree on the general look and feel of the website early in the project starting phase. In this phase we listen to our client's instructions, but if needed we can come up with our own unique website structure too. This is the end of the Project Start phase. </p> </div> </div> <div id="coding_part" class="slides_work"> <h2>This is where the magic happens</h2> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info"> We emphasize on the small, but important details - fonts, color scheme.. </div> <div class="desing_and_coding_info lower"> Banner/Logo design is big part of the web identity of the company </div> <div class="desing_and_coding_info"> Creating SEO friendly, clean front-end code in HTML5 and CSS3 </div> </div> <img src="img/fireworks.jpg" alt=""> </div> <div class="design_and_coding"> <div class="design_and_coding_info_holder"> <div class="desing_and_coding_info lower"> A website must include dynamically changing content in order to survive in today's www </div> <div class="desing_and_coding_info"> Here comes server-side scripting, databases and Content Management Systems </div> <div class="desing_and_coding_info lower"> We combine latest web technologies and innovative thinking to create the optimal website for your needs </div> </div> <img src="img/brackets.jpg" alt=""> </div> </div> <div id="end_work" class="slides_work"> <h2>What you receive at the end</h2> <div id="center_that"> <div class="end_work_info"> Beautiful website with great functionality </div> <div class="end_work_info"> Optimized content ensuring short loading time </div> <div class="end_work_info"> Website that works on all devices and gadgets </div> </div> <div id="end_work_img"> <img src="img/end_work.png" alt=""> </div> </div> </div> </section> <section id="section-Work"> <img class="bg animate" src="img/office2.jpeg" anim-detached="true"/> <div id="our_work"> <h2>Work</h2> <div id="slider_work"> <div class="active"> <div class="websites"> <div class="web_info1"> <h3>Academic Boxing Club</h3> <a href="http://www.academicboxingclub.org" target="_blank"><h4>academicboxingclub.org</h4></a> <div class="web_discription"> <ul> <li> <h5>Job Description</h5> <p> We created the website of our boxing club. It is made from ground up, including custom colors, fonts, pictures, banner and logo design and user experience. This website utilizes MySQL 5.x database for the news and features a small custom Content Management System. We also provide ongoing website support for this project. </p> </li> <li> <h5>Skills utilized</h5> <ul> <li>Graphic Design</li> <li>Photoshop</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website"> <img src="img/box.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>TeniskaShop</h3> <a href="http://www.teniskashop.eu" target="_blank"><h4>teniskashop.eu</h4></a> <div class="web_discription"> <ul> <li> <h5>Job Description</h5> <p> Online shop for uniquely designed art t-shirts. The whole design, site look and feel and banners/color scheme was designed by hand. Teniskashop.eu also has an own Content Management System designed and implemented manually by us. Range of services included hosting and server-side management (cPanel). </p> </li> <li> <h5>Skills utilized</h5> <ul> <li>Photoshop</li> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>AJAX</li> <li>PHP</li> <li>Apache 2.0/cPanel</li> </ul> </li> </ul> </div> </div> <div class="the_website1"> <img src="img/teniskashop.png" alt=""> </div> </div> </div> <div> <div class="websites"> <div class="web_info"> <h3>Physiotherapeutic Studio "GabieAngie"</h3> <a href="http://www.kineziterapiabg.com" target="_blank"><h4>kineziterapiabg.com</h4></a> <div class="web_discription"> <ul> <li> <h5>Job Description</h5> <p> Small one-page interactive website created for one the best physiotherapists in Bulgaria, Dimitar Stoyanov. We created the whole design concept and user experience, aiming for a lightweight, easy-to-navigate webpage as an end result. A small MySQL database was deployed in order to maintain the user reviews. </p> </li> <li> <h5>Skills utilized</h5> <ul> <li>HTML5</li> <li>CSS3</li> <li>JavaScript/jQuery</li> <li>PHP</li> <li>MySQL</li> </ul> </li> </ul> </div> </div> <div class="the_website2"> <img src="img/kineziterapiabg.png" alt=""> </div> </div> </div> </div> <span id="playback"><img src="img/playback_pause.png"/></span> </div> </section> <section id="section-Contact"> <div id="contact_us_background"> <div id="contact_us"> <h2>Interested in working with us?</h2> <div class="contact_us_nav"> <ul> <li><a href="javascript:;"> <span id="form_button_one" class="project_form_buttons">Detailed Project Form </span> </a> </li><li><a href="javascript:;"> <span class="project_form_buttons">Quick Project Form </span> </a> <li> </ul> </div> <?php //FORM USER ACTION FEEDBACK foreach ($message as $v) { echo "<div class='message_feedback'>".$v."</div>"; } ?> <div id="detailed_form" class="contact_forms"> <form method="POST" action="http://forafreeworld.com/#Contact"> <div class="quick_form_holder"> <input type="text" name="name_detail" placeholder="Name" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div id="email_and_phone_holder"> <div id="email"> <input type="text" name="email_detail" placeholder="Email Address" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div id="phone"> <input type="text" name="phone_detail" placeholder="Telephone" <?php if(isset($phone) && !$mailed) { echo "value='$phone'";} ?> > </div> </div> <div class="quick_form_holder1"> <input type="text" name="company_detail" placeholder="Company" <?php if(isset($company) && !$mailed) { echo "value='$company'";} ?> > </div> <div id="budget"> <h3>Budget</h3> <br /> <br /> <ul> <li> <div> <input type="radio" id="radio-1-1" name="budget" value="Up to $200" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "Up to $200") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-1"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-2" name="budget" value="$200 - $500" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "$200 - $500") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-2"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-3" name="budget" value="$500 - $2000" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "$500 - $2000") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-3"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-4" name="budget" value="$2000 and up" class="regular-radio" <?php if(isset($_POST['budget']) && $_POST['budget'] === "$2000 and up") {echo " checked"; $budget_checked = true;} ?> /><label for="radio-1-4"></label> </div> </li> <li> <div> <input type="radio" id="radio-1-5" name="budget" value="Not Sure" class="regular-radio" <?php if($budget_checked !== true) {echo " checked";} ?> /><label for="radio-1-5"></label> </div> </li> </ul> </div> <div id="project_type"> <h3>Project Type</h3> <br /> <br/> <ul> <li> <div> <input type="radio" id="radio-2-1" name="project_type" value="Full Service" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Full Service") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-1"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-2" name="project_type" value="Design only" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Design only") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-2"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-3" name="project_type" value="Maintenance" class="regular-radio" <?php if(isset($_POST['project_type']) && $_POST['project_type'] === "Maintenance") {echo " checked"; $project_type_checked = true;} ?> /><label for="radio-2-3"></label> </div> </li> <li> <div> <input type="radio" id="radio-2-4" name="project_type" value="Other" class="regular-radio" <?php if($project_type_checked !== true) {echo " checked";} ?> /><label for="radio-2-4"></label> </div> </li> </ul> </div> <div class="quick_form_holder2"> <textarea name="question_detail" cols="30" rows="1" placeholder="Anything else we need to know"><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="detailed_form_send"> <input type="image" name="submit" src="img/send.png"> </div> </form> </div> <div id="quick_form_wrapper"> <div id="quick_form" class="contact_forms"> <form method="POST" action="#Contact"> <div class="quick_form_holder"> <input type="text" name="name_short" placeholder="Name" <?php if(isset($name) && !$mailed) { echo "value='$name'";} ?> > </div> <div class="quick_form_holder"> <input type="text" name="email_short" placeholder="Email Address" <?php if(isset($email) && !$mailed) { echo "value='$email'";} ?> > </div> <div class="quick_form_holder1"> <textarea name="question_short" cols="30" rows="1" placeholder="What do you have in mind"><?php if(isset($question) && $question <> "" && !$mailed) { echo $question;} ?></textarea> </div> <div id="quick_form_send"> <input type="hidden" name="short_form_check" value="show_short_form"> <input type="image" name="submit" src="img/send.png"> </div> <!--[if lt IE 10]> <script src="js/placeholder.js"></script> <![endif]--> </form> </div> </div> </div> <!-- WEB FOOTER --> <footer id="container_footer"> <a href="#Home"> <div id="footer_arrow"> <img src="img/footer_arrow.png" alt=""> </div> </a> </footer> </div> </section> </div> </body> </html>
123-asdf
trunk/index.php
PHP
mit
33,455