📜 ⬆️ ⬇️

App Puzzle15. The road to Peter for android-background

image

More recently, in the glorious city on the Neva, a contest was held by guys from the local GTUG, the contest announcement is huddled in this topic. The contest itself, its implementation and the results will be described in detail in the report from arkady112 . I want to tell a little about the application Puzzle15, which received one of the 3 namination and together with it HTC WildFire.
Under the cut a small review and an example of the implementation of some functions ...

As I hope, it is clear from the name of Puzzle15 - these are all of us favorite tags, so to speak “ported” from the game shelf to the chrome browser.
The main features of the application I will take:
• game for fun
• sociality
• data synchronization

Game for fun


As for the first feature, it is a bit more complicated than it seems. Yes, the game is good, it's fun. Of course, puzzles, like other intellectual games, help our brain, so to speak, "not to swim fat." But behind all this entertainment there is an amusing fact- exactly half of the combinations of knuckles simply cannot be collected, which is half of 15!

Sociality


Collecting tag can be infinitely long, and one, and it is not always fun! Twitter comes to our rescue in this case.
image

Now we can share our template with all the inhabitants of this wonderful service with just one click of a button.
As a result, we will inform the rest of the birds your template.
image

And if you go through # 15 hash, you can download various templates of other users yourself.
')

Data synchronization


This is perhaps the most interesting thing for me in the process of creating an application, and it distinguished my application from the rest presented at the demo fest.
image

I will clarify, the synchronization is not the application, namely the data used in it.
Since I did not find a ready-made solution to this problem (maybe I was looking badly), then a “scooter” was invented.
Used browser skill to synchronize bookmarks. My task was to create a bookmark, write down the necessary data there (wrote in json) and update it for some actions in the application.
30.10

The browser does the rest (syncs to your G-docs).
image


Key points for working with bookmarks in the application
chrome.bookmarks.getChildren('1', function(tree) { if (!localStorage['FlagBookmarks']){ localStorage['IndexBookmarks']=""; localStorage['IDbookmarks']=""; } tree.forEach(function( item, index) { if (item.title=="Puzzle15") { localStorage['FlagBookmarks']=1; //        localStorage['IndexBookmarks']=item.index; localStorage['IDbookmarks']=item.id; } }); if (!localStorage['FlagBookmarks']) { //    -       chrome.bookmarks.create({ 'parentId' : '1', // other 'title' : 'Puzzle15', 'url' : 'http://puzzle-15.blogspot.com/{"id":["100"],"pattern";["1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0"],"added_on":["02.01 19:86"],"count":["0"]}' }, function(){ localStorage['FlagBookmarks']=1; console.log("create bookmark for sync (id="+localStorage['IDbookmarks']+")") }) } else if (localStorage['FlagBookmarks']==1){ // ,    ( ),  ,    JSON_bookmark      console.log("bookmark exists"); var JSON_bookmark={}; chrome.bookmarks.getChildren('1', function(tree) { tree.forEach(function( item, index) { if (item.title=="Puzzle15"){ temp_bookmark = item.url; temp=temp_bookmark.slice(30); //     : http://puzzle-15.blogspot.com/ JSON_bookmark=JSON.parse(unescape(temp)); //   escape-  ""  } }) //        JSON_bookmark,    web sql db    // ... }) } }) 

the code is not perfect, I admit, but it is efficient and reflects the basic data synchronization mechanisms

What's left overboard


Among other things, web sql db took part in the project (as it was implemented in the browser I wrote earlier)
image

Simple and advanced notifications are also used (HTML)
image


If you do not use the Chrome browser, you can simply look at all this mess in the next demo video

And if you still want to try to “stretch your brains”, you are welcome to Puzzle15

Chronology of development can be found here http://puzzle-15.blogspot.com/
I will be glad to answer your questions, of course, in the intervals between studying my new robot (HTC WildFire).
Thanks for attention.
PS
the event was wonderful, the organizers are great guys, the girl is lovely;)
It is a pity that there is no gtug in Minsk (but we will fix it;))
upd.

Source: https://habr.com/ru/post/107229/


All Articles